[B18] NullRef Exception in Bill_Medical.Notify_DoBillStarted

Started by Thirite, December 15, 2017, 07:41:05 PM

Previous topic - Next topic

Thirite

If you create a recipe with a Human as a recipeUser and define no ingredients, the game will throw this error on attempt to perform the bill:
JobDriver threw exception in initAction. Pawn=Winnie, Job=DoBill (Job_7204) A=Thing_Human368, Exception: System.NullReferenceException: Object reference not set to an instance of an object
  at RimWorld.Bill_Medical.Notify_DoBillStarted (Verse.Pawn billDoer) [0x00000] in <filename unknown>:0
  at Verse.AI.Toils_Recipe+<DoRecipeWork>c__AnonStorey1.<>m__0 () [0x00000] in <filename unknown>:0
  at Verse.AI.JobDriver.TryActuallyStartNextToil () [0x00000] in <filename unknown>:0  lastJobGiver=Verse.AI.ThinkNode_QueuedJob, curJob.def=DoBill, curDriver=Verse.AI.JobDriver_DoBill

(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)


However I modified the method to something like this via transpiling:
public override void Notify_DoBillStarted(Pawn billDoer)
{
base.Notify_DoBillStarted(billDoer);
this.consumedInitialMedicineDef = null;
if (!this.GiverPawn.Dead && this.recipe.ingredients.Count != 0 && this.recipe.anesthetize && HealthUtility.TryAnesthetize(this.GiverPawn))
{
...
}
}


And that fixes the issue cleanly.