summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/dungeon.cc32
-rw-r--r--crawl-ref/source/effects.cc5
-rw-r--r--crawl-ref/source/spells3.cc5
3 files changed, 14 insertions, 28 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 6518683197..17d488a8e9 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -2962,16 +2962,13 @@ static void _place_fog_machines(int level_number)
static void _place_specific_feature(dungeon_feature_type feat)
{
- int sx, sy;
+ coord_def c;
do
- {
- sx = random_range(X_BOUND_1 + 1, X_BOUND_2 - 1);
- sy = random_range(Y_BOUND_1 + 1, Y_BOUND_2 - 1);
- }
- while (grd[sx][sy] != DNGN_FLOOR || mgrd[sx][sy] != NON_MONSTER);
+ c = random_in_bounds();
+ while (grd(c) != DNGN_FLOOR || mgrd(c) != NON_MONSTER);
- grd[sx][sy] = feat;
+ grd(c) = feat;
}
static void _place_specific_stair(dungeon_feature_type stair,
@@ -4422,7 +4419,7 @@ static bool _build_vaults(int level_number, const map_def *vault,
_dig_vault_loose(place, target_connections);
}
- unsigned char pos_x, pos_y;
+ coord_def pos;
for (stx = 0; stx < 10; stx++)
stair_exist[stx] = 0;
@@ -4457,13 +4454,10 @@ static bool _build_vaults(int level_number, const map_def *vault,
int tries = 10000;
do
- {
- pos_x = random_range(X_BOUND_1 + 1, X_BOUND_2 - 1);
- pos_y = random_range(Y_BOUND_1 + 1, Y_BOUND_2 - 1);
- }
- while ((grd[pos_x][pos_y] != DNGN_FLOOR
- || (!is_layout && pos_x >= v1x && pos_x <= v2x
- && pos_y >= v1y && pos_y <= v2y))
+ pos = random_in_bounds();
+ while ((grd(pos) != DNGN_FLOOR
+ || (!is_layout && pos.x >= v1x && pos.x <= v2x
+ && pos.y >= v1y && pos.y <= v2y))
&& tries-- > 0);
@@ -4476,11 +4470,10 @@ static bool _build_vaults(int level_number, const map_def *vault,
"(layout: %s) failed",
place.map.name.c_str(), is_layout? "yes" : "no");
#endif
- pos_x = you.pos().x;
- pos_y = you.pos().y;
+ pos = you.pos();
}
- grd[pos_x][pos_y] = stair;
+ grd(pos) = stair;
}
return (true);
@@ -5627,8 +5620,7 @@ static void _place_shops(int level_number, int nshops)
do
{
- shop_place.set(random_range(X_BOUND_1 + 1, X_BOUND_2 - 1),
- random_range(Y_BOUND_1 + 1, Y_BOUND_2 - 1));
+ shop_place = random_in_bounds();
timeout++;
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 26289f2616..be30e40cc5 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -3945,10 +3945,7 @@ void handle_time(long time_delta)
// Spread jellies around the level.
coord_def newpos;
do
- {
- newpos.set(random_range(X_BOUND_1 + 1, X_BOUND_2 - 1),
- random_range(Y_BOUND_1 + 1, Y_BOUND_2 - 1));
- }
+ newpos = random_in_bounds();
while (grd(newpos) != DNGN_FLOOR
&& grd(newpos) != DNGN_SHALLOW_WATER
|| monster_at(newpos)
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index 8451322adb..d6293b7063 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -1585,10 +1585,7 @@ static bool _teleport_player(bool allow_control, bool new_abyss_area)
}
do
- {
- newpos.set( random_range(X_BOUND_1 + 1, X_BOUND_2 - 1),
- random_range(Y_BOUND_1 + 1, Y_BOUND_2 - 1) );
- }
+ newpos = random_in_bounds();
while (grd(newpos) != DNGN_FLOOR
&& grd(newpos) != DNGN_SHALLOW_WATER
&& (you.species != SP_MERFOLK