[L|0.0.466] Modding: NeverEats makes Pawn_HealthTracker crash

Started by gertvv, June 25, 2014, 01:14:39 PM

Previous topic - Next topic

gertvv

In the Droids mod I had an issue where Droids were mysteriously taking damage. This can be fixed by putting <diet>NeverEats</diet> in the RaceDef. However, when I do this the PawnGenerator won't create a food tracker:


if (pawn.RaceDef.EatsFood)
{
pawn.food = new Pawn_FoodTracker (pawn);
}


This is fine, unless the pawn goes below max health, in which case the following check (done twice) in Pawn_HealthTracker.HealthTick() dereferences the null pointer pawn.food:


if (!this.pawn.food.Food.Starving)


Which seems to stop it from functioning altogether. I'm working on a work around but seems like a null check would be in order.