diff options
author | Strangerke | 2013-01-08 08:37:42 +0100 |
---|---|---|
committer | Strangerke | 2013-01-08 08:37:42 +0100 |
commit | 5a961b104fb22ce1c32f46a112a185c1fc08b45c (patch) | |
tree | 1bc9506aa55ebf406db7cf28695c97cd9a26fa58 /engines/hopkins | |
parent | e67e84dfe75cffd1ed363c4f81054d6a1a62b868 (diff) | |
download | scummvm-rg350-5a961b104fb22ce1c32f46a112a185c1fc08b45c.tar.gz scummvm-rg350-5a961b104fb22ce1c32f46a112a185c1fc08b45c.tar.bz2 scummvm-rg350-5a961b104fb22ce1c32f46a112a185c1fc08b45c.zip |
HOPKINS: Refactor nextObjectIcon
Diffstat (limited to 'engines/hopkins')
-rw-r--r-- | engines/hopkins/dialogs.cpp | 4 | ||||
-rw-r--r-- | engines/hopkins/objects.cpp | 157 | ||||
-rw-r--r-- | engines/hopkins/objects.h | 4 |
3 files changed, 71 insertions, 94 deletions
diff --git a/engines/hopkins/dialogs.cpp b/engines/hopkins/dialogs.cpp index 246bd88455..81ef831dde 100644 --- a/engines/hopkins/dialogs.cpp +++ b/engines/hopkins/dialogs.cpp @@ -380,7 +380,7 @@ LABEL_7: _vm->_objectsManager.initBorder(newInventoryItem); if (_vm->_eventsManager._mouseCursorId != 1 && _vm->_eventsManager._mouseCursorId != 2 && _vm->_eventsManager._mouseCursorId != 3 && _vm->_eventsManager._mouseCursorId != 16) { if (mouseButton == 2) { - _vm->_objectsManager.OBJETPLUS(newInventoryItem); + _vm->_objectsManager.nextObjectIcon(newInventoryItem); if (_vm->_eventsManager._mouseCursorId != 23) _vm->_eventsManager.changeMouseCursor(_vm->_eventsManager._mouseCursorId); } @@ -388,7 +388,7 @@ LABEL_7: if (mouseButton == 1) { if (_vm->_eventsManager._mouseCursorId == 1 || _vm->_eventsManager._mouseCursorId == 2 || _vm->_eventsManager._mouseCursorId == 3 || _vm->_eventsManager._mouseCursorId == 16 || !_vm->_eventsManager._mouseCursorId) break; - _vm->_objectsManager.VALID_OBJET(_vm->_globals._inventory[newInventoryItem]); + _vm->_objectsManager.takeInventoryObject(_vm->_globals._inventory[newInventoryItem]); if (_vm->_eventsManager._mouseCursorId == 8) v20 = true; if (!v20) { diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index 23b7778165..a5659bca6f 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -273,15 +273,12 @@ int ObjectsManager::capture_mem_sprite(const byte *objectData, byte *sprite, int * Add Object */ int ObjectsManager::addObject(int objIndex) { - bool flag = false; int arrIndex = 0; - do { + for (;;) { ++arrIndex; - if (!_vm->_globals._inventory[arrIndex]) - flag = true; - if (arrIndex == 32) - flag = true; - } while (!flag); + if ((!_vm->_globals._inventory[arrIndex]) || (arrIndex == 32)) + break;; + } _vm->_globals._inventory[arrIndex] = objIndex; return arrIndex; @@ -3624,94 +3621,74 @@ void ObjectsManager::initBorder(int a1) { _vm->_eventsManager.getMouseY(); } -void ObjectsManager::OBJETPLUS(int idx) { - int v1; - int v2; - int v3; +/** + * Get next icon for an object in the inventory + */ +void ObjectsManager::nextObjectIcon(int idx) { + if (_vm->_eventsManager._mouseCursorId == 0 || _vm->_eventsManager._mouseCursorId == 16 || _vm->_eventsManager._mouseCursorId == 3 || + _vm->_eventsManager._mouseCursorId == 2 || _vm->_eventsManager._mouseCursorId == 7) + return; + + int nextCursorId = _vm->_eventsManager._mouseCursorId + 1; + do { + if (nextCursorId == 6) { + _vm->_eventsManager._mouseCursorId = 6; + if (_vm->_globals.ObjetW[_vm->_globals._inventory[idx]].field2 == 1) + return; + nextCursorId++; + } + if (nextCursorId == 7) { + _vm->_eventsManager._mouseCursorId = 7; + if (_vm->_globals.ObjetW[_vm->_globals._inventory[idx]].field3 == 1) + return; + nextCursorId++; + } + if (nextCursorId == 8) { + _vm->_eventsManager._mouseCursorId = 8; + return; + } + if (nextCursorId == 9 || nextCursorId == 10) { + _vm->_eventsManager._mouseCursorId = 10; + if (_vm->_globals.ObjetW[_vm->_globals._inventory[idx]].field7 == 1) + return; + nextCursorId = 11; + } - v1 = _vm->_eventsManager._mouseCursorId; - if (_vm->_eventsManager._mouseCursorId && _vm->_eventsManager._mouseCursorId != 16 && (uint16)(_vm->_eventsManager._mouseCursorId - 2) > 1u) { - v2 = _vm->_eventsManager._mouseCursorId++ + 1; - if (v1 == 5) - goto LABEL_24; - if (v2 == 7) - goto LABEL_26; - if (v2 != 8) { - if (v2 == 9) - _vm->_eventsManager._mouseCursorId = 10; - if (_vm->_eventsManager._mouseCursorId == 10) - goto LABEL_29; - if (_vm->_eventsManager._mouseCursorId == 11) - goto LABEL_31; - if (_vm->_eventsManager._mouseCursorId == 12) - _vm->_eventsManager._mouseCursorId = 13; - if (_vm->_eventsManager._mouseCursorId == 13) - goto LABEL_33; - if (_vm->_eventsManager._mouseCursorId == 14) - _vm->_eventsManager._mouseCursorId = 15; - if (_vm->_eventsManager._mouseCursorId == 15) - goto LABEL_35; - if ((uint16)(_vm->_eventsManager._mouseCursorId - 16) <= 6u) - _vm->_eventsManager._mouseCursorId = 23; - if (_vm->_eventsManager._mouseCursorId == 23) - goto LABEL_37; - if (_vm->_eventsManager._mouseCursorId == 24) - _vm->_eventsManager._mouseCursorId = 25; - if (_vm->_eventsManager._mouseCursorId == 25) - goto LABEL_39; - do { - _vm->_eventsManager._mouseCursorId = 6; -LABEL_24: - if (_vm->_globals.ObjetW[_vm->_globals._inventory[idx]].field2 == 1) - break; - ++_vm->_eventsManager._mouseCursorId; - if (_vm->_eventsManager._mouseCursorId == 7) { -LABEL_26: - if (_vm->_globals.ObjetW[_vm->_globals._inventory[idx]].field3 == 1) - return; - } - v3 = _vm->_eventsManager._mouseCursorId++; - if (_vm->_eventsManager._mouseCursorId == 8) - break; - _vm->_eventsManager._mouseCursorId = v3 + 3; - if (v3 == 7) { -LABEL_29: - if (_vm->_globals.ObjetW[_vm->_globals._inventory[idx]].field7 == 1) - return; - } - ++_vm->_eventsManager._mouseCursorId; - if (_vm->_eventsManager._mouseCursorId == 11) { -LABEL_31: - if (_vm->_globals.ObjetW[_vm->_globals._inventory[idx]].field4 == 1) - return; - } - _vm->_eventsManager._mouseCursorId += 2; - if (_vm->_eventsManager._mouseCursorId == 13) { -LABEL_33: - if (_vm->_globals.ObjetW[_vm->_globals._inventory[idx]].field5 == 1) - return; - } - _vm->_eventsManager._mouseCursorId += 2; - if (_vm->_eventsManager._mouseCursorId == 15) { -LABEL_35: - if (_vm->_globals.ObjetW[_vm->_globals._inventory[idx]].field6 == 1) - return; - } - _vm->_eventsManager._mouseCursorId = 23; -LABEL_37: - if (_vm->_globals.ObjetW[_vm->_globals._inventory[idx]].field6 == 2) - break; - _vm->_eventsManager._mouseCursorId = 25; -LABEL_39: - ; - } while (_vm->_globals.ObjetW[_vm->_globals._inventory[idx]].field7 != 2); + if (nextCursorId == 11) { + _vm->_eventsManager._mouseCursorId = 11; + ++_vm->_eventsManager._mouseCursorId; + if (_vm->_globals.ObjetW[_vm->_globals._inventory[idx]].field4 == 1) + return; + nextCursorId++; } - } + + if (nextCursorId == 12 || nextCursorId == 13) { + _vm->_eventsManager._mouseCursorId = 13; + if (_vm->_globals.ObjetW[_vm->_globals._inventory[idx]].field5 == 1) + return; + nextCursorId = 14; + } + + if (nextCursorId == 14 || nextCursorId == 15) { + _vm->_eventsManager._mouseCursorId = 15; + if (_vm->_globals.ObjetW[_vm->_globals._inventory[idx]].field6 == 1) + return; + nextCursorId = 23; + } + + if (nextCursorId >= 16 && nextCursorId <= 23) { + _vm->_eventsManager._mouseCursorId = 23; + if (_vm->_globals.ObjetW[_vm->_globals._inventory[idx]].field6 == 2) + return; + } + + nextCursorId = 6; + } while (_vm->_globals.ObjetW[_vm->_globals._inventory[idx]].field7 != 2); } -void ObjectsManager::VALID_OBJET(int a1) { +void ObjectsManager::takeInventoryObject(int idx) { if (_vm->_eventsManager._mouseCursorId == 8) - changeObject(a1); + changeObject(idx); } void ObjectsManager::OPTI_OBJET() { diff --git a/engines/hopkins/objects.h b/engines/hopkins/objects.h index 4acb0174a3..8b7ed924e1 100644 --- a/engines/hopkins/objects.h +++ b/engines/hopkins/objects.h @@ -194,8 +194,8 @@ public: void handleRightButton(); int MZONE(); void initBorder(int a1); - void OBJETPLUS(int a1); - void VALID_OBJET(int a1); + void nextObjectIcon(int idx); + void takeInventoryObject(int idx); void OPTI_OBJET(); void handleSpecialGames(); void BOB_VIVANT(int a1); |