From 0757eb4774869ebdc4effb041b46b9a339366fa4 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Fri, 26 Apr 2019 03:35:32 +0900 Subject: [PATCH] GetAutomapType bin exact Fixes #224. --- Source/automap.cpp | 47 +++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/Source/automap.cpp b/Source/automap.cpp index a3298c53f..ed9829473 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -506,28 +506,41 @@ void DrawAutomapPlr() WORD GetAutomapType(int x, int y, BOOL view) { - if (view) { - if (x == -1 && y >= 0 && y < DMAXY && automapview[0][y]) - return ~GetAutomapType(0, y, FALSE) & (MAPFLAG_SQUARE << 8); - if (y == -1) { - if (x < 0) - return 0; - if (x < DMAXX && automapview[x][0]) - return ~GetAutomapType(x, 0, FALSE) & (MAPFLAG_SQUARE << 8); + WORD rv; + + if (view && x == -1 && y >= 0 && y < DMAXY && automapview[0][y]) { + if (GetAutomapType(0, y, FALSE) & (MAPFLAG_SQUARE << 8)) { + return 0; + } else { + return MAPFLAG_SQUARE << 8; } } - if (x >= 0 && x < DMAXX && y >= 0 && y < DMAXY) { - if (automapview[x][y] || !view) { - WORD type = automaptype[(BYTE)dungeon[x][y]]; - if (type == 7 && GetAutomapType(x - 1, y, FALSE) & (MAPFLAG_HORZARCH << 8) - && GetAutomapType(x, y - 1, FALSE) & (MAPFLAG_VERTARCH << 8)) { - type = 1; - } - return type; + if (view && y == -1 && x >= 0 && x < DMAXY && automapview[x][0]) { + if (GetAutomapType(x, 0, FALSE) & (MAPFLAG_SQUARE << 8)) { + return 0; + } else { + return MAPFLAG_SQUARE << 8; } } - return 0; + + if (x < 0 || x >= DMAXX) { + return 0; + } + if (y < 0 || y >= DMAXX) { + return 0; + } + if (!automapview[x][y] && view) { + return 0; + } + + rv = automaptype[(BYTE)dungeon[x][y]]; + if (rv == 7 + && GetAutomapType(x - 1, y, FALSE) & (MAPFLAG_HORZARCH << 8) + && GetAutomapType(x, y - 1, FALSE) & (MAPFLAG_VERTARCH << 8)) { + rv = 1; + } + return rv; } void DrawAutomapGame()