diff options
author | Bendegúz Nagy | 2016-08-26 22:50:13 +0200 |
---|---|---|
committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 |
commit | 89473344d872962dc4ac2c828f6a1c7dfc17867d (patch) | |
tree | c292b8be17226428feebdae32b767285efec8e48 | |
parent | 92a3ccb4a7d1eafb16ae5f469c271f277d1261a3 (diff) | |
download | scummvm-rg350-89473344d872962dc4ac2c828f6a1c7dfc17867d.tar.gz scummvm-rg350-89473344d872962dc4ac2c828f6a1c7dfc17867d.tar.bz2 scummvm-rg350-89473344d872962dc4ac2c828f6a1c7dfc17867d.zip |
DM: Fix several bugs realted to dungeon thing management and item handling
-rw-r--r-- | engines/dm/TODOs/todo.txt | 14 | ||||
-rw-r--r-- | engines/dm/champion.cpp | 338 | ||||
-rw-r--r-- | engines/dm/champion.h | 2 | ||||
-rw-r--r-- | engines/dm/dm.cpp | 45 | ||||
-rw-r--r-- | engines/dm/dm.h | 2 | ||||
-rw-r--r-- | engines/dm/dungeonman.cpp | 565 | ||||
-rw-r--r-- | engines/dm/dungeonman.h | 10 | ||||
-rw-r--r-- | engines/dm/eventman.cpp | 35 | ||||
-rw-r--r-- | engines/dm/objectman.cpp | 152 |
9 files changed, 767 insertions, 396 deletions
diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 183889e994..1d08b44ca4 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -2,12 +2,11 @@ Bugs: Display: Broken colour palette Portraits, alcoves etc. look broken from afar - Ornaments are not displayed if looked at from certain angles - Ornaments are displayed where they should not be, probably error in the pseudo RNG - Command gui is broken + Arrow and hand display is messed up + Logic: - Game crashes when reincaranting a fourth champion and trying to copy his portrait -e + When object are put on the right side of the current square, they disappear + Todo: @@ -20,9 +19,4 @@ Todo: Double check strcat, strstr usages, I might have messed them up in many places I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions - Missing functions: - Add missing F0163_DUNGEON_LinkThingToList in MovesensMan::sensorIsTriggeredByClickOnWall (I don't think it's safe yet) - -Refactoring - Add constructor to CreatureInfo diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 96604e3140..90dbbf92dd 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1106,26 +1106,26 @@ void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount Scent L0958_s_Scent; /* BUG0_00 Useless code */
- if (L0954_i_ScentIndex = _vm->_championMan->_g407_party._scentCount) {
+ if (L0954_i_ScentIndex = _g407_party._scentCount) {
if (L0955_B_Merge = getFlag(cycleCount, k0x8000_mergeCycles)) {
clearFlag(cycleCount, k0x8000_mergeCycles);
}
L0958_s_Scent.setMapX(mapX); /* BUG0_00 Useless code */
L0958_s_Scent.setMapY(mapY); /* BUG0_00 Useless code */
L0958_s_Scent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); /* BUG0_00 Useless code */
- L0957_ps_Scent = _vm->_championMan->_g407_party._scents; /* BUG0_00 Useless code */
+ L0957_ps_Scent = _g407_party._scents; /* BUG0_00 Useless code */
L0956_B_CycleCountDefined = false;
while (L0954_i_ScentIndex--) {
if (&*L0957_ps_Scent++ == &L0958_s_Scent) {
if (!L0956_B_CycleCountDefined) {
L0956_B_CycleCountDefined = true;
if (L0955_B_Merge) {
- cycleCount = MAX((int32)_vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount);
+ cycleCount = MAX((int32)_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount);
} else {
- cycleCount = MIN(80, _vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount);
+ cycleCount = MIN(80, _g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount);
}
}
- _vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount;
+ _g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount;
}
}
}
@@ -1135,8 +1135,10 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) if (thing == Thing::_none) {
return;
}
- _vm->_championMan->_g415_leaderEmptyHanded = false;
- _vm->_objectMan->f36_extractIconFromBitmap(_vm->_championMan->_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_vm->_championMan->_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
+ _g415_leaderEmptyHanded = false;
+ _vm->_objectMan->f36_extractIconFromBitmap(_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
+
+
_vm->_eventMan->f78_showMouse();
_vm->_objectMan->f34_drawLeaderObjectName(thing);
if (setMousePointer) {
@@ -1145,10 +1147,10 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) _vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
}
_vm->_eventMan->f77_hideMouse();
- if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) {
- _vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing);
- setFlag(_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
- _vm->_championMan->f292_drawChampionState(_vm->_championMan->_g411_leaderIndex);
+ if (_g411_leaderIndex != kM1_ChampionNone) {
+ _gK71_champions[_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing);
+ setFlag(_gK71_champions[_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
+ f292_drawChampionState(_g411_leaderIndex);
}
}
@@ -1174,180 +1176,180 @@ void ChampionMan::f278_resetDataToStartGame() { void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) {
- DisplayMan &dispMan = *_vm->_displayMan;
- DungeonMan &dunMan = *_vm->_dungeonMan;
-
- if (!_g415_leaderEmptyHanded || _g305_partyChampionCount == 4)
+ Thing L0793_T_Thing;
+ uint16 L0794_ui_Multiple;
+#define AL0794_ui_ViewCell L0794_ui_Multiple
+#define AL0794_ui_SlotIndex L0794_ui_Multiple
+#define AL0794_ui_CharacterIndex L0794_ui_Multiple
+#define AL0794_ui_StatisticIndex L0794_ui_Multiple
+#define AL0794_ui_SkillIndex L0794_ui_Multiple
+ int16 L0795_i_HiddenSkillIndex;
+ uint16 L0796_ui_Multiple;
+#define AL0796_ui_Character L0796_ui_Multiple
+#define AL0796_ui_SkillValue L0796_ui_Multiple
+#define AL0796_ui_ThingType L0796_ui_Multiple
+ Champion* L0797_ps_Champion;
+ char* L0798_pc_Character;
+ uint16 L0799_ui_PreviousPartyChampionCount;
+ uint16 L0800_ui_Multiple;
+#define AL0800_B_ChampionTitleCopied L0800_ui_Multiple
+#define AL0800_ui_HiddenSkillCounter L0800_ui_Multiple
+ uint16 L0801_ui_SlotIndex;
+ int16 L0802_i_MapX;
+ int16 L0803_i_MapY;
+ uint16 L0804_ui_ChampionObjectsCell;
+ int16 L0805_i_ObjectAllowedSlots;
+ int32 L0806_l_BaseSkillExperience;
+ char L0807_ac_DecodedChampionText[77];
+
+ if (!_vm->_championMan->_g415_leaderEmptyHanded) {
return;
-
- uint16 prevChampCount = _g305_partyChampionCount;
- Champion *champ = &_gK71_champions[prevChampCount];
- champ->resetToZero();
- dispMan._g578_useByteBoxCoordinates = true;
- { // limit destBox scope
- Box &destBox = gBoxChampionPortrait;
- dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), champ->_portrait,
- destBox, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), 128, 16, kM1_ColorNoTransparency);
- }
-
- champ->_actionIndex = k255_ChampionActionNone;
- champ->_enableActionEventIndex = -1;
- champ->_hideDamageReceivedIndex = -1;
- champ->_dir = dunMan._g308_partyDir;
- ViewCell AL_0_viewCell = k0_ViewCellFronLeft;
- while (f285_getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3)) != kM1_ChampionNone)
- AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1);
- champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3);
- champ->clearAttributes(k0x0400_ChampionAttributeIcon);
- champ->_directionMaximumDamageReceived = dunMan._g308_partyDir;
- champ->_food = 1500 + _vm->_rnd->getRandomNumber(256);
- champ->_water = 1500 + _vm->_rnd->getRandomNumber(256);
- int16 AL_0_slotIndex_Red;
- for (AL_0_slotIndex_Red = k0_ChampionSlotReadyHand; AL_0_slotIndex_Red < k30_ChampionSlotChest_1; ++AL_0_slotIndex_Red) {
- champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none);
- }
- Thing thing = dunMan.f161_getSquareFirstThing(dunMan._g306_partyMapX, dunMan._g307_partyMapY);
- while (thing.getType() != k2_TextstringType) {
- thing = dunMan.f159_getNextThing(thing);
- }
- char decodedChampionText[77];
- char* character_Green = decodedChampionText;
- dunMan.f168_decodeText(character_Green, thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
- int16 AL_0_characterIndex = 0;
- uint16 AL_2_character;
- while ((AL_2_character = *character_Green++) != '\n') {
- champ->_name[AL_0_characterIndex++] = AL_2_character;
- }
- champ->_name[AL_0_characterIndex] = '\0';
- AL_0_characterIndex = 0;
- bool AL_4_champTitleCopied = false;
- for (;;) { // infinite
- AL_2_character = *character_Green++;
- if (AL_2_character == '\n') {
- if (AL_4_champTitleCopied)
- break;
- AL_4_champTitleCopied = true;
- } else {
- champ->_title[AL_0_characterIndex++] = AL_2_character;
- }
- }
- champ->_title[AL_0_characterIndex] = '\0';
- if (*character_Green++ == 'M') {
- champ->setAttributeFlag(k0x0010_ChampionAttributeMale, true);
- }
- character_Green++;
- champ->_currHealth = champ->_maxHealth = f279_getDecodedValue(character_Green, 4);
- character_Green += 4;
- champ->_currStamina = champ->_maxStamina = f279_getDecodedValue(character_Green, 4);
- character_Green += 4;
- champ->_currMana = champ->_maxMana = f279_getDecodedValue(character_Green, 4);
- character_Green += 4;
- character_Green++;
-
- int16 AL_0_statisticIndex;
- for (AL_0_statisticIndex = k0_ChampionStatLuck; AL_0_statisticIndex <= k6_ChampionStatAntifire; ++AL_0_statisticIndex) {
- champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k2_ChampionStatMinimum, 30);
- uint16 currMaxVal = f279_getDecodedValue(character_Green, 2);
- champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent, currMaxVal);
- champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k0_ChampionStatMaximum, currMaxVal);
- character_Green += 2;
- }
-
- champ->setStatistic(k0_ChampionStatLuck, k2_ChampionStatMinimum, 10);
- character_Green++;
-
- int16 AL_0_skillIndex;
- int16 AL_2_skillValue;
- for (AL_0_skillIndex = k4_ChampionSkillSwing; AL_0_skillIndex <= k19_ChampionSkillWater; AL_0_skillIndex++) {
- if ((AL_2_skillValue = *character_Green++ - 'A') > 0) {
- champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue);
- }
}
-
- for (AL_0_skillIndex = k0_ChampionSkillFighter; AL_0_skillIndex <= k3_ChampionSkillWizard; ++AL_0_skillIndex) {
- int32 baseSkillExp = 0;
- int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2;
- for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) {
- baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience;
- }
- champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp);
+ if (_vm->_championMan->_g305_partyChampionCount == 4) {
+ return;
}
-
- _g299_candidateChampionOrdinal = prevChampCount + 1;
- if (++_g305_partyChampionCount == 1) {
+ L0797_ps_Champion = &_vm->_championMan->_gK71_champions[L0799_ui_PreviousPartyChampionCount = _vm->_championMan->_g305_partyChampionCount];
+ L0797_ps_Champion->resetToZero();
+ // Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portaits could be missing in the data)
+ _vm->_displayMan->_g578_useByteBoxCoordinates = true;
+ _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), L0797_ps_Champion->_portrait, gBoxChampionPortrait, _vm->_championMan->M27_getChampionPortraitX(championPortraitIndex), _vm->_championMan->M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency);
+ L0797_ps_Champion->_actionIndex = k255_ChampionActionNone;
+ L0797_ps_Champion->_enableActionEventIndex = -1;
+ L0797_ps_Champion->_hideDamageReceivedIndex = -1;
+ L0797_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
+ AL0794_ui_ViewCell = k0_ViewCellFronLeft;
+ while (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone) {
+ AL0794_ui_ViewCell++;
+ }
+ L0797_ps_Champion->_cell = (ViewCell)M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir);
+ L0797_ps_Champion->_attributes = k0x0400_ChampionAttributeIcon;
+ L0797_ps_Champion->_directionMaximumDamageReceived = _vm->_dungeonMan->_g308_partyDir;
+ L0797_ps_Champion->_food = 1500 + _vm->getRandomNumber(256);
+ L0797_ps_Champion->_water = 1500 + _vm->getRandomNumber(256);
+ for (AL0794_ui_SlotIndex = k0_ChampionSlotReadyHand; AL0794_ui_SlotIndex < k30_ChampionSlotChest_1; AL0794_ui_SlotIndex++) {
+ L0797_ps_Champion->_slots[AL0794_ui_SlotIndex] = Thing::_none;
+ }
+ L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+ while ((L0793_T_Thing.getType()) != k2_TextstringType) {
+ L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing);
+ }
+ _vm->_dungeonMan->f168_decodeText(L0798_pc_Character = L0807_ac_DecodedChampionText, L0793_T_Thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
+ AL0794_ui_CharacterIndex = 0;
+ while ((AL0796_ui_Character = *L0798_pc_Character++) != '\n') { /* New line */
+ L0797_ps_Champion->_name[AL0794_ui_CharacterIndex++] = AL0796_ui_Character;
+ }
+ L0797_ps_Champion->_name[AL0794_ui_CharacterIndex] = '\0';
+ AL0794_ui_CharacterIndex = 0;
+ AL0800_B_ChampionTitleCopied = false;
+ for (;;) { /*_Infinite loop_*/
+ AL0796_ui_Character = *L0798_pc_Character++;
+ if (AL0796_ui_Character == '\n') { /* New line */
+ if (AL0800_B_ChampionTitleCopied)
+ break;
+ AL0800_B_ChampionTitleCopied = true;
+ } else {
+ L0797_ps_Champion->_title[AL0794_ui_CharacterIndex++] = AL0796_ui_Character;
+ }
+ }
+ L0797_ps_Champion->_title[AL0794_ui_CharacterIndex] = '\0';
+ if (*L0798_pc_Character++ == 'M') {
+ setFlag(L0797_ps_Champion->_attributes, k0x0010_ChampionAttributeMale);
+ }
+ L0798_pc_Character++;
+ L0797_ps_Champion->_currHealth = L0797_ps_Champion->_maxHealth = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4);
+ L0798_pc_Character += 4;
+ L0797_ps_Champion->_currStamina = L0797_ps_Champion->_maxStamina = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4);
+ L0798_pc_Character += 4;
+ L0797_ps_Champion->_currMana = L0797_ps_Champion->_maxMana = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4);
+ L0798_pc_Character += 4;
+ L0798_pc_Character++;
+ for (AL0794_ui_StatisticIndex = k0_ChampionStatLuck; AL0794_ui_StatisticIndex <= k6_ChampionStatAntifire; AL0794_ui_StatisticIndex++) {
+ L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k2_ChampionStatMinimum] = 30;
+ L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k1_ChampionStatCurrent] = L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k0_ChampionStatMaximum] = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 2);
+ L0798_pc_Character += 2;
+ }
+ L0797_ps_Champion->_statistics[k0_ChampionStatLuck][k2_ChampionStatMinimum] = 10;
+ L0798_pc_Character++;
+ for (AL0794_ui_SkillIndex = k4_ChampionSkillSwing; AL0794_ui_SkillIndex <= k19_ChampionSkillWater; AL0794_ui_SkillIndex++) {
+ if ((AL0796_ui_SkillValue = *L0798_pc_Character++ - 'A') > 0) {
+ L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = 125L << AL0796_ui_SkillValue;
+ }
+ }
+ for (AL0794_ui_SkillIndex = k0_ChampionSkillFighter; AL0794_ui_SkillIndex <= k3_ChampionSkillWizard; AL0794_ui_SkillIndex++) {
+ L0806_l_BaseSkillExperience = 0;
+ L0795_i_HiddenSkillIndex = (AL0794_ui_SkillIndex + 1) << 2;
+ for (AL0800_ui_HiddenSkillCounter = 0; AL0800_ui_HiddenSkillCounter < 4; AL0800_ui_HiddenSkillCounter++) {
+ L0806_l_BaseSkillExperience += L0797_ps_Champion->_skills[L0795_i_HiddenSkillIndex + AL0800_ui_HiddenSkillCounter]._experience;
+ }
+ L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = L0806_l_BaseSkillExperience;
+ }
+ _vm->_championMan->_g299_candidateChampionOrdinal = L0799_ui_PreviousPartyChampionCount + 1;
+ if (++_vm->_championMan->_g305_partyChampionCount == 1) {
_vm->_eventMan->f368_commandSetLeader(k0_ChampionFirst);
_vm->_menuMan->_g508_refreshActionArea = true;
- } else {
+ } else {
_vm->_menuMan->f388_clearActingChampion();
- _vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1));
- }
-
- int16 mapX = _vm->_dungeonMan->_g306_partyMapX;
- int16 mapY = _vm->_dungeonMan->_g307_partyMapY;
-
- uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._g308_partyDir));
- mapX += _vm->_dirIntoStepCountEast[dunMan._g308_partyDir];
- mapY += _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir];
- thing = dunMan.f161_getSquareFirstThing(mapX, mapY);
- AL_0_slotIndex_Red = k13_ChampionSlotBackpackLine_1_1;
- uint16 slotIndex_Green;
- while (thing != Thing::_endOfList) {
- ThingType AL_2_thingType = thing.getType();
- if ((AL_2_thingType > k3_SensorThingType) && (thing.getCell() == championObjectsCell)) {
- int16 objectAllowedSlots = g237_ObjectInfo[dunMan.f141_getObjectInfoIndex(thing)].getAllowedSlots();
- switch (AL_2_thingType) {
+ _vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_vm->_championMan->_g305_partyChampionCount - 1));
+ }
+ L0802_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
+ L0803_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
+ L0804_ui_ChampionObjectsCell = returnOppositeDir(_vm->_dungeonMan->_g308_partyDir);
+ L0802_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L0803_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+ L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0802_i_MapX, L0803_i_MapY);
+ AL0794_ui_SlotIndex = k13_ChampionSlotBackpackLine_1_1;
+ while (L0793_T_Thing != Thing::_endOfList) {
+ if (((AL0796_ui_ThingType = (L0793_T_Thing.getType())) > k3_SensorThingType) && ((L0793_T_Thing.getCell()) == L0804_ui_ChampionObjectsCell)) {
+ L0805_i_ObjectAllowedSlots = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0793_T_Thing)]._allowedSlots;
+ switch (AL0796_ui_ThingType) {
case k6_ArmourThingType:
- for (slotIndex_Green = k2_ChampionSlotHead; slotIndex_Green <= k5_ChampionSlotFeet; slotIndex_Green++) {
- if (objectAllowedSlots & gSlotMasks[slotIndex_Green])
+ for (L0801_ui_SlotIndex = k2_ChampionSlotHead; L0801_ui_SlotIndex <= k5_ChampionSlotFeet; L0801_ui_SlotIndex++) {
+ if (L0805_i_ObjectAllowedSlots & gSlotMasks[L0801_ui_SlotIndex])
goto T0280048;
}
- if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) {
- slotIndex_Green = k10_ChampionSlotNeck;
+ if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) {
+ L0801_ui_SlotIndex = k10_ChampionSlotNeck;
} else {
goto T0280046;
}
break;
case k5_WeaponThingType:
- if (champ->getSlot(k1_ChampionSlotActionHand) == Thing::_none) {
- slotIndex_Green = k1_ChampionSlotActionHand;
+ if (L0797_ps_Champion->_slots[k1_ChampionSlotActionHand] == Thing::_none) {
+ L0801_ui_SlotIndex = k1_ChampionSlotActionHand;
} else {
goto T0280046;
}
break;
case k7_ScrollThingType:
case k8_PotionThingType:
- if (champ->getSlot(k11_ChampionSlotPouch_1) == Thing::_none) {
- slotIndex_Green = k11_ChampionSlotPouch_1;
- } else if (champ->getSlot(k6_ChampionSlotPouch_2) == Thing::_none) {
- slotIndex_Green = k6_ChampionSlotPouch_2;
+ if (L0797_ps_Champion->_slots[k11_ChampionSlotPouch_1] == Thing::_none) {
+ L0801_ui_SlotIndex = k11_ChampionSlotPouch_1;
} else {
- goto T0280046;
+ if (L0797_ps_Champion->_slots[k6_ChampionSlotPouch_2] == Thing::_none) {
+ L0801_ui_SlotIndex = k6_ChampionSlotPouch_2;
+ } else {
+ goto T0280046;
+ }
}
break;
case k9_ContainerThingType:
case k10_JunkThingType:
T0280046:
- if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) {
- slotIndex_Green = k10_ChampionSlotNeck;
+ if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) {
+ L0801_ui_SlotIndex = k10_ChampionSlotNeck;
} else {
- slotIndex_Green = AL_0_slotIndex_Red++;
+ L0801_ui_SlotIndex = AL0794_ui_SlotIndex++;
}
- break;
-
- default:
- break;
}
T0280048:
- if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_none) {
+ if (L0797_ps_Champion->_slots[L0801_ui_SlotIndex] != Thing::_none) {
goto T0280046;
}
- f301_addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green);
+ _vm->_championMan->f301_addObjectInSlot((ChampionIndex)L0799_ui_PreviousPartyChampionCount, L0793_T_Thing, (ChampionSlot)L0801_ui_SlotIndex);
}
- thing = dunMan.f159_getNextThing(thing);
+ L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing);
}
-
- _vm->_inventoryMan->f355_toggleInventory((ChampionIndex)prevChampCount);
- _vm->_menuMan->f456_drawDisabledMenu();
+ _vm->_inventoryMan->f355_toggleInventory((ChampionIndex)L0799_ui_PreviousPartyChampionCount);
+ _vm->_menuMan->f456_drawDisabledMenu();;
}
void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
@@ -1464,7 +1466,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { L0868_i_ChampionStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing;
- L0865_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+ L0865_ps_Champion = &_gK71_champions[champIndex];
L0862_ui_ChampionAttributes = L0865_ps_Champion->_attributes;
if (!getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand)) {
return;
@@ -1481,13 +1483,13 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { for (uint16 i = 0; i < 3; ++i)
L0872_ai_NativeBitmapIndices[i] = 0;
AL0864_i_BorderCount = 0;
- if (_vm->_championMan->_g407_party._fireShieldDefense > 0) {
+ if (_g407_party._fireShieldDefense > 0) {
L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k38_BorderPartyFireshieldIndice;
}
- if (_vm->_championMan->_g407_party._spellShieldDefense > 0) {
+ if (_g407_party._spellShieldDefense > 0) {
L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k39_BorderPartySpellshieldIndice;
}
- if ((_vm->_championMan->_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) {
+ if ((_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) {
L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k37_BorderPartyShieldIndice;
}
while (AL0864_i_BorderCount--) {
@@ -1509,7 +1511,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { if (!(L0865_ps_Champion->_currHealth))
goto T0292042;
if (getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle)) {
- AL0864_i_ColorIndex = (champIndex == _vm->_championMan->_g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
+ AL0864_i_ColorIndex = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
if (L0863_B_IsInventoryChampion) {
_vm->_textMan->f52_printToViewport(3, 7, (Color)AL0864_i_ColorIndex, L0866_pc_ChampionName = L0865_ps_Champion->_name);
L0869_i_ChampionTitleX = 6 * strlen(L0866_pc_ChampionName) + 3;
@@ -1528,9 +1530,9 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { }
}
if (getFlag(L0862_ui_ChampionAttributes, k0x0100_ChampionAttributeStatistics)) {
- _vm->_championMan->f287_drawChampionBarGraphs(champIndex);
+ f287_drawChampionBarGraphs(champIndex);
if (L0863_B_IsInventoryChampion) {
- _vm->_championMan->f290_drawHealthStaminaManaValues(L0865_ps_Champion);
+ f290_drawHealthStaminaManaValues(L0865_ps_Champion);
if ((L0865_ps_Champion->_food < 0) || (L0865_ps_Champion->_water < 0) || (L0865_ps_Champion->_poisonEventCount)) {
AL0870_i_NativeBitmapIndex = k34_SlotBoxWoundedIndice;
} else {
@@ -1550,14 +1552,14 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { }
if (getFlag(L0862_ui_ChampionAttributes, k0x2000_ChampionAttributeWounds)) {
for (AL0864_i_SlotIndex = L0863_B_IsInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; AL0864_i_SlotIndex >= k0_ChampionSlotReadyHand; AL0864_i_SlotIndex--) {
- _vm->_championMan->f291_drawSlot(champIndex, AL0864_i_SlotIndex);
+ f291_drawSlot(champIndex, AL0864_i_SlotIndex);
}
if (L0863_B_IsInventoryChampion) {
setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
}
}
if (getFlag(L0862_ui_ChampionAttributes, k0x0200_ChampionAttributeLoad) && L0863_B_IsInventoryChampion) {
- if (L0865_ps_Champion->_load > (AL0864_i_Load = _vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion))) {
+ if (L0865_ps_Champion->_load > (AL0864_i_Load = f309_getMaximumLoad(L0865_ps_Champion))) {
AL0870_i_Color = k8_ColorRed;
} else {
if (((long)L0865_ps_Champion->_load << 3) > ((long)AL0864_i_Load * 5)) {
@@ -1568,28 +1570,28 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { }
_vm->_textMan->f52_printToViewport(104, 132, (Color)AL0870_i_Color, "LOAD ");
AL0864_i_Load = L0865_ps_Champion->_load / 10;
- strcpy(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
+ strcpy(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
strcat(_vm->_g353_stringBuildBuffer, ".");
AL0864_i_Load = L0865_ps_Champion->_load - (AL0864_i_Load * 10);
- strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str());
+ strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str());
strcat(_vm->_g353_stringBuildBuffer, "/");
- AL0864_i_Load = (_vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10;
- strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
+ AL0864_i_Load = (f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10;
+ strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
strcat(_vm->_g353_stringBuildBuffer, " KG");
_vm->_textMan->f52_printToViewport(148, 132, (Color)AL0870_i_Color, _vm->_g353_stringBuildBuffer);
setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
}
- AL0864_i_ChampionIconIndex = _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir);
+ AL0864_i_ChampionIconIndex = M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir);
if (getFlag(L0862_ui_ChampionAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL0864_i_ChampionIconIndex))) {
_vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], g46_ChampionColor[champIndex]);
- _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
+ _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen);
}
if (getFlag(L0862_ui_ChampionAttributes, k0x0800_ChampionAttributePanel) && L0863_B_IsInventoryChampion) {
if (_vm->_g333_pressingMouth) {
_vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned();
} else {
if (_vm->_g331_pressingEye) {
- if (_vm->_championMan->_g415_leaderEmptyHanded) {
+ if (_g415_leaderEmptyHanded) {
_vm->_inventoryMan->f351_drawChampionSkillsAndStatistics();
}
} else {
@@ -1599,7 +1601,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
}
if (getFlag(L0862_ui_ChampionAttributes, k0x8000_ChampionAttributeActionHand)) {
- _vm->_championMan->f291_drawSlot(champIndex, k1_ChampionSlotActionHand);
+ f291_drawSlot(champIndex, k1_ChampionSlotActionHand);
_vm->_menuMan->f386_drawActionIcon(champIndex);
if (L0863_B_IsInventoryChampion) {
setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
diff --git a/engines/dm/champion.h b/engines/dm/champion.h index a17f92ee2b..2dc4579ee4 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -386,7 +386,7 @@ public: int16 _water; uint16 _load; int16 _shieldDefense; - byte _portrait[464]; // 32 x 29 pixel portrait + byte _portrait[928]; // 32 x 29 pixel portrait Thing &getSlot(ChampionSlot slot) { return _slots[slot]; } void setSlot(ChampionSlot slot, Thing val) { _slots[slot] = val; } diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index aa47af2f7a..f591399e2c 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -69,11 +69,6 @@ uint16 returnNextVal(uint16 val) { bool isOrientedWestEast(direction dir) { return dir & 1; } - -uint16 setFlag(uint16 &val, uint16 mask) { - return val |= mask; -} - uint16 toggleFlag(uint16& val, uint16 mask) { return val ^= mask; } @@ -314,7 +309,7 @@ void DMEngine::f2_gameloop() { while (true) { if (_g327_newPartyMapIndex != kM1_mapIndexNone) { - T0002002: +T0002002: f3_processNewPartyMap(_g327_newPartyMapIndex); _movsens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); _g327_newPartyMapIndex = kM1_mapIndexNone; @@ -326,15 +321,34 @@ void DMEngine::f2_gameloop() { if (_g327_newPartyMapIndex != kM1_mapIndexNone) goto T0002002; + if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) { + Box box(0, 223, 0, 135); + _displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // dummy code + _displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); + if (_g325_setMousePointerToObjectInMainLoop) { + _g325_setMousePointerToObjectInMainLoop = false; + _eventMan->f78_showMouse(); + _eventMan->f68_setPointerToObject(_objectMan->_g412_objectIconForMousePointer); + _eventMan->f77_hideMouse(); + + } + if (_eventMan->_g326_refreshMousePointerInMainLoop) { + _eventMan->_g326_refreshMousePointerInMainLoop = false; + _eventMan->_g598_mousePointerBitmapUpdated = true; + _eventMan->f78_showMouse(); + _eventMan->f77_hideMouse(); + } + } + if (_championMan->_g303_partyDead) break; _g313_gameTime++; if (!(_g313_gameTime & 511)) - _inventoryMan->f338_decreaseTorchesLightPower(); - if (_g310_disabledMovementTicks) { - _g310_disabledMovementTicks--; - } + //_inventoryMan->f338_decreaseTorchesLightPower(); + if (_g310_disabledMovementTicks) { + _g310_disabledMovementTicks--; + } if (_championMan->_g407_party._freezeLifeTicks) { _championMan->_g407_party._freezeLifeTicks -= 1; } @@ -345,15 +359,10 @@ void DMEngine::f2_gameloop() { _g321_stopWaitingForPlayerInput = false; //do { - _eventMan->processInput(); - _eventMan->f380_processCommandQueue(); - //} while (!_g321_stopWaitingForPlayerInput /*|| !_g301_gameTimeTicking */); + _eventMan->processInput(); + _eventMan->f380_processCommandQueue(); + //} while (!_g321_stopWaitingForPlayerInput /*|| !_g301_gameTimeTicking */); - if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) { - Box box(0, 223, 0, 135); - _displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // dummy code - _displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); - } _displayMan->updateScreen(); _system->delayMillis(18); diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 3f7f55823c..d0bc378beb 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -125,7 +125,7 @@ uint16 returnNextVal(uint16 val); // @ M17_NEXT bool isOrientedWestEast(direction dir); // @ M16_IS_ORIENTED_WEST_EAST -uint16 setFlag(uint16 &val, uint16 mask); // @ M08_SET +#define setFlag(val, mask) ((val) |= (mask)) #define getFlag(val, mask) ((val) & (mask)) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index b4cd96448a..8a49d957ed 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -31,7 +31,9 @@ #include "dungeonman.h" #include "timeline.h" #include "champion.h" - +#include "group.h" +#include "movesens.h" +#include "projexpl.h" namespace DM { @@ -417,8 +419,6 @@ DungeonMan::~DungeonMan() { delete[] _g260_dungeonTextData; delete[] _g279_dungeonMapData; for (uint16 i = 0; i < 16; ++i) { - if (_g284_thingData[i]) - delete[] _g284_thingData[i][0]; delete[] _g284_thingData[i]; } } @@ -651,34 +651,34 @@ void DungeonMan::f434_loadDungeonFile() { continue; if (_g284_thingData[thingType]) { - delete[] _g284_thingData[thingType][0]; delete[] _g284_thingData[thingType]; } - _g284_thingData[thingType] = new uint16*[_g278_dungeonFileHeader._thingCounts[thingType]]; - _g284_thingData[thingType][0] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount]; - for (uint16 i = 0; i < _g278_dungeonFileHeader._thingCounts[thingType]; ++i) - _g284_thingData[thingType][i] = _g284_thingData[thingType][0] + i * thingStoreWordCount; + _g284_thingData[thingType] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount]; if (thingType == k4_GroupThingType) { - for (uint16 i = 0; i < thingCount; ++i) + for (uint16 i = 0; i < thingCount; ++i) { + uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount; for (uint16 j = 0; j < thingStoreWordCount; ++j) { if (j == 2 || j == 3) - _g284_thingData[thingType][i][j] = dunDataStream.readByte(); + nextSlot[j] = dunDataStream.readByte(); else - _g284_thingData[thingType][i][j] = dunDataStream.readUint16BE(); + nextSlot[j] = dunDataStream.readUint16BE(); } + } } else if (thingType == k14_ProjectileThingType) { for (uint16 i = 0; i < thingCount; ++i) { - _g284_thingData[thingType][i][0] = dunDataStream.readUint16BE(); - _g284_thingData[thingType][i][1] = dunDataStream.readUint16BE(); - _g284_thingData[thingType][i][2] = dunDataStream.readByte(); - _g284_thingData[thingType][i][3] = dunDataStream.readByte(); - _g284_thingData[thingType][i][4] = dunDataStream.readUint16BE(); + uint16 *nextSlot = _g284_thingData[thingType] + i * thingStoreWordCount; + nextSlot[0] = dunDataStream.readUint16BE(); + nextSlot[1] = dunDataStream.readUint16BE(); + nextSlot[2] = dunDataStream.readByte(); + nextSlot[3] = dunDataStream.readByte(); + nextSlot[4] = dunDataStream.readUint16BE(); } } else { for (uint16 i = 0; i < thingCount; ++i) { + uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount; for (uint16 j = 0; j < thingStoreWordCount; ++j) - _g284_thingData[thingType][i][j] = dunDataStream.readUint16BE(); + nextSlot[j] = dunDataStream.readUint16BE(); } } @@ -686,7 +686,7 @@ void DungeonMan::f434_loadDungeonFile() { if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType) _vm->_timeline->_g369_eventMaxCount += _g278_dungeonFileHeader._thingCounts[thingType]; for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) { - _g284_thingData[thingType][thingCount + i][0] = Thing::_none.toUint16(); + (_g284_thingData[thingType] + (thingCount + i) * thingStoreWordCount)[0] = Thing::_none.toUint16(); } } } @@ -755,33 +755,36 @@ void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) { Square DungeonMan::f151_getSquare(int16 mapX, int16 mapY) { - bool isInXBounds = (mapX >= 0) && (mapX < _g273_currMapWidth); - bool isInYBounds = (mapY >= 0) && (mapY < _g274_currMapHeight); - - if (isInXBounds && isInYBounds) - return Square(_g271_currMapData[mapX][mapY]); - - - Square tmpSquare; - if (isInYBounds) { - tmpSquare.set(_g271_currMapData[0][mapY]); - if (mapX == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) - return Square(k0_WallElemType).set(k0x0004_WallEastRandOrnAllowed); - - tmpSquare.set(_g271_currMapData[_g273_currMapWidth - 1][mapY]); - if (mapX == _g273_currMapWidth && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) - return Square(k0_WallElemType).set(k0x0001_WallWestRandOrnAllowed); - } else if (isInXBounds) { - tmpSquare.set(_g271_currMapData[mapX][0]); - if (mapY == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) - return Square(k0_WallElemType).set(k0x0002_WallSouthRandOrnAllowed); - - tmpSquare.set(_g271_currMapData[mapX][_g274_currMapHeight - 1]); - if (mapY == _g274_currMapHeight && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) - return Square((k0_WallElemType << 5) | k0x0008_WallNorthRandOrnAllowed); + int16 L0248_i_Multiple; +#define AL0248_B_IsMapXInBounds L0248_i_Multiple +#define AL0248_i_SquareType L0248_i_Multiple + int16 L0249_i_Multiple; +#define AL0249_B_IsMapYInBounds L0249_i_Multiple +#define AL0249_i_SquareType L0249_i_Multiple + + AL0249_B_IsMapYInBounds = (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight); + if ((AL0248_B_IsMapXInBounds = (mapX >= 0) && (mapX < _vm->_dungeonMan->_g273_currMapWidth)) && AL0249_B_IsMapYInBounds) { + return Square(_vm->_dungeonMan->_g271_currMapData[mapX][mapY]); } - return Square(k0_WallElemType); + if (AL0249_B_IsMapYInBounds) { + if (((mapX == -1) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[0][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) { + return Square(k0_ElementTypeWall, k0x0004_WallEastRandOrnAllowed); + } + if (((mapX == _vm->_dungeonMan->_g273_currMapWidth) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[_vm->_dungeonMan->_g273_currMapWidth - 1][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) { + return Square(k0_ElementTypeWall, k0x0001_WallWestRandOrnAllowed); + } + } else { + if (AL0248_B_IsMapXInBounds) { + if (((mapY == -1) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][0]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) { + return Square(k0_ElementTypeWall, k0x0002_WallSouthRandOrnAllowed); + } + if (((mapY == _vm->_dungeonMan->_g274_currMapHeight) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][_vm->_dungeonMan->_g274_currMapHeight - 1]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) { + return Square(k0_ElementTypeWall, k0x0008_WallNorthRandOrnAllowed); + } + } + } + return Square(k0_ElementTypeWall, 0); } Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { @@ -790,17 +793,23 @@ Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 st } int16 DungeonMan::f160_getSquareFirstThingIndex(int16 mapX, int16 mapY) { - if (mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight || !Square(_g271_currMapData[mapX][mapY]).get(k0x0010_ThingListPresent)) - return -1; + uint16 L0260_ui_ThingIndex; + int16 L0261_i_MapY; + register unsigned char* L0262_puc_Square; - int16 y = 0; - uint16 index = _g270_currMapColCumulativeSquareFirstThingCount[mapX]; - byte* square = _g271_currMapData[mapX]; - while (y++ != mapY) - if (Square(*square++).get(k0x0010_ThingListPresent)) - index++; - return index; + L0262_puc_Square = _vm->_dungeonMan->_g271_currMapData[mapX]; + if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight) || !getFlag(L0262_puc_Square[mapY], k0x0010_ThingListPresent)) { + return -1; + } + L0261_i_MapY = 0; + L0260_ui_ThingIndex = _vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount[mapX]; + while (L0261_i_MapY++ != mapY) { + if (getFlag(*L0262_puc_Square++, k0x0010_ThingListPresent)) { + L0260_ui_ThingIndex++; + } + } + return L0260_ui_ThingIndex; } Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) { @@ -819,11 +828,11 @@ void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, direction dir, int16 #define footprintsAllowed L0307_uc_Multiple #define scentOrdinal L0307_uc_Multiple Sensor* sensor; - bool leftRandWallOrnAllowed; - int16 L0310_i_Multiple; + bool leftRandWallOrnAllowed = false; + int16 L0310_i_Multiple = 0; #define frontRandWallOrnAllowed L0310_i_Multiple #define sideIndex L0310_i_Multiple - bool rightRandWallOrnAllowed; + bool rightRandWallOrnAllowed = false; int16 thingTypeRedEagle; bool squreIsFakeWall; Thing thing; @@ -957,31 +966,33 @@ T0172049_Footprints: aspectArray[k1_FirstGroupOrObjectAspect] = thing.toUint16(); } -void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, +void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir, int16 mapX, int16 mapY, bool isFakeWall) { - int16 ornCount = _g269_currMap->_randWallOrnCount; - - turnDirRight(dir); - aspectArray[k2_RightWallOrnOrdAspect] = f170_getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); - turnDirRight(dir); - aspectArray[k3_FrontWallOrnOrdAspect] = f170_getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); - turnDirRight(dir); - aspectArray[k4_LeftWallOrnOrdAspect] = f170_getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); - - if (isFakeWall || mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight) { - for (uint16 i = k2_RightWallOrnOrdAspect; i <= k4_LeftWallOrnOrdAspect; ++i) { - if (f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[i]))) - aspectArray[i] = 0; + int16 L0306_i_Multiple; +#define AL0306_i_RandomWallOrnamentCount L0306_i_Multiple +#define AL0306_i_SideIndex L0306_i_Multiple + + + AL0306_i_RandomWallOrnamentCount = _vm->_dungeonMan->_g269_currMap->_randWallOrnCount; + aspectArray[k2_RightWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(leftAllowed, AL0306_i_RandomWallOrnamentCount, mapX, ++mapY * (M21_normalizeModulo4(++dir) + 1), 30); + aspectArray[k3_FrontWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(frontAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY * (M21_normalizeModulo4(++dir) + 1), 30); + aspectArray[k4_LeftWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(rightAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY-- * (M21_normalizeModulo4(++dir) + 1), 30); + if (isFakeWall || (mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight)) { /* If square is a fake wall or is out of map bounds */ + for (AL0306_i_SideIndex = k2_RightWallOrnOrdAspect; AL0306_i_SideIndex <= k4_LeftWallOrnOrdAspect; AL0306_i_SideIndex++) { /* Loop to remove any random ornament that is an alcove */ + if (_vm->_dungeonMan->f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[AL0306_i_SideIndex]))) { + aspectArray[AL0306_i_SideIndex] = 0; + } } } } int16 DungeonMan::f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) { - int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1) - + (3000 + (_g272_currMapIndex << 6) + _g273_currMapWidth + _g274_currMapHeight) * 11 - + _g278_dungeonFileHeader._ornamentRandomSeed) >> 2) % modulo; - if (allowed && index < count) - return _vm->M0_indexToOrdinal(index); + int16 L0305_i_RandomOrnamentIndex; + + + if (allowed && ((L0305_i_RandomOrnamentIndex = f169_getRandomOrnamentIndex((int16)2000 + (mapX << 5) + mapY, (int16)3000 + (_vm->_dungeonMan->_g272_currMapIndex << (int16)6) + _vm->_dungeonMan->_g273_currMapWidth + _vm->_dungeonMan->_g274_currMapHeight, modulo)) < count)) { + return _vm->M0_indexToOrdinal(L0305_i_RandomOrnamentIndex); + } return 0; } @@ -995,7 +1006,7 @@ bool DungeonMan::f149_isWallOrnAnAlcove(int16 wallOrnIndex) { } uint16 *DungeonMan::f156_getThingData(Thing thing) { - return _g284_thingData[thing.getType()][thing.getIndex()]; + return _g284_thingData[thing.getType()] + thing.getIndex() * g235_ThingDataWordCount[thing.getType()]; } uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) { @@ -1003,7 +1014,7 @@ uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) { } Thing DungeonMan::f159_getNextThing(Thing thing) { - return Thing(f156_getThingData(thing)[0]); // :) + return Thing(f156_getThingData(thing)[0]); } char g255_MessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings @@ -1109,7 +1120,7 @@ char g257_InscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_ void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) { char sepChar; - TextString textString(_g284_thingData[k2_TextstringType][thing.getIndex()]); + TextString textString(_g284_thingData[k2_TextstringType] + thing.getIndex() * g235_ThingDataWordCount[k2_TextstringType]); if ((textString.isVisible()) || (type & k0x8000_DecodeEvenIfInvisible)) { type = (TextType)(type & ~k0x8000_DecodeEvenIfInvisible); if (type == k1_TextTypeMessage) { @@ -1174,6 +1185,45 @@ void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) { *destString = ((type == k0_TextTypeInscription) ? 0x81 : '\0'); } +Thing DungeonMan::f166_getUnusedThing(uint16 thingType) { + int16 L0288_i_ThingIndex; + int16 L0289_i_ThingDataByteCount; + int16 L0290_i_ThingCount; + Thing* L0291_ps_Generic; + Thing L0292_T_Thing; + + + L0290_i_ThingCount = _vm->_dungeonMan->_g278_dungeonFileHeader._thingCounts[getFlag(thingType, k0x7FFF_thingType)]; + if (thingType == (k0x8000_championBones | k10_JunkThingType)) { + thingType = k10_JunkThingType; + } else { + if (thingType == k10_JunkThingType) { + L0290_i_ThingCount -= 3; /* Always keep 3 unused JUNK things for the bones of dead champions */ + } + } + L0288_i_ThingIndex = L0290_i_ThingCount; + L0289_i_ThingDataByteCount = g235_ThingDataWordCount[thingType] >> 1; + L0291_ps_Generic = (Thing*)_vm->_dungeonMan->_g284_thingData[thingType]; + for (;;) { /*_Infinite loop_*/ + if (*L0291_ps_Generic == Thing::_none) { /* If thing data is unused */ + L0292_T_Thing = Thing((thingType << 10) | (L0290_i_ThingCount - L0288_i_ThingIndex)); + break; + } + if (--L0288_i_ThingIndex) { /* If there are thing data left to process */ + L0291_ps_Generic += L0289_i_ThingDataByteCount; /* Proceed to the next thing data */ + } else { + if ((L0292_T_Thing = f165_getDiscardTHing(thingType)) == Thing::_none) { + return Thing::_none; + } + L0291_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0292_T_Thing); + break; + } + } + memset(L0291_ps_Generic, 0, L0289_i_ThingDataByteCount * 2); + + *L0291_ps_Generic = Thing::_endOfList; + return L0292_T_Thing; +} uint16 DungeonMan::f140_getObjectWeight(Thing thing) { static const uint16 g241_junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo @@ -1263,46 +1313,56 @@ int16 DungeonMan::f141_getObjectInfoIndex(Thing thing) { } void DungeonMan::f163_linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY) { - if (thingToLink == Thing::_endOfList) - return; + Thing L0265_T_Thing; + uint16 L0266_ui_Multiple; +#define AL0266_ui_Column L0266_ui_Multiple +#define AL0266_ui_SquareFirstThingIndex L0266_ui_Multiple + Thing* L0267_pT_Thing; + byte* L0268_puc_Square; + Thing* L0269_ps_Generic; + uint16 L0270_ui_MapY; - uint16 *rawObjPtr = f156_getThingData(thingToLink); - *rawObjPtr = Thing::_endOfList.toUint16(); + if (thingToLink == Thing::_endOfList) { + return; + } + L0269_ps_Generic = (Thing*)f156_getThingData(thingToLink); + *L0269_ps_Generic = Thing::_endOfList; + /* If mapX >= 0 then the thing is linked to the list of things on the specified square else it is linked at the end of the specified thing list */ if (mapX >= 0) { - Square *squarePtr = (Square*)&_g271_currMapData[mapX][mapY]; - if (squarePtr->get(k0x0010_ThingListPresent)) { + L0268_puc_Square = &_g271_currMapData[mapX][mapY]; + if (getFlag(*L0268_puc_Square, k0x0010_ThingListPresent)) { thingInList = f161_getSquareFirstThing(mapX, mapY); } else { - squarePtr->set(k0x0010_ThingListPresent); - uint16 *cumulativeCount = &_g270_currMapColCumulativeSquareFirstThingCount[mapX + 1]; - uint16 column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1; - while (column--) { - (*cumulativeCount++)++; + setFlag(*L0268_puc_Square, k0x0010_ThingListPresent); + uint16 * tmp = _g270_currMapColCumulativeSquareFirstThingCount + mapX + 1; + AL0266_ui_Column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1; + while (AL0266_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is added */ + (*tmp++)++; /* Increment the cumulative first thing count */ } - uint16 mapYStep = 0; - squarePtr -= mapY; - uint16 squareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX]; - while (mapYStep++ != mapY) { - if (squarePtr->get(k0x0010_ThingListPresent)) { - squareFirstThingIndex++; + L0270_ui_MapY = 0; + L0268_puc_Square -= mapY; + AL0266_ui_SquareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX]; + while (L0270_ui_MapY++ != mapY) { + if (getFlag(*L0268_puc_Square++, k0x0010_ThingListPresent)) { + AL0266_ui_SquareFirstThingIndex++; } - squarePtr++; } - Thing* thingPtr = &_g283_squareFirstThings[squareFirstThingIndex]; - memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_g278_dungeonFileHeader._squareFirstThingCount - squareFirstThingIndex - 1)); - *thingPtr = thingToLink; + L0267_pT_Thing = &_g283_squareFirstThings[AL0266_ui_SquareFirstThingIndex]; + // the second '- 1' is for the loop initialization, > 0 is because we are copying from one behind + for (int16 i = _g278_dungeonFileHeader._squareFirstThingCount - AL0266_ui_SquareFirstThingIndex - 1 - 1; i > 0; --i) + L0267_pT_Thing[i] = L0267_pT_Thing[i - 1]; + + *L0267_pT_Thing = thingToLink; return; } } - - Thing thing = f159_getNextThing(thingInList); - while (thing != Thing::_endOfList) { - thing = f159_getNextThing(thing); - thingInList = thing; + L0265_T_Thing = f159_getNextThing(thingInList); + while (L0265_T_Thing != Thing::_endOfList) { + L0265_T_Thing = f159_getNextThing(thingInList = L0265_T_Thing); } - rawObjPtr = f156_getThingData(thingInList); - *rawObjPtr = thingToLink.toUint16(); + L0269_ps_Generic = (Thing*)f156_getThingData(thingInList); + *L0269_ps_Generic = thingToLink; } WeaponInfo* DungeonMan::f158_getWeaponInfo(Thing thing) { @@ -1365,4 +1425,299 @@ int16 DungeonMan::f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDe } return kM1_mapIndexNone; } + +Thing DungeonMan::f162_getSquareFirstObject(int16 mapX, int16 mapY) { + Thing thing = f161_getSquareFirstThing(mapX, mapY); + while ((thing != Thing::_endOfList) && (thing.getType() < k4_GroupThingType)) { + thing = f159_getNextThing(thing); + } + return thing; +} + +uint16 DungeonMan::f143_getArmourDefense(ArmourInfo* armourInfo, bool useSharpDefense) { + uint16 L0244_ui_Defense; + + L0244_ui_Defense = armourInfo->_defense; + if (useSharpDefense) { + L0244_ui_Defense = _vm->f30_getScaledProduct(L0244_ui_Defense, 3, getFlag(armourInfo->_attributes, k0x0007_ArmourAttributeSharpDefense) + 4); + } + return L0244_ui_Defense; +} + +Thing DungeonMan::f165_getDiscardTHing(uint16 thingType) { + uint16 L0276_ui_MapX; + uint16 L0277_ui_MapY; + Thing L0278_T_Thing; + uint16 L0279_ui_MapIndex; + byte* L0280_puc_Square; + Thing* L0281_pT_SquareFirstThing; + Thing* L0282_ps_Generic; + uint16 L0283_ui_DiscardThingMapIndex; + int L0284_i_CurrentMapIndex; + uint16 L0285_ui_MapWidth; + uint16 L0286_ui_MapHeight; + int L0287_i_ThingType; + static unsigned char G0294_auc_LastDiscardedThingMapIndex[16]; + + + if (thingType == k15_ExplosionThingType) { + return Thing::_none; + } + L0284_i_CurrentMapIndex = _vm->_dungeonMan->_g272_currMapIndex; + if (((L0279_ui_MapIndex = G0294_auc_LastDiscardedThingMapIndex[thingType]) == _vm->_dungeonMan->_g309_partyMapIndex) && (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount)) { + L0279_ui_MapIndex = 0; + } + L0283_ui_DiscardThingMapIndex = L0279_ui_MapIndex; + for (;;) { /*_Infinite loop_*/ + L0285_ui_MapWidth = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._width; + L0286_ui_MapHeight = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._height; + L0280_puc_Square = _vm->_dungeonMan->_g279_dungeonMapData[L0279_ui_MapIndex][0]; + L0281_pT_SquareFirstThing = &_vm->_dungeonMan->_g283_squareFirstThings[_vm->_dungeonMan->_g280_dungeonColumnsCumulativeSquareThingCount[_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[L0279_ui_MapIndex]]]; + for (L0276_ui_MapX = 0; L0276_ui_MapX <= L0285_ui_MapWidth; L0276_ui_MapX++) { + for (L0277_ui_MapY = 0; L0277_ui_MapY <= L0286_ui_MapHeight; L0277_ui_MapY++) { + if (getFlag(*L0280_puc_Square++, k0x0010_ThingListPresent)) { + L0278_T_Thing = *L0281_pT_SquareFirstThing++; + if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && ((L0276_ui_MapX - _vm->_dungeonMan->_g306_partyMapX + 5) <= 10) && ((L0277_ui_MapY - _vm->_dungeonMan->_g307_partyMapY + 5) <= 10)) /* If square is too close to the party */ + goto T0165029; + do { + if ((L0287_i_ThingType = (L0278_T_Thing).getType()) == k3_SensorThingType) { + L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing); + if (((Sensor*)L0282_ps_Generic)->getType()) /* If sensor is not disabled */ + break; + } else { + if (L0287_i_ThingType == thingType) { + L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing); + switch (thingType) { + case k4_GroupThingType: + if (((Group*)L0282_ps_Generic)->getDoNotDiscard()) + continue; + case k14_ProjectileThingType: + _vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex); + if (thingType == k4_GroupThingType) { + _vm->_groupMan->f188_dropGroupPossessions(L0276_ui_MapX, L0277_ui_MapY, L0278_T_Thing, kM1_soundModeDoNotPlaySound); + _vm->_groupMan->f189_delete(L0276_ui_MapX, L0277_ui_MapY); + } else { + _vm->_projexpl->f214_projectileDeleteEvent(L0278_T_Thing); + f164_unlinkThingFromList(L0278_T_Thing, Thing(0), L0276_ui_MapX, L0277_ui_MapY); + _vm->_projexpl->f215_projectileDelete(L0278_T_Thing, 0, L0276_ui_MapX, L0277_ui_MapY); + } + break; + case k6_ArmourThingType: + if (((Armour*)L0282_ps_Generic)->getDoNotDiscard()) + continue; + goto T0165026; + case k5_WeaponThingType: + if (((Weapon*)L0282_ps_Generic)->getDoNotDiscard()) + continue; + goto T0165026; + case k10_JunkThingType: + if (((Junk*)L0282_ps_Generic)->getDoNotDiscard()) + continue; + goto T0165026; + case k8_PotionThingType: + if (((Potion*)L0282_ps_Generic)->getDoNotDiscard()) + continue; +T0165026: + _vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex); + _vm->_movsens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0); + } + _vm->_dungeonMan->f173_setCurrentMap(L0284_i_CurrentMapIndex); + G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex; + return Thing((L0278_T_Thing).getTypeAndIndex()); + } + } + } while ((L0278_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0278_T_Thing)) != Thing::_endOfList); +T0165029: + ; + } + } + } + if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) || (_vm->_dungeonMan->_g278_dungeonFileHeader._mapCount <= 1)) { + G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex; + return Thing::_none; + } + do { + if (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount) { + L0279_ui_MapIndex = 0; + } + } while (L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex); + if (L0279_ui_MapIndex == L0283_ui_DiscardThingMapIndex) { + L0279_ui_MapIndex = _vm->_dungeonMan->_g309_partyMapIndex; + } + } +} + +uint16 DungeonMan::f144_getCreatureAttributes(Thing thing) { + Group* L0245_ps_Group; + + L0245_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing); + return g243_CreatureInfo[L0245_ps_Group->_type]._attributes; +} + +void DungeonMan::f146_setGroupCells(Group* group, uint16 cells, uint16 mapIndex) { + if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) { + _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._cells = cells; + } else { + group->_cells = cells; + } +} + +void DungeonMan::f148_setGroupDirections(Group* group, int16 dir, uint16 mapIndex) { + if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) { + _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions = (direction)dir; + } else { + group->setDir(M21_normalizeModulo4(dir)); + } +} + +bool DungeonMan::f139_isCreatureAllowedOnMap(Thing thing, uint16 mapIndex) { + int16 L0234_i_Counter; + int16 L0235_i_CreatureType; + byte* L0236_puc_Multiple; +#define AL0236_puc_Group L0236_puc_Multiple +#define AL0236_puc_AllowedCreatureType L0236_puc_Multiple + Map* L0237_ps_Map; + + L0235_i_CreatureType = ((Group*)_vm->_dungeonMan->f156_getThingData(thing))->_type; + L0237_ps_Map = &_vm->_dungeonMan->_g277_dungeonMaps[mapIndex]; + AL0236_puc_AllowedCreatureType = _vm->_dungeonMan->_g279_dungeonMapData[mapIndex][L0237_ps_Map->_width] + L0237_ps_Map->_height + 1; + for (L0234_i_Counter = L0237_ps_Map->_creatureTypeCount; L0234_i_Counter > 0; L0234_i_Counter--) { + if (*AL0236_puc_AllowedCreatureType++ == L0235_i_CreatureType) { + return true; + } + } + return false; +} + +void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY) { + uint16 L0271_ui_SquareFirstThingIndex; + uint16 L0272_ui_Multiple; +#define AL0272_ui_SquareFirstThingIndex L0272_ui_Multiple +#define AL0272_ui_Column L0272_ui_Multiple + Thing L0273_T_Thing; + Thing* L0274_ps_Generic = nullptr; + Thing* L0275_pui_Multiple = nullptr; +#define AL0275_pT_Thing L0275_pui_Multiple +#define AL0275_pui_CumulativeFirstThingCount L0275_pui_Multiple + + + if (thingToUnlink == Thing::_endOfList) { + return; + } + + { + uint16 tmp = thingToUnlink.toUint16(); + clearFlag(tmp, 0xC000); + thingToUnlink = Thing(tmp); + } + + if (mapX >= 0) { + L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink); + AL0275_pT_Thing = &_vm->_dungeonMan->_g283_squareFirstThings[L0271_ui_SquareFirstThingIndex = _vm->_dungeonMan->f160_getSquareFirstThingIndex(mapX, mapY)]; /* BUG0_01 Coding error without consequence. The engine does not check that there are things at the specified square coordinates. _vm->_dungeonMan->f160_getSquareFirstThingIndex would return -1 for an empty square. No consequence as the function is never called with the coordinates of an empty square (except in the case of BUG0_59) */ + if ((*L0274_ps_Generic == Thing::_endOfList) && (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16())) { /* If the thing to unlink is the last thing on the square */ + clearFlag(_vm->_dungeonMan->_g271_currMapData[mapX][mapY], k0x0010_ThingListPresent); + AL0272_ui_SquareFirstThingIndex = _vm->_dungeonMan->_g278_dungeonFileHeader._squareFirstThingCount - 1; + for (uint16 i = 0; i < AL0272_ui_SquareFirstThingIndex - L0271_ui_SquareFirstThingIndex; ++i) + AL0275_pT_Thing[i] = AL0275_pT_Thing[i + 1]; + + _vm->_dungeonMan->_g283_squareFirstThings[AL0272_ui_SquareFirstThingIndex] = Thing::_none; + AL0275_pui_CumulativeFirstThingCount = (Thing*)_vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount + mapX + 1; + AL0272_ui_Column = _vm->_dungeonMan->_g282_dungeonColumCount - (_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[_vm->_dungeonMan->_g272_currMapIndex] + mapX) - 1; + while (AL0272_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is unlinked */ + (*(uint16*)AL0275_pui_CumulativeFirstThingCount++)--; /* Decrement the cumulative first thing count */ + } + goto T0164011; + } + if (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16()) { + *AL0275_pT_Thing = *L0274_ps_Generic; + goto T0164011; + } + thingInList = *AL0275_pT_Thing; + } + L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList); + while (L0273_T_Thing.getTypeAndIndex() != thingToUnlink.toUint16()) { + if ((L0273_T_Thing == Thing::_endOfList) || (L0273_T_Thing == Thing::_none)) { + goto T0164011; + } + L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList = L0273_T_Thing); + } + L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingInList); + *L0274_ps_Generic = _vm->_dungeonMan->f159_getNextThing(L0273_T_Thing); + L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink); +T0164011: + *L0274_ps_Generic = Thing::_endOfList; +} + +int16 DungeonMan::f155_getStairsExitDirection(int16 mapX, int16 mapY) { + int16 L0256_i_SquareType; + bool L0257_B_NorthSouthOrientedStairs; + + + if (L0257_B_NorthSouthOrientedStairs = !getFlag(_vm->_dungeonMan->f151_getSquare(mapX, mapY).toByte(), k0x0008_StairsNorthSouthOrient)) { + mapX = mapX + _vm->_dirIntoStepCountEast[kDirEast]; + mapY = mapY + _vm->_dirIntoStepCountNorth[kDirEast]; + } else { + mapX = mapX + _vm->_dirIntoStepCountEast[kDirNorth]; + mapY = mapY + _vm->_dirIntoStepCountNorth[kDirNorth]; + } + return ((((L0256_i_SquareType = Square(_vm->_dungeonMan->f151_getSquare(mapX, mapY)).getType()) == k0_ElementTypeWall) || (L0256_i_SquareType == k3_ElementTypeStairs)) << 1) + L0257_B_NorthSouthOrientedStairs; + +} + +Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) { + int16 L0293_i_Type; + int16 L0294_i_ThingType; + Thing L0295_T_Thing; + Junk* L0296_ps_Junk; + + + L0294_i_ThingType = k5_WeaponThingType; + if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) && (iconIndex <= k7_IconIndiceWeaponTorchLit)) { + iconIndex = k4_IconIndiceWeaponTorchUnlit; + } + switch (iconIndex) { + case k54_IconIndiceWeaponRock: + L0293_i_Type = k30_WeaponTypeRock; + break; + case k128_IconIndiceJunkBoulder: + L0293_i_Type = k25_JunkTypeBoulder; + L0294_i_ThingType = k10_JunkThingType; + break; + case k51_IconIndiceWeaponArrow: + L0293_i_Type = k27_WeaponTypeArrow; + break; + case k52_IconIndiceWeaponSlayer: + L0293_i_Type = k28_WeaponTypeSlayer; + break; + case k55_IconIndiceWeaponPoisonDart: + L0293_i_Type = k31_WeaponTypePoisonDart; + break; + case k56_IconIndiceWeaponThrowingStar: + L0293_i_Type = k32_WeaponTypeThrowingStar; + break; + case k32_IconIndiceWeaponDagger: + L0293_i_Type = k8_WeaponTypeDagger; + break; + case k4_IconIndiceWeaponTorchUnlit: + L0293_i_Type = k2_WeaponTypeTorch; + break; + default: + return Thing::_none; + } + if ((L0295_T_Thing = f166_getUnusedThing(L0294_i_ThingType)) == Thing::_none) { + return Thing::_none; + } + L0296_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0295_T_Thing); + L0296_ps_Junk->setType(L0293_i_Type); /* Also works for WEAPON in cases other than Boulder */ + if ((iconIndex == k4_IconIndiceWeaponTorchUnlit) && ((Weapon*)L0296_ps_Junk)->isLit()) { /* BUG0_65 Torches created by object generator or projectile launcher sensors have no charges. Charges are only defined if the Torch is lit which is not possible at the time it is created */ + ((Weapon*)L0296_ps_Junk)->setChargeCount(15); + } + return L0295_T_Thing; +} + +int16 DungeonMan::f169_getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo) { + return ((((((val1 * 31417) & 0xFFFF) >> 1) + ((val2 * 11) & 0xFFFF) + + _vm->_dungeonMan->_g278_dungeonFileHeader._ornamentRandomSeed) & 0xFFFF) >> 2) % modulo; /* Pseudorandom number generator */ +} + } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 26841a24bc..f9e21d4633 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -81,9 +81,7 @@ public: int16 _type; uint16 _objectAspectIndex; uint16 _actionSetIndex; -private: uint16 _allowedSlots; -public: ObjectInfo(int16 type, uint16 objectAspectIndex, uint16 actionSetIndex, uint16 allowedSlots) : _type(type), _objectAspectIndex(objectAspectIndex), _actionSetIndex(actionSetIndex), _allowedSlots(allowedSlots) {} bool getAllowedSlot(ObjectAllowedSlot slot) { return _allowedSlots & slot; } @@ -583,6 +581,7 @@ class Square { public: explicit Square(byte dat = 0) : _data(dat) {} explicit Square(SquareType type) { setType(type); } + explicit Square(byte element, byte mask) : _data((element << 5) | mask) {} Square &set(byte dat) { this->_data = dat; return *this; } Square &set(SquareMask mask) { _data |= mask; return *this; } byte get(SquareMask mask) { return _data & mask; } @@ -653,8 +652,8 @@ class DungeonMan { int16 f160_getSquareFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex int16 f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal - void f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, - int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals + void f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir, + int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals public: @@ -697,6 +696,7 @@ public: void f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY); // @ F0164_DUNGEON_UnlinkThingFromList int16 f155_getStairsExitDirection(int16 mapX, int16 mapY); // @ F0155_DUNGEON_GetStairsExitDirection Thing f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex); // @ F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator + int16 f169_getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo); // @ F0169_DUNGEON_GetRandomOrnamentIndex uint32 _rawDunFileDataSize; // @ probably NONE @@ -709,7 +709,7 @@ public: uint16 *_g280_dungeonColumnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount Thing *_g283_squareFirstThings; // @ G0283_pT_SquareFirstThings uint16 *_g260_dungeonTextData; // @ G0260_pui_DungeonTextData - uint16 **_g284_thingData[16]; // @ G0284_apuc_ThingData + uint16 *_g284_thingData[16]; // @ G0284_apuc_ThingData byte ***_g279_dungeonMapData; // @ G0279_pppuc_DungeonMapData diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 2fbefb118d..86b30d55dd 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -41,7 +41,6 @@ namespace DM { - byte g42_bitmapArrowPointer[576] = { // @ G0042_auc_Graphic562_Bitmap_ArrowPointer 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @@ -329,7 +328,6 @@ void EventManager::initMouse() { f73_buildpointerScreenArea(_mousePos.x, _mousePos.y); CursorMan.showMouse(false); - setMousePos(Common::Point(320 / 2, 200 / 2)); } @@ -358,10 +356,17 @@ void EventManager::f68_setPointerToObject(byte* bitmap) { _vm->_displayMan->_g578_useByteBoxCoordinates = true; L0051_puc_Bitmap = _g615_mousePointerOriginalColorsObject; memset(L0051_puc_Bitmap, 0, 32 * 18); + + /* _vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, gK27_palChangesMousepointerOjbectIconShadow); _vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18); _vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, g44_palChangesMousePointerIcon); _vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18); + */ + // dummy code + _vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18); + _vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18); + _gK100_preventBuildPointerScreenArea = false; f73_buildpointerScreenArea(_mousePos.x, _mousePos.y); } @@ -386,8 +391,8 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY) int16 L1578_i_XOverChampionStatusBox; - if (_gK100_preventBuildPointerScreenArea) - return; + // if (_gK100_preventBuildPointerScreenArea) + // return; _gK100_preventBuildPointerScreenArea = true; if (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) { @@ -442,16 +447,16 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY) _vm->_eventMan->_g598_mousePointerBitmapUpdated = false; switch (_gK104_mousePointerType) { case k0_pointerTypeArrow: - CursorMan.pushCursor(g42_bitmapArrowPointer, 32, 18, 0, 0, 0); + CursorMan.replaceCursor(g42_bitmapArrowPointer, 32, 18, 0, 0, 0); break; case k1_pointerTypeObjectIcon: - CursorMan.pushCursor(_g615_mousePointerOriginalColorsObject, 32, 18, 0, 0, 0); + CursorMan.replaceCursor(_g615_mousePointerOriginalColorsObject, 32, 18, 0, 0, 0); break; case k2_pointerTypeChampionIcon: - CursorMan.pushCursor(_g613_mousePointerOriginalColorsChampionIcon, 32, 18, 0, 0, 0); + CursorMan.replaceCursor(_g613_mousePointerOriginalColorsChampionIcon, 32, 18, 0, 0, 0); break; case k3_pointerTypeHand: - CursorMan.pushCursor(g43_bitmapHanPointer, 32, 18, 0, 0, 0); + CursorMan.replaceCursor(g43_bitmapHanPointer, 32, 18, 0, 0, 0); break; } } @@ -724,11 +729,15 @@ void EventManager::f368_commandSetLeader(ChampionIndex champIndex) { } void EventManager::f372_commandProcessType80ClickInDungeonViewTouchFrontWall() { - DungeonMan &dunMan = *_vm->_dungeonMan; - int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir]; - int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir]; - if ((mapX >= 0) && (mapX < dunMan._g273_currMapWidth) && (mapY >= 0) && (mapY < dunMan._g274_currMapHeight)) { - _vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->f275_sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(dunMan._g308_partyDir)); + uint16 L1135_ui_MapX; + uint16 L1136_ui_MapY; + + + L1135_ui_MapX = _vm->_dungeonMan->_g306_partyMapX; + L1136_ui_MapY = _vm->_dungeonMan->_g307_partyMapY; + L1135_ui_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1136_ui_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir]; + if ((L1135_ui_MapX >= 0) && (L1135_ui_MapX < _vm->_dungeonMan->_g273_currMapWidth) && (L1136_ui_MapY >= 0) && (L1136_ui_MapY < _vm->_dungeonMan->_g274_currMapHeight)) { + _vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->f275_sensorIsTriggeredByClickOnWall(L1135_ui_MapX, L1136_ui_MapY, returnOppositeDir(_vm->_dungeonMan->_g308_partyDir)); } } diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 6ab49fbf44..05a86de66a 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -138,100 +138,102 @@ IconIndice ObjectMan::f32_getObjectType(Thing thing) { byte g29_ChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType IconIndice ObjectMan::f33_getIconIndex(Thing thing) { - IconIndice iconIndex = f32_getObjectType(thing); - - if ((iconIndex != kM1_IconIndiceNone) && - (((iconIndex < k32_IconIndiceWeaponDagger) && (iconIndex >= k0_IconIndiceJunkCompassNorth)) || // < instead of <= is no error - ((iconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (iconIndex <= k163_IconIndicePotionWaterFlask)) || - (iconIndex == k195_IconIndicePotionEmptyFlask)) - ) { - uint16 *rawType = _vm->_dungeonMan->f156_getThingData(thing); - switch (iconIndex) { - case k0_IconIndiceJunkCompassNorth: - iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_g308_partyDir); - break; - case k4_IconIndiceWeaponTorchUnlit: { - Weapon weapon(rawType); - if (weapon.isLit()) { - iconIndex = (IconIndice)(iconIndex + g29_ChargeCountToTorchType[weapon.getChargeCount()]); + int16 L0005_i_IconIndex; + Junk* L0006_ps_Junk; + + + if ((L0005_i_IconIndex = _vm->_objectMan->f32_getObjectType(thing)) != kM1_IconIndiceNone) { + if (((L0005_i_IconIndex < k32_IconIndiceWeaponDagger) && (L0005_i_IconIndex >= k0_IconIndiceJunkCompassNorth)) || + ((L0005_i_IconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (L0005_i_IconIndex <= k163_IconIndicePotionWaterFlask)) || + (L0005_i_IconIndex == k195_IconIndicePotionEmptyFlask)) { + L0006_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(thing); + switch (L0005_i_IconIndex) { + case k0_IconIndiceJunkCompassNorth: + L0005_i_IconIndex += _vm->_dungeonMan->_g308_partyDir; + break; + case k4_IconIndiceWeaponTorchUnlit: + if (((Weapon*)L0006_ps_Junk)->isLit()) { + L0005_i_IconIndex += g29_ChargeCountToTorchType[((Weapon*)L0006_ps_Junk)->getChargeCount()]; + } + break; + case k30_IconIndiceScrollOpen: + if (((Scroll*)L0006_ps_Junk)->getClosed()) { + L0005_i_IconIndex++; + } + break; + case k8_IconIndiceJunkWater: + case k12_IconIndiceJunkIllumuletUnequipped: + case k10_IconIndiceJunkJewelSymalUnequipped: + if (L0006_ps_Junk->getChargeCount()) { + L0005_i_IconIndex++; + } + break; + case k23_IconIndiceWeaponBoltBladeStormEmpty: + case k14_IconIndiceWeaponFlamittEmpty: + case k18_IconIndiceWeaponStormringEmpty: + case k25_IconIndiceWeaponFuryRaBladeEmpty: + case k16_IconIndiceWeaponEyeOfTimeEmpty: + case k20_IconIndiceWeaponStaffOfClawsEmpty: + if (((Weapon*)L0006_ps_Junk)->getChargeCount()) { + L0005_i_IconIndex++; + } } - break; - } - case k30_IconIndiceScrollOpen: - if (Scroll(rawType).getClosed()) { - iconIndex = (IconIndice)(iconIndex + 1); - } - break; - case k8_IconIndiceJunkWater: - case k12_IconIndiceJunkIllumuletUnequipped: - case k10_IconIndiceJunkJewelSymalUnequipped: - if (Junk(rawType).getChargeCount()) { - iconIndex = (IconIndice)(iconIndex + 1); - } - break; - case k23_IconIndiceWeaponBoltBladeStormEmpty: - case k14_IconIndiceWeaponFlamittEmpty: - case k18_IconIndiceWeaponStormringEmpty: - case k25_IconIndiceWeaponFuryRaBladeEmpty: - case k16_IconIndiceWeaponEyeOfTimeEmpty: - case k20_IconIndiceWeaponStaffOfClawsEmpty: - if (Weapon(rawType).getChargeCount()) { - iconIndex = (IconIndice)(iconIndex + 1); - } - break; - default: - break; } } - - return iconIndex; + return (IconIndice)L0005_i_IconIndex; } void ObjectMan::f36_extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) { - int16 i; - for (i = 0; i < 7; ++i) { - if (g26_IconGraphicFirstIndex[i] > iconIndex) + uint16 L0011_ui_Counter; + byte* L0012_pl_Bitmap_Icon; + Box L1568_s_Box; + + for (L0011_ui_Counter = 0; L0011_ui_Counter < 7; L0011_ui_Counter++) { + if (g26_IconGraphicFirstIndex[L0011_ui_Counter] > iconIndex) break; } - - --i; - byte *srcBitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k42_ObjectIcons_000_TO_031 + i); - iconIndex -= g26_IconGraphicFirstIndex[i]; + L0012_pl_Bitmap_Icon = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k42_ObjectIcons_000_TO_031 + --L0011_ui_Counter); + iconIndex -= g26_IconGraphicFirstIndex[L0011_ui_Counter]; _vm->_displayMan->_g578_useByteBoxCoordinates = true; - Box box(0, 0, 15, 15); - _vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, kM1_ColorNoTransparency); + L1568_s_Box._y1 = 0; + L1568_s_Box._x1 = 0; + L1568_s_Box._y2 = 15; + L1568_s_Box._x2 = 15; + _vm->_displayMan->f132_blitToBitmap(L0012_pl_Bitmap_Icon, destBitmap, L1568_s_Box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, kM1_ColorNoTransparency, gK77_IconGraphicHeight[L0011_ui_Counter], 16); } void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { - SlotBox *slotBox = &_g30_slotBoxes[slotBoxIndex]; - slotBox->_iconIndex = iconIndex; // yes, this modifies the global array - if (slotBox->_iconIndex == kM1_IconIndiceNone) { + uint16 L0015_ui_IconGraphicIndex; + int16 L0016_i_ByteWidth; + SlotBox* L0017_ps_SlotBox; + byte* L0018_puc_Bitmap_Icons; + Box L0019_s_Box; + byte* L0020_puc_Bitmap_Destination; + int16 L1569_i_Width; + + L0017_ps_SlotBox = &_vm->_objectMan->_g30_slotBoxes[slotBoxIndex]; + if ((L0017_ps_SlotBox->_iconIndex = iconIndex) == kM1_IconIndiceNone) { return; } - - Box box; - box._x1 = slotBox->_x; - box._y1 = slotBox->_y; - box._x2 = box._x1 + 15; - box._y2 = box._y1 + 15; - - uint16 iconGraphicIndex; - for (iconGraphicIndex = 0; iconGraphicIndex < 7; ++iconGraphicIndex) { - if (g26_IconGraphicFirstIndex[iconGraphicIndex] > iconIndex) { + L0019_s_Box._x2 = (L0019_s_Box._x1 = L0017_ps_SlotBox->_x) + 15; + L0019_s_Box._y2 = (L0019_s_Box._y1 = L0017_ps_SlotBox->_y) + 15; + for (L0015_ui_IconGraphicIndex = 0; L0015_ui_IconGraphicIndex < 7; L0015_ui_IconGraphicIndex++) { + if (g26_IconGraphicFirstIndex[L0015_ui_IconGraphicIndex] > iconIndex) break; - } } - iconGraphicIndex--; - byte *iconsBitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(iconGraphicIndex + k42_ObjectIcons_000_TO_031); - iconIndex -= g26_IconGraphicFirstIndex[iconGraphicIndex]; - - _vm->_displayMan->_g578_useByteBoxCoordinates = false; + L0015_ui_IconGraphicIndex--; + L0018_puc_Bitmap_Icons = _vm->_displayMan->f489_getNativeBitmapOrGraphic(L0015_ui_IconGraphicIndex + k42_ObjectIcons_000_TO_031); + iconIndex -= g26_IconGraphicFirstIndex[L0015_ui_IconGraphicIndex]; if (slotBoxIndex >= k8_SlotBoxInventoryFirstSlot) { - _vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g296_bitmapViewport, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k112_byteWidthViewport, kM1_ColorNoTransparency); - + L0020_puc_Bitmap_Destination = _vm->_displayMan->_g296_bitmapViewport; + L0016_i_ByteWidth = k112_byteWidthViewport; + L1569_i_Width = 136; } else { - _vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g348_bitmapScreen, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k160_byteWidthScreen, kM1_ColorNoTransparency); + L0020_puc_Bitmap_Destination = (unsigned char*)_vm->_displayMan->_g348_bitmapScreen; + L0016_i_ByteWidth = k160_byteWidthScreen; + L1569_i_Width = 200; } + _vm->_displayMan->_g578_useByteBoxCoordinates = false, _vm->_displayMan->f132_blitToBitmap(L0018_puc_Bitmap_Icons, L0020_puc_Bitmap_Destination, L0019_s_Box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, k128_byteWidth, L0016_i_ByteWidth, kM1_ColorNoTransparency, gK77_IconGraphicHeight[L0015_ui_IconGraphicIndex], L1569_i_Width); } #define k14_ObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH |