Browse Source

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++;
	}
pull/831/head^2
Robin Eklind 6 years ago committed by Anders Jenbo
parent
commit
7b63273336
  1. 1
      Source/monster.cpp

1
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

Loading…
Cancel
Save