From 25738071b9b5f5580f7b0dc64a347eb341ac296d Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 7 Nov 2019 22:35:42 +0100 Subject: [PATCH] Add BUGFIX to a handful of OOB issues --- Source/drlg_l3.cpp | 5 +++-- Source/lighting.cpp | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index b88161c24..0f661b3e3 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -423,11 +423,11 @@ static void DRLG_L3River() rx = 0; ry = 0; i = 0; - while ((dungeon[rx][ry] < 25 || dungeon[rx][ry] > 28) && i < 100) { + while ((dungeon[rx][ry] < 25 || dungeon[rx][ry] > 28) && i < 100) { /// BUGFIX: OOB `while (ry < DMAXY && (` rx = random_(0, DMAXX); ry = random_(0, DMAXY); i++; - while ((dungeon[rx][ry] < 25 || dungeon[rx][ry] > 28) && ry < DMAXY) { + while ((dungeon[rx][ry] < 25 || dungeon[rx][ry] > 28) && ry < DMAXY) { /// BUGFIX: OOB `while (ry < DMAXY && (` rx++; if (rx >= DMAXX) { rx = 0; @@ -435,6 +435,7 @@ static void DRLG_L3River() } } } + /// BUGFIX: OOB `if (ry >= DMAXY) continue;` if (i >= 100) { return; } diff --git a/Source/lighting.cpp b/Source/lighting.cpp index 073e2a47d..875cc2289 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -746,10 +746,10 @@ void DoVision(int nXPos, int nYPos, int nRadius, BOOL doautomap, BOOL visible) } break; } - if (nCrawlX >= 0 && nCrawlX <= MAXDUNX && nCrawlY >= 0 && nCrawlY <= MAXDUNY) { + if (nCrawlX >= 0 && nCrawlX <= MAXDUNX && nCrawlY >= 0 && nCrawlY <= MAXDUNY) { /// BUGFIX: OOB `< MAXDUNX` && `< MAXDUNY` nBlockerFlag = nBlockTable[dPiece[nCrawlX][nCrawlY]]; - if (!nBlockTable[dPiece[x1adj + nCrawlX][y1adj + nCrawlY]] - || !nBlockTable[dPiece[x2adj + nCrawlX][y2adj + nCrawlY]]) { + if (!nBlockTable[dPiece[x1adj + nCrawlX][y1adj + nCrawlY]] /// BUGFIX: OOB `x1adj + nCrawlX >= 0 && x1adj + nCrawlX < MAXDUNX && y1adj + nCrawlY >= 0 && y1adj + nCrawlY < MAXDUNY` + || !nBlockTable[dPiece[x2adj + nCrawlX][y2adj + nCrawlY]]) { /// BUGFIX: OOB `x2adj + nCrawlX >= 0 && x2adj + nCrawlX < MAXDUNX && y2adj + nCrawlY >= 0 && y2adj + nCrawlY < MAXDUNY` if (doautomap) { if (dFlags[nCrawlX][nCrawlY] >= 0) { SetAutomapView(nCrawlX, nCrawlY);