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 diff --git a/Monika After Story/game/overrides.rpy b/Monika After Story/game/overrides.rpy index 4283d4c6e7..cbbdc59142 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,88 @@ python early in mas_overrides: savelocation.init = savelocation_init_override + def parser_report_parse_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. + + 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 + + try: + if obj.filename == "script-poemgame.rpyc": + renpy.game.script.initcode.pop(index) + except: + pass + report_parse_errors_ran = True + + # 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 + + report_parse_errors_ran = False + parser.report_parse_errors = parser_report_parse_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