diff options
Diffstat (limited to 'game')
-rw-r--r-- | game/client.rpy | 41 | ||||
-rw-r--r-- | game/core.rpy | 17 | ||||
-rw-r--r-- | game/renpy.rpy | 106 |
3 files changed, 108 insertions, 56 deletions
diff --git a/game/client.rpy b/game/client.rpy index e01d0b3..1d3d680 100644 --- a/game/client.rpy +++ b/game/client.rpy @@ -22,7 +22,7 @@ init 2 python: return f def launch_game(idx): - global progress, responsive, statusmsg + global progress, responsive, statusmsg, MLP_DEST ######################################################################## ## Setup RPCUpdate(persistent.serverlist[idx]["Name"], persistent.serverlist[idx]["Back"]) @@ -84,11 +84,11 @@ init 2 python: renpy.iconify() ## Sanitize input to avoid arbitrary code execution - CMD=CMD.replace(";", "").replace("&", "").replace(">", "").replace("<", "").replace("|", "") - OPT=OPT.replace(";", "").replace("&", "").replace(">", "").replace("<", "").replace("|", "") - PWD=PWD.replace(";", "").replace("&", "").replace(">", "").replace("<", "").replace("|", "") + CMD=CMD.replace(";", "").replace("&", "").replace(">", "").replace("<", "").replace("|", "").replace("$", "") + OPT=OPT.replace(";", "").replace("&", "").replace(">", "").replace("<", "").replace("|", "").replace("$", "") + PWD=PWD.replace(";", "").replace("&", "").replace(">", "").replace("<", "").replace("|", "").replace("$", "") - ## Launch your prefered game client, wait for it to finish + ## Launch your preferred game client, wait for it to finish if renpy.windows: app=execute("\"%s\" %s%s" % (CMD, OPT, PWD), shell=True) else: @@ -96,11 +96,38 @@ init 2 python: ## Determine error messages if app == 7: - stdout("[CLIENT] Mirror Lake trigger.") + stdout("[CLIENT] Mirror Lake triggered.") ## Give "plenty" time to ensure data will be available statusmsg=_("Synchronizing data...") time.sleep(0.5) - + try: + r=vault.post(VAULT_HOST+"/getlake", json=auth, timeout=15.0) + ## We got the access credentials + if r.status_code == 200: + goto=r.json()["world"] + stdout("MLP Target: %s" % str(goto)) + if goto == "" or goto.lower() == "vault": + stdout("Mirror Lake False Positive") + else: + MLP_DEST=goto + progress=100 + return + ## We were refused by Vault + elif r.status_code == 403: + stdout("Warning: Connection was refused (Vault logout?)") + statusmsg=_("You're not logged in.") + time.sleep(1.0) + responsive = False + return + else: + stdout("[CLIENT] Sync error code %d." % r.status_code) + statusmsg=_("Synchronization error.") # 500 = No Lake + time.sleep(1.0) + except: + traceback.print_exc() + stdout("[CLIENT] Sync failed.") + statusmsg=_("Synchronization error.") + time.sleep(1.0) elif app: traceback.print_exc() stdout("[CLIENT] An error happened: %d" % app) diff --git a/game/core.rpy b/game/core.rpy index af165ea..7361a6f 100644 --- a/game/core.rpy +++ b/game/core.rpy @@ -104,17 +104,27 @@ init -3 python: list.__setitem__(self, index, value) # Search for array[?][key]==search in an array of dicts - # Returns the dictionary, or returns ERR_INVALID + # Returns the dictionary, or returns None def dl_search(array, key, search): try: r=(item for item in array if item[key] == search).next() except: - r=ERR_INVALID + r=None if r is None: - r=ERR_INVALID stdout("dlsearch: r is None") return r + # Search for array[?][key]==search in an array of dicts + # Returns the index, or returns -1 + def dl_search_idx(array, key, search): + try: + r=next((i for i, item in enumerate(array) if item[key] == search), None) + except: + traceback.print_exc() + r=-1 + return ifte(r is None, -1, r) + + ############################################################################# ## Some other stuff if renpy.linux: @@ -204,6 +214,7 @@ default responsive = True default has_steam = False default SCR_PROMPT = None default SCR_RESULT = None +default MLP_DEST = None ## Command Line Interface init -4 python: diff --git a/game/renpy.rpy b/game/renpy.rpy index 2e413bf..e26d20a 100644 --- a/game/renpy.rpy +++ b/game/renpy.rpy @@ -122,52 +122,66 @@ label start: #if config.developer: # "User ID: [vaultId]" label start_loop: - while True: - $ renpy.block_rollback() - call screen mirrorlake - ## Quit request - if _return is None or _return == "QUIT": - $ stdout("Good bye!") - $ renpy.quit() - return - ## Asked for The Void - if _return < 0: - $ stdout("V0id") - call thevoid - jump start_loop - ## Asked for any subworld + $ renpy.block_rollback() + call screen mirrorlake + ## Quit request + if _return is None or _return == "QUIT": + $ stdout("Good bye!") + $ renpy.quit() + return + ## Asked for The Void + if _return < 0: + $ stdout("V0id") + call thevoid + jump start_loop +label load_world: + ## Asked for any subworld + scene black + # FIXME: Improve this waiting screen + # Possibly retrieve messages from the thread + $ statusmsg=_("Now loading...") + show screen serverdata(_return) + with None + pause 0.01 + python: + renpy.invoke_in_thread(launch_game, _return) + progress = 0 + # Block the main thread until the socket connection is done + while progress < 100: + if responsive: + sdelay() + else: + break + + # Maybe we are waiting some prompt + if SCR_PROMPT is not None: + SCR_RESULT = renpy.call_screen("confirm", SCR_PROMPT, + Return(True), Return(False)) + SCR_PROMPT = None + + hide screen serverdata + # Kill the program instead of looping back + if not responsive: scene black - # FIXME: Improve this waiting screen - # Possibly retrieve messages from the thread - $ statusmsg=_("Now loading...") - show screen serverdata(_return) - with None - pause 0.01 + centered "{color=#FFF}{b}An error happened.{/b}\n\nPlease login again. If this issue persists, relaunch the app or {a=https://discord.gg/BQNTe68}contact us{/a}{/color}" + $ stdout("Program died - unsucessful game launch") + return + + ## Requested a Mirror Lake + if MLP_DEST is not None: + $ stdout("MLP Destination is set") python: - renpy.invoke_in_thread(launch_game, _return) - progress = 0 - # Block the main thread until the socket connection is done - while progress < 100: - if responsive: - sdelay() - else: - break - - # Maybe we are waiting some prompt - if SCR_PROMPT is not None: - SCR_RESULT = renpy.call_screen("confirm", SCR_PROMPT, - Return(True), Return(False)) - SCR_PROMPT = None - - hide screen serverdata - # Kill the program instead of looping back - if not responsive: - scene black - centered "{color=#FFF}{b}An error happened.{/b}\n\nPlease login again. If this issue persists, relaunch the app or {a=https://discord.gg/BQNTe68}contact us{/a}{/color}" - $ stdout("Program died - unsucessful game launch") - return - - # Automatically loop back - # Will never reach this line - return + try: + _return=dl_search_idx(persistent.serverlist, "UUID", MLP_DEST) + except: + traceback.print_exc() + _return=-1 + MLP_DEST=None + ## Internal Sanitization + $ stdout("WID Target: %d" % (_return)) + if _return > 0: + jump load_world + + # Automatically loop back + jump start_loop |