Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPA checks + scripts.rpa handling #10212

Open
wants to merge 4 commits into
base: content
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/mas_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
86 changes: 86 additions & 0 deletions Monika After Story/game/overrides.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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


12 changes: 6 additions & 6 deletions Monika After Story/game/splash.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down