summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/ghost.cc2
-rw-r--r--crawl-ref/source/monstuff.cc9
-rw-r--r--crawl-ref/source/stuff.h5
3 files changed, 8 insertions, 8 deletions
diff --git a/crawl-ref/source/ghost.cc b/crawl-ref/source/ghost.cc
index 52077c4e77..5e4044dde7 100644
--- a/crawl-ref/source/ghost.cc
+++ b/crawl-ref/source/ghost.cc
@@ -577,7 +577,7 @@ int ghost_demon::n_extra_ghosts()
if (you.where_are_you == BRANCH_ECUMENICAL_TEMPLE)
return (0);
- // No multiple ghosts until level 14 of the Main Dungeon.
+ // No multiple ghosts until level 9 of the Main Dungeon.
if ((lev < 9 && you.where_are_you == BRANCH_MAIN_DUNGEON)
|| (subdepth < 2 && you.where_are_you == BRANCH_LAIR)
|| (subdepth < 2 && you.where_are_you == BRANCH_ORCISH_MINES))
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 4534a5020d..4dffb17f14 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -2125,13 +2125,8 @@ static bool handle_special_ability(struct monsters *monster, bolt & beem)
continue;
// faking LOS by checking the neighbouring square
- int dx = targ->x - monster->x;
- if (dx)
- dx /= dx;
-
- int dy = targ->y - monster->y;
- if (dy)
- dy /= dy;
+ int dx = sgn(targ->x - monster->x);
+ int dy = sgn(targ->y - monster->y);
const int tx = monster->x + dx;
const int ty = monster->y + dy;
diff --git a/crawl-ref/source/stuff.h b/crawl-ref/source/stuff.h
index 9c958361a1..82b8727b7a 100644
--- a/crawl-ref/source/stuff.h
+++ b/crawl-ref/source/stuff.h
@@ -112,6 +112,11 @@ inline int cap_int(int val, int cap)
return (val > cap? cap : val);
}
+template <typename Z> inline Z sgn(Z x)
+{
+ return (x < 0? -1 : (x > 0? 1 : 0));
+}
+
bool is_trap_square(int x, int y);
void zap_los_monsters();