summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dgn-layouts.cc
diff options
context:
space:
mode:
authorSteve Melenchuk <smelenchuk@gmail.com>2013-11-21 18:53:57 -0700
committerSteve Melenchuk <smelenchuk@gmail.com>2013-11-21 18:53:57 -0700
commita2f29cb57bf704a557fd0af6853f28ac2680687b (patch)
treea21d9653319f57f8db48c9529229e6e4e31c66c0 /crawl-ref/source/dgn-layouts.cc
parent02ba3863cec303b2257e9c4d254fe7f338bda320 (diff)
downloadcrawl-ref-a2f29cb57bf704a557fd0af6853f28ac2680687b.tar.gz
crawl-ref-a2f29cb57bf704a557fd0af6853f28ac2680687b.zip
Don't try to _make_trail from a boxed-in start location.
Diffstat (limited to 'crawl-ref/source/dgn-layouts.cc')
-rw-r--r--crawl-ref/source/dgn-layouts.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/crawl-ref/source/dgn-layouts.cc b/crawl-ref/source/dgn-layouts.cc
index 7d1ecfc4a8..6f684dec56 100644
--- a/crawl-ref/source/dgn-layouts.cc
+++ b/crawl-ref/source/dgn-layouts.cc
@@ -7,6 +7,7 @@
#include "dgn-layouts.h"
+#include "coord.h"
#include "coordit.h"
#include "dungeon.h"
#include "libutil.h"
@@ -325,6 +326,25 @@ static int _trail_random_dir(int pos, int bound, int margin)
return dir;
}
+static bool _viable_trail_start_location(const coord_def &c)
+{
+ if (grd(c) != DNGN_ROCK_WALL && grd(c) != DNGN_FLOOR
+ || map_masked(c, MMT_VAULT))
+ {
+ return false;
+ }
+ for (orth_adjacent_iterator ai(c); ai; ++ai)
+ {
+ if (in_bounds(*ai)
+ && grd(*ai) == DNGN_ROCK_WALL
+ && !map_masked(*ai, MMT_VAULT))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
static void _make_trail(int xs, int xr, int ys, int yr, int corrlength,
int intersect_chance, int no_corr,
coord_def& begin, coord_def& end)
@@ -341,8 +361,7 @@ static void _make_trail(int xs, int xr, int ys, int yr, int corrlength,
pos.x = xs + random2(xr);
pos.y = ys + random2(yr);
}
- while (grd(pos) != DNGN_ROCK_WALL && grd(pos) != DNGN_FLOOR
- || map_masked(pos, MMT_VAULT) && tries-- > 0);
+ while (!_viable_trail_start_location(pos) && tries-- > 0);
if (tries < 0)
return;