-
-
Notifications
You must be signed in to change notification settings - Fork 5
Add payload for YARPE AUTO LOAD using Persistent file. #8
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
base: main
Are you sure you want to change the base?
Add payload for YARPE AUTO LOAD using Persistent file. #8
Conversation
WalkthroughA new payload module is introduced that embeds a YARPE persistence mechanism into Ren'Py save files. It injects a custom pickle object into the persistent save, which triggers bootstrap code execution when the save is loaded, then overwrites the serialized persistent file to disk. Changes
Sequence DiagramsequenceDiagram
participant P as Payload Module
participant R as Ren'Py Persistent
participant D as Disk (/saves/persistent)
rect rgb(200, 220, 240)
Note over P,D: Injection Phase
P->>R: Attach Yummy trigger object
P->>R: Mark persistent as changed
end
rect rgb(240, 220, 200)
Note over P,D: Serialization Phase
P->>P: Pickle persistent (protocol 2)
P->>P: Compress with zlib
end
rect rgb(220, 240, 200)
Note over P,D: Write Phase
P->>D: Overwrite /saves/persistent
end
rect rgb(240, 200, 220)
Note over P,D: Trigger Phase (on game load)
D->>R: Load persistent from disk
R->>R: Unpickle & decompress
R->>R: Call Yummy.__reduce__()
R->>R: Execute SCRIPT via Ren'Py globals
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
payloads/force_persistent.py (3)
12-59: Label callback override may clobber any existing game callbackThe bootstrap script unconditionally assigns
renpy.config.label_callback = yarpe_label_callback, which will discard any label callback the host game (or other mods) may have installed. That’s fine if you don’t care about compatibility, but if you want to be less invasive you could capture and chain the previous callback, e.g. insideSCRIPT:old_cb = renpy.config.label_callback def yarpe_label_callback(label, abnormal): ylog("LABEL: %s (abnormal=%r)" % (label, abnormal)) if label == "splashscreen" and not ys.game_initialized: ys.game_initialized = True ylog("YARPE: Entered _call__enter_game_menu_0 → autoloading slot '1-1'.") try: renpy.load("1-1") except Exception as e: ylog("YARPE ERROR: renpy.load('1-1') failed: %r" % e) if old_cb is not None: try: old_cb(label, abnormal) except Exception as e: ylog("YARPE: original label_callback raised: %r" % e)This keeps your behavior while preserving any existing callback.
66-94: Unify syscall error typing and consider wiring guarantees forgetpid/killTwo minor points here:
getpidfailure raises a bareExceptionwhilekillraisesSocketError. For consistency (and to satisfy linters complaining about generic exceptions), consider using the same domain-specific exception in both branches, e.g.:- if pid < 0: - raise Exception( + if pid < 0: + raise SocketError( "getpid failed with return value %d, error %d\n%s" % ( pid, sc.syscalls.getpid.errno, sc.syscalls.getpid.get_error_string(), ) )
kill_gameassumessc.syscalls.getpidandsc.syscalls.killhave already been bound using the updatedSYSCALLentries. It’s worth double‑checking that your initialization path guarantees these call wrappers exist before this payload runs; otherwise, you could get anAttributeErrorhere instead of a clean error.
95-138: BroadExceptioncatches are acceptable here but can be tightened or made more debuggableGiven this is a one‑shot payload, catching
Exceptionaroundpickle.dumps,zlib.compress, and the file write to log and bail is reasonable. If you want to placate stricter linters and improve diagnostics:
- Narrow the exceptions to likely failures, e.g.
pickle.PicklingError,zlib.error, andOSError/IOErrorfor the file operations.- Or, keep
Exceptionbut log a traceback as well so you don’t lose context during debugging.Functionally it’s fine as is; this is more about tooling friendliness and future debugging ease.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
payloads/force_persistent.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
payloads/force_persistent.py (3)
src/utils/rp.py (1)
log(45-52)payloads/updater_for_up_to_2.x.x.py (1)
sc(16-34)renpy/python.py (1)
py_exec(1-2)
🪛 Ruff (0.14.4)
payloads/force_persistent.py
75-82: Create your own exception
(TRY002)
116-116: Do not catch blind exception: Exception
(BLE001)
122-122: Do not catch blind exception: Exception
(BLE001)
136-136: Do not catch blind exception: Exception
(BLE001)
🔇 Additional comments (2)
payloads/force_persistent.py (2)
1-11: Imports and base constants look tight and purposefulAll imported symbols are used, and the single
PERSISTENT_PATHconstant keeps the file’s external contract minimal. No issues here.
62-64: Pickle-based bootstrap viaYummy.__reduce__is coherentUsing
__reduce__to returnrenpy.python.py_execwith the embeddedSCRIPTensures the payload runs on unpickle as intended, and the tuple shape matches whatpickleexpects. Just make surerenpy.python.py_execexists for all Ren’Py versions/platforms you target.
Summary by CodeRabbit
Note: This release contains internal technical changes with no direct impact on user-facing features or gameplay.