From: SHIRAKATA Kentaro Date: Sun, 26 Jun 2022 20:22:05 +0000 (+0900) Subject: split starving dog into separate function X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=58b32e76f0f0e1199459d0ef9e5c2afe8693fbdd;p=nethack split starving dog into separate function --- diff --git a/src/dogmove.c b/src/dogmove.c index 8b746c7a4..2d8bc924e 100644 --- a/src/dogmove.c +++ b/src/dogmove.c @@ -11,6 +11,7 @@ #define DOG_WEAK 500 #define DOG_STARVE 750 +static void dog_starve(struct monst *); static boolean dog_hunger(struct monst *, struct edog *); static int dog_invent(struct monst *, struct edog *, int); static int dog_goal(struct monst *, struct edog *, int, int, int); @@ -376,6 +377,19 @@ dog_eat(struct monst *mtmp, return 1; } +static void +dog_starve(struct monst *mtmp) +{ + if (mtmp->mleashed && mtmp != u.usteed) + Your("leash goes slack."); + else if (cansee(mtmp->mx, mtmp->my)) + pline("%s starves.", Monnam(mtmp)); + else + You_feel("%s for a moment.", + Hallucination ? "bummed" : "sad"); + mondied(mtmp); +} + /* hunger effects -- returns TRUE on starvation */ static boolean dog_hunger(struct monst *mtmp, struct edog *edog) @@ -392,8 +406,10 @@ dog_hunger(struct monst *mtmp, struct edog *edog) mtmp->mhpmax = newmhpmax; if (mtmp->mhp > mtmp->mhpmax) mtmp->mhp = mtmp->mhpmax; - if (DEADMONSTER(mtmp)) - goto dog_died; + if (DEADMONSTER(mtmp)) { + dog_starve(mtmp); + return TRUE; + } if (cansee(mtmp->mx, mtmp->my)) pline("%s is confused from hunger.", Monnam(mtmp)); else if (couldsee(mtmp->mx, mtmp->my)) @@ -403,16 +419,8 @@ dog_hunger(struct monst *mtmp, struct edog *edog) stop_occupation(); } else if (g.moves > edog->hungrytime + DOG_STARVE || DEADMONSTER(mtmp)) { - dog_died: - if (mtmp->mleashed && mtmp != u.usteed) - Your("leash goes slack."); - else if (cansee(mtmp->mx, mtmp->my)) - pline("%s starves.", Monnam(mtmp)); - else - You_feel("%s for a moment.", - Hallucination ? "bummed" : "sad"); - mondied(mtmp); - return TRUE; + dog_starve(mtmp); + return TRUE; } } return FALSE;