summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-stuff.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/mon-stuff.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/mon-stuff.cc')
-rw-r--r--crawl-ref/source/mon-stuff.cc38
1 files changed, 15 insertions, 23 deletions
diff --git a/crawl-ref/source/mon-stuff.cc b/crawl-ref/source/mon-stuff.cc
index bf40170354..fd300ea86c 100644
--- a/crawl-ref/source/mon-stuff.cc
+++ b/crawl-ref/source/mon-stuff.cc
@@ -3832,15 +3832,9 @@ int clone_mons(const monsters* orig, bool quiet, bool* obvious,
coord_def pos)
{
// Is there an open slot in menv?
- int midx = NON_MONSTER;
- for (int i = 0; i < MAX_MONSTERS; i++)
- if (menv[i].type == MONS_NO_MONSTER)
- {
- midx = i;
- break;
- }
+ monsters* mons = get_free_monster();
- if (midx == NON_MONSTER)
+ if (!mons)
return (NON_MONSTER);
if (!in_bounds(pos))
@@ -3866,11 +3860,9 @@ int clone_mons(const monsters* orig, bool quiet, bool* obvious,
ASSERT( !actor_at(pos) );
- monsters &mon(menv[midx]);
-
- mon = *orig;
- mon.set_position(pos);
- mgrd(pos) = midx;
+ *mons = *orig;
+ mons->set_position(pos);
+ mgrd(pos) = mons->mindex();
// Duplicate objects, or unequip them if they can't be duplicated.
for (int i = 0; i < NUM_MONSTER_SLOTS; i++)
@@ -3883,14 +3875,14 @@ int clone_mons(const monsters* orig, bool quiet, bool* obvious,
const int new_index = get_item_slot(0);
if (new_index == NON_ITEM)
{
- mon.unequip(mitm[old_index], i, 0, true);
- mon.inv[i] = NON_ITEM;
+ mons->unequip(mitm[old_index], i, 0, true);
+ mons->inv[i] = NON_ITEM;
continue;
}
- mon.inv[i] = new_index;
+ mons->inv[i] = new_index;
mitm[new_index] = mitm[old_index];
- mitm[new_index].set_holding_monster(midx);
+ mitm[new_index].set_holding_monster(mons->mindex());
}
bool _obvious;
@@ -3898,24 +3890,24 @@ int clone_mons(const monsters* orig, bool quiet, bool* obvious,
obvious = &_obvious;
*obvious = false;
- if (you.can_see(orig) && you.can_see(&mon))
+ if (you.can_see(orig) && you.can_see(mons))
{
if (!quiet)
simple_monster_message(orig, " is duplicated!");
*obvious = true;
}
- mark_interesting_monst(&mon, mon.behaviour);
- if (you.can_see(&mon))
+ mark_interesting_monst(mons, mons->behaviour);
+ if (you.can_see(mons))
{
- handle_seen_interrupt(&mon);
+ handle_seen_interrupt(mons);
viewwindow(false);
}
if (crawl_state.arena)
- arena_placed_monster(&mon);
+ arena_placed_monster(mons);
- return (midx);
+ return (mons->mindex());
}
std::string summoned_poof_msg(const monsters* monster, bool plural)