X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fserver%2Fthing_actions.c;h=dea23323bcf6b7a9f2b43974b5af180720d55faa;hb=5a139c5b058beedf631a2e316b336759edf48667;hp=839a6e36d85eaa84644e723f576c9fa069c2cf6c;hpb=3fb2cb493ae564f8b14ddb4143b6c1f5bf16f16a;p=plomrogue diff --git a/src/server/thing_actions.c b/src/server/thing_actions.c index 839a6e3..dea2332 100644 --- a/src/server/thing_actions.c +++ b/src/server/thing_actions.c @@ -7,11 +7,11 @@ #include "thing_actions.h" #include /* NULL */ -#include /* uint8_t, INT16_MIN */ +#include /* uint8_t, INT16_MIN, INT16_MAX */ #include /* sprintf() */ #include /* free() */ #include /* strlen() */ -#include "../common/rexit.h" /* exit_trouble() */ +#include "../common/rexit.h" /* exit_err(), exit_trouble() */ #include "../common/try_malloc.h" /* try_malloc() */ #include "../common/yx_uint8.h" /* yx_uint8 */ #include "field_of_view.h" /* build_fov_map() */ @@ -317,6 +317,8 @@ extern void actor_use(struct Thing * t) { t->owns = next; } + t->satiation = t->satiation + tt->consumable > INT16_MAX ? + INT16_MAX : t->satiation + tt->consumable; t->lifepoints = t->lifepoints + tt->consumable; } } @@ -330,17 +332,14 @@ extern void actor_use(struct Thing * t) extern void hunger(struct Thing * t) { - struct ThingType * tt = get_thing_type(t->type); - if (!(tt->stomach)) - { - return; - } if (t->satiation > INT16_MIN) { t->satiation--; } + struct ThingType * tt = get_thing_type(t->type); uint16_t testbase = t->satiation < 0 ? -(t->satiation) : t->satiation; - uint16_t endurance = tt->stomach; + exit_err(!(tt->lifepoints), "A thing that should not hunger is hungering."); + uint16_t endurance = INT16_MAX / tt->lifepoints; if ((testbase / endurance) / ((rrand() % endurance) + 1)) { if (get_player() == t)