Skip to content

Commit

Permalink
LILLIPUT: Fix bug in sub167EF
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke authored and sev- committed Mar 28, 2018
1 parent bcfbf5d commit 3ea9558
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 31 deletions.
57 changes: 33 additions & 24 deletions engines/lilliput/lilliput.cpp
Expand Up @@ -1450,10 +1450,10 @@ byte LilliputEngine::sub16799(int index, Common::Point param1) {
}

void LilliputEngine::sub167EF(int index) {
debugC(2, kDebugEngineTBC, "sub167EF(%d)", index);
debugC(2, kDebugEngine, "sub167EF(%d)", index);

int word167EB = findHotspot(Common::Point(_scriptHandler->_array16123PosX[index], _scriptHandler->_array1614BPosY[index]));
int word167ED = findHotspot(Common::Point(_array10999PosX[index], _array109C1PosY[index]));
int16 word167EB = findHotspot(Common::Point(_scriptHandler->_array16123PosX[index], _scriptHandler->_array1614BPosY[index]));
int16 word167ED = findHotspot(Common::Point(_array10999PosX[index], _array109C1PosY[index]));

if (word167EB == word167ED) {
_array109E9PosX[index] = _array10999PosX[index];
Expand Down Expand Up @@ -1484,42 +1484,51 @@ void LilliputEngine::sub167EF(int index) {
int var4l = (_rectXMinMax[word167EB] & 0xFF);

if (var4h != var4l) {
if (_array109E9PosX[index] == var4h) {
--_array109E9PosX[index];
if (_rulesBuffer12Pos4[word167EB].x == var4h) {
_array109E9PosX[index] = _rulesBuffer12Pos4[word167EB].x - 1;
_array10A11PosY[index] = _rulesBuffer12Pos4[word167EB].y;
return;
}

if (_array109E9PosX[index] == var4l) {
++_array109E9PosX[index];
if (_rulesBuffer12Pos4[word167EB].x == var4l) {
_array109E9PosX[index] = _rulesBuffer12Pos4[word167EB].x + 1;
_array10A11PosY[index] = _rulesBuffer12Pos4[word167EB].y;
return;
}

var4h = (_rectYMinMax[word167EB] >> 8);
var4l = (_rectYMinMax[word167EB] & 0xFF);

if (var4h != var4l) {
if (_array10A11PosY[index] == var4h)
--_array10A11PosY[index];
else
++_array10A11PosY[index];
if (_rulesBuffer12Pos4[word167EB].y == var4h) {
_array109E9PosX[index] = _rulesBuffer12Pos4[word167EB].x;
_array10A11PosY[index] = _rulesBuffer12Pos4[word167EB].y - 1;
} else {
_array109E9PosX[index] = _rulesBuffer12Pos4[word167EB].x;
_array10A11PosY[index] = _rulesBuffer12Pos4[word167EB].y + 1;
}
return;
}
}

// var4h == var4l
int mapIndex = (_array10A11PosY[index] * 64 + _array109E9PosX[index]) * 4;
int mapIndex = (_rulesBuffer12Pos4[word167EB].y * 64 + _rulesBuffer12Pos4[word167EB].x) * 4;
assert(mapIndex < 16384);

int tmpVal = _bufferIsoMap[mapIndex + 3];
if ((tmpVal & 8) != 0)
++_array109E9PosX[index];
else if ((tmpVal & 4) != 0)
--_array10A11PosY[index];
else if ((tmpVal & 2) != 0)
++_array10A11PosY[index];
else
--_array109E9PosX[index];

if ((tmpVal & 8) != 0) {
_array109E9PosX[index] = _rulesBuffer12Pos4[word167EB].x + 1;
_array10A11PosY[index] = _rulesBuffer12Pos4[word167EB].y;
} else if ((tmpVal & 4) != 0) {
_array109E9PosX[index] = _rulesBuffer12Pos4[word167EB].x;
_array10A11PosY[index] = _rulesBuffer12Pos4[word167EB].y - 1;
} else if ((tmpVal & 2) != 0) {
_array109E9PosX[index] = _rulesBuffer12Pos4[word167EB].x;
_array10A11PosY[index] = _rulesBuffer12Pos4[word167EB].y + 1;
} else {
_array109E9PosX[index] = _rulesBuffer12Pos4[word167EB].x - 1;
_array10A11PosY[index] = _rulesBuffer12Pos4[word167EB].y;
}
return;
}

Expand Down Expand Up @@ -1966,7 +1975,7 @@ bool LilliputEngine::isMouseOverHotspot(Common::Point mousePos, Common::Point ho
}

void LilliputEngine::sub1305C(byte index, byte button) {
debugC(2, kDebugEngineTBC, "sub1305C(%d, %d)", index, button);
debugC(2, kDebugEngine, "sub1305C(%d, %d)", index, button);

if (_scriptHandler->_interfaceHotspotStatus[index] < kHotspotEnabled)
return;
Expand Down Expand Up @@ -2717,9 +2726,9 @@ void LilliputEngine::handleGameScripts() {
//debugC(1, kDebugEngineTBC, "before char %d, pos %d %d, var0 %d, var1 %d, var2 %d var16 %d, script enabled %d", i, _characterPositionX[i], _characterPositionY[i], *getCharacterVariablesPtr(i * 32 + 0), *getCharacterVariablesPtr(i * 32 + 1), *getCharacterVariablesPtr(i * 32 + 2), *getCharacterVariablesPtr(i * 32 + 22), _scriptHandler->_characterScriptEnabled[i]);

assert(tmpVal < _gameScriptIndexSize);
debugC(1, kDebugEngineTBC, "================= Game Script %d for character %d ==================", tmpVal, index);
debugC(1, kDebugEngine, "================= Game Script %d for character %d ==================", tmpVal, index);
_scriptHandler->runScript(ScriptStream(&_arrayGameScripts[_arrayGameScriptIndex[tmpVal]], _arrayGameScriptIndex[tmpVal + 1] - _arrayGameScriptIndex[tmpVal]));
debugC(1, kDebugEngineTBC, "============= End Game Script %d for character %d ==================", tmpVal, index);
debugC(1, kDebugEngine, "============= End Game Script %d for character %d ==================", tmpVal, index);

//warning("dump char stat");
//debugC(1, kDebugEngineTBC, "after char %d, pos %d %d, var0 %d, var1 %d, var2 %d var16 %d, script enabled %d", i, _characterPositionX[i], _characterPositionY[i], *getCharacterVariablesPtr(i * 32 + 0), *getCharacterVariablesPtr(i * 32 + 1), *getCharacterVariablesPtr(i * 32 + 2), *getCharacterVariablesPtr(i * 32 + 22), _scriptHandler->_characterScriptEnabled[i]);
Expand Down
8 changes: 4 additions & 4 deletions engines/lilliput/script.cpp
Expand Up @@ -3285,17 +3285,17 @@ void LilliputScript::OC_sub1870A_snd() {
void LilliputScript::OC_sub18725_snd() {
debugC(1, kDebugScript, "OC_sub18725_snd()");

int var4 = getValue1() | 0xFF00;
Common::Point var4 = Common::Point(-1, getValue1() & 0xFF);

_vm->_soundHandler->contentFct3();
_vm->_soundHandler->contentFct3(var4);
}

void LilliputScript::OC_sub18733_snd() {
debugC(1, kDebugScriptTBC, "OC_sub18733_snd()");
debugC(1, kDebugScript, "OC_sub18733_snd()");

Common::Point var4 = getPosFromScript();

_vm->_soundHandler->contentFct3();
_vm->_soundHandler->contentFct3(var4);
}

void LilliputScript::OC_sub1873F_snd() {
Expand Down
4 changes: 2 additions & 2 deletions engines/lilliput/sound.cpp
Expand Up @@ -46,8 +46,8 @@ void LilliputSound::contentFct2(int var1, Common::Point var2, Common::Point var3
debugC(1, kDebugSound, "contentFct2(%d, %d - %d, %d - %d, %d - %d)", var1, var2.x, var2.y, var3.x, var3.y, var4.x, var4.y);
}

void LilliputSound::contentFct3() {
debugC(1, kDebugSound, "contentFct3()");
void LilliputSound::contentFct3(Common::Point pos) {
debugC(1, kDebugSound, "contentFct3(%d - %d)", pos.x, pos.y);
}

void LilliputSound::contentFct4() {
Expand Down
2 changes: 1 addition & 1 deletion engines/lilliput/sound.h
Expand Up @@ -35,7 +35,7 @@ class LilliputSound {
void contentFct0();
void contentFct1();
void contentFct2(int var1, Common::Point var2, Common::Point var3, Common::Point var4);
void contentFct3();
void contentFct3(Common::Point pos);
void contentFct4();
void contentFct5();
void contentFct6();
Expand Down

0 comments on commit 3ea9558

Please sign in to comment.