KongMD-Steam / QuestionableEthicsEnhanced

The source code of the Questionable Ethics Enhanced mod for RimWorld.
MIT License
12 stars 7 forks source link

Null reference exception in JobDriver_ExtractGrowerProduct #53

Closed KongMD-Steam closed 4 years ago

KongMD-Steam commented 5 years ago

Describe the bug A user experienced a NullReferenceException message when extracting a pawn from the vat. The report from Steam Workshop gave this stacktrace:

JobDriver threw exception in initAction for pawn Grub driver=JobDriver_ExtractGrowerProduct (toilIndex=3) driver.job=(QE_ExtractFromGrowerJob (Job_4563749) A=Thing_QE_PawnVat928027) lastJobGiver=Verse.AI.ThinkNode_QueuedJob
System.NullReferenceException: Object reference not set to an instance of an object
at QEthics.Building_PawnVatGrower.ExtractProduct (Verse.Pawn pawn) [0x00000] in <filename unknown>:0 
at QEthics.JobDriver_ExtractGrowerProduct.<MakeNewToils>b__1_0 () [0x00000] in <filename unknown>:0 
at Verse.AI.JobDriver.TryActuallyStartNextToil () [0x00000] in <filename unknown>:0 

Verse.Log:Error(String, Boolean)
Verse.AI.JobUtility:TryStartErrorRecoverJob(Pawn, String, Exception, JobDriver)
Verse.AI.JobDriver:TryActuallyStartNextToil()
Verse.AI.JobDriver:ReadyForNextToil()
Verse.AI.JobDriver:DriverTick()
Verse.AI.Pawn_JobTracker:JobTrackerTick()
Verse.Pawn:Tick()
Verse.TickList:Tick()
Verse.TickManager:DoSingleTick()
Verse.TickManager:TickManagerUpdate()
Verse.Game:UpdatePlay()
Verse.Root_Play:Update()

Expected behavior All pawn extractions from the cloning vat should either work or fail giving the user an error message with info on why it failed. Here is the end-state of the changes I want to make for this:

If there is a Failure, Success, or player Aborts growing process, all paths result in the same save data for Cloning Vat and Organ vat.

To Reproduce

  1. Save the game with a pawn growing in a Clone Vat.
  2. Edit the save file and find the vat by searching for text 'Building_PawnVatGrower'.
  3. Remove the node <pawnBeingGrown> and everything it contains and replace it with <pawnBeingGrown />. This simulates the bug the users are having where crafting starts with no pawn growing.
  4. Click Finish Growing gizmo on the Clone Vat, and let pawn extract contents.
  5. Observe that error occurs.

Additional context Thanks to 'dragonslayer' on Steam Workshop for reporting.

KongMD-Steam commented 5 years ago

I've found a way to reproduce this error and have updated the Issue description. Working on a fix.

KongMD-Steam commented 4 years ago

bc3513a61f8d8917e695749ae55ca3f1803c5179 and f56435932c8e5f16bc2ac735d9acb068c9688d9d should fix this issue.