From ce60a17fd5db7aedf3f0f2ec836c46c70165d849 Mon Sep 17 00:00:00 2001 From: staphen Date: Mon, 29 Apr 2024 14:54:53 -0400 Subject: [PATCH] Fix OOB when debugging megatile data near the edge of the dungeon --- Source/debug.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/debug.cpp b/Source/debug.cpp index 4e6720384..b5eb09a14 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -208,16 +208,20 @@ bool GetDebugGridText(Point dungeonCoords, char *debugGridTextBuffer) info = TileHasAny(dungeonCoords, TileProperties::Trap); break; case DebugGridTextItem::AutomapView: - info = AutomapView[megaCoords.x][megaCoords.y]; + if (megaCoords.x >= 0 && megaCoords.x < DMAXX && megaCoords.y >= 0 && megaCoords.y < DMAXY) + info = AutomapView[megaCoords.x][megaCoords.y]; break; case DebugGridTextItem::dungeon: - info = dungeon[megaCoords.x][megaCoords.y]; + if (megaCoords.x >= 0 && megaCoords.x < DMAXX && megaCoords.y >= 0 && megaCoords.y < DMAXY) + info = dungeon[megaCoords.x][megaCoords.y]; break; case DebugGridTextItem::pdungeon: - info = pdungeon[megaCoords.x][megaCoords.y]; + if (megaCoords.x >= 0 && megaCoords.x < DMAXX && megaCoords.y >= 0 && megaCoords.y < DMAXY) + info = pdungeon[megaCoords.x][megaCoords.y]; break; case DebugGridTextItem::Protected: - info = Protected.test(megaCoords.x, megaCoords.y); + if (megaCoords.x >= 0 && megaCoords.x < DMAXX && megaCoords.y >= 0 && megaCoords.y < DMAXY) + info = Protected.test(megaCoords.x, megaCoords.y); break; case DebugGridTextItem::None: return false;