Colonist attempts to eat silver, causes null exception

Started by ZorbaTHut, November 21, 2016, 02:59:25 AM

Previous topic - Next topic

ZorbaTHut

Repro steps: Load attached save, hit 3, wait for a tiny fraction of a second, watch error log start to fill with errors.

I've found a glitch in the drug ingestion code. When looking for a drug to ingest, the colonist first checks everything they're carrying. Unfortunately, Beatriz is carrying silver, and the code doesn't test if things actually *are* ingestible before testing to see what kind of joy they produce.

Turns out you can't eat silver, so it gets a null dereference error in JoyGiver_Ingest.CanUseIngestItemForJoy.

I'm not entirely sure how Beatriz ended up carrying silver - she joined the colony as a wanderer, so she may have just come with it in her inventory. It's possible this is mod-related (the game had a lot of mods before I stripped them) but I kinda feel like the game should be able to handle this case in general.

This error seems mostly harmless, except I bet it's preventing Beatriz from successfully dealing with low joy. On the other hand, I can just get Beatriz to drop her silver, and everything's fixed. So, I got a workaround, don't mind me :)

(yay, 30 free silver)

Exception in RimWorld.ThinkNode_ConditionalNeedPercentageAbove TryIssueJobPackage: System.NullReferenceException: Object reference not set to an instance of an object
  at RimWorld.JoyGiver_Ingest.CanUseIngestItemForJoy (Verse.Pawn pawn, Verse.Thing t) [0x00000] in <filename unknown>:0
  at RimWorld.JoyGiver_TakeDrug+<BestIngestItem>c__AnonStorey23B.<>m__121 (Verse.Thing t) [0x00000] in <filename unknown>:0
  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 RimWorld.JobGiver_IdleJoy.TryGiveJob (Verse.Pawn pawn) [0x00000] in <filename unknown>:0
  at Verse.AI.ThinkNode_JobGiver.TryIssueJobPackage (Verse.Pawn pawn) [0x00000] in <filename unknown>:0
  at Verse.AI.ThinkNode_Priority.TryIssueJobPackage (Verse.Pawn pawn) [0x00000] in <filename unknown>:0

[attachment deleted by admin due to age]

milon

Human pawns entering a map can all carry silver, whether they're Colonists or Raiders or Traders or visitors or whatever.  That's vanilla behavior.  Unfortunately I'm at work and can't check your save right now, but if the drug-ingestion job-giver doesn't validate if an inventory item can be consumed or not, then that's a bug.  And a rather funny one too.  :)

nccvoyager

*Tick-Shh*
"Aw yeah, that's some good silver."
*Universe Implodes*
:o

schizmo

I swallowed a penny once, but this is just ridiculous!  8)

Zhentar

So that's what's been doing it. I'd noticed that getting logged occasionally but hadn't dug into it. I got 57 free silver 8)

I put this in Mantis: https://ludeon.com/mantis/view.php?id=2746

ZorbaTHut

#5
Sweet, hadn't realized that existed :D Thanks!