summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spl-cast.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-12 08:33:22 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-12 09:38:24 +0100
commit9f7066eab03883b18610a629a3a84731cd26ca13 (patch)
tree46a9727513639d1e952aaa8ae0c2bf4fb2e4ef09 /crawl-ref/source/spl-cast.cc
parent62a3121fcb79a591a6d7310dfa3b394a85bb54e5 (diff)
downloadcrawl-ref-9f7066eab03883b18610a629a3a84731cd26ca13.tar.gz
crawl-ref-9f7066eab03883b18610a629a3a84731cd26ca13.zip
Use get_free_monster in other places.
Diffstat (limited to 'crawl-ref/source/spl-cast.cc')
-rw-r--r--crawl-ref/source/spl-cast.cc14
1 files changed, 4 insertions, 10 deletions
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);