From 9f7066eab03883b18610a629a3a84731cd26ca13 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Thu, 12 Nov 2009 08:33:22 +0100 Subject: Use get_free_monster in other places. --- crawl-ref/source/spl-cast.cc | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'crawl-ref/source/spl-cast.cc') diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 94d6aa27cc..bc0e65d97e 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -34,6 +34,7 @@ #include "misc.h" #include "message.h" #include "mon-cast.h" +#include "mon-place.h" #include "mon-stuff.h" #include "mutation.h" #include "ouch.h" @@ -1039,13 +1040,8 @@ static void _try_monster_cast(spell_type spell, int powc, return; } - int midx; - - for (midx = 0; midx < MAX_MONSTERS; midx++) - if (menv[midx].type == MONS_NO_MONSTER) - break; - - if (midx == MAX_MONSTERS) + monsters* mon = get_free_monster(); + if (!mon) { mpr("Couldn't try casting monster spell because there is " "no empty monster slot."); @@ -1054,8 +1050,6 @@ static void _try_monster_cast(spell_type spell, int powc, mpr("Invalid player spell, attempting to cast it as monster spell."); - monsters* mon = &menv[midx]; - mon->mname = "Dummy Monster"; mon->type = MONS_HUMAN; mon->behaviour = BEH_SEEK; @@ -1079,7 +1073,7 @@ static void _try_monster_cast(spell_type spell, int powc, else mon->foe = mgrd(spd.target); - mgrd(you.pos()) = midx; + mgrd(you.pos()) = mon->mindex(); mons_cast(mon, beam, spell); -- cgit v1.2.3-54-g00ecf