[Scummvm-cvs-logs] SF.net SVN: scummvm:[44588] scummvm/trunk/engines/draci

spalek at users.sourceforge.net spalek at users.sourceforge.net
Sun Oct 4 11:13:15 CEST 2009


Revision: 44588
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44588&view=rev
Author:   spalek
Date:     2009-10-04 09:13:15 +0000 (Sun, 04 Oct 2009)

Log Message:
-----------
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.

Modified Paths:
--------------
    scummvm/trunk/engines/draci/game.cpp
    scummvm/trunk/engines/draci/game.h
    scummvm/trunk/engines/draci/saveload.cpp

Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp	2009-10-04 06:39:07 UTC (rev 44587)
+++ scummvm/trunk/engines/draci/game.cpp	2009-10-04 09:13:15 UTC (rev 44588)
@@ -619,25 +619,30 @@
 	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 @@
 	// 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::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;
 

Modified: scummvm/trunk/engines/draci/game.h
===================================================================
--- scummvm/trunk/engines/draci/game.h	2009-10-04 06:39:07 UTC (rev 44587)
+++ scummvm/trunk/engines/draci/game.h	2009-10-04 09:13:15 UTC (rev 44588)
@@ -316,6 +316,7 @@
 	void inventoryInit();
 	void inventoryDraw();
 	void inventoryDone();
+	void inventoryReload();
 
 	void dialogueMenu(int dialogueID);
 	int dialogueDraw();

Modified: scummvm/trunk/engines/draci/saveload.cpp
===================================================================
--- scummvm/trunk/engines/draci/saveload.cpp	2009-10-04 06:39:07 UTC (rev 44587)
+++ scummvm/trunk/engines/draci/saveload.cpp	2009-10-04 09:13:15 UTC (rev 44588)
@@ -149,6 +149,8 @@
 	vm->_game->setRoomNum(oldRoomNum);
 	vm->_game->setExitLoop(true);
 
+	vm->_game->inventoryReload();
+
 	return Common::kNoError;
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list