mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Don't throw away exception info on save/load.
Makes it much easier to determine what we did that broke save game compatibility.
This commit is contained in:
parent
023925d741
commit
944748a0ac
@ -41,30 +41,33 @@ def restore_game():
|
|||||||
try:
|
try:
|
||||||
save = pickle.load(f)
|
save = pickle.load(f)
|
||||||
return save
|
return save
|
||||||
except:
|
except Exception:
|
||||||
logging.error("Invalid Save game")
|
logging.exception("Invalid Save game")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def load_game(path):
|
def load_game(path):
|
||||||
with open(path, "rb") as f:
|
with open(path, "rb") as f:
|
||||||
try:
|
try:
|
||||||
save = pickle.load(f)
|
save = pickle.load(f)
|
||||||
save.savepath = path
|
save.savepath = path
|
||||||
return save
|
return save
|
||||||
except:
|
except Exception:
|
||||||
logging.error("Invalid Save game")
|
logging.exception("Invalid Save game")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def save_game(game) -> bool:
|
def save_game(game) -> bool:
|
||||||
try:
|
try:
|
||||||
with open(_temporary_save_file(), "wb") as f:
|
with open(_temporary_save_file(), "wb") as f:
|
||||||
pickle.dump(game, f)
|
pickle.dump(game, f)
|
||||||
shutil.copy(_temporary_save_file(), game.savepath)
|
shutil.copy(_temporary_save_file(), game.savepath)
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logging.error(e)
|
logging.exception("Could not save game")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def autosave(game) -> bool:
|
def autosave(game) -> bool:
|
||||||
"""
|
"""
|
||||||
Autosave to the autosave location
|
Autosave to the autosave location
|
||||||
@ -75,7 +78,7 @@ def autosave(game) -> bool:
|
|||||||
with open(_autosave_path(), "wb") as f:
|
with open(_autosave_path(), "wb") as f:
|
||||||
pickle.dump(game, f)
|
pickle.dump(game, f)
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logging.error(e)
|
logging.exception("Could not save game")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user