diff options
author | Strangerke | 2013-01-08 23:45:15 +0100 |
---|---|---|
committer | Strangerke | 2013-01-08 23:45:15 +0100 |
commit | 0376c6bcb8266275aefca3540489a92a402c5b06 (patch) | |
tree | d0544a273217f805f3e00db8002b014dc50de712 /engines | |
parent | 2b1b6689086e73b77041ec36a8337f044486ad73 (diff) | |
download | scummvm-rg350-0376c6bcb8266275aefca3540489a92a402c5b06.tar.gz scummvm-rg350-0376c6bcb8266275aefca3540489a92a402c5b06.tar.bz2 scummvm-rg350-0376c6bcb8266275aefca3540489a92a402c5b06.zip |
HOPKINS: Remove some nasty casts from menuManager and ObjectManager
Diffstat (limited to 'engines')
-rw-r--r-- | engines/hopkins/menu.cpp | 12 | ||||
-rw-r--r-- | engines/hopkins/objects.cpp | 103 |
2 files changed, 58 insertions, 57 deletions
diff --git a/engines/hopkins/menu.cpp b/engines/hopkins/menu.cpp index f607f2c15c..3368afa6c3 100644 --- a/engines/hopkins/menu.cpp +++ b/engines/hopkins/menu.cpp @@ -101,16 +101,16 @@ int MenuManager::menu() { menuIndex = MENU_NONE; mousePos = Common::Point(_vm->_eventsManager.getMouseX(), _vm->_eventsManager.getMouseY()); - if ((uint16)(mousePos.x - 232) <= 176) { - if ((uint16)(mousePos.y - 261) <= 23) + if (mousePos.x >= 232 && mousePos.x <= 408) { + if (mousePos.y >= 261 && mousePos.y <= 284) menuIndex = PLAY_GAME; - if ((uint16)(mousePos.y - 293) <= 23) + else if (mousePos.y >= 293 && mousePos.y <= 316) menuIndex = LOAD_GAME; - if ((uint16)(mousePos.y - 325) <= 22) + else if (mousePos.y >= 325 && mousePos.y <= 347) menuIndex = OPTIONS; - if ((uint16)(mousePos.y - 356) <= 23) + else if (mousePos.y >= 356 && mousePos.y <= 379) menuIndex = INTRODUCTION; - if ((uint16)(mousePos.y - 388) <= 23) + else if (mousePos.y >= 388 && mousePos.y <= 411) menuIndex = QUIT; } diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index 99b992bb23..43a5dd7888 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -2365,7 +2365,9 @@ void ObjectsManager::handleLeftButton() { destX = _vm->_eventsManager.getMouseX(); destY = _vm->_eventsManager.getMouseY(); - if (!_vm->_dialogsManager._inventFl && !_vm->_globals.PLAN_FLAG && destX > _vm->_graphicsManager._scrollOffset - 30 && destX < _vm->_graphicsManager._scrollOffset + 50 && (uint16)(destY + 29) <= 78) { + if (!_vm->_dialogsManager._inventFl && !_vm->_globals.PLAN_FLAG && + destX > _vm->_graphicsManager._scrollOffset - 30 && destX < _vm->_graphicsManager._scrollOffset + 50 && + destY > -30 && destY < 50) { v1 = _vm->_eventsManager._mouseCursorId; _vm->_dialogsManager._inventFl = true; _vm->_dialogsManager.showInventory(); @@ -2377,32 +2379,24 @@ void ObjectsManager::handleLeftButton() { } return; } - if (_vm->_globals._saveData->data[svField354] == 1 - && !_vm->_globals.PLAN_FLAG - && (uint16)(destX - 533) <= 26 - && (uint16)(destY - 26) <= 33) { + if (_vm->_globals._saveData->data[svField354] == 1 && !_vm->_globals.PLAN_FLAG + && destX >= 533 && destX <= 559 && destY >= 26 && destY <= 59) { changeCharacterHead(CHARACTER_HOPKINS_CLONE, CHARACTER_HOPKINS); return; } - if (_vm->_globals._saveData->data[svField356] == 1 - && !_vm->_globals.PLAN_FLAG - && (uint16)(destX - 533) <= 26 - && (uint16)(destY - 26) <= 22) { + if (_vm->_globals._saveData->data[svField356] == 1 && !_vm->_globals.PLAN_FLAG + && destX >= 533 && destX <= 559 && destY >= 26 && destY <= 48) { changeCharacterHead(CHARACTER_SAMANTHA, CHARACTER_HOPKINS); return; } if (_vm->_globals._saveData->data[svField357] == 1) { - if (_vm->_globals._saveData->data[svField353] == 1 - && !_vm->_globals.PLAN_FLAG - && (uint16)(destX - 533) <= 26 - && (uint16)(destY - 26) <= 33) { + if (_vm->_globals._saveData->data[svField353] == 1 && !_vm->_globals.PLAN_FLAG + && destX >= 533 && destX <= 559 && destY >= 26 && destY <= 59) { changeCharacterHead(CHARACTER_HOPKINS, CHARACTER_HOPKINS_CLONE); return; } - if (_vm->_globals._saveData->data[svField355] == 1 - && !_vm->_globals.PLAN_FLAG - && (uint16)(destX - 567) <= 26 - && (uint16)(destY - 26) <= 33) { + if (_vm->_globals._saveData->data[svField355] == 1 && !_vm->_globals.PLAN_FLAG + && destX >= 567 && destX <= 593 && destY >= 26 && destY <= 59) { changeCharacterHead(CHARACTER_HOPKINS, CHARACTER_SAMANTHA); return; } @@ -2452,7 +2446,7 @@ LABEL_38: _vm->_globals.GOACTION = false; v9 = _vm->_globals.chemin; _vm->_globals.chemin = (int16 *)g_PTRNUL; - if (_vm->_globals._forestFl && ((uint16)(NUMZONE - 20) <= 1u || (uint16)(NUMZONE - 22) <= 1u)) { + if (_vm->_globals._forestFl && NUMZONE >= 20 && NUMZONE <= 23) { if (getSpriteY(0) <= 374 || getSpriteY(0) > 410) { v10 = getSpriteX(0); v11 = getSpriteY(0); @@ -2504,10 +2498,12 @@ LABEL_65: _vm->_globals.chemin = PARC_VOITURE(v18, v17, destX, destY); } } - if ((uint16)(NUMZONE + 1) > 1u) { - // TODO: Reformat the weird if statement generated by the decompiler - if (_vm->_eventsManager._mouseCursorId == 23 || (_vm->_globals._saveData->data[svField1] = _vm->_eventsManager._mouseCursorId, _vm->_eventsManager._mouseCursorId == 23)) + if (NUMZONE < -1 || NUMZONE > 0) { + if (_vm->_eventsManager._mouseCursorId == 23) _vm->_globals._saveData->data[svField1] = 5; + else + _vm->_globals._saveData->data[svField1] = _vm->_eventsManager._mouseCursorId; + if (_vm->_globals.PLAN_FLAG) _vm->_globals._saveData->data[svField1] = 6; _vm->_globals._saveData->data[svField2] = NUMZONE; @@ -2536,7 +2532,7 @@ void ObjectsManager::PARADISE() { result = _vm->_globals._saveData->data[svField1]; if (result && _vm->_globals._saveData->data[svField2] && result != 4 && result > 3) { _vm->_fontManager.hideText(5); - if (!_vm->_globals._forestFl || ((uint16)(NUMZONE - 20) > 1u && (uint16)(NUMZONE - 22) > 1u)) { + if (!_vm->_globals._forestFl || NUMZONE < 20 || NUMZONE > 23) { if (_vm->_graphicsManager._largeScreenFl) { _vm->_graphicsManager.no_scroll = 2; if (_vm->_eventsManager._startPos.x >= getSpriteX(0) - 320) @@ -2602,7 +2598,7 @@ LABEL_64: NUMZONE = -1; _forceZoneFl = true; } - if (NUMZONE != _vm->_globals._saveData->data[svField2] || (uint16)(NUMZONE + 1) <= 1u) { + if (NUMZONE != _vm->_globals._saveData->data[svField2] || NUMZONE == -1 || NUMZONE == 0) { _vm->_eventsManager._mouseCursorId = 4; _changeVerbFl = false; } else { @@ -2627,7 +2623,7 @@ LABEL_64: if (_vm->_globals.NOMARCHE) { if (_vm->_eventsManager._mouseCursorId == 4) { result = NUMZONE + 1; - if ((uint16)(NUMZONE + 1) > 1u) + if (NUMZONE < -1 || NUMZONE > 0) handleRightButton(); } } @@ -3417,7 +3413,7 @@ LABEL_67: * Handle Right button */ void ObjectsManager::handleRightButton() { - if ((uint16)(NUMZONE + 1) > 1u) { + if (NUMZONE < -1 || NUMZONE > 0) { VERBEPLUS(); if (_vm->_eventsManager._mouseCursorId != 23) _vm->_eventsManager.changeMouseCursor(_vm->_eventsManager._mouseCursorId); @@ -3561,60 +3557,65 @@ LABEL_58: * Prepare border used to highlight the place below mouse cursor, in the inventory. * Also set the mouse cursor */ -void ObjectsManager::initBorder(int a1) { +void ObjectsManager::initBorder(int zoneIdx) { _oldBorderPos = _borderPos; _oldBorderSpriteIndex = _borderSpriteIndex; - if ((uint16)(a1 - 1) <= 5u) + if (zoneIdx >= 1 && zoneIdx <= 6) _borderPos.y = 120; - if ((uint16)(a1 - 7) <= 5u) + else if (zoneIdx >= 7 && zoneIdx <= 12) _borderPos.y = 158; - if ((uint16)(a1 - 13) <= 5u) + else if (zoneIdx >= 13 && zoneIdx <= 18) _borderPos.y = 196; - if ((uint16)(a1 - 19) <= 5u) + else if (zoneIdx >= 19 && zoneIdx <= 24) _borderPos.y = 234; - if ((uint16)(a1 - 25) <= 4u) + else if (zoneIdx >= 25 && zoneIdx <= 29) _borderPos.y = 272; - if (a1 == 1 || a1 == 7 || a1 == 13 || a1 == 19 || a1 == 25) + else if (zoneIdx == 30) + _borderPos.y = 272; + else if (zoneIdx == 31) + _borderPos.y = 290; + + if (zoneIdx == 1 || zoneIdx == 7 || zoneIdx == 13 || zoneIdx == 19 || zoneIdx == 25) _borderPos.x = _vm->_graphicsManager._scrollOffset + 158; - if (a1 == 2 || a1 == 8 || a1 == 14 || a1 == 20 || a1 == 26) + else if (zoneIdx == 2 || zoneIdx == 8 || zoneIdx == 14 || zoneIdx == 20 || zoneIdx == 26) _borderPos.x = _vm->_graphicsManager._scrollOffset + 212; - if (a1 == 3 || a1 == 9 || a1 == 15 || a1 == 21 || a1 == 27) + else if (zoneIdx == 3 || zoneIdx == 9 || zoneIdx == 15 || zoneIdx == 21 || zoneIdx == 27) _borderPos.x = _vm->_graphicsManager._scrollOffset + 266; - if (a1 == 4 || a1 == 10 || a1 == 16 || a1 == 22 || a1 == 28) + else if (zoneIdx == 4 || zoneIdx == 10 || zoneIdx == 16 || zoneIdx == 22 || zoneIdx == 28) _borderPos.x = _vm->_graphicsManager._scrollOffset + 320; - if (a1 == 5 || a1 == 11 || a1 == 17 || a1 == 23 || a1 == 29) + else if (zoneIdx == 5 || zoneIdx == 11 || zoneIdx == 17 || zoneIdx == 23 || zoneIdx == 29) _borderPos.x = _vm->_graphicsManager._scrollOffset + 374; - if (a1 == 6 || a1 == 12 || a1 == 18 || a1 == 24 || (uint16)(a1 - 30) <= 1u) + else if (zoneIdx == 6 || zoneIdx == 12 || zoneIdx == 18 || zoneIdx == 24 || zoneIdx == 30 || zoneIdx == 31) _borderPos.x = _vm->_graphicsManager._scrollOffset + 428; - if ((uint16)(a1 - 1) <= 28) + + if (zoneIdx >= 1 && zoneIdx <= 29) _borderSpriteIndex = 0; - if ((uint16)(a1 - 30) <= 1) + else if (zoneIdx == 30 || zoneIdx == 31) _borderSpriteIndex = 2; - if (a1 == 30) - _borderPos.y = 272; - if (a1 == 31) - _borderPos.y = 290; - if (!a1 || a1 == 32) { + else if (!zoneIdx || zoneIdx == 32) { _borderPos = Common::Point(0, 0); _borderSpriteIndex = 0; } - if (!a1) + + if (!zoneIdx) _vm->_eventsManager._mouseCursorId = 0; - if (a1 == 32) + else if (zoneIdx == 32) _vm->_eventsManager._mouseCursorId = 16; - if (a1 == 30) + else if (zoneIdx == 30) _vm->_eventsManager._mouseCursorId = 2; - if (a1 == 31) + else if (zoneIdx == 31) _vm->_eventsManager._mouseCursorId = 3; - if ((uint16)(a1 - 1) <= 28) + else if (zoneIdx >= 1 && zoneIdx <= 28) _vm->_eventsManager._mouseCursorId = 8; - if (a1 == 29) + else if (zoneIdx == 29) _vm->_eventsManager._mouseCursorId = 1; - if ((uint16)(a1 - 1) <= 27 && !_vm->_globals._inventory[a1]) { + + if (zoneIdx >= 1 && zoneIdx <= 28 && !_vm->_globals._inventory[zoneIdx]) { _vm->_eventsManager._mouseCursorId = 0; _borderPos = Common::Point(0, 0); _borderSpriteIndex = 0; } + if (_vm->_eventsManager._mouseCursorId != 23) _vm->_eventsManager.changeMouseCursor(_vm->_eventsManager._mouseCursorId); _vm->_eventsManager.getMouseX(); |