aboutsummaryrefslogtreecommitdiff
path: root/engines/draci
diff options
context:
space:
mode:
authorRobert Špalek2009-10-04 09:13:15 +0000
committerRobert Špalek2009-10-04 09:13:15 +0000
commit1ed6a2668be5462694c81369cc5abb89e199e2dc (patch)
treef50763a5eb00d6aebbd92d110a463267690bdcd7 /engines/draci
parent06f5393ed41a4c003d7c46f6a37637c8f9a4dc1e (diff)
downloadscummvm-rg350-1ed6a2668be5462694c81369cc5abb89e199e2dc.tar.gz
scummvm-rg350-1ed6a2668be5462694c81369cc5abb89e199e2dc.tar.bz2
scummvm-rg350-1ed6a2668be5462694c81369cc5abb89e199e2dc.zip
Load inventory items properly after loading the game.
This solution is quite hacky, but so is the rest of the code, before a future refactoring done one day. svn-id: r44588
Diffstat (limited to 'engines/draci')
-rw-r--r--engines/draci/game.cpp33
-rw-r--r--engines/draci/game.h1
-rw-r--r--engines/draci/saveload.cpp2
3 files changed, 26 insertions, 10 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index 297214d8b2..1745a23e10 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -619,25 +619,30 @@ void Game::putItem(int itemID, int position) {
if (itemID == kNoItem)
return;
- uint i = position;
-
if (position >= 0 &&
position < kInventoryLines * kInventoryColumns &&
- _inventory[position] == kNoItem) {
+ (_inventory[position] == kNoItem || _inventory[position] == itemID)) {
_inventory[position] = itemID;
} else {
- for (i = 0; i < kInventorySlots; ++i) {
- if (_inventory[i] == kNoItem) {
- _inventory[i] = itemID;
+ for (position = 0; position < kInventorySlots; ++position) {
+ if (_inventory[position] == kNoItem) {
+ _inventory[position] = itemID;
break;
}
}
}
- const int line = i / kInventoryColumns + 1;
- const int column = i % kInventoryColumns + 1;
+ const int line = position / kInventoryColumns + 1;
+ const int column = position % kInventoryColumns + 1;
- Animation *anim = _vm->_anims->getAnimation(kInventoryItemsID - itemID);
+ const int anim_id = kInventoryItemsID - itemID;
+ Animation *anim = _vm->_anims->getAnimation(anim_id);
+ if (!anim) {
+ anim = _vm->_anims->addItem(anim_id);
+ const BAFile *img = _vm->_itemImagesArchive->getFile(2 * itemID);
+ Sprite *sp = new Sprite(img->_data, img->_length, 0, 0, true);
+ anim->addFrame(sp);
+ }
Drawable *frame = anim->getFrame();
const int x = kInventoryX +
@@ -658,7 +663,7 @@ void Game::putItem(int itemID, int position) {
// upon returning it to its slot but *not* in other modes because it should be
// invisible then (along with the inventory)
if (_loopStatus == kStatusInventory && _loopSubstatus == kSubstatusOrdinary) {
- _vm->_anims->play(kInventoryItemsID - itemID);
+ _vm->_anims->play(anim_id);
}
}
@@ -710,6 +715,14 @@ void Game::inventoryDraw() {
}
}
+void Game::inventoryReload() {
+ // Make sure all items are loaded into memory (e.g., after loading a
+ // savegame) by re-putting them on the same spot in the inventory.
+ for (uint i = 0; i < kInventorySlots; ++i) {
+ putItem(_inventory[i], i);
+ }
+}
+
void Game::dialogueMenu(int dialogueID) {
int oldLines, hit;
diff --git a/engines/draci/game.h b/engines/draci/game.h
index 3687c3d2de..6a982c80fd 100644
--- a/engines/draci/game.h
+++ b/engines/draci/game.h
@@ -316,6 +316,7 @@ public:
void inventoryInit();
void inventoryDraw();
void inventoryDone();
+ void inventoryReload();
void dialogueMenu(int dialogueID);
int dialogueDraw();
diff --git a/engines/draci/saveload.cpp b/engines/draci/saveload.cpp
index 89516d2ba2..805e4f607c 100644
--- a/engines/draci/saveload.cpp
+++ b/engines/draci/saveload.cpp
@@ -149,6 +149,8 @@ Common::Error loadSavegameData(int saveGameIdx, DraciEngine *vm) {
vm->_game->setRoomNum(oldRoomNum);
vm->_game->setExitLoop(true);
+ vm->_game->inventoryReload();
+
return Common::kNoError;
}