diff options
| -rw-r--r-- | engines/draci/game.cpp | 33 | ||||
| -rw-r--r-- | engines/draci/game.h | 1 | ||||
| -rw-r--r-- | engines/draci/saveload.cpp | 2 | 
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;  }  | 
