Syncing pawns with addictions triggers an error during the exposure process.
Label: Multifaction, Bug, 1.5
ModList:
Prepatcher, Harmony, Core, Biotech, Ideology, Multiplayer
Reproduce:
- Be in a multifaction game
- Create a new faction
- Randomize a pawn until they have an addiction
- Generate the faction
- three exceptions are thrown
- Root Exception: Error while determining if [PawnName] should have Need Food: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object`
Severity:
The exception does not appear to affect game flow or causes desyncs. The pawn is initialized correctly and the map generates without issues. This seems to be a non-critical error.
My Understanding:
The method FactionSidebar.DoCreateFaction calls the [SyncMethod] FactionCreator.SendPawn, which takes an exposable Pawn as a parameter.
During the syncing process the pawn gets exposed in both ways on all clients (loading, saving). I assume that in standard RimWorld behavior, when a pawn is load from disk for the first time, the program state is not yet set to Playing, which ensures certain initialization code paths are used.
However, in a this multiplayer scenario, the program state is already set to Playing during this process. This causes a different code path to execute during pawn exposure - one that assumes some of the pawn’s internal values have already been initialized.
Because those values are not yet initialized at that point, a NullReferenceException is thrown.
Stacktrace and explaination:
I didn't see this one, and just raised another. #589 looks to be very clearly a duplicate, but mine causes instant desyncs on unpause. I'll close mine @Tick-git. I can re-open if it's somehow different, but it doesn't seem to be.