diff --git a/engines/gob/scenery.cpp b/engines/gob/scenery.cpp index 9b29e22c1d7..c467a22440c 100644 --- a/engines/gob/scenery.cpp +++ b/engines/gob/scenery.cpp @@ -51,6 +51,17 @@ Scenery::Scenery(GobEngine *vm) : _vm(vm) { _curStatic = 0; _curStaticLayer = 0; + if (_vm->getGameType() == kGameTypeGob2 || _vm->getGameType() == kGameTypeGob3) { + // The maximum draw order is known to be 40 in Gobliins 2 and Goblins 3, and 100 in Woodruff and Adibou2. + // It was previously set to 100 for all games, but it caused a glitch in the first screen of Goblins 3, + // see issue #9682. + // Probably most pre-Woodruff titles should use 40, but it should be verified, and most of the time a higher + // limit does not harm. + _maxDrawOrder = 40; + } else { + _maxDrawOrder = 100; + } + _toRedrawLeft = 0; _toRedrawRight = 0; _toRedrawTop = 0; @@ -269,7 +280,7 @@ void Scenery::renderStatic(int16 scenery, int16 layer) { } planeCount = layerPtr->planeCount; - for (order = 0; order < 100; order++) { + for (order = 0; order < _maxDrawOrder; order++) { for (plane = 0, planePtr = layerPtr->planes; plane < planeCount; plane++, planePtr++) { if (planePtr->drawOrder != order) continue; @@ -329,7 +340,7 @@ void Scenery::updateStatic(int16 orderFrom, byte index, byte layer) { planeCount = layerPtr->planeCount; - for (order = orderFrom; order < 100; order++) { + for (order = orderFrom; order < _maxDrawOrder; order++) { for (planePtr = layerPtr->planes, plane = 0; plane < planeCount; plane++, planePtr++) { if (planePtr->drawOrder != order) diff --git a/engines/gob/scenery.h b/engines/gob/scenery.h index 5a0c459eecf..64db9522fea 100644 --- a/engines/gob/scenery.h +++ b/engines/gob/scenery.h @@ -93,6 +93,8 @@ public: int16 _curStatic; int16 _curStaticLayer; + int16 _maxDrawOrder; + int16 _toRedrawLeft; int16 _toRedrawRight; int16 _toRedrawTop;