summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-09 02:38:36 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-09 02:38:36 +0000
commitf98e8b06b0f7431afa6a25f6577066bf4a43942f (patch)
tree9fe972706fa685ae5ddfebcb03b25eb361264eff /crawl-ref
parent8d0ff904180d271bb7c87b46cfe728624cc5fba3 (diff)
downloadcrawl-ref-f98e8b06b0f7431afa6a25f6577066bf4a43942f.tar.gz
crawl-ref-f98e8b06b0f7431afa6a25f6577066bf4a43942f.zip
Add still more miscellaneous minor fixes.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5628 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/misc.cc9
-rw-r--r--crawl-ref/source/misc.h4
-rw-r--r--crawl-ref/source/monstuff.cc23
-rw-r--r--crawl-ref/source/religion.cc10
-rw-r--r--crawl-ref/source/xom.cc12
5 files changed, 28 insertions, 30 deletions
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index cfd8e6a52e..342e7f96ae 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -2672,15 +2672,17 @@ void get_playervisible_monsters(std::vector<monsters*> &mons,
const int xend = MIN(GXM - 1, you.x_pos + range);
// Monster check.
- for (int y = ystart; y <= yend; y++)
- for (int x = xstart; x <= xend; x++)
+ for (int y = ystart; y <= yend; ++y)
+ {
+ for (int x = xstart; x <= xend; ++x)
{
const unsigned short targ_monst = env.mgrid[x][y];
if (targ_monst != NON_MONSTER)
{
- if (see_grid(x,y))
+ 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)
@@ -2697,6 +2699,7 @@ void get_playervisible_monsters(std::vector<monsters*> &mons,
}
}
}
+ }
}
bool i_feel_safe(bool announce, bool want_move, bool just_monsters, int range)
diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h
index 2880e79cfb..bb030a9402 100644
--- a/crawl-ref/source/misc.h
+++ b/crawl-ref/source/misc.h
@@ -119,8 +119,8 @@ void curare_hits_player(int agent, int degree);
bool mons_is_safe(const monsters *mon, bool want_move = false);
void get_playervisible_monsters(std::vector<monsters*>& mons,
- bool just_check = false, bool want_move = false,
- bool dangerous = false, int range = -1);
+ bool want_move = false, bool just_check = false,
+ bool dangerous_only = false, int range = -1);
bool i_feel_safe(bool announce = false, bool want_move = false,
bool just_monsters = false, int range = -1);
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index dcb5f33d9b..7fdc25a084 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -2973,25 +2973,22 @@ monsters *choose_random_monster_on_level(int weight,
monsters *chosen = NULL;
int mons_count = weight;
- int xstart = 0, ystart = 0;
- int xend = GXM, yend = GYM;
+ int ystart = 0, yend = GXM - 1;
+ int xstart = 0, xend = GYM - 1;
if (near_by)
{
- xstart = you.x_pos - 9;
- ystart = you.y_pos - 9;
- xend = you.x_pos + 9;
- yend = you.y_pos + 9;
-
- if ( xstart < 0 ) xstart = 0;
- if ( ystart < 0 ) ystart = 0;
- if ( xend >= GXM ) xend = GXM - 1;
- if ( yend >= GYM ) yend = GYM - 1;
+ ystart = MAX(0, you.y_pos - 9);
+ xstart = MAX(0, you.x_pos - 9);
+ yend = MIN(GYM - 1, you.y_pos + 9);
+ xend = MIN(GXM - 1, you.x_pos + 9);
}
- // monster check
+ // Monster check.
for ( int y = ystart; y <= yend; ++y )
+ {
for ( int x = xstart; x <= xend; ++x )
+ {
if ( mgrd[x][y] != NON_MONSTER && (!in_sight || see_grid(x,y)) )
{
monsters *mon = &menv[mgrd[x][y]];
@@ -3018,6 +3015,8 @@ monsters *choose_random_monster_on_level(int weight,
chosen = mon;
}
}
+ }
+ }
return chosen;
}
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index cac1cdac33..54e1c3fc86 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -4139,12 +4139,10 @@ static bool _beogh_followers_abandon_you()
}
else
{
- int ystart = you.y_pos - 9, xstart = you.x_pos - 9;
- int yend = you.y_pos + 9, xend = you.x_pos + 9;
- if ( xstart < 0 ) xstart = 0;
- if ( ystart < 0 ) ystart = 0;
- if ( xend >= GXM ) xend = GXM - 1;
- if ( yend >= GYM ) yend = GYM - 1;
+ const int ystart = MAX(0, you.y_pos - 9);
+ const int yend = MIN(GYM - 1, you.y_pos + 9);
+ const int xstart = MAX(0, you.x_pos - 9);
+ const int xend = MIN(GXM - 1, you.x_pos + 9);
// monster check
for ( int y = ystart; y <= yend; ++y )
diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc
index 4480bcafab..d5507f12e6 100644
--- a/crawl-ref/source/xom.cc
+++ b/crawl-ref/source/xom.cc
@@ -384,12 +384,10 @@ bool xom_gives_item(int power)
bool there_are_monsters_nearby()
{
- int ystart = you.y_pos - 9, xstart = you.x_pos - 9;
- int yend = you.y_pos + 9, xend = you.x_pos + 9;
- if (xstart < 0) xstart = 0;
- if (ystart < 0) ystart = 0;
- if (xend >= GXM) xend = GXM - 1;
- if (yend >= GYM) yend = GYM - 1;
+ const int ystart = MAX(0, you.y_pos - 9);
+ const int yend = MIN(GYM - 1, you.y_pos + 9);
+ const int xstart = MAX(0, you.x_pos - 9);
+ const int xend = MIN(GXM - 1, you.x_pos + 9);
// Monster check.
for (int y = ystart; y <= yend; ++y)
@@ -400,7 +398,7 @@ bool there_are_monsters_nearby()
if (see_grid(x, y))
{
const int targ_monst = mgrd[x][y];
- if ( targ_monst != NON_MONSTER )
+ if (targ_monst != NON_MONSTER)
{
const monsters *mon = &menv[targ_monst];
if (!mons_is_submerged(mon))