diff options
author | Paul Gilbert | 2015-04-25 04:42:15 -0500 |
---|---|---|
committer | Paul Gilbert | 2015-04-25 04:42:15 -0500 |
commit | 2379824e32fd0cb49e3f2b6c997cb6070f0b0393 (patch) | |
tree | b7278331994774b3e25d08bb44b681f035ee39e1 /engines/sherlock | |
parent | eb91c01cf160984f52edf5ba1da3f5db1e2a6519 (diff) | |
download | scummvm-rg350-2379824e32fd0cb49e3f2b6c997cb6070f0b0393.tar.gz scummvm-rg350-2379824e32fd0cb49e3f2b6c997cb6070f0b0393.tar.bz2 scummvm-rg350-2379824e32fd0cb49e3f2b6c997cb6070f0b0393.zip |
SHERLOCK: Fix saving and display of inventory items
Diffstat (limited to 'engines/sherlock')
-rw-r--r-- | engines/sherlock/inventory.cpp | 19 | ||||
-rw-r--r-- | engines/sherlock/inventory.h | 4 | ||||
-rw-r--r-- | engines/sherlock/journal.cpp | 3 | ||||
-rw-r--r-- | engines/sherlock/saveload.cpp | 2 |
4 files changed, 23 insertions, 5 deletions
diff --git a/engines/sherlock/inventory.cpp b/engines/sherlock/inventory.cpp index 3ba6f9d2bd..808429f643 100644 --- a/engines/sherlock/inventory.cpp +++ b/engines/sherlock/inventory.cpp @@ -31,6 +31,17 @@ InventoryItem::InventoryItem(int requiredFlag, const Common::String &name, _examine(examine), _lookFlag(0) { } +/** + * Synchronize the data for an inventory item + */ +void InventoryItem::synchronize(Common::Serializer &s) { + s.syncAsSint16LE(_requiredFlag); + s.syncAsSint16LE(_lookFlag); + s.syncString(_name); + s.syncString(_description); + s.syncString(_examine); +} + /*----------------------------------------------------------------*/ Inventory::Inventory(SherlockEngine *vm) : Common::Array<InventoryItem>(), _vm(vm) { @@ -47,6 +58,9 @@ Inventory::~Inventory() { freeGraphics(); } +/** + * Free inventory data + */ void Inventory::freeInv() { freeGraphics(); @@ -117,7 +131,7 @@ void Inventory::loadGraphics() { * and returns the numer that matches the passed name */ int Inventory::findInv(const Common::String &name) { - for (int idx = 0; idx < (int)size(); ++idx) { + for (int idx = 0; idx < (int)_names.size(); ++idx) { if (scumm_stricmp(name.c_str(), _names[idx].c_str()) == 0) return idx; } @@ -502,7 +516,8 @@ void Inventory::synchronize(Common::Serializer &s) { } for (uint idx = 0; idx < size(); ++idx) { - // TODO + (*this)[idx].synchronize(s); + } } diff --git a/engines/sherlock/inventory.h b/engines/sherlock/inventory.h index bccdc9336e..0dafdddde9 100644 --- a/engines/sherlock/inventory.h +++ b/engines/sherlock/inventory.h @@ -57,16 +57,18 @@ struct InventoryItem { InventoryItem() : _requiredFlag(0), _lookFlag(0) {} InventoryItem(int requiredFlag, const Common::String &name, const Common::String &description, const Common::String &examine); + + void synchronize(Common::Serializer &s); }; class Inventory : public Common::Array<InventoryItem> { private: SherlockEngine *_vm; + Common::StringArray _names; void copyToInventory(Object &obj); public: ImageFile *_invShapes[MAX_VISIBLE_INVENTORY]; - Common::StringArray _names; bool _invGraphicsLoaded; InvMode _invMode; int _invIndex; diff --git a/engines/sherlock/journal.cpp b/engines/sherlock/journal.cpp index 46114cd746..ffda25a533 100644 --- a/engines/sherlock/journal.cpp +++ b/engines/sherlock/journal.cpp @@ -134,7 +134,6 @@ void Journal::loadJournalLocations() { * word wraps the result to prepare it for being displayed */ int Journal::loadJournalFile(bool alreadyLoaded) { - Inventory &inv = *_vm->_inventory; Screen &screen = *_vm->_screen; Talk &talk = *_vm->_talk; JournalEntry &journalEntry = _journal[_index]; @@ -224,7 +223,7 @@ int Journal::loadJournalFile(bool alreadyLoaded) { journalString += "the Inspector"; break; default: - journalString += inv._names[talk._talkTo]; + journalString += NAMES[talk._talkTo]; break; } journalString += ", \""; diff --git a/engines/sherlock/saveload.cpp b/engines/sherlock/saveload.cpp index 7610c42d8c..a694e21b28 100644 --- a/engines/sherlock/saveload.cpp +++ b/engines/sherlock/saveload.cpp @@ -366,6 +366,7 @@ Common::String SaveManager::generateSaveName(int slot) { * Synchronize the data for a savegame */ void SaveManager::synchronize(Common::Serializer &s) { + Inventory &inv = *_vm->_inventory; Journal &journal = *_vm->_journal; People &people = *_vm->_people; Scene &scene = *_vm->_scene; @@ -374,6 +375,7 @@ void SaveManager::synchronize(Common::Serializer &s) { int oldFont = screen.fontNumber(); + inv.synchronize(s); journal.synchronize(s); people.synchronize(s); scene.synchronize(s); |