diff options
author | Bendegúz Nagy | 2016-08-26 22:50:17 +0200 |
---|---|---|
committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 |
commit | 3447af80f8a48413958f64e60890138c9dbe12da (patch) | |
tree | 1ad8cf94441b09afb770309bb579e52196b6e503 /engines/dm/champion.cpp | |
parent | 8504f944e07d4a73f570e642476ae1819eb28568 (diff) | |
download | scummvm-rg350-3447af80f8a48413958f64e60890138c9dbe12da.tar.gz scummvm-rg350-3447af80f8a48413958f64e60890138c9dbe12da.tar.bz2 scummvm-rg350-3447af80f8a48413958f64e60890138c9dbe12da.zip |
DM: Some soft refactoring in champion.cpp
Diffstat (limited to 'engines/dm/champion.cpp')
-rw-r--r-- | engines/dm/champion.cpp | 397 |
1 files changed, 188 insertions, 209 deletions
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 24cfda9225..823a37f72c 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -511,18 +511,15 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch }
int16 ChampionMan::f315_getScentOrdinal(int16 mapX, int16 mapY) {
- uint16 searchedScentRedEagle;
- int16 scentIndex;
- Scent* scent;
- Scent searchedScent;
+ int16 scentIndex = _g407_party._scentCount;
-
- if (scentIndex = _g407_party._scentCount) {
+ if (scentIndex) {
+ Scent searchedScent;
searchedScent.setMapX(mapX);
searchedScent.setMapY(mapY);
searchedScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex);
- searchedScentRedEagle = searchedScent.toUint16();
- scent = &_g407_party._scents[scentIndex--];
+ uint16 searchedScentRedEagle = searchedScent.toUint16();
+ Scent* scent = &_g407_party._scents[scentIndex--];
do {
if ((*(--scent)).toUint16() == searchedScentRedEagle) {
return _vm->M0_indexToOrdinal(scentIndex);
@@ -992,27 +989,20 @@ int16 ChampionMan::f324_damageAll_getDamagedChampionCount(uint16 attack, int16 w }
int16 ChampionMan::f286_getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell) {
- uint16 L0838_ui_Counter;
- int16 L0839_i_ChampionIndex;
- signed char L0840_auc_OrderedCellsToAttack[4];
-
-
if (_g305_partyChampionCount && (M38_distance(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)) {
+ signed char L0840_auc_OrderedCellsToAttack[4];
_vm->_groupMan->f229_setOrderedCellsToAttack(L0840_auc_OrderedCellsToAttack, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, mapX, mapY, cell);
- for (L0838_ui_Counter = 0; L0838_ui_Counter < 4; L0838_ui_Counter++) {
- if ((L0839_i_ChampionIndex = f285_getIndexInCell(L0840_auc_OrderedCellsToAttack[L0838_ui_Counter])) >= 0) {
+ for (uint16 L0838_ui_Counter = 0; L0838_ui_Counter < 4; L0838_ui_Counter++) {
+ int16 L0839_i_ChampionIndex = f285_getIndexInCell(L0840_auc_OrderedCellsToAttack[L0838_ui_Counter]);
+ if (L0839_i_ChampionIndex >= 0)
return L0839_i_ChampionIndex;
- }
}
}
return kM1_ChampionNone;
}
int16 ChampionMan::f311_getDexterity(Champion* champ) {
- int16 L0934_i_Dexterity;
-
-
- L0934_i_Dexterity = _vm->getRandomNumber(8) + champ->_statistics[k2_ChampionStatDexterity][k1_ChampionStatCurrent];
+ int16 L0934_i_Dexterity = _vm->getRandomNumber(8) + champ->_statistics[k2_ChampionStatDexterity][k1_ChampionStatCurrent];
L0934_i_Dexterity -= ((int32)(L0934_i_Dexterity >> 1) * (int32)champ->_load) / f309_getMaximumLoad(champ);
if (_g300_partyIsSleeping) {
L0934_i_Dexterity >>= 1;
@@ -1022,27 +1012,21 @@ int16 ChampionMan::f311_getDexterity(Champion* champ) { bool ChampionMan::f308_isLucky(Champion* champ, uint16 percentage) {
#define AP0646_ui_IsLucky percentage
- register unsigned char* L0928_puc_Statistic;
-
if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage)) {
return true;
}
- L0928_puc_Statistic = champ->_statistics[k0_ChampionStatLuck];
+ register unsigned char* L0928_puc_Statistic = champ->_statistics[k0_ChampionStatLuck];
AP0646_ui_IsLucky = (_vm->getRandomNumber(L0928_puc_Statistic[k1_ChampionStatCurrent]) > percentage);
L0928_puc_Statistic[k1_ChampionStatCurrent] = f26_getBoundedValue((int32)L0928_puc_Statistic[k2_ChampionStatMinimum], (int32)L0928_puc_Statistic[k1_ChampionStatCurrent] + (AP0646_ui_IsLucky ? -2 : 2), (int32)L0928_puc_Statistic[k0_ChampionStatMaximum]);
return AP0646_ui_IsLucky;
}
void ChampionMan::f322_championPoison(int16 champIndex, uint16 attack) {
- TimelineEvent L0980_s_Event;
- Champion* L0981_ps_Champion;
-
-
- if ((champIndex == kM1_ChampionNone) || (_vm->M0_indexToOrdinal(champIndex) == _g299_candidateChampionOrdinal)) {
+ if ((champIndex == kM1_ChampionNone) || (_vm->M0_indexToOrdinal(champIndex) == _g299_candidateChampionOrdinal))
return;
- }
- L0981_ps_Champion = &_gK71_champions[champIndex];
+
+ Champion* L0981_ps_Champion = &_gK71_champions[champIndex];
f321_addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), k0x0000_ChampionWoundNone, k0_attackType_NORMAL);
setFlag(L0981_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
if ((_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) && (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
@@ -1050,6 +1034,7 @@ void ChampionMan::f322_championPoison(int16 champIndex, uint16 attack) { }
if (--attack) {
L0981_ps_Champion->_poisonEventCount++;
+ TimelineEvent L0980_s_Event;
L0980_s_Event._type = k75_TMEventTypePoisonChampion;
L0980_s_Event._priority = champIndex;
M33_setMapAndTime(L0980_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 36);
@@ -1099,33 +1084,29 @@ void ChampionMan::f316_deleteScent(uint16 scentIndex) { }
void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount) {
- int16 L0954_i_ScentIndex;
- bool L0955_B_Merge;
- bool L0956_B_CycleCountDefined;
- Scent* L0957_ps_Scent; /* BUG0_00 Useless code */
- Scent L0958_s_Scent; /* BUG0_00 Useless code */
-
-
- if (L0954_i_ScentIndex = _g407_party._scentCount) {
- if (L0955_B_Merge = getFlag(cycleCount, k0x8000_mergeCycles)) {
+ int16 L0954_i_ScentIndex = _vm->_championMan->_g407_party._scentCount;
+ if (L0954_i_ScentIndex) {
+ bool L0955_B_Merge = getFlag(cycleCount, k0x8000_mergeCycles);
+ if (L0955_B_Merge) {
clearFlag(cycleCount, k0x8000_mergeCycles);
}
+ Scent L0958_s_Scent; /* BUG0_00 Useless code */
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 = _g407_party._scents; /* BUG0_00 Useless code */
- L0956_B_CycleCountDefined = false;
+ Scent* L0957_ps_Scent = _vm->_championMan->_g407_party._scents; /* BUG0_00 Useless code */
+ bool 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)_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount);
+ cycleCount = MAX((int32)_vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount);
} else {
- cycleCount = MIN(80, _g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount);
+ cycleCount = MIN(80, _vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount);
}
}
- _g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount;
+ _vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount;
}
}
}
@@ -1135,10 +1116,8 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) if (thing == Thing::_none) {
return;
}
- _g415_leaderEmptyHanded = false;
- _vm->_objectMan->f36_extractIconFromBitmap(_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer);
-
-
+ _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);
_vm->_eventMan->f78_showMouse();
_vm->_objectMan->f34_drawLeaderObjectName(thing);
if (setMousePointer) {
@@ -1147,10 +1126,10 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) _vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer);
}
_vm->_eventMan->f77_hideMouse();
- 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);
+ 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);
}
}
@@ -1176,180 +1155,180 @@ void ChampionMan::f278_resetDataToStartGame() { void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) {
- 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;
- }
- if (_vm->_championMan->_g305_partyChampionCount == 4) {
+ DisplayMan &dispMan = *_vm->_displayMan;
+ DungeonMan &dunMan = *_vm->_dungeonMan;
+
+ if (!_g415_leaderEmptyHanded || _g305_partyChampionCount == 4)
return;
- }
- 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)
+
+ 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;
- AL0800_B_ChampionTitleCopied = true;
+ AL_4_champTitleCopied = 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) {
+ 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);
+ }
+
+ _g299_candidateChampionOrdinal = prevChampCount + 1;
+ if (++_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)(_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) {
+ _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) {
case k6_ArmourThingType:
- for (L0801_ui_SlotIndex = k2_ChampionSlotHead; L0801_ui_SlotIndex <= k5_ChampionSlotFeet; L0801_ui_SlotIndex++) {
- if (L0805_i_ObjectAllowedSlots & gSlotMasks[L0801_ui_SlotIndex])
+ for (slotIndex_Green = k2_ChampionSlotHead; slotIndex_Green <= k5_ChampionSlotFeet; slotIndex_Green++) {
+ if (objectAllowedSlots & gSlotMasks[slotIndex_Green])
goto T0280048;
}
- if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) {
- L0801_ui_SlotIndex = k10_ChampionSlotNeck;
+ if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) {
+ slotIndex_Green = k10_ChampionSlotNeck;
} else {
goto T0280046;
}
break;
case k5_WeaponThingType:
- if (L0797_ps_Champion->_slots[k1_ChampionSlotActionHand] == Thing::_none) {
- L0801_ui_SlotIndex = k1_ChampionSlotActionHand;
+ if (champ->getSlot(k1_ChampionSlotActionHand) == Thing::_none) {
+ slotIndex_Green = k1_ChampionSlotActionHand;
} else {
goto T0280046;
}
break;
case k7_ScrollThingType:
case k8_PotionThingType:
- if (L0797_ps_Champion->_slots[k11_ChampionSlotPouch_1] == Thing::_none) {
- L0801_ui_SlotIndex = k11_ChampionSlotPouch_1;
+ 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;
} else {
- if (L0797_ps_Champion->_slots[k6_ChampionSlotPouch_2] == Thing::_none) {
- L0801_ui_SlotIndex = k6_ChampionSlotPouch_2;
- } else {
- goto T0280046;
- }
+ goto T0280046;
}
break;
case k9_ContainerThingType:
case k10_JunkThingType:
T0280046:
- if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) {
- L0801_ui_SlotIndex = k10_ChampionSlotNeck;
+ if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) {
+ slotIndex_Green = k10_ChampionSlotNeck;
} else {
- L0801_ui_SlotIndex = AL0794_ui_SlotIndex++;
+ slotIndex_Green = AL_0_slotIndex_Red++;
}
+ break;
+
+ default:
+ break;
}
T0280048:
- if (L0797_ps_Champion->_slots[L0801_ui_SlotIndex] != Thing::_none) {
+ if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_none) {
goto T0280046;
}
- _vm->_championMan->f301_addObjectInSlot((ChampionIndex)L0799_ui_PreviousPartyChampionCount, L0793_T_Thing, (ChampionSlot)L0801_ui_SlotIndex);
+ f301_addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green);
}
- L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing);
+ thing = dunMan.f159_getNextThing(thing);
}
- _vm->_inventoryMan->f355_toggleInventory((ChampionIndex)L0799_ui_PreviousPartyChampionCount);
- _vm->_menuMan->f456_drawDisabledMenu();;
+
+ _vm->_inventoryMan->f355_toggleInventory((ChampionIndex)prevChampCount);
+ _vm->_menuMan->f456_drawDisabledMenu();
}
void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) {
@@ -1466,7 +1445,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { L0868_i_ChampionStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing;
- L0865_ps_Champion = &_gK71_champions[champIndex];
+ L0865_ps_Champion = &_vm->_championMan->_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;
@@ -1483,13 +1462,13 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { for (uint16 i = 0; i < 3; ++i)
L0872_ai_NativeBitmapIndices[i] = 0;
AL0864_i_BorderCount = 0;
- if (_g407_party._fireShieldDefense > 0) {
+ if (_vm->_championMan->_g407_party._fireShieldDefense > 0) {
L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k38_BorderPartyFireshieldIndice;
}
- if (_g407_party._spellShieldDefense > 0) {
+ if (_vm->_championMan->_g407_party._spellShieldDefense > 0) {
L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k39_BorderPartySpellshieldIndice;
}
- if ((_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) {
+ if ((_vm->_championMan->_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) {
L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k37_BorderPartyShieldIndice;
}
while (AL0864_i_BorderCount--) {
@@ -1511,7 +1490,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 == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray;
+ AL0864_i_ColorIndex = (champIndex == _vm->_championMan->_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;
@@ -1530,9 +1509,9 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { }
}
if (getFlag(L0862_ui_ChampionAttributes, k0x0100_ChampionAttributeStatistics)) {
- f287_drawChampionBarGraphs(champIndex);
+ _vm->_championMan->f287_drawChampionBarGraphs(champIndex);
if (L0863_B_IsInventoryChampion) {
- f290_drawHealthStaminaManaValues(L0865_ps_Champion);
+ _vm->_championMan->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 {
@@ -1552,14 +1531,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--) {
- f291_drawSlot(champIndex, AL0864_i_SlotIndex);
+ _vm->_championMan->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 = f309_getMaximumLoad(L0865_ps_Champion))) {
+ if (L0865_ps_Champion->_load > (AL0864_i_Load = _vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion))) {
AL0870_i_Color = k8_ColorRed;
} else {
if (((long)L0865_ps_Champion->_load << 3) > ((long)AL0864_i_Load * 5)) {
@@ -1570,28 +1549,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, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
+ strcpy(_vm->_g353_stringBuildBuffer, _vm->_championMan->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, f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str());
+ strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str());
strcat(_vm->_g353_stringBuildBuffer, "/");
- AL0864_i_Load = (f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10;
- strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str());
+ 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());
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 = M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir);
+ AL0864_i_ChampionIconIndex = _vm->_championMan->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], 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], _vm->_championMan->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 (_g415_leaderEmptyHanded) {
+ if (_vm->_championMan->_g415_leaderEmptyHanded) {
_vm->_inventoryMan->f351_drawChampionSkillsAndStatistics();
}
} else {
@@ -1601,7 +1580,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
}
if (getFlag(L0862_ui_ChampionAttributes, k0x8000_ChampionAttributeActionHand)) {
- f291_drawSlot(champIndex, k1_ChampionSlotActionHand);
+ _vm->_championMan->f291_drawSlot(champIndex, k1_ChampionSlotActionHand);
_vm->_menuMan->f386_drawActionIcon(champIndex);
if (L0863_B_IsInventoryChampion) {
setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport);
|