diff options
author | Andrew Kurushin | 2005-05-12 15:11:32 +0000 |
---|---|---|
committer | Andrew Kurushin | 2005-05-12 15:11:32 +0000 |
commit | 91ff7f7a31e18a42438d08aaea515c38bb319755 (patch) | |
tree | cb1f1b5b620f3666e4de0ee434be50cbd7f9d3d4 /saga/interface.cpp | |
parent | b3ec4726391e80be92e6faff68be5e5de495d29a (diff) | |
download | scummvm-rg350-91ff7f7a31e18a42438d08aaea515c38bb319755.tar.gz scummvm-rg350-91ff7f7a31e18a42438d08aaea515c38bb319755.tar.bz2 scummvm-rg350-91ff7f7a31e18a42438d08aaea515c38bb319755.zip |
fixed interpreter bug (negative address offset - may crush system)
implemented inventory save-load
svn-id: r18071
Diffstat (limited to 'saga/interface.cpp')
-rw-r--r-- | saga/interface.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/saga/interface.cpp b/saga/interface.cpp index f7077c62c2..b40512c3bf 100644 --- a/saga/interface.cpp +++ b/saga/interface.cpp @@ -642,12 +642,7 @@ void Interface::updateInventory(int pos) { } } -void Interface::addToInventory(int objectId, int pos) { - if (pos != -1) { - _inventory[pos] = objectId; - _inventoryCount = MAX(_inventoryCount, pos + 1); - return; - } +void Interface::addToInventory(int objectId) { if (_inventoryCount >= _inventorySize) { return; @@ -1034,5 +1029,23 @@ void Interface::handleConverseClick(const Point& mousePoint) { } +void Interface::saveState(Common::File& out) { + out.writeUint16LE(_inventoryCount); + + for (int i = 0; i < _inventoryCount; i++) { + out.writeUint16LE(_inventory[i]); + } +} + +void Interface::loadState(Common::File& in) { + _inventoryCount = in.readUint16LE(); + + for (int i = 0; i < _inventoryCount; i++) { + _inventory[i] = in.readUint16LE(); + } + + updateInventory(0); +} + } // End of namespace Saga |