From 7b63273336d378f7dc7d5b0b4440b9e2152e4e63 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Sat, 11 Jul 2020 23:36:47 +0200 Subject: [PATCH] monster: add BUGFIX comment to DirOK The issue here is probably very unlikely to trigger anything in-game, as the first 4 monster array elements are reserverd for golems. However, after executing the body of the `if (mi != 0) { mi-- }` if-statement, it is not possible to determine whether mi was 0 or 1 before executing the body. This is relevant as the pack member check should only be performed if mi was non-zero prior to executing the body of the if-statement. A fixed may look something as follows: if (mi != 0) { mi--; // BUGFIX: should only run pack member check if mi was non-zero prior to executing the body of the above if-statemnet (fixed). if (monster[mi].leaderflag == 1 && monster[mi].leader == i && monster[mi]._mfutx == x && monster[mi]._mfuty == y) { mcount++; } --- Source/monster.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/monster.cpp b/Source/monster.cpp index 4c9cb29cf..57a7df26a 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -4730,6 +4730,7 @@ BOOL DirOK(int i, int mdir) mi = -mi; if (mi != 0) mi--; + // BUGFIX: should only run pack member check if mi was non-zero prior to executing the body of the above if-statemnet. if (monster[mi].leaderflag == 1 && monster[mi].leader == i && monster[mi]._mfutx == x