[Altered Carbon] Seemingly harmless error when loading a save
Opened this issue · 1 comments
Related mods are Pawnmorpher(tested in Dev release from 18-03-2023) and Altered Carbon: Ultratech Unleashed. Error occurs when loading a save, 6 times. Likely correlates to the amount of pawns with a cortical stack
Could not instantiate or initialize a ThingComp: System.NullReferenceException: Object reference not set to an instance of an object
at AlteredCarbon.ACUtils.IsEmptySleeve (Verse.Pawn pawn) [0x00001] in <714fcbf373ed425faaf9f38e6976fa1d>:0
at AlteredCarbon.PawnUtility_ShouldSendNotificationAbout_Patch.Prefix (Verse.Pawn p) [0x00001] in <714fcbf373ed425faaf9f38e6976fa1d>:0
at (wrapper dynamic-method) RimWorld.PawnUtility.RimWorld.PawnUtility.ShouldSendNotificationAbout_Patch2(Verse.Pawn)
at Pawnmorph.AspectTracker.Add (Pawnmorph.Aspect aspect, System.Int32 startStage) [0x001ab] in <6db10fc42b7d41dfa2036b8edcff7ed5>:0
at Pawnmorph.MorphTrackingComp.Awake () [0x00091] in <6db10fc42b7d41dfa2036b8edcff7ed5>:0
at Pawnmorph.MorphTrackingComp.Initialize (Verse.CompProperties props) [0x0001e] in <6db10fc42b7d41dfa2036b8edcff7ed5>:0
at (wrapper dynamic-method) Verse.ThingWithComps.Verse.ThingWithComps.InitializeComps_Patch1(Verse.ThingWithComps)
UnityEngine.StackTraceUtility:ExtractStackTrace ()
(wrapper dynamic-method) Verse.Log:Verse.Log.Error_Patch4 (string)
(wrapper dynamic-method) Verse.ThingWithComps:Verse.ThingWithComps.InitializeComps_Patch1 (Verse.ThingWithComps)
(wrapper dynamic-method) Verse.ThingWithComps:Verse.ThingWithComps.ExposeData_Patch1 (Verse.ThingWithComps)
(wrapper dynamic-method) Verse.Pawn:Verse.Pawn.ExposeData_Patch1 (Verse.Pawn)
Verse.ScribeExtractor:SaveableFromNode<Verse.Pawn> (System.Xml.XmlNode,object[])
Verse.Scribe_Collections:Look<Verse.Pawn> (System.Collections.Generic.List`1<Verse.Pawn>&,bool,string,Verse.LookMode,object[])
Verse.Scribe_Collections:Look<Verse.Pawn> (System.Collections.Generic.HashSet`1<Verse.Pawn>&,bool,string,Verse.LookMode)
Verse.Scribe_Collections:Look<Verse.Pawn> (System.Collections.Generic.HashSet`1<Verse.Pawn>&,string,Verse.LookMode)
RimWorld.Planet.WorldPawns:ExposeData ()
Verse.ScribeExtractor:SaveableFromNode<RimWorld.Planet.WorldPawns> (System.Xml.XmlNode,object[])
Verse.Scribe_Deep:Look<RimWorld.Planet.WorldPawns> (RimWorld.Planet.WorldPawns&,bool,string,object[])
Verse.Scribe_Deep:Look<RimWorld.Planet.WorldPawns> (RimWorld.Planet.WorldPawns&,string,object[])
RimWorld.Planet.World:ExposeComponents ()
RimWorld.Planet.WorldGenStep_Components:GenerateFromScribe (string)
RimWorld.Planet.WorldGenerator:GenerateFromScribe (string)
RimWorld.Planet.World:ExposeData ()
(wrapper dynamic-method) Verse.Game:Verse.Game.LoadGame_Patch7 (Verse.Game)
(wrapper dynamic-method) Verse.SavedGameLoaderNow:Verse.SavedGameLoaderNow.LoadGameFromSaveFileNow_Patch3 (string)
Verse.Root_Play/<>c:<Start>b__1_1 ()
Verse.LongEventHandler:RunEventFromAnotherThread (System.Action)
Verse.LongEventHandler/<>c:<UpdateCurrentAsynchronousEvent>b__27_0 ()
System.Threading.ThreadHelper:ThreadStart_Context (object)
System.Threading.ExecutionContext:RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)
System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)
System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object)
System.Threading.ThreadHelper:ThreadStart ()
"return pawn.Dead is false && AlteredCarbonManager.Instance.emptySleeves.Contains(pawn);"
The only thing i can see that might throw NullReference here is AlteredCarbonManager.Instance or .emptySleeves.
That indicates the issue is not as much an incompatibility as a timing issue.
They prefix rimworld generic notification method which we trigger to notify about added mutations, and seemingly this is triggered before AlteredCarbon is fully initialised.
https://github.com/Helixien/AlteredCarbon/blob/422ac624b44ae1806882adcec686beb7b7feb35b/1.4/Source/AlteredCarbon/HarmonyPatches/PawnUtility_ShouldSendNotificationAbout_Patch.cs#L8-L18
A guess would be that PM is ahead of AlteredCarbon in expose data load order, so mutations are loaded before sleeves.
Can you try moving Pawnmorpher below Altered Carbon in load order?