From 16a154f062e73ef076bf2d298375eb68aea458c9 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Tue, 29 Oct 2019 23:20:46 +0000 Subject: [PATCH 1/3] Change _INVALID enum values from 0xFFFFFFFF to -1 Some of these are assigned to `char` (assumed to be signed), and 0xFFFFFFFF is `-1` only when sizeof(int) == 4. --- enums.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/enums.h b/enums.h index 240ff2154..e9f1539e3 100644 --- a/enums.h +++ b/enums.h @@ -2158,7 +2158,7 @@ typedef enum spell_id { SPL_HEALOTHER = 0x22, SPL_FLARE = 0x23, SPL_BONESPIRIT = 0x24, - SPL_INVALID = 0xFFFFFFFF, + SPL_INVALID = -1, } spell_id; typedef enum _cmd_id { @@ -2469,7 +2469,7 @@ typedef enum item_misc_id { IMISC_MAPOFDOOM = 0x2A, IMISC_EAR = 0x2B, IMISC_SPECELIX = 0x2C, - IMISC_INVALID = 0xFFFFFFFF, + IMISC_INVALID = -1, } item_misc_id; typedef enum item_type { @@ -2488,7 +2488,7 @@ typedef enum item_type { ITYPE_RING = 0xC, ITYPE_AMULET = 0xD, ITYPE_0E = 0xE, - ITYPE_NONE = 0xFFFFFFFF, + ITYPE_NONE = -1, } item_type; typedef enum _item_indexes { @@ -2557,7 +2557,7 @@ typedef enum quest_id { QTYPE_PW = 0xD, QTYPE_BONE = 0xE, QTYPE_VB = 0xF, - QTYPE_INVALID = 0xFFFFFFFF, + QTYPE_INVALID = -1, } quest_id; typedef enum quest_mush_state { From 1b24dac9428a4269db855556b5c99c159ea2e213 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Tue, 29 Oct 2019 23:27:26 +0000 Subject: [PATCH 2/3] Add BUGFIX comment in DrawSpell --- Source/control.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/control.cpp b/Source/control.cpp index 630ed66e3..83e9ee25e 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -380,6 +380,8 @@ void DrawSpell() spl = plr[myplr]._pRSpell; st = plr[myplr]._pRSplType; + + // BUGFIX: Move the next line into the if statement to avoid OOB (SPL_INVALID is -1) tlvl = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[spl]; if (st == RSPLTYPE_SPELL && spl != SPL_INVALID) { if (!CheckSpell(myplr, spl, RSPLTYPE_SPELL, TRUE)) From e396aafa3b4e6d47cb37c633781e3ac33745bc94 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 30 Oct 2019 01:59:51 +0100 Subject: [PATCH 3/3] Add bugfix note --- Source/monster.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/monster.cpp b/Source/monster.cpp index 8db5f0ab2..390e67507 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -1207,6 +1207,7 @@ void M_CheckEFlag(int i) x = monster[i]._mx - 1; y = monster[i]._my + 1; f = 0; + // BUGFIX check (x > 0 && y < MAXDUNY) m = dpiece_defs_map_2[x][y].mt; if (m >= dpiece_defs_map_2[0][0].mt) { for (j = 2; j < 10; j++) {