From 2dc2beee3b4479c6061787881d22341cbb21a33d Mon Sep 17 00:00:00 2001 From: dshaligram Date: Tue, 1 Apr 2008 13:13:31 +0000 Subject: Filter out SPELL_NO_SPELL from fleeing monster decisions (redundant in trunk, but the checks do no harm). seekspell now asserts when it's asked for a bad spell. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4015 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/mon-util.cc | 6 +++++- crawl-ref/source/spl-util.cc | 7 +++---- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 60b6e7ef46..364feab6f5 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -1932,7 +1932,7 @@ bool ms_direct_nasty(spell_type monspell) // the player is not in sight. bool ms_useful_fleeing_out_of_sight( const monsters *mon, spell_type monspell ) { - if (ms_waste_of_time( mon, monspell )) + if (monspell == SPELL_NO_SPELL || ms_waste_of_time( mon, monspell )) return (false); switch (monspell) @@ -2150,6 +2150,10 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell ) break; + case SPELL_NO_SPELL: + ret = true; + break; + default: break; } diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc index 2aec6deff0..38c783d9e1 100644 --- a/crawl-ref/source/spl-util.cc +++ b/crawl-ref/source/spl-util.cc @@ -44,7 +44,6 @@ #include #endif - static struct spell_desc spelldata[] = { #include "spl-data.h" }; @@ -298,8 +297,7 @@ int count_bits(unsigned int bits) const char *spell_title(spell_type spell) { - const spell_desc *spd = seekspell(spell); - return (spd? spd->title : NULL); + return (seekspell(spell)->title); } @@ -881,7 +879,8 @@ int spell_type2skill(unsigned int spelltype) static spell_desc *seekspell(spell_type spell) { const int index = spell_list[spell]; - return (index != -1? &spelldata[index] : NULL); + ASSERT(index != -1); + return (&spelldata[index]); } static bool cloud_helper(int (*func)(int, int, int, int, cloud_type, -- cgit v1.2.3-54-g00ecf