Multiplayer icon indicating copy to clipboard operation
Multiplayer copied to clipboard

Syncing pawns with addictions triggers an error during the exposure process.

Open Tick-git opened this issue 6 months ago • 1 comments

Label: Multifaction, Bug, 1.5

ModList:

Prepatcher, Harmony, Core, Biotech, Ideology, Multiplayer

Reproduce:

  1. Be in a multifaction game
  2. Create a new faction
  3. Randomize a pawn until they have an addiction
  4. Generate the faction
  5. three exceptions are thrown
  6. 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:

Error while determining if Rosie should have Need Food.txt

Tick-git avatar Jun 15 '25 14:06 Tick-git

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.

ianleeder avatar Jul 20 '25 13:07 ianleeder