summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/stuff.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-12 23:09:31 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-12 23:10:43 +0100
commita57747c0c0f207a2cb5bee3e4d576f1feb355f96 (patch)
tree2311bf623b4bf2bcf3c3a709786930c2fb373c03 /crawl-ref/source/stuff.cc
parent4f78c6e2e966681bc6249febc076bd7fa51ffe46 (diff)
downloadcrawl-ref-a57747c0c0f207a2cb5bee3e4d576f1feb355f96.tar.gz
crawl-ref-a57747c0c0f207a2cb5bee3e4d576f1feb355f96.zip
Rewrite zap_los_monsters using monster_iter.
Not sure it was broken before, but it's cleaner now. Also move tutorial item zapping into a separate function.
Diffstat (limited to 'crawl-ref/source/stuff.cc')
-rw-r--r--crawl-ref/source/stuff.cc54
1 files changed, 21 insertions, 33 deletions
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index 377b9ba84a..61820de23a 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -14,6 +14,7 @@
#include "los.h"
#include "message.h"
#include "misc.h"
+#include "mon-iter.h"
#include "mon-place.h"
#include "state.h"
#include "stuff.h"
@@ -883,52 +884,39 @@ bool is_trap_square(dungeon_feature_type grid)
return (grid >= DNGN_TRAP_MECHANICAL && grid <= DNGN_UNDISCOVERED_TRAP);
}
+// At tutorial beginning disallow items in line of sight.
+void zap_los_items()
+{
+ for (radius_iterator ri(you.pos(), LOS_RADIUS); ri; ++ri)
+ {
+ int item = igrd(*ri);
+
+ if (item != NON_ITEM && mitm[item].is_valid() )
+ destroy_item(item);
+ }
+}
+
// Does the equivalent of KILL_RESET on all monsters in LOS. Should only be
// applied to new games.
void zap_los_monsters()
{
- calc_show_los();
-
- for (rectangle_iterator ri(crawl_view.vlos1, crawl_view.vlos2); ri; ++ri )
+ you.update_los();
+ // If we ever allow starting with a friendly monster,
+ // we'll have to check here.
+ for (monster_iterator mi(&you.get_los()); mi; ++mi)
{
- const coord_def g = view2grid(*ri);
-
- if (!map_bounds(g))
- continue;
-
- if (!you.see_cell(g))
- continue;
-
- if (g == you.pos())
- continue;
-
- // At tutorial beginning disallow items in line of sight.
- if (Options.tutorial_events[TUT_SEEN_FIRST_OBJECT])
- {
- int item = igrd(g);
-
- if (item != NON_ITEM && mitm[item].is_valid() )
- destroy_item(item);
- }
-
- // If we ever allow starting with a friendly monster,
- // we'll have to check here.
- monsters *mon = monster_at(g);
- if (mon == NULL)
- continue;
-
- if (mons_class_flag( mon->type, M_NO_EXP_GAIN ))
+ if (mons_class_flag(mi->type, M_NO_EXP_GAIN))
continue;
#ifdef DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS, "Dismissing %s",
- mon->name(DESC_PLAIN, true).c_str() );
+ mi->name(DESC_PLAIN, true).c_str() );
#endif
// Do a hard reset so the monster's items will be discarded.
- mon->flags |= MF_HARD_RESET;
+ mi->flags |= MF_HARD_RESET;
// Do a silent, wizard-mode monster_die() just to be extra sure the
// player sees nothing.
- monster_die(mon, KILL_DISMISSED, NON_MONSTER, true, true);
+ monster_die(*mi, KILL_DISMISSED, NON_MONSTER, true, true);
}
}