AGOS: Fix restoreBlock() regression

The whole restoreBlock() function looked strange. It said it took x, y,
w and h, but it seems pretty clear that what it expects is left, top,
right and bottom.

Except in one case, where the order of the parameters had been swapped.

The most visible result of all this was that The Feeble Files crashed
when you pressed the "Off" button in the Oracle interface.

I've changed the names of the parameters, and that one strange call, and
changed how the function calculates the dirty rect. Hopefully that
should be correct.
This commit is contained in:
Torbjörn Andersson 2021-05-20 20:30:32 +02:00 committed by David Turner
parent 5bc9d05467
commit f6bac7b6c6
2 changed files with 10 additions and 10 deletions

View File

@ -1212,7 +1212,7 @@ protected:
void colorBlock(WindowBlock *window, uint16 x, uint16 y, uint16 w, uint16 h);
void restoreWindow(WindowBlock *window);
void restoreBlock(uint16 x, uint16 y, uint16 w, uint16 h);
void restoreBlock(uint16 left, uint16 top, uint16 right, uint16 bottom);
byte *getBackBuf();
byte *getBackGround();

View File

@ -201,7 +201,7 @@ void AGOSEngine::restoreWindow(WindowBlock *window) {
_videoLockOut |= 0x8000;
if (getGameType() == GType_FF || getGameType() == GType_PP) {
restoreBlock(window->y + window->height, window->x + window->width, window->y, window->x);
restoreBlock(window->x, window->y, window->x + window->width, window->y + window->height);
} else if (getGameType() == GType_SIMON2) {
if (_restoreWindow6 && _windowArray[2] == window) {
window = _windowArray[6];
@ -232,7 +232,7 @@ void AGOSEngine::restoreWindow(WindowBlock *window) {
_videoLockOut &= ~0x8000;
}
void AGOSEngine::restoreBlock(uint16 x, uint16 y, uint16 w, uint16 h) {
void AGOSEngine::restoreBlock(uint16 left, uint16 top, uint16 right, uint16 bottom) {
byte *dst, *src;
uint i;
@ -240,18 +240,18 @@ void AGOSEngine::restoreBlock(uint16 x, uint16 y, uint16 w, uint16 h) {
dst = (byte *)screen->getPixels();
src = getBackGround();
dst += y * screen->pitch;
src += y * _backGroundBuf->pitch;
dst += top * screen->pitch;
src += top * _backGroundBuf->pitch;
uint8 paletteMod = 0;
Common::Rect dirtyRect(x, y, x + w, h);
if (getGameType() == GType_ELVIRA1 && !(getFeatures() & GF_DEMO) && y >= 133)
Common::Rect dirtyRect(left, top, right, bottom);
if (getGameType() == GType_ELVIRA1 && !(getFeatures() & GF_DEMO) && top >= 133)
paletteMod = 16;
while (y < h) {
for (i = x; i < w; i++)
while (top < bottom) {
for (i = left; i < right; i++)
dst[i] = src[i] + paletteMod;
y++;
top++;
dst += screen->pitch;
src += _backGroundBuf->pitch;
}