From ec96a3b1e7c888fa4b3a2957854942d7fed3e766 Mon Sep 17 00:00:00 2001 From: whiterandrek Date: Fri, 27 Apr 2018 11:27:45 +0300 Subject: PINK: added check for item owner --- engines/pink/objects/inventory.cpp | 14 +++++++++----- engines/pink/objects/pages/game_page.cpp | 9 ++++++++- 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'engines/pink') diff --git a/engines/pink/objects/inventory.cpp b/engines/pink/objects/inventory.cpp index 2c4aa5966f..1b5ac2b378 100644 --- a/engines/pink/objects/inventory.cpp +++ b/engines/pink/objects/inventory.cpp @@ -178,12 +178,16 @@ void InventoryMgr::showNextItem(bool direction) { break; } } - index = (direction == kLeft) ? --index : ++index; - index %= _items.size(); - //add check for item owner - _itemActor->setAction(_items[index]->getName()); - _item = _items[index]; + int i = 0; + do { + index = (direction == kLeft) ? --index : ++index; + } while(_items[index % _items.size()]->getCurrentOwner() != _item->getCurrentOwner() && ++i < _items.size()); + + if (i != _items.size()) { + _item = _items[index % _items.size()]; + _itemActor->setAction(_item->getName()); + } } } // End of namespace Pink diff --git a/engines/pink/objects/pages/game_page.cpp b/engines/pink/objects/pages/game_page.cpp index 6b029fbae3..47437a83a3 100644 --- a/engines/pink/objects/pages/game_page.cpp +++ b/engines/pink/objects/pages/game_page.cpp @@ -86,7 +86,7 @@ void GamePage::init(bool isLoadingSave) { _actors[i]->init(startNow); } - bool isHandler = 0; + bool isHandler = false; if (!isLoadingSave) { isHandler = initHandler(); } @@ -106,6 +106,7 @@ bool GamePage::initHandler() { void GamePage::loadManagers() { _isLoaded = true; + _cursorMgr = new CursorMgr(_module->getGame(), this); _walkMgr = new WalkMgr; _sequencer = new Sequencer(this); @@ -114,6 +115,7 @@ void GamePage::loadManagers() { if (_memFile != nullptr) { loadState(); + delete _memFile; _memFile = nullptr; } @@ -176,18 +178,23 @@ void GamePage::saveState() { void GamePage::unload() { _leadActor->setAction(_leadActor->findAction("Idle")); + saveState(); clear(); + _isLoaded = false; } void GamePage::clear() { Page::clear(); _variables.clear(1); + for (int i = 0; i < _handlers.size(); ++i) { delete _handlers[i]; } + _handlers.clear(); + delete _cursorMgr; _cursorMgr = nullptr; delete _sequencer; _sequencer = nullptr; delete _walkMgr; _walkMgr = nullptr; -- cgit v1.2.3