mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Checkpoint game before sim, auto-revert on abort.
An alternative to https://github.com/dcs-liberation/dcs_liberation/pull/2891 that I ended up liking much better (I had assumed some part of the UI would fail or at least look terrible with this approach, but it seems to work quite well). On by default now since it's far less frightening than the previous thing. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2735.
This commit is contained in:
@@ -69,12 +69,9 @@ class AircraftSimulation:
|
||||
for flight in self.iter_flights():
|
||||
flight.state.reinitialize(now)
|
||||
|
||||
def reset(self, events: GameUpdateEvents | None = None) -> None:
|
||||
if events is None:
|
||||
events = GameUpdateEvents()
|
||||
def reset(self) -> None:
|
||||
for flight in self.iter_flights():
|
||||
flight.set_state(Uninitialized(flight, self.game.settings))
|
||||
events.update_flight(flight)
|
||||
self.combats = []
|
||||
|
||||
def iter_flights(self) -> Iterator[Flight]:
|
||||
|
||||
@@ -36,17 +36,10 @@ class GameLoop:
|
||||
def elapsed_time(self) -> timedelta:
|
||||
return self.sim.time - self.game.conditions.start_time
|
||||
|
||||
def reset(self) -> None:
|
||||
self.pause()
|
||||
self.events = GameUpdateEvents()
|
||||
self.sim.reset(self.events)
|
||||
self.send_update(rate_limit=False)
|
||||
self.started = False
|
||||
self.completed = False
|
||||
|
||||
def start(self) -> None:
|
||||
if self.started:
|
||||
raise RuntimeError("Cannot start game loop because it has already started")
|
||||
self.game.save_manager.save_pre_sim_checkpoint()
|
||||
self.started = True
|
||||
self.sim.begin_simulation()
|
||||
|
||||
|
||||
@@ -33,11 +33,6 @@ class MissionSimulation:
|
||||
self.completed = False
|
||||
self.time = self.game.conditions.start_time
|
||||
|
||||
def reset(self, events: GameUpdateEvents) -> None:
|
||||
self.completed = False
|
||||
self.time = self.game.conditions.start_time
|
||||
self.aircraft_simulation.reset(events)
|
||||
|
||||
def begin_simulation(self) -> None:
|
||||
self.time = self.game.conditions.start_time
|
||||
self.aircraft_simulation.begin_simulation()
|
||||
|
||||
Reference in New Issue
Block a user