Reliable reproduction of Exception in RimWorld.ThinkNode_Priority_GetJoy in 0.17

Started by Anvil_Pants, July 08, 2017, 08:31:20 AM

Previous topic - Next topic

Anvil_Pants

RimWorld 0.17.1557 rev1146

Exception in RimWorld.ThinkNode_Priority_GetJoy TryIssueJobPackage: System.NullReferenceException: Object reference not set to an instance of an object
  at RimWorld.JoyGiver_TakeDrug.BestIngestItem (Verse.Pawn pawn, System.Predicate`1 extraValidator) [0x00000] in <filename unknown>:0
  at RimWorld.JoyGiver_Ingest.TryGiveJobInternal (Verse.Pawn pawn, System.Predicate`1 extraValidator) [0x00000] in <filename unknown>:0
  at RimWorld.JoyGiver_Ingest.TryGiveJob (Verse.Pawn pawn) [0x00000] in <filename unknown>:0
  at RimWorld.JobGiver_GetJoy.TryGiveJobFromJoyGiverDefDirect (RimWorld.JoyGiverDef def, Verse.Pawn pawn) [0x00000] in <filename unknown>:0
  at RimWorld.JobGiver_GetJoy.TryGiveJob (Verse.Pawn pawn) [0x00000] in <filename unknown>:0
  at Verse.AI.ThinkNode_JobGiver.TryIssueJobPackage (Verse.Pawn pawn, JobIssueParams jobParams) [0x00000] in <filename unknown>:0
  at Verse.AI.ThinkNode_Priority.TryIssueJobPackage (Verse.Pawn pawn, JobIssueParams jobParams) [0x00000] in <filename unknown>:0
Verse.Log:Error(String)
Verse.AI.ThinkNode_Priority:TryIssueJobPackage(Pawn, JobIssueParams)
Verse.AI.ThinkNode_PrioritySorter:TryIssueJobPackage(Pawn, JobIssueParams)
Verse.AI.ThinkNode_Priority:TryIssueJobPackage(Pawn, JobIssueParams)
Verse.AI.ThinkNode_Tagger:TryIssueJobPackage(Pawn, JobIssueParams)
Verse.AI.ThinkNode_Priority:TryIssueJobPackage(Pawn, JobIssueParams)
RimWorld.ThinkNode_Conditional:TryIssueJobPackage(Pawn, JobIssueParams)
Verse.AI.ThinkNode_Priority:TryIssueJobPackage(Pawn, JobIssueParams)
Verse.AI.Pawn_JobTracker:DetermineNextJob(ThinkTreeDef&)
Verse.AI.Pawn_JobTracker:TryFindAndStartJob()
Verse.AI.Pawn_JobTracker:EndCurrentJob(JobCondition, Boolean)
Verse.AI.Pawn_JobTracker:JobTrackerTick()
Verse.Pawn:Tick()
Verse.TickList:Tick()
Verse.TickManager:DoSingleTick()
Verse.TickManager:TickManagerUpdate()
Verse.Game:UpdatePlay()
Verse.Root_Play:Update()


I'm causing this in vanilla, with this patch:

<?xml version="1.0" encoding="utf-8" ?>
<Patch>
  <Operation Class="PatchOperationSequence">
    <success>Always</success>
    <operations>
      <li Class="PatchOperationTest">
        <xpath>*/NeedDef[defName = "Joy"]/colonistAndPrisonersOnly</xpath>
      </li>
      <li Class="PatchOperationRemove">
         <xpath>*/NeedDef[defName = "Joy"]/colonistAndPrisonersOnly</xpath>
      </li>
    </operations>
  </Operation>

  <Operation Class="PatchOperationSequence">
    <success>Always</success>
    <operations>
      <li Class="PatchOperationTest">
        <xpath>*/NeedDef[defName = "Joy"]/neverOnPrisoner</xpath>
      </li>
      <li Class="PatchOperationRemove">
         <xpath>*/NeedDef[defName = "Joy"]/neverOnPrisoner</xpath>
      </li>
    </operations>
  </Operation>

  <Operation Class="PatchOperationAdd">
    <xpath>*/NeedDef[defName = "Joy"]</xpath>
    <value>
      <neverOnPrisoner>false</neverOnPrisoner>
    </value>
  </Operation>

  <Operation Class="PatchOperationSequence">
    <success>Always</success>
    <operations>
      <li Class="PatchOperationTest">
        <xpath>*/NeedDef[defName = "Joy"]/colonistsOnly</xpath>
      </li>
      <li Class="PatchOperationRemove">
         <xpath>*/NeedDef[defName = "Joy"]/colonistsOnly</xpath>
      </li>
    </operations>
  </Operation>

  <Operation Class="PatchOperationAdd">
    <xpath>*/NeedDef[defName = "Joy"]</xpath>
    <value>
      <colonistsOnly>false</colonistsOnly>
    </value>
  </Operation>

</Patch>


Edit: With patch, lock up a prisoner with a joy item and hit the prisoner with -20% joy until they try to play.

It's similar to this closed issue on Mantis.

Here's the full log. In that test I had Hospitality loaded as well, just to be thorough in my own testing. I discovered the exception because Prisoner Joy's author tried to use colonistAndPrisonersOnly=true on Joy NeedDef, and that stopped Hospitality's guests from doing joy things. I think that the patch above is the right way to do it.

ison