aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2018-03-24 14:43:51 -0400
committerPaul Gilbert2018-03-24 15:13:11 -0400
commite06ff763ab951a4cc76eefce88cb5128d325710f (patch)
tree8c1cb1e2136f4fa08d9c42b6e96220631cdae33f
parent7cbf5a92895cd35c0606a14a76ee48d2e3a0c557 (diff)
downloadscummvm-rg350-e06ff763ab951a4cc76eefce88cb5128d325710f.tar.gz
scummvm-rg350-e06ff763ab951a4cc76eefce88cb5128d325710f.tar.bz2
scummvm-rg350-e06ff763ab951a4cc76eefce88cb5128d325710f.zip
XEEN: Fix crash in Mine 3 due to out of bounds monster
-rw-r--r--engines/xeen/combat.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp
index 6c337c1150..d2857a99c5 100644
--- a/engines/xeen/combat.cpp
+++ b/engines/xeen/combat.cpp
@@ -459,7 +459,9 @@ void Combat::moveMonsters() {
for (uint idx = 0; idx < map._mobData._monsters.size(); ++idx) {
MazeMonster &monster = map._mobData._monsters[idx];
- if ((uint)monster._position.y < 32) {
+
+ // WORKAROUND: Original only checked on y, but some monsters have an invalid X instead
+ if ((uint)monster._position.x < 32 && (uint)monster._position.y < 32) {
assert((uint)monster._position.x < 32);
_monsterMap[monster._position.y][monster._position.x]++;
}
@@ -720,6 +722,7 @@ void Combat::moveMonster(int monsterId, const Common::Point &moveDelta) {
MazeMonster &monster = map._mobData._monsters[monsterId];
Common::Point newPos = monster._position + moveDelta;
+ assert((uint)newPos.x < 32 && (uint)newPos.y < 32);
if (_monsterMap[newPos.y][newPos.x] < 3 && monster._damageType == DT_PHYSICAL && _moveMonsters) {
// Adjust monster's position
++_monsterMap[newPos.y][newPos.x];