Skip to content

Switch lock type on BeforeBaseGame saveables#80

Open
k073l wants to merge 2 commits into
ifBars:stablefrom
k073l:fix/saveable-before-lock
Open

Switch lock type on BeforeBaseGame saveables#80
k073l wants to merge 2 commits into
ifBars:stablefrom
k073l:fix/saveable-before-lock

Conversation

@k073l
Copy link
Copy Markdown
Collaborator

@k073l k073l commented Jun 1, 2026

Switches the lock on BeforeBaseGame saveable loader from save path check to a flag-based system, where the lock is set on first load of all eligible saveables and released when game invokes onLoadComplete.

This allows for these saveables to be correctly reloaded on another load cycle (e.g. load save1 -> exit to menu -> load save1). Previous system blocked this exact example.

Tested on Mono with MoreNPCs and MultiDelivery (regression testing and testing the fix) and on IL2CPP with the same + BigWillyMod (regression testing for custom items).
Let me know if I missed anything.

Release Notes

  • Replace save-path-based lock mechanism with flag-based lock on BeforeBaseGame saveables for improved reload handling
  • New sameSession boolean flag prevents repeated execution within the same load session
  • Flag is reset via onLoadComplete listener, enabling proper reloading across load cycles (e.g., load save1 → exit to menu → load save1)
  • Retains existing per-saveable LoadOrder == BeforeBaseGame filtering and initialization-on-completion behavior for missing save data

Contributions by Author

Author Lines Added Lines Removed
k0 208 0

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

Warning

Review limit reached

@k073l, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 52 minutes and 43 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3021f35e-784a-4fb6-8c61-9ac1ef56cd3c

📥 Commits

Reviewing files that changed from the base of the PR and between c3571c8 and 8517240.

📒 Files selected for processing (1)
  • S1API/Internal/Patches/GenericSaveables.Patches.cs
📝 Walkthrough

Walkthrough

The pull request refactors load-cycle tracking in GenericSaveables.Patches.cs by replacing a folder-path comparison mechanism with a session-scoped boolean flag. The BeforeBaseLoaders prefix now returns early when a load is already in progress within the same session, and registers an event listener to reset the lock when loading completes.

Changes

Session-scoped Load-Once Lock

Layer / File(s) Summary
Session lock mechanism with load-complete reset
S1API/Internal/Patches/GenericSaveables.Patches.cs
MelonLoader import is added; lastLoadedGameFolderPath is replaced with sameSession boolean flag; BeforeBaseLoaders prefix returns early when flag is set; after BeforeBaseGame load logic, flag is set and ClearLockOnLoadComplete listener is registered on lm.onLoadComplete to reset the flag when loading finishes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A lock so swift, a session's guard,
No path to check, the task less hard,
When loading ends, the flag drops low—
Next time around, the prefix flows! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 70.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: switching the lock mechanism for BeforeBaseGame saveables, which aligns with the core objective of replacing the save-path-based lock with a flag-based lock.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
S1API/Internal/Patches/GenericSaveables.Patches.cs (1)

77-81: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Docstring is outdated.

Line 81 states "Uses the LoadedGameFolderPath to detect new load cycles" but the implementation now uses a sameSession flag cleared by onLoadComplete. Update to reflect the new mechanism.

📝 Suggested docstring update
 		/// <summary>
 		/// Loads saveables marked with BeforeBaseGame load order BEFORE base game loaders run.
 		/// This runs as a prefix to LoadManager.QueueLoadRequest on the first LoadRequest creation,
 		/// which happens right before base game loaders start processing.
-		/// Uses the LoadedGameFolderPath to detect new load cycles.
+		/// Uses a session flag cleared by onLoadComplete to detect new load cycles.
 		/// </summary>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@S1API/Internal/Patches/GenericSaveables.Patches.cs` around lines 77 - 81,
Update the outdated XML docstring for the prefix that loads saveables (the
method patch that runs before LoadManager.QueueLoadRequest) to remove the
reference to LoadedGameFolderPath and instead state that it uses an internal
sameSession flag (cleared by onLoadComplete) to detect new load cycles; mention
that this runs on the first LoadRequest creation before base game loaders run
and that sameSession is reset by onLoadComplete to allow subsequent load cycle
detection.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@S1API/Internal/Patches/GenericSaveables.Patches.cs`:
- Around line 77-81: Update the outdated XML docstring for the prefix that loads
saveables (the method patch that runs before LoadManager.QueueLoadRequest) to
remove the reference to LoadedGameFolderPath and instead state that it uses an
internal sameSession flag (cleared by onLoadComplete) to detect new load cycles;
mention that this runs on the first LoadRequest creation before base game
loaders run and that sameSession is reset by onLoadComplete to allow subsequent
load cycle detection.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 666cc5a7-2076-49ea-a351-eaac9707a942

📥 Commits

Reviewing files that changed from the base of the PR and between 248d8fe and c3571c8.

📒 Files selected for processing (1)
  • S1API/Internal/Patches/GenericSaveables.Patches.cs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant