diff options
author | Paul Gilbert | 2014-05-03 13:47:04 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-05-03 13:47:04 -0400 |
commit | 9cd7e8b886c2c72d659cd3439ae4f004126393de (patch) | |
tree | a4ccd845884a37cb2d848767aeb2233bbb23907a /engines | |
parent | 800ff80c52523fd044df3aa879caddb8a617134c (diff) | |
download | scummvm-rg350-9cd7e8b886c2c72d659cd3439ae4f004126393de.tar.gz scummvm-rg350-9cd7e8b886c2c72d659cd3439ae4f004126393de.tar.bz2 scummvm-rg350-9cd7e8b886c2c72d659cd3439ae4f004126393de.zip |
MADS: Maintain inventory ordering in savegames
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mads/inventory.cpp | 29 | ||||
-rw-r--r-- | engines/mads/inventory.h | 2 |
2 files changed, 21 insertions, 10 deletions
diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp index a6459c764b..fecb1b34eb 100644 --- a/engines/mads/inventory.cpp +++ b/engines/mads/inventory.cpp @@ -47,10 +47,22 @@ void InventoryObject::synchronize(Common::Serializer &s) { void InventoryObjects::load() { File f("*OBJECTS.DAT"); + int count = f.readUint16LE(); Common::Serializer s(&f, nullptr); // Load the objects data - synchronize(s); + reserve(count); + for (int i = 0; i < count; ++i) { + InventoryObject obj; + obj.synchronize(s); + push_back(obj); + + // If it's for the player's inventory, add the index to the inventory list + if (obj._roomNumber == PLAYER_INVENTORY) { + _inventoryList.push_back(i); + assert(_inventoryList.size() <= 32); + } + } } void InventoryObjects::synchronize(Common::Serializer &s) { @@ -61,23 +73,22 @@ void InventoryObjects::synchronize(Common::Serializer &s) { // Store the data for each object in the inventory lsit for (int idx = 0; idx < count; ++idx) (*this)[idx].synchronize(s); + + // Synchronize the player's inventory + _inventoryList.synchronize(s); } else { clear(); - _inventoryList.clear(); - reserve(count); // Read in each object + reserve(count); for (int i = 0; i < count; ++i) { InventoryObject obj; obj.synchronize(s); push_back(obj); - - // If it's for the player's inventory, add the index to the inventory list - if (obj._roomNumber == PLAYER_INVENTORY) { - _inventoryList.push_back(i); - assert(_inventoryList.size() <= 32); - } } + + // Synchronize the player's inventory + _inventoryList.synchronize(s); } } diff --git a/engines/mads/inventory.h b/engines/mads/inventory.h index 5e3ecd6a69..f3c63f8c4b 100644 --- a/engines/mads/inventory.h +++ b/engines/mads/inventory.h @@ -60,7 +60,7 @@ private: MADSEngine *_vm; public: - Common::Array<int> _inventoryList; + SynchronizedList _inventoryList; /** * Constructor |