Skip to content

Commit

Permalink
Disable HungerHealthLoss if rule is set to 0, instead of crashing (dk…
Browse files Browse the repository at this point in the history
  • Loading branch information
walt253 authored Feb 28, 2024
1 parent e176412 commit 59bfee9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/creature_states.c
Original file line number Diff line number Diff line change
Expand Up @@ -4071,11 +4071,15 @@ TbBool process_creature_hunger(struct Thing *thing)
cctrl->hunger_level++;
if (!hunger_is_creature_hungry(thing))
return false;
// Make sure every creature loses health on different turn
if (((game.play_gameturn + thing->index) % game.conf.rules.health.turns_per_hunger_health_loss) == 0) {
SYNCDBG(9,"The %s index %d lost %d health due to hunger",thing_model_name(thing), (int)thing->index, (int)game.conf.rules.health.hunger_health_loss);
remove_health_from_thing_and_display_health(thing, game.conf.rules.health.hunger_health_loss);
return true;
// HungerHealthLoss is disabled if set to 0 on rules.cfg.
if (game.conf.rules.health.turns_per_hunger_health_loss > 0)
{
// Make sure every creature loses health on different turn.
if (((game.play_gameturn + thing->index) % game.conf.rules.health.turns_per_hunger_health_loss) == 0) {
SYNCDBG(9,"The %s index %d lost %d health due to hunger",thing_model_name(thing), (int)thing->index, (int)game.conf.rules.health.hunger_health_loss);
remove_health_from_thing_and_display_health(thing, game.conf.rules.health.hunger_health_loss);
return true;
}
}
return false;
}
Expand Down

0 comments on commit 59bfee9

Please sign in to comment.