Skip to content

Commit

Permalink
Create PauseLockSession during PostLoadInit in ExposeData
Browse files Browse the repository at this point in the history
Normally, calling `UniqueIDsManager.GetNextID` gives a warning when that happens, which made me realize that it's potentially unsafe to do so - the IDs may have not been loaded at that point. This should not happen when saving the data, as the session should exist at that point.

The solution here is to only create the session when `Scribe.mode` is `LoadSaveMode.PostLoadInit`. This ensures the IDs are initialized and getting the next ID won't cause any issues.
  • Loading branch information
SokyranTheDragon committed Aug 16, 2024
1 parent f0221d0 commit 4543feb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Source/Client/Comp/World/MultiplayerWorldComp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void ExposeData()

sessionManager.ExposeSessions();
// Ensure a pause lock session exists if there's any pause locks registered
if (!PauseLockSession.pauseLocks.NullOrEmpty())
if (!PauseLockSession.pauseLocks.NullOrEmpty() && Scribe.mode == LoadSaveMode.PostLoadInit)
sessionManager.AddSession(new PauseLockSession(null));

DoBackCompat();
Expand Down

0 comments on commit 4543feb

Please sign in to comment.