aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBendegúz Nagy2016-06-29 00:23:40 +0200
committerBendegúz Nagy2016-08-26 23:02:22 +0200
commit6daa5c572e3a96602be4df5115126415cecc72f7 (patch)
tree3022ae2fd1826bc424460e2d8ad9ae0f9c815cc3
parentd4ad444ecc753674c862d92f5e3533bdd799fef2 (diff)
downloadscummvm-rg350-6daa5c572e3a96602be4df5115126415cecc72f7.tar.gz
scummvm-rg350-6daa5c572e3a96602be4df5115126415cecc72f7.tar.bz2
scummvm-rg350-6daa5c572e3a96602be4df5115126415cecc72f7.zip
DM: Add F0301_CHAMPION_AddObjectInSlot
-rw-r--r--engines/dm/TODOs/methodtree.txt18
-rw-r--r--engines/dm/champion.cpp73
-rw-r--r--engines/dm/champion.h3
-rw-r--r--engines/dm/dungeonman.h12
4 files changed, 94 insertions, 12 deletions
diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt
index d213c03ab6..71846ef3bc 100644
--- a/engines/dm/TODOs/methodtree.txt
+++ b/engines/dm/TODOs/methodtree.txt
@@ -97,9 +97,9 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon // done
G0237_as_Graphic559_ObjectInfo // done
G0509_B_ActionAreaContainsIcons // done
- F0301_CHAMPION_AddObjectInSlot
+ F0301_CHAMPION_AddObjectInSlot // done
F0299_CHAMPION_ApplyObjectModifiersToStatistics // done
- F0296_CHAMPION_DrawChangedObjectIcons
+ F0296_CHAMPION_DrawChangedObjectIcons // done
F0068_MOUSE_SetPointerToObject // skip
F0077_MOUSE_HidePointer_CPSE // skip
F0078_MOUSE_ShowPointer // skip
@@ -107,14 +107,14 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so
F0386_MENUS_DrawActionIcon // done
F0295_CHAMPION_HasObjectIconInSlotBoxChanged // done
F0039_OBJECT_GetIconIndexInSlotBox // done
- M70_HAND_SLOT_INDEX
+ M70_HAND_SLOT_INDEX // done
G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen // done
- G0412_puc_Bitmap_ObjectIconForMousePointer
- G0413_i_LeaderHandObjectIconIndex
- G0414_T_LeaderHandObject
- F0337_INVENTORY_SetDungeonViewPalette
- G0407_s_Party
- G0039_ai_Graphic562_LightPowerToLightAmount
+ G0412_puc_Bitmap_ObjectIconForMousePointer // done
+ G0413_i_LeaderHandObjectIconIndex // done
+ G0414_T_LeaderHandObject // done
+ F0337_INVENTORY_SetDungeonViewPalette // skip
+ G0407_s_Party // done
+ G0039_ai_Graphic562_LightPowerToLightAmount // skip
F0355_INVENTORY_Toggle_CPSE // done
F0292_CHAMPION_DrawState // done
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 1d9e19ed9a..cce3f558a7 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -45,6 +45,8 @@ Box gBoxChampionIcons[4] = {
Box(281, 299, 15, 28)};
Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14};
+int16 gLightPowerToLightAmount[16] = {0, 5, 12, 24, 33, 40, 46, 51, 59, 68, 76, 82, 89, 94, 97, 100};
+
uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks
/* 30 for champion inventory, 8 for chest */
0xFFFF, /* Ready Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
@@ -306,7 +308,7 @@ void ChampionMan::drawChangedObjectIcons() {
if (((leaderHandObjIconIndex < kIconIndiceWeaponDagger) && (leaderHandObjIconIndex >= kIconIndiceJunkCompassNorth)) // < instead of <= is correct
|| ((leaderHandObjIconIndex >= kIconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= kIconIndicePotionWaterFlask))
- || (leaderHandObjIconIndex == kIconIndicePotionEmptyFlask)) {
+ || (leaderHandObjIconIndex == kIconIndicePotionEmptyFlask)) {
IconIndice iconIndex = objMan.getIconIndex(_leaderHandObject);
if (iconIndex != leaderHandObjIconIndex) {
_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
@@ -320,7 +322,7 @@ void ChampionMan::drawChangedObjectIcons() {
for (uint16 slotBoxIndex = 0; slotBoxIndex < (_partyChampionCount * 2); ++slotBoxIndex) {
int16 champIndex = slotBoxIndex >> 1;
- if(invChampOrdinal == _vm->indexToOrdinal(champIndex))
+ if (invChampOrdinal == _vm->indexToOrdinal(champIndex))
continue;
if (hasObjectIconInSlotBoxChanged(slotBoxIndex, _champions[champIndex].getSlot((ChampionSlot)handSlotIndex(slotBoxIndex)))
@@ -360,6 +362,71 @@ void ChampionMan::drawChangedObjectIcons() {
warning("MISSING CODE: F0078_MOUSE_ShowPointer");
}
+void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex) {
+ InventoryMan &invMan = *_vm->_inventoryMan;
+ DungeonMan &dunMan = *_vm->_dungeonMan;
+ ObjectMan &objMan = *_vm->_objectMan;
+ MenuMan &menuMan = *_vm->_menuMan;
+
+ if (thing == Thing::_thingNone)
+ return;
+
+ Champion *champ = &_champions[champIndex];
+
+ if (slotIndex >= kChampionSlotChest_1) {
+ invMan._chestSlots[slotIndex - kChampionSlotChest_1] = thing;
+ } else {
+ champ->setSlot(slotIndex, thing);
+ }
+
+ champ->_load += dunMan.getObjectWeight(thing);
+ champ->setAttributeFlag(kChampionAttributeLoad, true);
+ IconIndice iconIndex = objMan.getIconIndex(thing);
+ bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
+ applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
+ uint16 *rawObjPtr = dunMan.getThingData(thing);
+
+ if (slotIndex < kChampionSlotHead) {
+
+ if (slotIndex == kChampionSlotActionHand) {
+ champ->setAttributeFlag(kChampionAttributeActionHand, true);
+ if (_actingChampionOrdinal == _vm->indexToOrdinal(champIndex))
+ menuMan.clearActingChampion();
+
+ if ((iconIndex >= kIconIndiceScrollOpen) && (iconIndex <= kIconIndiceScrollClosed)) {
+ ((Scroll*)rawObjPtr)->setClosed(false);
+ drawChangedObjectIcons();
+ }
+ }
+
+ if (iconIndex = kIconIndiceWeaponTorchUnlit) {
+ ((Weapon*)rawObjPtr)->setLit(true);
+ warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette");
+ drawChangedObjectIcons();
+ } else if (isInventoryChampion && (slotIndex == kChampionSlotActionHand) &&
+ ((iconIndex == kIconIndiceContainerChestClosed) || ((iconIndex >= kIconIndiceScrollOpen) && (iconIndex <= kIconIndiceScrollClosed)))) {
+ champ->setAttributeFlag(kChampionAttributePanel, true);
+ }
+
+ } else if (slotIndex == kChampionSlotNeck) {
+
+ if ((iconIndex >= kIconIndiceJunkIllumuletUnequipped) && (iconIndex <= kIconIndiceJunkIllumuletEquipped)) {
+ ((Junk*)rawObjPtr)->setChargeCount(1);
+ _party._magicalLightAmount += gLightPowerToLightAmount[2];
+ warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette");
+ iconIndex = (IconIndice) (iconIndex + 1);
+ } else if ((iconIndex >= kIconIndiceJunkJewelSymalUnequipped) && (iconIndex <= kIconIndiceJunkJewelSymalEquipped)) {
+ ((Junk*)rawObjPtr)->setChargeCount(1);
+ iconIndex = (IconIndice) (iconIndex + 1);
+ }
+
+ }
+
+ drawSlot(champIndex, slotIndex);
+ if (isInventoryChampion)
+ champ->setAttributeFlag(kChampionAttributeViewport, true);
+}
+
ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
for (uint16 i = 0; i < _partyChampionCount; ++i) {
if ((_champions[i]._cell == cell) && _champions[i]._currHealth)
@@ -549,7 +616,7 @@ T0280048:
if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) {
goto T0280046;
}
- warning("MISSING CODE: F0301_CHAMPION_AddObjectInSlot");
+ addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green);
}
thing = dunMan.getNextThing(thing);
}
diff --git a/engines/dm/champion.h b/engines/dm/champion.h
index f3a411646d..d712e6b6c2 100644
--- a/engines/dm/champion.h
+++ b/engines/dm/champion.h
@@ -41,6 +41,8 @@ namespace DM {
extern Box gBoxChampionIcons[4]; // @ G0054_ai_Graphic562_Box_ChampionIcons
extern Color gChampionColor[4]; // @ G0046_auc_Graphic562_ChampionColor
+extern int16 gLightPowerToLightAmount[16]; // @ G0039_ai_Graphic562_LightPowerToLightAmount
+
class Scent {
uint16 _scent;
public:
@@ -463,6 +465,7 @@ public:
int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics
bool hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged
void drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons
+ void addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex); // @ F0301_CHAMPION_AddObjectInSlot
};
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 69746acff2..9a49fe9e7b 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -365,6 +365,12 @@ public:
WeaponType getType() { return (WeaponType)(_desc & 0x7F); }
bool isLit() { return (_desc >> 15) & 1; }
+ void setLit(bool val) {
+ if (val)
+ _desc |= (1 << 15);
+ else
+ _desc &= (~(1 << 15));
+ }
uint16 getChargeCount() { return (_desc >> 10) & 0xF; }
Thing getNextThing() { return _nextThing; }
uint16 getCursed() { return (_desc >> 8) & 1; }
@@ -402,6 +408,12 @@ public:
}
Thing getNextThing() { return _nextThing; }
uint16 getClosed() { return (_attributes >> 10) & 0x3F; } // ??? dunno why, the original bitfield is 6 bits long
+ void setClosed(bool val) {
+ if (val)
+ _attributes |= (1 << 10);
+ else
+ _attributes &= (~(0x3F << 10));
+ }
uint16 getTextStringThingIndex() { return _attributes & 0x3FF; }
}; // @ SCROLL