From f3ece5fe657885c0488a536404ba9164db4aeedf Mon Sep 17 00:00:00 2001 From: haranp Date: Fri, 27 Apr 2007 07:01:38 +0000 Subject: Fix 1708496, crash due to bug in ms_low_hitpoint_cast(). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1375 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/mon-util.cc | 9 +++++---- crawl-ref/source/monstuff.cc | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index aca5b3bf90..b92ead92b9 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -1892,6 +1892,9 @@ bool ms_low_hitpoint_cast( const monsters *mon, spell_type monspell ) ret = true; break; + case SPELL_NO_SPELL: + ret = false; + default: if (!targ_adj && (get_spell_flags(monspell) & SPTYP_SUMMONING)) ret = true; @@ -1904,9 +1907,8 @@ bool ms_low_hitpoint_cast( const monsters *mon, spell_type monspell ) // Checks to see if a particular spell is worth casting in the first place. bool ms_waste_of_time( const monsters *mon, spell_type monspell ) { - bool ret = false; + bool ret = false; int intel, est_magic_resist, power, diff; - struct monsters *targ; // Eventually, we'll probably want to be able to have monsters // learn which of their elemental bolts were resisted and have those @@ -1986,8 +1988,7 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell ) est_magic_resist = player_res_magic(); else { - targ = &menv[ mon->foe ]; - est_magic_resist = mons_resist_magic( targ ); + est_magic_resist = mons_resist_magic(&menv[mon->foe]); } // now randomize (normal intels less accurate than high): diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index c4ea1066d6..fcbe7142bb 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -3035,7 +3035,7 @@ static bool handle_spell( monsters *monster, bolt & beem ) finalAnswer = true; } else if (hspell_pass[2] == SPELL_LESSER_HEALING - && monster->hit_points < monster->max_hit_points) + && monster->hit_points < monster->max_hit_points) { // The player's out of sight! // Quick, let's take a turn to heal ourselves. -- bwr -- cgit v1.2.3-54-g00ecf