From 3bdf3126617e95dd0f5720a21cbd3420c00e5618 Mon Sep 17 00:00:00 2001 From: potato Date: Sat, 24 Feb 2024 21:37:59 -0600 Subject: [PATCH 1/4] readded rpa checks but removed script-poemgame from loading --- Monika After Story/game/overrides.rpy | 74 +++++++++++++++++++++++++++ Monika After Story/game/splash.rpy | 12 ++--- 2 files changed, 80 insertions(+), 6 deletions(-) diff --git a/Monika After Story/game/overrides.rpy b/Monika After Story/game/overrides.rpy index 4283d4c6e7..ca7c49bfc6 100644 --- a/Monika After Story/game/overrides.rpy +++ b/Monika After Story/game/overrides.rpy @@ -24,6 +24,7 @@ python early in mas_overrides: import renpy import renpy.savelocation as savelocation + import renpy.parser as parser def verify_data_override(data, signatures, check_verifying=True): @@ -66,3 +67,76 @@ python early in mas_overrides: savelocation.init = savelocation_init_override + def parser_report_parser_errors_override(): + """ + This override is actually for something unrelated. + + We need to prevent scripts.rpa code from being loaded, but there's + no way to override script loading code since by the time THIS script + is loaded (and override set), the scripts.rpa contents are already + queued to be loaded later. + + This specific function is called before the init scripts start running + so this is the last place we can remove the scripts rpa stuff we dont + want. + """ + for index, initcode in reversed(list(enumerate(renpy.game.script.initcode))): + init_lvl, obj = initcode + + try: + if obj.filename == "script-poemgame.rpyc": + renpy.game.script.initcode.pop(index) + except: + pass + + # non-override code below + + parser.release_deferred_errors() + + if not parser.parse_errors: + return False + + full_text = "" + + f, error_fn = renpy.error.open_error_file("errors.txt", "w") + with f: + f.write("\ufeff") # BOM + + print("I'm sorry, but errors were detected in your script. Please correct the", file=f) + print("errors listed below, and try again.", file=f) + print("", file=f) + + for i in parser.parse_errors: + + full_text += i + full_text += "\n\n" + + if not isinstance(i, str): + i = str(i, "utf-8", "replace") + + print("", file=f) + print(i, file=f) + + try: + print("") + print(i) + except Exception: + pass + + print("", file=f) + print("Ren'Py Version:", renpy.version, file=f) + print(str(time.ctime()), file=f) + + renpy.display.error.report_parse_errors(full_text, error_fn) + + try: + if renpy.game.args.command == "run": # type: ignore + renpy.exports.launch_editor([ error_fn ], 1, transient=True) + except Exception: + pass + + return True + + parser.report_parse_errors = parser_report_parser_errors_override + + diff --git a/Monika After Story/game/splash.rpy b/Monika After Story/game/splash.rpy index 58b06aa1fe..3c4b4260d1 100644 --- a/Monika After Story/game/splash.rpy +++ b/Monika After Story/game/splash.rpy @@ -2,12 +2,12 @@ ## ## Before load, check to be sure that the archive files were found. ## If not, display an error message and quit. -# init -100 python: -# #Check for each archive needed -# for archive in ['audio','images','scripts','fonts']: -# if not archive in config.archives: -# #If one is missing, throw an error and chlose -# renpy.error("DDLC archive files not found in /game folder. Check installation and try again.") +init -100 python: + #Check for each archive needed + for archive in ['audio','images', 'scripts', 'fonts']: + if not archive in config.archives: + #If one is missing, throw an error and chlose + renpy.error("DDLC archive files not found in /game folder. Check installation and try again.") ## First, a disclaimer declaring this is a mod is shown, then there is a ## check for the original DDLC assets in the install folder. If those are From 4a51dc6f04975a365333214281c604d8815cf56f Mon Sep 17 00:00:00 2001 From: potato Date: Sat, 24 Feb 2024 21:46:03 -0600 Subject: [PATCH 2/4] no longer delete the scripts.rpa in ci --- .github/workflows/mas_check.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/mas_check.yml b/.github/workflows/mas_check.yml index 67e9db0e5f..d203d07160 100644 --- a/.github/workflows/mas_check.yml +++ b/.github/workflows/mas_check.yml @@ -75,7 +75,6 @@ jobs: run: | mkdir $MAS_DIR cp -Rf $MAS_BASE_DIR/* $MAS_DIR/ - rm $MAS_DIR/game/scripts.rpa # remove when we can handle scripts rpa # copy over gh files to base - name: copy source over From a04fc92f950a028e5e4e5b7dd554908542a4056a Mon Sep 17 00:00:00 2001 From: potato Date: Sun, 25 Feb 2024 04:52:03 -0600 Subject: [PATCH 3/4] rename function to match override and only run the override code once --- Monika After Story/game/overrides.rpy | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Monika After Story/game/overrides.rpy b/Monika After Story/game/overrides.rpy index ca7c49bfc6..2f3604eb8d 100644 --- a/Monika After Story/game/overrides.rpy +++ b/Monika After Story/game/overrides.rpy @@ -67,7 +67,7 @@ python early in mas_overrides: savelocation.init = savelocation_init_override - def parser_report_parser_errors_override(): + def parser_report_parse_errors_override(): """ This override is actually for something unrelated. @@ -80,14 +80,18 @@ python early in mas_overrides: so this is the last place we can remove the scripts rpa stuff we dont want. """ - for index, initcode in reversed(list(enumerate(renpy.game.script.initcode))): - init_lvl, obj = initcode + global report_parse_errors_ran - try: - if obj.filename == "script-poemgame.rpyc": - renpy.game.script.initcode.pop(index) - except: - pass + if not report_parse_errors_ran: + for index, initcode in reversed(list(enumerate(renpy.game.script.initcode))): + init_lvl, obj = initcode + + try: + if obj.filename == "script-poemgame.rpyc": + renpy.game.script.initcode.pop(index) + except: + pass + report_parse_errors_ran = True # non-override code below @@ -137,6 +141,7 @@ python early in mas_overrides: return True - parser.report_parse_errors = parser_report_parser_errors_override + report_parse_errors_ran = False + parser.report_parse_errors = parser_report_parse_errors_override From 27dd2572a6359289693a6792602ec2af2b92167d Mon Sep 17 00:00:00 2001 From: potato Date: Sun, 25 Feb 2024 04:54:14 -0600 Subject: [PATCH 4/4] add clarifying comments on what the override does and why --- Monika After Story/game/overrides.rpy | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Monika After Story/game/overrides.rpy b/Monika After Story/game/overrides.rpy index 2f3604eb8d..cbbdc59142 100644 --- a/Monika After Story/game/overrides.rpy +++ b/Monika After Story/game/overrides.rpy @@ -79,9 +79,16 @@ python early in mas_overrides: This specific function is called before the init scripts start running so this is the last place we can remove the scripts rpa stuff we dont want. + + renpy.game.script.initcode contains a list of AST nodes that will be + loaded on init - script-poemgame is the only known init that crashes + startup, so any AST node coming from that file is removed from + initcode here. """ global report_parse_errors_ran + # report_parse_errors runs multiple times (counted 10 on startup) + # so this is guarded to only run once if not report_parse_errors_ran: for index, initcode in reversed(list(enumerate(renpy.game.script.initcode))): init_lvl, obj = initcode