diff options
author | Jesusaves <cpntb1@ymail.com> | 2021-08-07 23:46:48 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2021-08-07 23:46:48 -0300 |
commit | 10f79752c0446ce5939eb12260f65343846a567d (patch) | |
tree | 916dd8d2da20ecf4a31e85fac1a08bbfff6ba503 | |
parent | fd73aef79ac834a035ab6840309f9cafa3dca1ac (diff) | |
download | client-10f79752c0446ce5939eb12260f65343846a567d.tar.gz client-10f79752c0446ce5939eb12260f65343846a567d.tar.bz2 client-10f79752c0446ce5939eb12260f65343846a567d.tar.xz client-10f79752c0446ce5939eb12260f65343846a567d.zip |
Respond better to fatal errors
-rw-r--r-- | game/01_init.rpy | 7 | ||||
-rw-r--r-- | game/02_init.rpy | 99 | ||||
-rw-r--r-- | game/05_init.rpy | 1 | ||||
-rw-r--r-- | game/script.rpy | 13 |
4 files changed, 75 insertions, 45 deletions
diff --git a/game/01_init.rpy b/game/01_init.rpy index bcdd844..9b12e74 100644 --- a/game/01_init.rpy +++ b/game/01_init.rpy @@ -328,7 +328,7 @@ init -3 python: ############################################################################# # URL3 Function def GAME_UPDATER(): - global tr_uptodate + global tr_uptodate, tr_fatality tr_uptodate=False # If no version is provided, we are using default files @@ -346,6 +346,7 @@ init -3 python: # TODO: Should we set a "ver"? if (int(persistent.version) < ver): + try: # TODO: Check if the server have SSL support stdout("Downloading updated game data...") @@ -393,6 +394,10 @@ init -3 python: persistent.version=ver stdout("Update complete") + except: + tr_fatality = False + traceback.print_exc() + stdout("[FATAL] Unable to update JSON files; Aborted") # Download server news # Handled by GAME_LOADER diff --git a/game/02_init.rpy b/game/02_init.rpy index 844c9c9..2e8a489 100644 --- a/game/02_init.rpy +++ b/game/02_init.rpy @@ -113,58 +113,69 @@ init -1 python: def GAME_LOADER(): global allunitsbase, allunits, allquests, allstory, allworld, alltaverns - global allnews, tr_uptodate, tr_memcheck + global allnews, tr_uptodate, tr_memcheck, tr_fatality # Wait until everything is up to date while not tr_uptodate: sdelay() - # FIXME: Error handling - # Load unit data - #allunitsbase=json.loads(requests.get("http://"+HOST+'/units.json', verify=False).text) - f=open(get_path_if_exists("units.json"), "r") - allunitsbase=json.load(f) - f.close() - - # Reorder unit data - allunits={} - for j in allunitsbase: - allunits[j["unit_id"]]=j - - # Load summons data - f=open(get_path_if_exists("summons.json"), "r") - allsummons=json.load(f) - f.close() - - # Load quest data - f=open(get_path_if_exists("quests.json"), "r") - allquests=json.load(f) - f.close() - - # Load story data - f=open(get_path_if_exists("story.json"), "r") - allstory=json.load(f) - f.close() - - # Load world data - f=open(get_path_if_exists("world.json"), "r") - allworld=json.load(f) - f.close() - - # Load tavern data - f=open(get_path_if_exists("bar.json"), "r") - alltaverns=json.load(f) - f.close() - - stdout("PREPARING FOR NEWS") - # Load server news try: - allnews=json.loads(requests.get("http://"+HOST+'/news.json', verify=False, timeout=5.0).text) + # Load unit data + #allunitsbase=json.loads(requests.get("http://"+HOST+'/units.json', verify=False).text) + stdout("Loading units...") + f=open(get_path_if_exists("units.json"), "r") + allunitsbase=json.load(f) + f.close() + + # Reorder unit data + allunits={} + for j in allunitsbase: + allunits[j["unit_id"]]=j + + # Load summons data + stdout("Loading summons...") + f=open(get_path_if_exists("summons.json"), "r") + allsummons=json.load(f) + f.close() + + # Load quest data + stdout("Loading quests...") + f=open(get_path_if_exists("quests.json"), "r") + allquests=json.load(f) + f.close() + + # Load story data + stdout("Loading story...") + f=open(get_path_if_exists("story.json"), "r") + allstory=json.load(f) + f.close() + + # Load world data + stdout("Loading world...") + f=open(get_path_if_exists("world.json"), "r") + allworld=json.load(f) + f.close() + + # Load tavern data + stdout("Loading tavern...") + f=open(get_path_if_exists("bar.json"), "r") + alltaverns=json.load(f) + f.close() + + stdout("PREPARING FOR NEWS") + # Load server news + try: + allnews=json.loads(requests.get("http://"+HOST+'/news.json', verify=False, timeout=5.0).text) + except: + allnews=[] + pass + + stdout("[OK] Game data loaded to memory") except: - allnews=[] - pass + tr_fatality = True + traceback.print_exc() + stdout("[FATAL] Unable to load game data; Aborted.") - stdout("[OK] Game data loaded to memory") tr_memcheck=True return tr_load diff --git a/game/05_init.rpy b/game/05_init.rpy index 3ffbe03..d35ad75 100644 --- a/game/05_init.rpy +++ b/game/05_init.rpy @@ -26,6 +26,7 @@ label prestart: tr_load=False tr_uptodate=False tr_memcheck=False + tr_fatality=False TMP_MUSIC=get_sfx("bgm03") TMP_BACKG="battle" session_id=uuid.uuid4().hex diff --git a/game/script.rpy b/game/script.rpy index 2f1f7ca..0b4fa11 100644 --- a/game/script.rpy +++ b/game/script.rpy @@ -79,6 +79,7 @@ label login: #while not tr_load: # sdelay() + show spinner at truecenter $ persistent.password=password $ dlcode-=5000 #$ ping_routine() @@ -89,6 +90,11 @@ label login: stdout("IRC disabled") pass + ## Are we alive? + if tr_fatality: + e "An unexpected error was found and the game will now terminate. Please report this to developers." + jump quit + # We're now logged in, load misc data (TODO: What if ERR_ is returned?) $ who = -1 $ inv=get_inventory() @@ -106,7 +112,14 @@ label login: python: while not tr_memcheck: sdelay() + hide spinner with None + + ## Are we alive? + if tr_fatality: + e "An unexpected error was found and the game will now terminate. Please report this to developers." + jump quit + ## If you just registered, go to prologue if (email): $ del email jump prologue |