This issue is to document the steps analyzing and reproducing the starvation bug, fixed in 54e11c21cf251d24ea38d76e28f6923dc28ce7cc
Note that this might not be the only cause of the bug.
This bug was triggered by eating food with a title, such as Waybread of Aelingas. In food.cpp:food_type_apply(), eating food with a title calls eat_special_food(). This will create a force on the player with a duration based on the food value. (eg waybread = 600, duration = 150).
The force would exist, and continued existing until the food value hits -150. This is because both the duration and food variables were being decremented inside time.cpp:process_object().
If the player ate another piece of food while the force exists, then the negative food value stored inside the force would get added to the players hunger, resulting in losing hunger.
If the players hunger then dropped below 0, the player would auto-eat causing the bug to continue. Also, since the forces are saved with the player, logging out then back in would not fix the issue. The only way to stop the issue was to wait for all the forces to expire.
Steps to reproduce:
Add logging of the force food values inside time.cpp:process_object(), just before FLAG_IS_USED_UP is tested.
if (op->stats.food < 0)
LOG(llevError, "food %d\n", op->stats.food);
create 50 waybread of Aelingas
I think this is where the other part of the issue is, but we all investigated and fixed this a while back:
After eating the food, it calls
fix_object(), which then adds up all the negative food variables of typeFORCE, and uses that to set the player digestion.Fix 54e11c21cf251d24ea38d76e28f6923dc28ce7cc was to not decrement the food if there was a duration set, so that the food value did not end up negative.
Diff:
Two cases observed, very similar situations. First in Mostrai Dwarven Mines, second in Guild Big Chest (empty except for chest being detrapped + summoned mobs from trap).
In both cases:
HP regenerating.
No food in inventory.
Instant death upon entering map.
Mobs not able to one hit character.
Multiple mobs surrounding map entrance.
No messages of any kind indicating starvation.
Only known starvation was cause by retrieving tombstone.
One or both Mana / Grace regenerating (but in second case, not grace, only mana).
Scenario:
Probable full mana/grace, but not sure.
Very sure at full HP.
Pop into map.
Encounter mobs.
Take minor damage.
Pop back up.
Prepare for battle.
Pop back in.
Instant death.
Food level unknown, but assume very low at start.
In first case, on initial entry, pop off holy word.
In second case, on initial entry, drop trapped chest, search, disarm fail -> 2 water golems. Possibly regenerating mana due to prior cast identify, but not sure.
Both on Invidious (Crossfire v1.75.0-1456-g5ec6b5586). Second case on the date of this post (Rayvin). First case, several days prior (Kadahbray).
Last edit: Kevin R. Bulgrien 2025-06-06