aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2012-01-07 18:55:11 +0200
committerFilippos Karapetis2012-01-07 18:56:23 +0200
commitbeb1f5b316b2d00bc02bf9c4f674278dc71aba7a (patch)
treeb7670c1bd16e9bc5e71dd87c29dcbdefe5479e8f
parent4222a728e16e07e1d0fa29d8ade2dfca608ce400 (diff)
downloadscummvm-rg350-beb1f5b316b2d00bc02bf9c4f674278dc71aba7a.tar.gz
scummvm-rg350-beb1f5b316b2d00bc02bf9c4f674278dc71aba7a.tar.bz2
scummvm-rg350-beb1f5b316b2d00bc02bf9c4f674278dc71aba7a.zip
AGI: Fix bug #3451122 - "AGI-FANMADE: Nick's Quest hangs ScummVM upon starting"
-rw-r--r--engines/agi/checks.cpp16
-rw-r--r--engines/agi/picture.h2
2 files changed, 18 insertions, 0 deletions
diff --git a/engines/agi/checks.cpp b/engines/agi/checks.cpp
index c3b31f6ba9..624476509e 100644
--- a/engines/agi/checks.cpp
+++ b/engines/agi/checks.cpp
@@ -113,6 +113,22 @@ int AgiEngine::checkPriority(VtEntry *v) {
water = 1;
+ // Check if any picture is loaded before checking for priority below.
+ // If no picture has been loaded, the priority buffer won't be initialized,
+ // thus the check below will always fail. This case causes an infinite loop
+ // in the fanmade game Nick's Quest (bug #3451122), as the game attempts to
+ // draw a sprite (view 4, floating Nick) before it loads any picture. This
+ // causes the checks below to always fail, and the engine keeps readjusting
+ // the sprite's position in fixPosition() forever, as there is no valid
+ // position to place it (the default visual and priority screen is set to
+ // zero, i.e. unconditional black). To remedy this situation, we always
+ // return true here if no picture has been loaded and no priority screen
+ // has been set up.
+ if (!_game._vm->_picture->isPictureLoaded()) {
+ warning("checkPriority: no picture loaded");
+ return pass;
+ }
+
p0 = &_game.sbuf16c[v->xPos + v->yPos * _WIDTH];
for (i = 0; i < v->xSize; i++, p0++) {
diff --git a/engines/agi/picture.h b/engines/agi/picture.h
index f2a6586b93..45a95202e5 100644
--- a/engines/agi/picture.h
+++ b/engines/agi/picture.h
@@ -115,6 +115,8 @@ public:
putVirtPixel(x, y);
}
+ bool isPictureLoaded() { return _data != NULL; }
+
private:
uint8 *_data;
uint32 _flen;