diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-11-12 23:21:01 +0100 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-11-12 23:21:01 +0100 |
commit | 4659bda92ee4748248f9ef5e5e978f155fb20672 (patch) | |
tree | 749b6b524ea7cd42f5bd7ee633a8782e95ca69c2 | |
parent | a57747c0c0f207a2cb5bee3e4d576f1feb355f96 (diff) | |
download | crawl-ref-4659bda92ee4748248f9ef5e5e978f155fb20672.tar.gz crawl-ref-4659bda92ee4748248f9ef5e5e978f155fb20672.zip |
Revert "Rewrite zap_los_monsters using monster_iter."
This reverts commit a57747c0c0f207a2cb5bee3e4d576f1feb355f96.
-rw-r--r-- | crawl-ref/source/acr.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/stuff.cc | 54 | ||||
-rw-r--r-- | crawl-ref/source/stuff.h | 1 |
3 files changed, 33 insertions, 26 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 904ffeb6f4..e3d2edfaba 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -3739,10 +3739,6 @@ static bool _initialise(void) // For a new game, wipe out monsters in LOS. zap_los_monsters(); - // At tutorial beginning disallow items in line of sight. - if (Options.tutorial_events[TUT_SEEN_FIRST_OBJECT]) - zap_los_items(); - // For a newly started tutorial, turn secret doors into normal ones. if (Options.tutorial_left) tutorial_zap_secret_doors(); diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index 61820de23a..377b9ba84a 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -14,7 +14,6 @@ #include "los.h" #include "message.h" #include "misc.h" -#include "mon-iter.h" #include "mon-place.h" #include "state.h" #include "stuff.h" @@ -884,39 +883,52 @@ 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() { - 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) + calc_show_los(); + + for (rectangle_iterator ri(crawl_view.vlos1, crawl_view.vlos2); ri; ++ri ) { - if (mons_class_flag(mi->type, M_NO_EXP_GAIN)) + 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 )) continue; #ifdef DEBUG_DIAGNOSTICS mprf(MSGCH_DIAGNOSTICS, "Dismissing %s", - mi->name(DESC_PLAIN, true).c_str() ); + mon->name(DESC_PLAIN, true).c_str() ); #endif // Do a hard reset so the monster's items will be discarded. - mi->flags |= MF_HARD_RESET; + mon->flags |= MF_HARD_RESET; // Do a silent, wizard-mode monster_die() just to be extra sure the // player sees nothing. - monster_die(*mi, KILL_DISMISSED, NON_MONSTER, true, true); + monster_die(mon, KILL_DISMISSED, NON_MONSTER, true, true); } } diff --git a/crawl-ref/source/stuff.h b/crawl-ref/source/stuff.h index fe5ff15245..4a7fab6c11 100644 --- a/crawl-ref/source/stuff.h +++ b/crawl-ref/source/stuff.h @@ -93,7 +93,6 @@ template <typename Z> inline Z sgn(Z x) } bool is_trap_square(dungeon_feature_type grid); -void zap_los_items(); void zap_los_monsters(); int integer_sqrt(int value); |