From 6ca6fb605d96e0088f4883879e790515d40a4245 Mon Sep 17 00:00:00 2001 From: johndoe123 Date: Fri, 11 Dec 2015 12:51:38 +0100 Subject: ILLUSIONS: BBDOU: Implement more special opcodes and finish putBackInventoryItem --- engines/illusions/bbdou/bbdou_inventory.cpp | 21 +++++++++++++++++---- engines/illusions/bbdou/bbdou_inventory.h | 1 + engines/illusions/bbdou/bbdou_specialcode.cpp | 16 ++++++++++++++++ engines/illusions/bbdou/bbdou_specialcode.h | 3 +++ 4 files changed, 37 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/illusions/bbdou/bbdou_inventory.cpp b/engines/illusions/bbdou/bbdou_inventory.cpp index 064be4edde..fbe10a5bee 100644 --- a/engines/illusions/bbdou/bbdou_inventory.cpp +++ b/engines/illusions/bbdou/bbdou_inventory.cpp @@ -78,6 +78,17 @@ void InventoryBag::removeInventoryItem(InventoryItem *inventoryItem) { (*it)->_inventoryItem = 0; } +bool InventoryBag::hasInventoryItem(uint32 objectId) { + for (InventorySlotsIterator it = _inventorySlots.begin(); + it != _inventorySlots.end(); ++it) { + InventorySlot *inventorySlot = *it; + InventoryItem *inventoryItem = inventorySlot->_inventoryItem; + if (inventoryItem && inventoryItem->_objectId == objectId) + return true; + } + return false; +} + void InventoryBag::buildItems() { for (InventorySlotsIterator it = _inventorySlots.begin(); it != _inventorySlots.end(); ++it) { @@ -333,11 +344,13 @@ void BbdouInventory::putBackInventoryItem(uint32 objectId, Common::Point cursorP if (!flag && !inventoryItem->_assigned) return; for (uint i = 0; i < _inventoryBags.size(); ++i) { - if (_inventoryBags[i]->_sceneId == _activeInventorySceneId) { - InventorySlot *inventorySlot = _inventoryBags[i]->findClosestSlot(cursorPosition, _index); - _inventoryBags[i]->addInventoryItem(inventoryItem, inventorySlot); + InventoryBag *inventoryBag = _inventoryBags[i]; + if (inventoryBag->_sceneId == _activeInventorySceneId) { + InventorySlot *inventorySlot = inventoryBag->findClosestSlot(cursorPosition, _index); + inventoryBag->addInventoryItem(inventoryItem, inventorySlot); } else { - debug("putBackInventoryItem OTHER STUFF TODO"); + if (!inventoryBag->hasInventoryItem(objectId)) + inventoryBag->addInventoryItem(inventoryItem, 0); } } refresh(); diff --git a/engines/illusions/bbdou/bbdou_inventory.h b/engines/illusions/bbdou/bbdou_inventory.h index 27843478e9..2a275d41fd 100644 --- a/engines/illusions/bbdou/bbdou_inventory.h +++ b/engines/illusions/bbdou/bbdou_inventory.h @@ -57,6 +57,7 @@ public: void registerInventorySlot(uint32 namedPointId); bool addInventoryItem(InventoryItem *inventoryItem, InventorySlot *inventorySlot); void removeInventoryItem(InventoryItem *inventoryItem); + bool hasInventoryItem(uint32 objectId); void buildItems(); InventorySlot *getInventorySlot(uint32 objectId); InventorySlot *findClosestSlot(Common::Point putPos, int index); diff --git a/engines/illusions/bbdou/bbdou_specialcode.cpp b/engines/illusions/bbdou/bbdou_specialcode.cpp index 497bc561b0..f230a7c5cf 100644 --- a/engines/illusions/bbdou/bbdou_specialcode.cpp +++ b/engines/illusions/bbdou/bbdou_specialcode.cpp @@ -135,6 +135,7 @@ void BbdouSpecialCode::init() { SPECIAL(0x00160013, spcInitBubble); SPECIAL(0x00160014, spcSetupBubble); SPECIAL(0x00160015, spcSetObjectInteractMode); + SPECIAL(0x00160017, spcInitInventory); SPECIAL(0x00160019, spcRegisterInventoryBag); SPECIAL(0x0016001A, spcRegisterInventorySlot); SPECIAL(0x0016001B, spcRegisterInventoryItem); @@ -143,8 +144,10 @@ void BbdouSpecialCode::init() { SPECIAL(0x0016001E, spcRemoveInventoryItem); SPECIAL(0x0016001F, spcHasInventoryItem); SPECIAL(0x00160025, spcCloseInventory); + SPECIAL(0x00160027, spcInitConversation); SPECIAL(0x00160030, spcResetCursor); SPECIAL(0x00160032, spcSetCursorField90); + SPECIAL(0x00160036, spcInitMenu); SPECIAL(0x00160037, spcIsCursorHoldingObjectId); SPECIAL(0x00160038, spcInitRadarMicrophone); SPECIAL(0x0016003A, spcSaladCtl); @@ -243,6 +246,11 @@ void BbdouSpecialCode::spcSetObjectInteractMode(OpCall &opCall) { _vm->notifyThreadId(opCall._threadId); } +void BbdouSpecialCode::spcInitInventory(OpCall &opCall) { + // Called but not used in the reimplementation since the + // inventory is initialized in this class' constructor +} + void BbdouSpecialCode::spcRegisterInventoryBag(OpCall &opCall) { ARG_UINT32(sceneId); _inventory->registerInventoryBag(sceneId); @@ -282,6 +290,10 @@ void BbdouSpecialCode::spcCloseInventory(OpCall &opCall) { _inventory->close(); } +void BbdouSpecialCode::spcInitConversation(OpCall &opCall) { + // Conversations seem unused but this is still called +} + void BbdouSpecialCode::spcResetCursor(OpCall &opCall) { ARG_UINT32(objectId); _cursor->reset(objectId); @@ -295,6 +307,10 @@ void BbdouSpecialCode::spcSetCursorField90(OpCall &opCall) { _vm->notifyThreadId(opCall._threadId); } +void BbdouSpecialCode::spcInitMenu(OpCall &opCall) { + // Called but not used in the reimplementation +} + void BbdouSpecialCode::spcIsCursorHoldingObjectId(OpCall &opCall) { ARG_UINT32(cursorObjectId); ARG_UINT32(objectId); diff --git a/engines/illusions/bbdou/bbdou_specialcode.h b/engines/illusions/bbdou/bbdou_specialcode.h index 0ee5fae4a1..d117cd7231 100644 --- a/engines/illusions/bbdou/bbdou_specialcode.h +++ b/engines/illusions/bbdou/bbdou_specialcode.h @@ -121,6 +121,7 @@ public: void spcInitBubble(OpCall &opCall); void spcSetupBubble(OpCall &opCall); void spcSetObjectInteractMode(OpCall &opCall); + void spcInitInventory(OpCall &opCall); void spcRegisterInventoryBag(OpCall &opCall); void spcRegisterInventorySlot(OpCall &opCall); void spcRegisterInventoryItem(OpCall &opCall); @@ -129,8 +130,10 @@ public: void spcRemoveInventoryItem(OpCall &opCall); void spcHasInventoryItem(OpCall &opCall); void spcCloseInventory(OpCall &opCall); + void spcInitConversation(OpCall &opCall); void spcResetCursor(OpCall &opCall); void spcSetCursorField90(OpCall &opCall); + void spcInitMenu(OpCall &opCall); void spcIsCursorHoldingObjectId(OpCall &opCall); void spcInitRadarMicrophone(OpCall &opCall); void spcSaladCtl(OpCall &opCall); -- cgit v1.2.3