diff options
| -rw-r--r-- | engines/dm/TODOs/methodtree.txt | 8 | ||||
| -rw-r--r-- | engines/dm/dungeonman.cpp | 4 | ||||
| -rw-r--r-- | engines/dm/dungeonman.h | 10 | ||||
| -rw-r--r-- | engines/dm/inventory.cpp | 37 | ||||
| -rw-r--r-- | engines/dm/inventory.h | 2 | ||||
| -rw-r--r-- | engines/dm/menus.cpp | 4 | 
6 files changed, 51 insertions, 14 deletions
| diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index 15e01ee8ee..36237c2205 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -104,10 +104,10 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so  		G0407_s_Party  	F0355_INVENTORY_Toggle_CPSE // done  		F0292_CHAMPION_DrawState // done -		F0334_INVENTORY_CloseChest -			F0163_DUNGEON_LinkThingToList -			G0426_T_OpenChest -			G0425_aT_ChestSlots +		F0334_INVENTORY_CloseChest // done +			F0163_DUNGEON_LinkThingToList // done +			G0426_T_OpenChest // done +			G0425_aT_ChestSlots // done  		F0395_MENUS_DrawMovementArrows // done diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 7de4d76e60..6d5a54069d 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1194,8 +1194,8 @@ uint16 DungeonMan::getObjectWeight(Thing thing) {  	}  	case kContainerThingType: {  		uint16 weight = 50; -		Container container = getThingData(thing); -		Thing slotThing = container.getNextContainedThing(); +		Container container(getThingData(thing)); +		Thing slotThing = container.getSlot();  		while (slotThing != Thing::_thingEndOfList) {  			weight += getObjectWeight(slotThing);  			slotThing = getNextThing(slotThing); diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 064ea49056..1175298917 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -34,6 +34,8 @@  namespace DM { +#define kMapXNotOnASquare -1 // @ CM1_MAPX_NOT_ON_A_SQUARE +  enum ElementType {  	kElementTypeChampion = -2, // @ CM2_ELEMENT_CHAMPION /* Values -2 and -1 are only used as projectile impact types */  	kElementTypeCreature = -1, // @ CM1_ELEMENT_CREATURE @@ -417,14 +419,14 @@ public:  class Container {  	Thing _nextThing; -	Thing _nextContainedThing; +	Thing _slot;  	uint16 _type;  public: -	explicit Container(uint16 *rawDat) : _nextThing(rawDat[0]), _nextContainedThing(rawDat[1]), _type(rawDat[2]) {} +	explicit Container(uint16 *rawDat) : _nextThing(rawDat[0]), _slot(rawDat[1]), _type(rawDat[2]) {}  	uint16 getType() { return (_type >> 1) & 0x3; } -	Thing getNextContainedThing() { return _nextContainedThing; } -	Thing getNextThing() { return _nextThing; } +	Thing &getSlot() { return _slot; } +	Thing &getNextThing() { return _nextThing; }  }; // @ CONTAINER  enum JunkType { diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 550c4c85c6..c02aed4494 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -46,6 +46,8 @@ InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {  	_panelContent = kPanelContentFoodWaterPoisoned;  	for (uint16 i = 0; i < 8; ++i)  		_chestSlots[i] = Thing::_thingNone; +	_openChest = Thing::_thingNone; +	_openChest = Thing::_thingNone;  }  void InventoryMan::toggleInventory(ChampionIndex championIndex) { @@ -66,7 +68,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {  	Champion *champion;  	if (invChampOrdinal) {  		_inventoryChampionOrdinal = _vm->indexToOrdinal(kChampionNone); -		warning("MISSING CODE: F0334_INVENTORY_CloseChest"); +		closeChest();  		champion = &cm._champions[_vm->ordinalToIndex(invChampOrdinal)];  		if (champion->_currHealth && !cm._candidateChampionOrdinal) {  			champion->setAttributeFlag(kChampionAttributeStatusBox, true); @@ -159,7 +161,7 @@ void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {  void InventoryMan::drawPanelFoodWaterPoisoned() {  	Champion &champ = _vm->_championMan->_champions[_inventoryChampionOrdinal]; -	warning("MISSING CODE: F0334_INVENTORY_CloseChest"); +	closeChest();  	DisplayMan &dispMan = *_vm->_displayMan;  	dispMan.blitToScreen(dispMan.getBitmap(kPanelEmptyIndice), 144, 0, 0, gBoxPanel, kColorRed);  	dispMan.blitToScreen(dispMan.getBitmap(kFoodLabelIndice), 48, 0, 0, gBoxFood, kColorDarkestGray); @@ -177,7 +179,8 @@ void InventoryMan::drawPanelResurrectReincarnate() {  }  void InventoryMan::drawPanel() { -	warning("MISSING CODE: F0334_INVENTORY_CloseChest, altho adding it may reintroduce BUG0_48"); +	warning("possible reintroduction of BUG0_48"); +	closeChest(); // possibility of BUG0_48  	ChampionMan &cm = *_vm->_championMan;  	if (cm._candidateChampionOrdinal) { @@ -205,4 +208,32 @@ void InventoryMan::drawPanel() {  		warning("MISSING CODE: F0342_INVENTORY_DrawPanel_Object(L1075_T_Thing, C0_FALSE);");  	}  } + +void InventoryMan::closeChest() { +	DungeonMan &dunMan = *_vm->_dungeonMan; + +	bool processFirstChestSlot = true; +	if (_openChest == Thing::_thingNone) +		return; +	Container *container = (Container*)dunMan.getThingData(_openChest); +	_openChest = Thing::_thingNone; +	container->getSlot() = Thing::_thingEndOfList; +	Thing prevThing; +	for (int16 chestSlotIndex = 0; chestSlotIndex < 8; ++chestSlotIndex) { +		Thing thing = _chestSlots[chestSlotIndex]; +		if (thing != Thing::_thingNone) { +			_chestSlots[chestSlotIndex] = Thing::_thingNone; // CHANGE8_09_FIX + +			if (processFirstChestSlot) { +				processFirstChestSlot = false; +				*dunMan.getThingData(thing) = Thing::_thingEndOfList.toUint16(); +				container->getSlot() = prevThing = thing; +			} else { +				dunMan.linkThingToList(thing, prevThing, kMapXNotOnASquare, 0); +				prevThing = thing; +			} +		} +	} +} +  } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index f225e417bd..8457e98faa 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -55,6 +55,7 @@ public:  	int16 _inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal  	PanelContent _panelContent; // @ G0424_i_PanelContent   	Thing _chestSlots[8]; // @ G0425_aT_ChestSlots +	Thing _openChest; // @ G0426_T_OpenChest  	void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE  	void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait @@ -63,6 +64,7 @@ public:  	void drawPanelFoodWaterPoisoned(); // @ F0345_INVENTORY_DrawPanel_FoodWaterPoisoned  	void drawPanelResurrectReincarnate(); // @ F0346_INVENTORY_DrawPanel_ResurrectReincarnate  	void drawPanel(); // @ F0347_INVENTORY_DrawPanel +	void closeChest(); // @ F0334_INVENTORY_CloseChest  }; diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index dfbe5b564e..d6c09d85e6 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -124,7 +124,9 @@ void MenuMan::drawDisabledMenu() {  		warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable");
  		_vm->_displayMan->_useByteBoxCoordinates = false;
  		if (_vm->_inventoryMan->_inventoryChampionOrdinal) {
 -			warning("MISSING CODE: F0334_INVENTORY_CloseChest");
 +			if (_vm->_inventoryMan->_panelContent == kPanelContentChest) {
 +				_vm->_inventoryMan->closeChest();
 +			}
  		} else {
  			warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
  		}
 | 
