sanity_check: current hero health better than max

Changes to setuhpmax() a couple of days ago to deal with sanity_check
for "current hero health as monster better than maximum" ended up
triggering sanity_check about "current hero health better than maximum"
when gaining experience level(s) while polymorphed.
This commit is contained in:
PatR
2024-09-26 23:00:42 -07:00
parent 01a6e4e1d1
commit e9a25a0a1c
10 changed files with 31 additions and 29 deletions

View File

@@ -251,14 +251,14 @@ losexp(
num = (int) u.uhpinc[u.ulevel];
u.uhpmax -= num;
if (u.uhpmax < uhpmin)
setuhpmax(uhpmin);
setuhpmax(uhpmin, TRUE);
/* uhpmax might try to go up if it has previously been reduced by
strength loss or by a fire trap or by an attack by Death which
all use a different minimum than life-saving or experience loss;
we don't allow it to go up because that contradicts assumptions
elsewhere (such as healing wielder who drains with Stormbringer) */
if (u.uhpmax > olduhpmax)
setuhpmax(olduhpmax);
setuhpmax(olduhpmax, TRUE);
u.uhp -= num;
if (u.uhp < 1)
@@ -306,7 +306,8 @@ newexplevel(void)
void
pluslvl(
boolean incr) /* True: incremental experience growth;
* False: potion of gain level or wraith corpse */
* False: potion of gain level or wraith corpse
* or wizard mode #levelchange */
{
int hpinc, eninc;
@@ -317,12 +318,13 @@ pluslvl(
in order to retain normal human/whatever increase for later) */
if (Upolyd) {
hpinc = monhp_per_lvl(&gy.youmonst);
u.mhmax += hpinc;
u.mh += hpinc;
setuhpmax(u.mhmax, FALSE); /* acts as setmhmax() when Upolyd */
}
hpinc = newhp();
u.uhp += hpinc;
setuhpmax(u.uhpmax + hpinc); /* will lower u.uhp if it exceeds uhpmax */
setuhpmax(u.uhpmax + hpinc, TRUE); /* will lower u.uhp if it exceeds
* u.uhpmax */
/* increase spell power/energy points */
eninc = newpw();