mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
persistent time and weather between regular and quick missions; defense AA for frontline CAS
This commit is contained in:
@@ -90,8 +90,9 @@ class Debriefing:
|
||||
enemy.name: self.alive_units.get(enemy.id, {}),
|
||||
}
|
||||
|
||||
|
||||
def debriefing_directory_location() -> str:
|
||||
return "build/debriefing"
|
||||
return os.path.expanduser("~\Saved Games\DCS")
|
||||
|
||||
|
||||
def _logfiles_snapshot() -> typing.Dict[str, float]:
|
||||
@@ -108,11 +109,19 @@ def _poll_new_debriefing_log(snapshot: typing.Dict[str, float], callback: typing
|
||||
while should_run:
|
||||
for file, timestamp in _logfiles_snapshot().items():
|
||||
if file not in snapshot or timestamp != snapshot[file]:
|
||||
callback(Debriefing.parse(os.path.join(debriefing_directory_location(), file)))
|
||||
for _ in range(0, 3):
|
||||
# some solid programming going on in here
|
||||
try:
|
||||
debriefing = Debriefing.parse(os.path.join(debriefing_directory_location(), file))
|
||||
break
|
||||
except:
|
||||
time.sleep(3)
|
||||
|
||||
callback(debriefing)
|
||||
should_run = False
|
||||
break
|
||||
|
||||
time.sleep(1)
|
||||
time.sleep(3)
|
||||
|
||||
|
||||
def wait_for_debriefing(callback: typing.Callable):
|
||||
|
||||
@@ -3,22 +3,24 @@ import pickle
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from game.game import Game
|
||||
|
||||
|
||||
def _save_file() -> str:
|
||||
return "build/save"
|
||||
return os.path.expanduser("~\Saved Games\DCS\liberation_save")
|
||||
|
||||
|
||||
def _temporary_save_file() -> str:
|
||||
return "build/save_tmp"
|
||||
return os.path.expanduser("~\Saved Games\DCS\liberation_save_tmp")
|
||||
|
||||
|
||||
def _save_file_exists() -> bool:
|
||||
return os.path.exists(_save_file())
|
||||
|
||||
|
||||
def restore_game() -> typing.Optional[Game]:
|
||||
def mission_path_for(name: str) -> str:
|
||||
return os.path.expanduser("~\Saved Games\DCS\Missions\{}".format(name))
|
||||
|
||||
|
||||
def restore_game():
|
||||
if not _save_file_exists():
|
||||
return None
|
||||
|
||||
@@ -30,7 +32,7 @@ def restore_game() -> typing.Optional[Game]:
|
||||
return None
|
||||
|
||||
|
||||
def save_game(game: Game) -> bool:
|
||||
def save_game(game) -> bool:
|
||||
try:
|
||||
with open(_temporary_save_file(), "wb") as f:
|
||||
pickle.dump(game, f)
|
||||
|
||||
Reference in New Issue
Block a user