diff options
-rw-r--r-- | engines/pegasus/items/item.cpp | 14 | ||||
-rw-r--r-- | engines/pegasus/items/item.h | 7 | ||||
-rw-r--r-- | engines/pegasus/items/itemlist.cpp | 5 | ||||
-rw-r--r-- | engines/pegasus/items/itemlist.h | 1 | ||||
-rw-r--r-- | engines/pegasus/pegasus.cpp | 3 |
5 files changed, 27 insertions, 3 deletions
diff --git a/engines/pegasus/items/item.cpp b/engines/pegasus/items/item.cpp index 8089f2b93d..830d3f2f34 100644 --- a/engines/pegasus/items/item.cpp +++ b/engines/pegasus/items/item.cpp @@ -39,9 +39,9 @@ namespace Pegasus { Item::Item(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) : IDObject(id) { - _itemNeighborhood = neighborhood; - _itemRoom = room; - _itemDirection = direction; + _originalNeighborhood = _itemNeighborhood = neighborhood; + _originalRoom = _itemRoom = room; + _originalDirection = _itemDirection = direction; _itemWeight = 1; _itemOwnerID = kNoActorID; _itemState = 0; @@ -131,6 +131,14 @@ Item::~Item() { delete[] _itemExtras.entries; } +void Item::reset() { + _itemNeighborhood = _originalNeighborhood; + _itemRoom = _originalRoom; + _itemDirection = _originalDirection; + _itemOwnerID = kNoActorID; + _itemState = 0; +} + void Item::writeToStream(Common::WriteStream *stream) { stream->writeUint16BE(_itemNeighborhood); stream->writeUint16BE(_itemRoom); diff --git a/engines/pegasus/items/item.h b/engines/pegasus/items/item.h index a1451b2a58..26cccf043c 100644 --- a/engines/pegasus/items/item.h +++ b/engines/pegasus/items/item.h @@ -339,6 +339,9 @@ public: void findItemExtra(const uint32 extraID, ItemExtraEntry &entry); + // Reset to its original state at the beginning of the game + void reset(); + protected: NeighborhoodID _itemNeighborhood; RoomID _itemRoom; @@ -347,6 +350,10 @@ protected: WeightType _itemWeight; ItemState _itemState; + NeighborhoodID _originalNeighborhood; + RoomID _originalRoom; + DirectionConstant _originalDirection; + JMPItemInfo _itemInfo; ItemStateInfo _sharedAreaInfo; ItemExtraInfo _itemExtras; diff --git a/engines/pegasus/items/itemlist.cpp b/engines/pegasus/items/itemlist.cpp index ff8cae546b..4b58d9ad78 100644 --- a/engines/pegasus/items/itemlist.cpp +++ b/engines/pegasus/items/itemlist.cpp @@ -64,4 +64,9 @@ Item *ItemList::findItemByID(const ItemID id) { return 0; } +void ItemList::resetAllItems() { + for (ItemIterator it = begin(); it != end(); it++) + (*it)->reset(); +} + } // End of namespace Pegasus diff --git a/engines/pegasus/items/itemlist.h b/engines/pegasus/items/itemlist.h index 9b59206ab3..22bef2c96e 100644 --- a/engines/pegasus/items/itemlist.h +++ b/engines/pegasus/items/itemlist.h @@ -48,6 +48,7 @@ public: virtual void readFromStream(Common::ReadStream *stream); Item *findItemByID(const ItemID id); + void resetAllItems(); }; typedef ItemList::iterator ItemIterator; diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp index 978cb24790..2062fe6847 100644 --- a/engines/pegasus/pegasus.cpp +++ b/engines/pegasus/pegasus.cpp @@ -1682,6 +1682,9 @@ void PegasusEngine::startNewGame() { removeAllItemsFromInventory(); removeAllItemsFromBiochips(); + // Properly reset all items to their original state + g_allItems.resetAllItems(); + BiochipItem *biochip = (BiochipItem *)_allItems.findItemByID(kAIBiochip); addItemToBiochips(biochip); |