From: Pasi Kallinen Date: Sun, 10 Jul 2022 09:56:20 +0000 (+0300) Subject: Praying on an altar with pet corpse on it can revive the pet X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=314715038d877f9aa34964bde1d8668c9e6fcfea;p=nethack Praying on an altar with pet corpse on it can revive the pet --- diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 905a71868..0b54451d4 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -950,6 +950,7 @@ a hero on the quest home level who runs or travels past the quest leader and allow rush/run over water if wearing discovered water walking boots flying pets wouldn't target underwater food but if they happened to fly over such food they could and would eat it +praying on an altar with pet corpse on it can revive the pet Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/src/pray.c b/src/pray.c index 14c5555b6..5d56f867f 100644 --- a/src/pray.c +++ b/src/pray.c @@ -22,6 +22,7 @@ static void gods_upset(aligntyp); static void consume_offering(struct obj *); static void offer_too_soon(aligntyp); static void desecrate_high_altar(aligntyp); +static boolean pray_revive(void); static boolean water_prayer(boolean); static boolean blocked_boulder(int, int); @@ -1994,6 +1995,23 @@ can_pray(boolean praying) /* false means no messages should be given */ return !praying ? (boolean) (g.p_type == 3 && !Inhell) : TRUE; } +/* return TRUE if praying revived a pet corpse */ +static boolean +pray_revive(void) +{ + struct obj *otmp; + + for (otmp = g.level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) + if (otmp->otyp == CORPSE && has_omonst(otmp) + && OMONST(otmp)->mtame && !OMONST(otmp)->isminion) + break; + + if (!otmp) + return FALSE; + + return (revive(otmp, TRUE) != NULL); +} + /* #pray commmand */ int dopray(void) @@ -2102,8 +2120,10 @@ prayer_done(void) /* M. Stephenson (1.0.3b) */ pleased(alignment); } else { /* coaligned */ - if (on_altar()) + if (on_altar()) { + (void) pray_revive(); (void) water_prayer(TRUE); + } pleased(alignment); /* nice */ } return 1;