diff options
author | Jesusaves <cpntb1@ymail.com> | 2021-05-07 18:37:44 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2021-05-07 18:37:44 -0300 |
commit | 65f6925fab3fa3474eeee10680665f70b59e0506 (patch) | |
tree | f3562f2be4c23625f7b7394ab0bd50c61c067907 | |
parent | 6af52634238e7160245e89838ebf616a2abb3ea7 (diff) | |
download | renpy-65f6925fab3fa3474eeee10680665f70b59e0506.tar.gz renpy-65f6925fab3fa3474eeee10680665f70b59e0506.tar.bz2 renpy-65f6925fab3fa3474eeee10680665f70b59e0506.tar.xz renpy-65f6925fab3fa3474eeee10680665f70b59e0506.zip |
Check for mirrors, error handling
-rw-r--r-- | game/core.rpy | 10 | ||||
-rw-r--r-- | game/renpy.rpy | 9 | ||||
-rw-r--r-- | game/update.rpy | 36 |
3 files changed, 52 insertions, 3 deletions
diff --git a/game/core.rpy b/game/core.rpy index 0af84aa..3be95cd 100644 --- a/game/core.rpy +++ b/game/core.rpy @@ -10,7 +10,7 @@ init -3 python: import requests, zlib, base64, sys, copy, uuid, time, json, traceback import os.path - print("[STDBY] Loading Basic functions.......") + print("\n[STDBY] Loading Basic functions.......") # set PYTHON_VERSION variable (e.g. 2715, 3605 etc.) PYTHON_VERSION="%d%d%02d" % (sys.version_info.major, sys.version_info.minor, sys.version_info.micro) @@ -25,6 +25,8 @@ init -3 python: config.autoreload = False config.save_on_mobile_background = False persistent.release_name = "Core" + LAUNCHER_VERSION = 1 + HOST_LIST = ["https://tmw2.org/launcher", "http://localhost/launcher"]#"themanaworld.org", "germantmw.de", "moubootaurlegends.org"] # Smart Print command def stdout(message): @@ -88,9 +90,15 @@ label splashscreen: hide TMW2 with Dissolve(1.5) return +label die: + $ stdout("Program died.") + pause + return + ####### Defaults default statusmsg = "Not yet initialized" default progress = 0 +default responsive = True diff --git a/game/renpy.rpy b/game/renpy.rpy index cdb4616..be00f4e 100644 --- a/game/renpy.rpy +++ b/game/renpy.rpy @@ -36,7 +36,14 @@ label start: python: # Block the main thread until the socket connection is done while progress < 100: - sdelay() + if responsive: + sdelay() + else: + break + + # Kill the program + if not responsive: + jump die $ stdout("Connection established!") diff --git a/game/update.rpy b/game/update.rpy index 810be2c..5b345df 100644 --- a/game/update.rpy +++ b/game/update.rpy @@ -7,8 +7,42 @@ init python: def CONFIGURE_LAUNCHER(): - global progress, statusmsg + global progress, statusmsg, responsive + statusmsg="Loading user configuration..." + # If persistent data is not yet set + if persistent.version is not LAUNCHER_VERSION: + progress=1 + statusmsg="Welcome to the Mana Launcher.\nBuilding user data, please wait..." + time.sleep(1.0) + # Determine from where we should fetch updates + for host in HOST_LIST: + try: + r=requests.get("%s/server_list.json" % host, timeout=10.0) + if (r.status_code != 200): + raise AssertionError("Mirror %s seems to be down!\nReturned error %03d\n\nTrying next mirror..." % (host.replace("https://", "").replace("http://", ""), r.status_code)) + j=json.loads(r.text) + for server in j: + persistent.serverlist.append(server) + + # If we were successful, save this host + persistent.host = host + break # Terminate the for loop + except: + traceback.print_exc() + + # If we don't have a host - DIE HARD + if (persistent.host is None): + stdout("No mirror could be found.") + statusmsg="{color=#f00}{b}ERROR: No active mirror found.\nMana Launcher needs to be updated.{/b}{/color}" + responsive=False + return + persistent.version = ifte(config.developer, 0, LAUNCHER_VERSION) + + progress=10 + statusmsg="Checking for installed clients..." + # TODO time.sleep(1.0) + progress=25 statusmsg="Loading..." time.sleep(1.0) |