From 854155dfa9fb71dfa2071010955d52c5e8714b4a Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 14 Aug 2018 18:06:59 -0700 Subject: [PATCH] git pull request #123 - wallification vs map edge Fixes #123 Make sure wallification doesn't go out of bounds when operating near the map edge. The top and left edges were ok (although the left edge could uselessly try to wallify unused column 0) but the right and bottom ones weren't validating the map boundary. None of the 3.6.x levels were affected. I've done this a little differently from the suggested commit in the pull request. --- doc/fixes36.2 | 2 ++ src/sp_lev.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index 7d94ac579..9fd4f3aa0 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -83,6 +83,8 @@ succubus/incubus seduction might result in loss of levitation which in turn fix hole/trapdoor passage inconsistency when polymorphed into a giant making a wide-open special level with FLAGS:inaccessibles could trigger a "floodfill stack overrun" panic (no 3.6.x levels were affected) +wallifying a special level might go out of map bounds (not with 3.6.x levels) + and corrupt other level data Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository diff --git a/src/sp_lev.c b/src/sp_lev.c index b1fd86086..af1cdc678 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -2552,19 +2552,23 @@ region *tmpregion; } } -void +STATIC_OVL void wallify_map(x1, y1, x2, y2) int x1, y1, x2, y2; { int x, y, xx, yy, lo_xx, lo_yy, hi_xx, hi_yy; + y1 = max(y1, 0); + x1 = max(x1, 1); + y2 = min(y2, ROWNO - 1); + x2 = min(x2, COLNO - 1); for (y = y1; y <= y2; y++) { lo_yy = (y > 0) ? y - 1 : 0; hi_yy = (y < y2) ? y + 1 : y2; for (x = x1; x <= x2; x++) { if (levl[x][y].typ != STONE) continue; - lo_xx = (x > 0) ? x - 1 : 0; + lo_xx = (x > 1) ? x - 1 : 1; hi_xx = (x < x2) ? x + 1 : x2; for (yy = lo_yy; yy <= hi_yy; yy++) for (xx = lo_xx; xx <= hi_xx; xx++)