diff options
author | Jesusaves <cpntb1@ymail.com> | 2021-05-09 13:05:36 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2021-05-09 13:05:36 -0300 |
commit | f4a49a91994b4505bce9370003623d882d75be89 (patch) | |
tree | 1de5d0a3169f29fe746dcfe485227544974344cb | |
parent | 619e065679167f6476160fa7256a4bb06db04e04 (diff) | |
download | renpy-f4a49a91994b4505bce9370003623d882d75be89.tar.gz renpy-f4a49a91994b4505bce9370003623d882d75be89.tar.bz2 renpy-f4a49a91994b4505bce9370003623d882d75be89.tar.xz renpy-f4a49a91994b4505bce9370003623d882d75be89.zip |
Integrity check for the client (needed for updating as well as for Povo bug)
-rw-r--r-- | game/client.rpy | 46 | ||||
-rw-r--r-- | game/core.rpy | 2 | ||||
-rw-r--r-- | game/screens.rpy | 10 |
3 files changed, 47 insertions, 11 deletions
diff --git a/game/client.rpy b/game/client.rpy index 4d0bfe0..5137fb3 100644 --- a/game/client.rpy +++ b/game/client.rpy @@ -5,7 +5,7 @@ # Distributed under the MIT license, except for Steam parts. ################################################################################# init 2 python: - def handle_client(CLIENT_NAME="", launch=False): + def handle_client(CLIENT_NAME="", launch=False, download=True): ## Local variables f=False if (CLIENT_NAME == ""): @@ -13,14 +13,36 @@ init 2 python: ## Main loop if (CLIENT_NAME == "manaplus"): - f=cli_manaplus(launch) + f=cli_manaplus(launch, download) elif (CLIENT_NAME == "mana"): - f=cli_mana(launch) + f=cli_mana(launch, download) else: status_update("ERROR, unrecognized client: %s" % CLIENT_NAME) return f + def md5check_client(): + renpy.notify("Checking md5sum...") + try: + installdir=get_path(persistent.client) + fname=handle_client(launch=True, download=False).split("/").pop() + r=requests.get(persistent.host+"/%s.md5" % fname, timeout=10.0) + md5up=r.text.replace("\n", "") + + md5us=md5sum(installdir+"/%s" % fname) + if md5up != md5us: + stdout("MD5 Mismatch: hashes differ", True) + stdout("Ours: %s" % md5us, True) + stdout("Them: %s" % md5up, True) + shutil.rmtree(get_path(persistent.client)) + renpy.notify("Files are corrupted!") + else: + renpy.notify("All files up to date!") + except: + traceback.print_exc() + renpy.notify("An error happened.") + return + init 1 python: ############################################################################# def download_manaplus(fname): @@ -62,7 +84,7 @@ init 1 python: return False status_update("Marking as executable...", 70) - execute("chmod +x %s" % installdir+"/ManaPlus.AppImage", shell=True) + execute("chmod +x \"%s\"" % installdir+"/ManaPlus.AppImage", shell=True) status_update("Installation successful!", 75) ######################################################### elif renpy.windows: @@ -84,17 +106,17 @@ init 1 python: return True ############################### - def cli_manaplus(launch=False): + def cli_manaplus(launch=False, download=True): global SCR_PROMPT, SCR_RESULT ## Check if ManaPlus is already installed try: MANAPLUS=os.path.exists(get_path("manaplus")) except: - traceback.printexc() + traceback.print_exc() MANAPLUS=False ## Installer - if not MANAPLUS: + if not MANAPLUS and download: SCR_PROMPT=("Selected client \"%s\" is not installed.\nDo you wish to install it now?\n\n{size=14}By installing you agree with its {a=%s}Terms of Use and Conditions{/a}.%s{/size}" % ("ManaPlus", "https://gitlab.com/themanaworld/manaplus/manaplus/-/raw/master/COPYING", ifte(renpy.linux, "\n{i}libfuse2{/i} is required to run AppImages.", ""))) @@ -115,6 +137,8 @@ init 1 python: traceback.print_exc() stdout("Installation failed!", True) return False + elif not MANAPLUS: + return False ########## if launch: @@ -129,7 +153,7 @@ init 1 python: return True ############################################################################# - def cli_mana(launch=False): + def cli_mana(launch=False, download=True): stdout("ERROR, Mana Client is not implemented!") return False @@ -141,14 +165,16 @@ init 1 python: MANA=False ## Installer - if not MANAPLUS: + if not MANA and download: SCR_PROMPT=("Selected client \"%s\" is not installed.\nDo you wish to install it now?\n\n{size=14}By installing you agree with its {a=%s}Terms of Use and Conditions{/a}.{/size}" % ("Mana", "https://gitlab.com/themanaworld/tmw-client/????/-/raw/master/COPYING")) while SCR_RESULT is None: time.sleep(0.02) ret=copy.copy(SCR_RESULT) SCR_RESULT=None - if (not ret): + if (not ret): + return False + elif not MANA: return False return True diff --git a/game/core.rpy b/game/core.rpy index 762c0a0..1e29da0 100644 --- a/game/core.rpy +++ b/game/core.rpy @@ -110,7 +110,7 @@ init -3 python: path=path.replace("/", "_") return renpy.config.savedir + "/" + path else: - return os.path.join(renpy.config.basedir, path) + return renpy.config.basedir + "/" + path # Global classes # We need to override standard list method. Original by Triptych (stackoverflow) diff --git a/game/screens.rpy b/game/screens.rpy index 88f3046..1342e26 100644 --- a/game/screens.rpy +++ b/game/screens.rpy @@ -735,6 +735,16 @@ screen preferences(): textbutton _("Mute All"): action Preference("all mute", "toggle") style "mute_all_button" + null height gui.pref_spacing + + if persistent.hello is not None: + textbutton _("Check Files Integrity"): + action ifte(persistent.client is not None and + persistent.host is not None and + handle_client(launch=True, download=False), + Function(md5check_client), + None) + style "mute_all_button" if persistent.hello is None: fixed: |