From 4543febdd7fad3e3fa76cb20f2395bfb09f2e4a9 Mon Sep 17 00:00:00 2001 From: SokyranTheDragon Date: Fri, 16 Aug 2024 18:31:27 +0200 Subject: [PATCH] Create PauseLockSession during PostLoadInit in ExposeData 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. --- Source/Client/Comp/World/MultiplayerWorldComp.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Client/Comp/World/MultiplayerWorldComp.cs b/Source/Client/Comp/World/MultiplayerWorldComp.cs index f30f1d71..b9f5398f 100644 --- a/Source/Client/Comp/World/MultiplayerWorldComp.cs +++ b/Source/Client/Comp/World/MultiplayerWorldComp.cs @@ -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();