diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-15 21:43:04 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-15 21:43:04 +0000 |
commit | a73c04ebd82cc74e5b73af7a90b4c5ad292361a9 (patch) | |
tree | e0a4148dcfa70f7de771a892034588a99a30b124 | |
parent | 81267749e6aaaf8b532692a85af73e5838663575 (diff) | |
download | crawl-ref-a73c04ebd82cc74e5b73af7a90b4c5ad292361a9.tar.gz crawl-ref-a73c04ebd82cc74e5b73af7a90b4c5ad292361a9.zip |
Use radius_iterator instead of manually looping.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5866 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/abl-show.cc | 1 | ||||
-rw-r--r-- | crawl-ref/source/misc.cc | 39 |
2 files changed, 14 insertions, 26 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index 1f745ed30e..cc4c24f954 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -323,7 +323,6 @@ static const ability_def Ability_List[] = const struct ability_def & get_ability_def( ability_type abil ) -/****************************************************/ { for (unsigned int i = 0; i < sizeof(Ability_List) / sizeof(Ability_List[0]); i++) diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index f0d5b17aee..ca152ad59f 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -2367,36 +2367,25 @@ void get_playervisible_monsters(std::vector<monsters*> &mons, if (range == -1) range = LOS_RADIUS; - const int ystart = MAX(0, you.y_pos - range); - const int yend = MIN(GYM - 1, you.y_pos + range); - const int xstart = MAX(0, you.x_pos - range); - const int xend = MIN(GXM - 1, you.x_pos + range); + // Sweep every square within range. + radius_iterator ri(you.pos(), range); - // Monster check. - for (int y = ystart; y <= yend; ++y) + for ( ; ri; ++ri ) { - for (int x = xstart; x <= xend; ++x) + const unsigned short targ_monst = env.mgrid(*ri); + if (targ_monst != NON_MONSTER) { - const unsigned short targ_monst = env.mgrid[x][y]; - if (targ_monst != NON_MONSTER) + if (see_grid(*ri)) { - if (see_grid(x, y)) + monsters *mon = &env.mons[targ_monst]; + if (player_monster_visible(mon) + && !mons_is_submerged(mon) + && (!mons_is_mimic(mon->type) || mons_is_known_mimic(mon)) + && (!dangerous_only || !mons_is_safe(mon, want_move))) { - monsters *mon = &env.mons[targ_monst]; - - if (player_monster_visible(mon) - && !mons_is_submerged(mon) - && (!mons_is_mimic(mon->type) - || mons_is_known_mimic(mon)) - && (!dangerous_only || !mons_is_safe(mon, want_move))) - { - mons.push_back(mon); - if (just_check) - { - // One monster found, that's enough. - return; - } - } + mons.push_back(mon); + if (just_check) // stop once you find one + return; } } } |