aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2019-08-23 16:31:09 +0200
committerEugene Sandulenko2019-09-03 17:17:35 +0200
commit4d186571d543a9e52afc62920ac00b7ebe5a35bd (patch)
tree51f698874e02f04605f0f62b5acca31233378d46 /engines
parente5883e999b81a771d78c43fc69fe1249dfee0124 (diff)
downloadscummvm-rg350-4d186571d543a9e52afc62920ac00b7ebe5a35bd.tar.gz
scummvm-rg350-4d186571d543a9e52afc62920ac00b7ebe5a35bd.tar.bz2
scummvm-rg350-4d186571d543a9e52afc62920ac00b7ebe5a35bd.zip
HDB: Fix closed loops with laser beams
Nipun was able to construct such position in Map28 which led to a closed loop and the game hung. We're inserting a watchdog here now.
Diffstat (limited to 'engines')
-rw-r--r--engines/hdb/ai-bots.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 33a15c08dd..ac4b24197c 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -1407,6 +1407,8 @@ void aiLaserAction(AIEntity *e) {
AIEntity *hit = e;
int moveOK = 0;
+ int moveCount = 0;
+
do {
int nx = hit->tileX;
int ny = hit->tileY;
@@ -1541,6 +1543,13 @@ void aiLaserAction(AIEntity *e) {
hit = NULL;
}
}
+
+ moveCount++;
+
+ // It is possible to set a configuration which leads to a closed loop.
+ // Thus, we're breaking it here
+ if (moveCount > 1000)
+ hit = NULL;
} while (hit && hit->type == AI_DIVERTER);
}