summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/maps.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-12-02 04:36:18 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-12-02 04:36:18 +0000
commitfa6393b63b270a07e02ce4c8333b23013b5ded75 (patch)
tree043489a6bc83f6fa827ccb34bd574a4aa18ba7ee /crawl-ref/source/maps.cc
parent20c98d67894a6fe8c8fac01e841108b5878160db (diff)
downloadcrawl-ref-fa6393b63b270a07e02ce4c8333b23013b5ded75.tar.gz
crawl-ref-fa6393b63b270a07e02ce4c8333b23013b5ded75.zip
Fix broken sewer messaging (dpeg).
Fixed bad bounds checks for minivaults placed by dgn_place_map. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7716 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/maps.cc')
-rw-r--r--crawl-ref/source/maps.cc29
1 files changed, 18 insertions, 11 deletions
diff --git a/crawl-ref/source/maps.cc b/crawl-ref/source/maps.cc
index adc4df3f09..1e35bed17e 100644
--- a/crawl-ref/source/maps.cc
+++ b/crawl-ref/source/maps.cc
@@ -195,17 +195,24 @@ static bool bad_map_place(const map_def &map, const coord_def &c,
return (false);
}
-void fit_region_into_map_bounds(coord_def &pos, const coord_def &size)
-{
- ASSERT(size.x <= GXM && size.y <= GYM);
- if (pos.x < X_BOUND_1)
- pos.x = X_BOUND_1;
- if (pos.y < Y_BOUND_1)
- pos.y = Y_BOUND_1;
- if (pos.x + size.x - 1 > X_BOUND_2)
- pos.x = X_BOUND_2 - size.x + 1;
- if (pos.y + size.y - 1 > Y_BOUND_2)
- pos.y = Y_BOUND_2 - size.y + 1;
+void fit_region_into_map_bounds(coord_def &pos, const coord_def &size,
+ int margin)
+{
+ const int X_1(X_BOUND_1 + margin);
+ const int X_2(X_BOUND_2 - margin);
+ const int Y_1(Y_BOUND_1 + margin);
+ const int Y_2(Y_BOUND_2 - margin);
+
+ ASSERT(size.x <= (X_2 - X_1 + 1) && size.y <= (Y_2 - Y_1 + 1));
+
+ if (pos.x < X_1)
+ pos.x = X_1;
+ if (pos.y < Y_1)
+ pos.y = Y_1;
+ if (pos.x + size.x - 1 > X_2)
+ pos.x = X_2 - size.x + 1;
+ if (pos.y + size.y - 1 > Y_2)
+ pos.y = Y_2 - size.y + 1;
}
static bool apply_vault_grid(map_def &def,