DM: Add G0426_T_OpenChest, F0334_INVENTORY_CloseChest

This commit is contained in:
Bendegúz Nagy 2016-08-26 22:40:13 +02:00
parent 7ecd3333d7
commit f00f5c19e7
6 changed files with 51 additions and 14 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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");
}