fixed interpreter bug (negative address offset - may crush system)

implemented inventory save-load

svn-id: r18071
This commit is contained in:
Andrew Kurushin 2005-05-12 15:11:32 +00:00
parent b3ec472639
commit 91ff7f7a31
4 changed files with 68 additions and 51 deletions

View file

@ -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