hero health manipulation
I've been investigating issue #1252 (while the fuzzer was running, sanity_check complained that hero's current health was greater than maximum health) off and on for three months and haven't found the cause. I've checked all the places that lower maximum HP that I've managed to find, but not spent much time looking for places that raise current HP. These changes might provide some more information. They don't rely on sanity_check being enabled. Issue #1252 is still open.
This commit is contained in:
13
src/mcastu.c
13
src/mcastu.c
@@ -342,14 +342,12 @@ castmu(
|
||||
break;
|
||||
case AD_SPEL: /* wizard spell */
|
||||
case AD_CLRC: /* clerical spell */
|
||||
{
|
||||
if (mattk->adtyp == AD_SPEL)
|
||||
cast_wizard_spell(mtmp, dmg, spellnum);
|
||||
else
|
||||
cast_cleric_spell(mtmp, dmg, spellnum);
|
||||
dmg = 0; /* done by the spell casting functions */
|
||||
break;
|
||||
}
|
||||
} /* switch */
|
||||
if (dmg)
|
||||
mdamageu(mtmp, dmg);
|
||||
@@ -441,6 +439,11 @@ death_inflicted_by(
|
||||
staticfn void
|
||||
cast_wizard_spell(struct monst *mtmp, int dmg, int spellnum)
|
||||
{
|
||||
if (dmg < 0) {
|
||||
impossible("monster cast wizard spell (%d) with negative dmg (%d)?",
|
||||
spellnum, dmg);
|
||||
return;
|
||||
}
|
||||
if (dmg == 0 && !is_undirected_spell(AD_SPEL, spellnum)) {
|
||||
impossible("cast directed wizard spell (%d) with dmg=0?", spellnum);
|
||||
return;
|
||||
@@ -620,6 +623,12 @@ staticfn void
|
||||
cast_cleric_spell(struct monst *mtmp, int dmg, int spellnum)
|
||||
{
|
||||
int orig_dmg = 0;
|
||||
|
||||
if (dmg < 0) {
|
||||
impossible("monster cast cleric spell (%d) with negative dmg (%d)?",
|
||||
spellnum, dmg);
|
||||
return;
|
||||
}
|
||||
if (dmg == 0 && !is_undirected_spell(AD_CLRC, spellnum)) {
|
||||
impossible("cast directed cleric spell (%d) with dmg=0?", spellnum);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user