updated version check

This commit is contained in:
Vasyl Horbachenko 2018-09-11 03:35:52 +03:00
parent d31876b65e
commit 12853feec3
3 changed files with 14 additions and 9 deletions

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import re
import sys import sys
import dcs import dcs
import logging import logging
@ -33,13 +34,19 @@ def proceed_to_main_menu(game: Game):
def is_version_compatible(save_version): def is_version_compatible(save_version):
current_version = VERSION_STRING.split(".") current_version_components = re.split(r"[\._]", VERSION_STRING)
save_version = save_version.split(".") save_version_components = re.split(r"[\._]", save_version)
if "--ignore-save" in sys.argv: if "--ignore-save" in sys.argv:
return False return False
if current_version[:2] == save_version[:2]: if current_version_components == save_version_components:
return True
if save_version == "1.4_rc1":
return False
if current_version_components[:2] == save_version_components[:2]:
return True return True
return False return False
@ -80,9 +87,10 @@ try:
new_game_menu = ui.newgamemenu.NewGameMenu(w, start_new_game) new_game_menu = ui.newgamemenu.NewGameMenu(w, start_new_game)
new_game_menu.display() new_game_menu.display()
else: else:
game.settings.version = VERSION_STRING
proceed_to_main_menu(game) proceed_to_main_menu(game)
except Exception as e: except Exception as e:
print(e) logging.exception(e)
ui.corruptedsavemenu.CorruptedSaveMenu(w).display() ui.corruptedsavemenu.CorruptedSaveMenu(w).display()
w.run() w.run()

Binary file not shown.

View File

@ -44,11 +44,8 @@ def restore_game():
if not _save_file_exists(): if not _save_file_exists():
return None return None
try:
with open(_save_file(), "rb") as f: with open(_save_file(), "rb") as f:
return pickle.load(f) return pickle.load(f)
except Exception as e:
raise e
def save_game(game) -> bool: def save_game(game) -> bool: