aboutsummaryrefslogtreecommitdiff
path: root/engines/dm/menus.cpp
diff options
context:
space:
mode:
authorStrangerke2016-09-26 21:12:51 +0200
committerStrangerke2016-09-26 21:15:04 +0200
commitdc19419507240ba42650e671b4e379578f571d53 (patch)
treef9276bcaeab6dec6dd3ceeaf372f435efdbefde5 /engines/dm/menus.cpp
parent53790e749725f92d43f1a09b342203eb5022c2fc (diff)
downloadscummvm-rg350-dc19419507240ba42650e671b4e379578f571d53.tar.gz
scummvm-rg350-dc19419507240ba42650e671b4e379578f571d53.tar.bz2
scummvm-rg350-dc19419507240ba42650e671b4e379578f571d53.zip
DM: reduce some more redirections
Diffstat (limited to 'engines/dm/menus.cpp')
-rw-r--r--engines/dm/menus.cpp211
1 files changed, 119 insertions, 92 deletions
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index bfe9c35101..e4e4792039 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -189,7 +189,8 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) {
if (!_actionAreaContainsIcons)
return;
DisplayMan &dm = *_vm->_displayMan;
- Champion &champion = _vm->_championMan->_champions[championIndex];
+ ChampionMan &championMan = *_vm->_championMan;
+ Champion &champion = championMan._champions[championIndex];
Box box;
box._rect.left = championIndex * 22 + 233;
@@ -222,18 +223,19 @@ T0386006:
box2._rect.top = 95;
box2._rect.bottom = 110;
dm.blitToScreen(bitmapIcon, &box2, k8_byteWidth, kDMColorNoTransparency, 16);
- if (champion.getAttributes(kDMAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) {
+ if (champion.getAttributes(kDMAttributeDisableAction) || championMan._candidateChampionOrdinal || championMan._partyIsSleeping)
_vm->_displayMan->shadeScreenBox(&box, kDMColorBlack);
- }
}
void MenuMan::drawDisabledMenu() {
+ InventoryMan &inventory = *_vm->_inventoryMan;
+
if (!_vm->_championMan->_partyIsSleeping) {
_vm->_eventMan->highlightBoxDisable();
_vm->_displayMan->_useByteBoxCoordinates = false;
- if (_vm->_inventoryMan->_inventoryChampionOrdinal) {
- if (_vm->_inventoryMan->_panelContent == kDMPanelContentChest) {
- _vm->_inventoryMan->closeChest();
+ if (inventory._inventoryChampionOrdinal) {
+ if (inventory._panelContent == kDMPanelContentChest) {
+ inventory.closeChest();
}
} else {
_vm->_displayMan->shadeScreenBox(&_vm->_displayMan->_boxMovementArrows, kDMColorBlack);
@@ -349,12 +351,13 @@ const char *MenuMan::getActionName(ChampionAction actionIndex) {
void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
static Box boxSpellAreaControls(233, 319, 42, 49); // @ G0504_s_Graphic560_Box_SpellAreaControls
- Champion *champ = &_vm->_championMan->_champions[champIndex];
+ ChampionMan &championMan = *_vm->_championMan;
+ Champion *champ = &championMan._champions[champIndex];
_vm->_displayMan->_useByteBoxCoordinates = false;
- int16 champHP0 = _vm->_championMan->_champions[0]._currHealth;
- int16 champHP1 = _vm->_championMan->_champions[1]._currHealth;
- int16 champHP2 = _vm->_championMan->_champions[2]._currHealth;
- int16 champHP3 = _vm->_championMan->_champions[3]._currHealth;
+ int16 champHP0 = championMan._champions[0]._currHealth;
+ int16 champHP1 = championMan._champions[1]._currHealth;
+ int16 champHP2 = championMan._champions[2]._currHealth;
+ int16 champHP3 = championMan._champions[3]._currHealth;
_vm->_eventMan->showMouse();
_vm->_displayMan->fillScreenBox(boxSpellAreaControls, kDMColorBlack);
@@ -362,15 +365,15 @@ void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
case 0:
_vm->_eventMan->highlightScreenBox(233, 277, 42, 49);
_vm->_textMan->printToLogicalScreen(235, 48, kDMColorBlack, kDMColorCyan, champ->_name);
- if (_vm->_championMan->_partyChampionCount > 1) {
+ if (championMan._partyChampionCount > 1) {
if (champHP1)
_vm->_eventMan->highlightScreenBox(280, 291, 42, 48);
- if (_vm->_championMan->_partyChampionCount > 2) {
+ if (championMan._partyChampionCount > 2) {
if (champHP2)
_vm->_eventMan->highlightScreenBox(294, 305, 42, 48);
- if ((_vm->_championMan->_partyChampionCount > 3) && champHP3)
+ if ((championMan._partyChampionCount > 3) && champHP3)
_vm->_eventMan->highlightScreenBox(308, 319, 42, 48);
}
}
@@ -381,11 +384,11 @@ void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
_vm->_eventMan->highlightScreenBox(247, 291, 42, 49);
_vm->_textMan->printToLogicalScreen(249, 48, kDMColorBlack, kDMColorCyan, champ->_name);
- if (_vm->_championMan->_partyChampionCount > 2) {
+ if (championMan._partyChampionCount > 2) {
if (champHP2)
_vm->_eventMan->highlightScreenBox(294, 305, 42, 48);
- if ((_vm->_championMan->_partyChampionCount > 3) && champHP3)
+ if ((championMan._partyChampionCount > 3) && champHP3)
_vm->_eventMan->highlightScreenBox(308, 319, 42, 48);
}
break;
@@ -398,7 +401,7 @@ void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
_vm->_eventMan->highlightScreenBox(261, 305, 42, 49);
_vm->_textMan->printToLogicalScreen(263, 48, kDMColorBlack, kDMColorCyan, champ->_name);
- if ((_vm->_championMan->_partyChampionCount > 3) && champHP3)
+ if ((championMan._partyChampionCount > 3) && champHP3)
_vm->_eventMan->highlightScreenBox(308, 319, 42, 48);
break;
@@ -423,9 +426,10 @@ void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) {
static Box boxSpellAreaLine(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine
+ ChampionMan &championMan = *_vm->_championMan;
char spellSymbolString[2] = {'\0', '\0'};
- Champion *magicChampion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
+ Champion *magicChampion = &championMan._champions[championMan._magicCasterChampionIndex];
if (spellAreaBitmapLine == kDMSpellAreaAvailableSymbols) {
_vm->_displayMan->_useByteBoxCoordinates = false;
_vm->_displayMan->blitToBitmap(_bitmapSpellAreaLines, _bitmapSpellAreaLine, boxSpellAreaLine, 0, 12, k48_byteWidth, k48_byteWidth, kDMColorNoTransparency, 36, 12);
@@ -453,24 +457,26 @@ void MenuMan::setMagicCasterAndDrawSpellArea(ChampionIndex champIndex) {
static Box boxSpellAreaLine2(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2
static Box boxSpellAreaLine3(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3
- if ((champIndex == _vm->_championMan->_magicCasterChampionIndex)
- || ((champIndex != kDMChampionNone) && !_vm->_championMan->_champions[champIndex]._currHealth))
+ ChampionMan &championMan = *_vm->_championMan;
+
+ if ((champIndex == championMan._magicCasterChampionIndex)
+ || ((champIndex != kDMChampionNone) && !championMan._champions[champIndex]._currHealth))
return;
- if (_vm->_championMan->_magicCasterChampionIndex == kDMChampionNone) {
+ if (championMan._magicCasterChampionIndex == kDMChampionNone) {
_vm->_eventMan->showMouse();
_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(kDMGraphicIdxMenuSpellAreaBackground), &_boxSpellArea, k48_byteWidth, kDMColorNoTransparency, 33);
_vm->_eventMan->hideMouse();
}
if (champIndex == kDMChampionNone) {
- _vm->_championMan->_magicCasterChampionIndex = kDMChampionNone;
+ championMan._magicCasterChampionIndex = kDMChampionNone;
_vm->_eventMan->showMouse();
_vm->_displayMan->_useByteBoxCoordinates = false;
_vm->_displayMan->fillScreenBox(_boxSpellArea, kDMColorBlack);
_vm->_eventMan->hideMouse();
return;
}
- _vm->_championMan->_magicCasterChampionIndex = champIndex;
+ championMan._magicCasterChampionIndex = champIndex;
buildSpellAreaLine(kDMSpellAreaAvailableSymbols);
_vm->_eventMan->showMouse();
drawSpellAreaControls(champIndex);
@@ -481,21 +487,24 @@ void MenuMan::setMagicCasterAndDrawSpellArea(ChampionIndex champIndex) {
}
void MenuMan::drawEnabledMenus() {
- if (_vm->_championMan->_partyIsSleeping) {
+ InventoryMan &inventory = *_vm->_inventoryMan;
+ ChampionMan &championMan = *_vm->_championMan;
+
+ if (championMan._partyIsSleeping) {
_vm->_eventMan->drawSleepScreen();
_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
} else {
- ChampionIndex casterChampionIndex = _vm->_championMan->_magicCasterChampionIndex;
- _vm->_championMan->_magicCasterChampionIndex = kDMChampionNone; /* Force next function to draw the spell area */
+ ChampionIndex casterChampionIndex = championMan._magicCasterChampionIndex;
+ championMan._magicCasterChampionIndex = kDMChampionNone; /* Force next function to draw the spell area */
setMagicCasterAndDrawSpellArea(casterChampionIndex);
- if (!_vm->_championMan->_actingChampionOrdinal)
+ if (!championMan._actingChampionOrdinal)
_actionAreaContainsIcons = true;
drawActionArea();
- int16 AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_inventoryChampionOrdinal;
+ int16 AL1462_i_InventoryChampionOrdinal = inventory._inventoryChampionOrdinal;
if (AL1462_i_InventoryChampionOrdinal) {
- _vm->_inventoryMan->_inventoryChampionOrdinal = _vm->indexToOrdinal(kDMChampionNone);
- _vm->_inventoryMan->toggleInventory((ChampionIndex)_vm->ordinalToIndex(AL1462_i_InventoryChampionOrdinal));
+ inventory._inventoryChampionOrdinal = _vm->indexToOrdinal(kDMChampionNone);
+ inventory.toggleInventory((ChampionIndex)_vm->ordinalToIndex(AL1462_i_InventoryChampionOrdinal));
} else {
_vm->_displayMan->drawFloorAndCeiling();
drawMovementArrows();
@@ -505,11 +514,13 @@ void MenuMan::drawEnabledMenus() {
}
int16 MenuMan::getClickOnSpellCastResult() {
- Champion *casterChampion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
+ ChampionMan &championMan = *_vm->_championMan;
+
+ Champion *casterChampion = &championMan._champions[championMan._magicCasterChampionIndex];
_vm->_eventMan->showMouse();
_vm->_eventMan->highlightBoxDisable();
- int16 spellCastResult = getChampionSpellCastResult(_vm->_championMan->_magicCasterChampionIndex);
+ int16 spellCastResult = getChampionSpellCastResult(championMan._magicCasterChampionIndex);
if (spellCastResult != kDMSpellCastFailureNeedsFlask) {
casterChampion->_symbols[0] = '\0';
drawAvailableSymbols(casterChampion->_symbolStep = 0);
@@ -522,10 +533,12 @@ int16 MenuMan::getClickOnSpellCastResult() {
}
int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
- if (champIndex >= _vm->_championMan->_partyChampionCount)
+ ChampionMan &championMan = *_vm->_championMan;
+
+ if (champIndex >= championMan._partyChampionCount)
return kDMSpellCastFailure;
- Champion *curChampion = &_vm->_championMan->_champions[champIndex];
+ Champion *curChampion = &championMan._champions[champIndex];
if (!curChampion->_currHealth)
return kDMSpellCastFailure;
@@ -537,12 +550,12 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
int16 powerSymbolOrdinal = curChampion->_symbols[0] - '_'; /* Values 1 to 6 */
uint16 requiredSkillLevel = curSpell->_baseRequiredSkillLevel + powerSymbolOrdinal;
uint16 experience = _vm->getRandomNumber(8) + (requiredSkillLevel << 4) + ((_vm->ordinalToIndex(powerSymbolOrdinal) * curSpell->_baseRequiredSkillLevel) << 3) + (requiredSkillLevel * requiredSkillLevel);
- uint16 skillLevel = _vm->_championMan->getSkillLevel(champIndex, curSpell->_skillIndex);
+ uint16 skillLevel = championMan.getSkillLevel(champIndex, curSpell->_skillIndex);
if (skillLevel < requiredSkillLevel) {
int16 missingSkillLevelCount = requiredSkillLevel - skillLevel;
while (missingSkillLevelCount--) {
if (_vm->getRandomNumber(128) > MIN(curChampion->_statistics[kDMStatWisdom][kDMStatCurrent] + 15, 115)) {
- _vm->_championMan->addSkillExperience(champIndex, curSpell->_skillIndex, experience >> (requiredSkillLevel - skillLevel));
+ championMan.addSkillExperience(champIndex, curSpell->_skillIndex, experience >> (requiredSkillLevel - skillLevel));
menusPrintSpellFailureMessage(curChampion, kDMFailureNeedsMorePractice, curSpell->_skillIndex);
return kDMSpellCastFailure;
}
@@ -560,10 +573,10 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
newPotion->setType((PotionType)curSpell->getType());
newPotion->setPower(_vm->getRandomNumber(16) + (powerSymbolOrdinal * 40));
curChampion->_load += _vm->_dungeonMan->getObjectWeight(newObject) - emptyFlaskWeight;
- _vm->_championMan->drawChangedObjectIcons();
+ championMan.drawChangedObjectIcons();
if (_vm->_inventoryMan->_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex)) {
setFlag(curChampion->_attributes, kDMAttributeLoad);
- _vm->_championMan->drawChampionState((ChampionIndex)champIndex);
+ championMan.drawChampionState((ChampionIndex)champIndex);
}
}
break;
@@ -571,12 +584,12 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
if (curChampion->_dir != _vm->_dungeonMan->_partyDir) {
curChampion->_dir = _vm->_dungeonMan->_partyDir;
setFlag(curChampion->_attributes, kDMAttributeIcon);
- _vm->_championMan->drawChampionState((ChampionIndex)champIndex);
+ championMan.drawChampionState((ChampionIndex)champIndex);
}
if (curSpell->getType() == kDMSpellTypeProjectileOpenDoor)
skillLevel <<= 1;
- _vm->_championMan->isProjectileSpellCast(champIndex, Thing(curSpell->getType() + Thing::_firstExplosion.toUint16()), CLIP(21, (powerSymbolOrdinal + 2) * (4 + (skillLevel << 1)), 255), 0);
+ championMan.isProjectileSpellCast(champIndex, Thing(curSpell->getType() + Thing::_firstExplosion.toUint16()), CLIP(21, (powerSymbolOrdinal + 2) * (4 + (skillLevel << 1)), 255), 0);
break;
case kDMSpellKindOther: {
TimelineEvent newEvent;
@@ -588,7 +601,7 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
ticks = 10000 + ((spellPower - 8) << 9);
uint16 lightPower = (spellPower >> 1);
lightPower--;
- _vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[lightPower];
+ championMan._party._magicalLightAmount += championMan._lightPowerToLightAmount[lightPower];
createEvent70_light(-lightPower, ticks);
}
break;
@@ -596,19 +609,19 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
ticks = 2000 + ((spellPower - 3) << 7);
uint16 lightPower = (spellPower >> 2);
lightPower++;
- _vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[lightPower];
+ championMan._party._magicalLightAmount += championMan._lightPowerToLightAmount[lightPower];
createEvent70_light(-lightPower, ticks);
}
break;
case kDMSpellTypeOtherDarkness: {
uint16 lightPower = (spellPower >> 2);
- _vm->_championMan->_party._magicalLightAmount -= _vm->_championMan->_lightPowerToLightAmount[lightPower];
+ championMan._party._magicalLightAmount -= championMan._lightPowerToLightAmount[lightPower];
createEvent70_light(lightPower, 98);
}
break;
case kDMSpellTypeOtherThievesEye: {
newEvent._type = kDMEventTypeThievesEye;
- _vm->_championMan->_party._event73Count_ThievesEye++;
+ championMan._party._event73Count_ThievesEye++;
spellPower = (spellPower >> 1);
uint16 spellTicks = spellPower * spellPower;
newEvent._mapTime = _vm->setMapAndTime(_vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + spellTicks);
@@ -617,7 +630,7 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
break;
case kDMSpellTypeOtherInvisibility: {
newEvent._type = kDMEventTypeInvisibility;
- _vm->_championMan->_party._event71Count_Invisibility++;
+ championMan._party._event71Count_Invisibility++;
uint16 spellTicks = spellPower;
newEvent._mapTime = _vm->setMapAndTime(_vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + spellTicks);
_vm->_timeline->addEventGetEventIndex(&newEvent);
@@ -626,10 +639,10 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
case kDMSpellTypeOtherPartyShield: {
newEvent._type = kDMEventTypePartyShield;
newEvent._Bu._defense = spellPower;
- if (_vm->_championMan->_party._shieldDefense > 50)
+ if (championMan._party._shieldDefense > 50)
newEvent._Bu._defense >>= 2;
- _vm->_championMan->_party._shieldDefense += newEvent._Bu._defense;
+ championMan._party._shieldDefense += newEvent._Bu._defense;
_vm->_timeline->refreshAllChampionStatusBoxes();
uint16 spellTicks = spellPower * spellPower;
newEvent._mapTime = _vm->setMapAndTime(_vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + spellTicks);
@@ -638,12 +651,12 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
break;
case kDMSpellTypeOtherFootprints: {
newEvent._type = kDMEventTypeFootprints;
- _vm->_championMan->_party._event79Count_Footprints++;
- _vm->_championMan->_party._firstScentIndex = _vm->_championMan->_party._scentCount;
+ championMan._party._event79Count_Footprints++;
+ championMan._party._firstScentIndex = championMan._party._scentCount;
if (powerSymbolOrdinal < 3)
- _vm->_championMan->_party._lastScentIndex = _vm->_championMan->_party._firstScentIndex;
+ championMan._party._lastScentIndex = championMan._party._firstScentIndex;
else
- _vm->_championMan->_party._lastScentIndex = 0;
+ championMan._party._lastScentIndex = 0;
uint16 spellTicks = spellPower * spellPower;
newEvent._mapTime = _vm->setMapAndTime(_vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + spellTicks);
@@ -666,8 +679,8 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
slotIndex = kDMSlotLeaderHand;
if ((slotIndex == kDMSlotReadyHand) || (slotIndex == kDMSlotActionHand)) {
- _vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, unusedObject, slotIndex);
- _vm->_championMan->drawChampionState((ChampionIndex)champIndex);
+ championMan.addObjectInSlot((ChampionIndex)champIndex, unusedObject, slotIndex);
+ championMan.drawChampionState((ChampionIndex)champIndex);
} else
_vm->_moveSens->getMoveResult(unusedObject, kDMMapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
@@ -681,8 +694,8 @@ int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
}
}
}
- _vm->_championMan->addSkillExperience(champIndex, curSpell->_skillIndex, experience);
- _vm->_championMan->disableAction(champIndex, curSpell->getDuration());
+ championMan.addSkillExperience(champIndex, curSpell->_skillIndex, experience);
+ championMan.disableAction(champIndex, curSpell->getDuration());
return kDMSpellCastSuccess;
}
@@ -835,20 +848,22 @@ bool MenuMan::isPartySpellOrFireShieldSuccessful(Champion *champ, bool spellShie
} else
champ->_currMana -= 4;
}
+ ChampionMan &championMan = *_vm->_championMan;
+
TimelineEvent newEvent;
newEvent._Bu._defense = ticks >> 5;
if (spellShield) {
newEvent._type = kDMEventTypeSpellShield;
- if (_vm->_championMan->_party._spellShieldDefense > 50)
+ if (championMan._party._spellShieldDefense > 50)
newEvent._Bu._defense >>= 2;
- _vm->_championMan->_party._spellShieldDefense += newEvent._Bu._defense;
+ championMan._party._spellShieldDefense += newEvent._Bu._defense;
} else {
newEvent._type = kDMEventTypeFireShield;
- if (_vm->_championMan->_party._fireShieldDefense > 50)
+ if (championMan._party._fireShieldDefense > 50)
newEvent._Bu._defense >>= 2;
- _vm->_championMan->_party._fireShieldDefense += newEvent._Bu._defense;
+ championMan._party._fireShieldDefense += newEvent._Bu._defense;
}
newEvent._priority = 0;
newEvent._mapTime = _vm->setMapAndTime(_vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + ticks);
@@ -896,7 +911,8 @@ void MenuMan::addChampionSymbol(int16 symbolIndex) {
};
static byte symbolManaCostMultiplier[6] = {8, 12, 16, 20, 24, 28};
- Champion *casterChampion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
+ ChampionMan &championMan = *_vm->_championMan;
+ Champion *casterChampion = &championMan._champions[championMan._magicCasterChampionIndex];
uint16 symbolStep = casterChampion->_symbolStep;
uint16 manaCost = symbolBaseManaCost[symbolStep][symbolIndex];
if (symbolStep) {
@@ -913,13 +929,14 @@ void MenuMan::addChampionSymbol(int16 symbolIndex) {
_vm->_eventMan->showMouse();
drawAvailableSymbols(symbolStep);
drawChampionSymbols(casterChampion);
- _vm->_championMan->drawChampionState(_vm->_championMan->_magicCasterChampionIndex);
+ championMan.drawChampionState(championMan._magicCasterChampionIndex);
_vm->_eventMan->hideMouse();
}
}
void MenuMan::deleteChampionSymbol() {
- Champion *casterChampion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
+ ChampionMan &championMan = *_vm->_championMan;
+ Champion *casterChampion = &championMan._champions[championMan._magicCasterChampionIndex];
if (!strlen(casterChampion->_symbols))
return;
@@ -935,11 +952,12 @@ void MenuMan::deleteChampionSymbol() {
bool MenuMan::didClickTriggerAction(int16 actionListIndex) {
bool retVal = false;
- if (!_vm->_championMan->_actingChampionOrdinal || (actionListIndex != -1 && (_actionList._actionIndices[actionListIndex] == kDMActionNone)))
+ ChampionMan &championMan = *_vm->_championMan;
+ if (!championMan._actingChampionOrdinal || (actionListIndex != -1 && (_actionList._actionIndices[actionListIndex] == kDMActionNone)))
return retVal;
- uint16 championIndex = _vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal);
- Champion *curChampion = &_vm->_championMan->_champions[championIndex];
+ uint16 championIndex = _vm->ordinalToIndex(championMan._actingChampionOrdinal);
+ Champion *curChampion = &championMan._champions[championIndex];
if (actionListIndex == -1)
retVal = true;
else {
@@ -1051,10 +1069,11 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
1 /* FUSE */
};
- if (champIndex >= _vm->_championMan->_partyChampionCount)
+ ChampionMan &championMan = *_vm->_championMan;
+ if (champIndex >= championMan._partyChampionCount)
return false;
- Champion *curChampion = &_vm->_championMan->_champions[champIndex];
+ Champion *curChampion = &championMan._champions[champIndex];
if (!curChampion->_currHealth)
return false;
@@ -1073,7 +1092,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
int16 requiredManaAmount = 0;
if (((actionSkillIndex >= kDMSkillFire) && (actionSkillIndex <= kDMSkillWater)) || (actionSkillIndex == kDMSkillWizard))
- requiredManaAmount = 7 - MIN<uint16>(6, _vm->_championMan->getSkillLevel(champIndex, actionSkillIndex));
+ requiredManaAmount = 7 - MIN<uint16>(6, championMan.getSkillLevel(champIndex, actionSkillIndex));
bool setDirectionFl = false;
int16 kineticEnergy = 0;
@@ -1109,7 +1128,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
if ((Square(targetSquare).getType() == kDMElementTypeDoor) && (Square(targetSquare).getDoorState() == kDMDoorStateClosed)) {
_vm->_sound->requestPlay(kDMSoundIndexAttackSkelettonAnimatedArmorDethKnight, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kDMSoundModePlayIfPrioritized);
actionDisabledTicks = 6;
- _vm->_groupMan->groupIsDoorDestoryedByAttack(nextMapX, nextMapY, _vm->_championMan->getStrength(champIndex, kDMSlotActionHand), false, 2);
+ _vm->_groupMan->groupIsDoorDestoryedByAttack(nextMapX, nextMapY, championMan.getStrength(champIndex, kDMSlotActionHand), false, 2);
_vm->_sound->requestPlay(kDMSoundIndexWoodenThudAttackTrolinAntmanStoneGolem, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kDMSoundModePlayOneTickLater);
break;
}
@@ -1175,9 +1194,9 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
}
setChampionDirectionToPartyDirection(curChampion);
- Thing removedObject = _vm->_championMan->getObjectRemovedFromSlot(champIndex, kDMSlotReadyHand);
+ Thing removedObject = championMan.getObjectRemovedFromSlot(champIndex, kDMSlotReadyHand);
_vm->_sound->requestPlay(kDMSoundIndexAttackSkelettonAnimatedArmorDethKnight, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kDMSoundModePlayIfPrioritized);
- _vm->_championMan->championShootProjectile(curChampion, removedObject, weaponInfoActionHand->_kineticEnergy + weaponInfoReadyHand->_kineticEnergy, (weaponInfoActionHand->getShootAttack() + _vm->_championMan->getSkillLevel(champIndex, kDMSkillShoot)) << 1, stepEnergy);
+ championMan.championShootProjectile(curChampion, removedObject, weaponInfoActionHand->_kineticEnergy + weaponInfoReadyHand->_kineticEnergy, (weaponInfoActionHand->getShootAttack() + championMan.getSkillLevel(champIndex, kDMSkillShoot)) << 1, stepEnergy);
}
break;
case kDMActionFlip: {
@@ -1251,7 +1270,7 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
Experience gain is 2 + 2 * heal cycle count */
int16 missingHealth = curChampion->_maxHealth - curChampion->_currHealth;
if ((missingHealth > 0) && curChampion->_currMana) {
- int16 healingCapability = MIN((uint16)10, _vm->_championMan->getSkillLevel(champIndex, kDMSkillHeal));
+ int16 healingCapability = MIN((uint16)10, championMan.getSkillLevel(champIndex, kDMSkillHeal));
actionExperienceGain = 2;
uint16 healingAmount;
do {
@@ -1272,13 +1291,13 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
}
break;
case kDMActionWindow: {
- int16 windowTicks = _vm->getRandomNumber(_vm->_championMan->getSkillLevel(champIndex, actionSkillIndex) + 8) + 5;
+ int16 windowTicks = _vm->getRandomNumber(championMan.getSkillLevel(champIndex, actionSkillIndex) + 8) + 5;
TimelineEvent newEvent;
newEvent._priority = 0;
newEvent._type = kDMEventTypeThievesEye;
newEvent._mapTime = _vm->setMapAndTime(_vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + windowTicks);
_vm->_timeline->addEventGetEventIndex(&newEvent);
- _vm->_championMan->_party._event73Count_ThievesEye++;
+ championMan._party._event73Count_ThievesEye++;
decrementCharges(curChampion);
}
break;
@@ -1303,27 +1322,27 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
int16 freezeTicks;
if (weaponInHand->getType() == (int)kDMJunkTypeMagicalBoxBlue) {
freezeTicks = 30;
- _vm->_championMan->getObjectRemovedFromSlot(champIndex, kDMSlotActionHand);
+ championMan.getObjectRemovedFromSlot(champIndex, kDMSlotActionHand);
weaponInHand->setNextThing(Thing::_none);
} else if (weaponInHand->getType() == (int)kDMJunkTypeMagicalBoxGreen) {
freezeTicks = 125;
- _vm->_championMan->getObjectRemovedFromSlot(champIndex, kDMSlotActionHand);
+ championMan.getObjectRemovedFromSlot(champIndex, kDMSlotActionHand);
weaponInHand->setNextThing(Thing::_none);
} else {
freezeTicks = 70;
decrementCharges(curChampion);
}
- _vm->_championMan->_party._freezeLifeTicks = MIN(200, _vm->_championMan->_party._freezeLifeTicks + freezeTicks);
+ championMan._party._freezeLifeTicks = MIN(200, championMan._party._freezeLifeTicks + freezeTicks);
}
break;
case kDMActionLight:
- _vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[2];
+ championMan._party._magicalLightAmount += championMan._lightPowerToLightAmount[2];
createEvent70_light(-2, 2500);
decrementCharges(curChampion);
break;
case kDMActionThrow:
setChampionDirectionToPartyDirection(curChampion);
- actionPerformed = _vm->_championMan->isObjectThrown(champIndex, kDMSlotActionHand, (curChampion->_cell == (ViewCell)_vm->turnDirRight(_vm->_dungeonMan->_partyDir)) || (curChampion->_cell == (ViewCell)_vm->returnOppositeDir(_vm->_dungeonMan->_partyDir)));
+ actionPerformed = championMan.isObjectThrown(champIndex, kDMSlotActionHand, (curChampion->_cell == (ViewCell)_vm->turnDirRight(_vm->_dungeonMan->_partyDir)) || (curChampion->_cell == (ViewCell)_vm->returnOppositeDir(_vm->_dungeonMan->_partyDir)));
if (actionPerformed)
_vm->_timeline->_events[curChampion->_enableActionEventIndex]._Bu._slotOrdinal = _vm->indexToOrdinal(kDMSlotActionHand);
break;
@@ -1338,22 +1357,22 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
kineticEnergy = MAX(2, curChampion->_currMana * kineticEnergy / requiredManaAmount);
requiredManaAmount = curChampion->_currMana;
}
- actionPerformed = _vm->_championMan->isProjectileSpellCast(champIndex, explosionThing, kineticEnergy, requiredManaAmount);
+ actionPerformed = championMan.isProjectileSpellCast(champIndex, explosionThing, kineticEnergy, requiredManaAmount);
if (!actionPerformed)
actionExperienceGain >>= 1;
decrementCharges(curChampion);
}
if (actionDisabledTicks)
- _vm->_championMan->disableAction(champIndex, actionDisabledTicks);
+ championMan.disableAction(champIndex, actionDisabledTicks);
if (actionStamina)
- _vm->_championMan->decrementStamina(champIndex, actionStamina);
+ championMan.decrementStamina(champIndex, actionStamina);
if (actionExperienceGain)
- _vm->_championMan->addSkillExperience(champIndex, actionSkillIndex, actionExperienceGain);
+ championMan.addSkillExperience(champIndex, actionSkillIndex, actionExperienceGain);
- _vm->_championMan->drawChampionState((ChampionIndex)champIndex);
+ championMan.drawChampionState((ChampionIndex)champIndex);
return actionPerformed;
}
@@ -1523,6 +1542,8 @@ bool MenuMan::isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, in
if (_actionTargetGroupThing == Thing::_endOfList)
return retVal;
+ ChampionMan &championMan = *_vm->_championMan;
+
uint16 experience = 0;
int16 frightAmount = 0;
@@ -1548,7 +1569,7 @@ bool MenuMan::isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, in
experience = 45;
break;
}
- frightAmount += _vm->_championMan->getSkillLevel(champIndex, kDMSkillInfluence);
+ frightAmount += championMan.getSkillLevel(champIndex, kDMSkillInfluence);
Group *targetGroup = (Group *)_vm->_dungeonMan->getThingData(_actionTargetGroupThing);
CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[targetGroup->_type];
uint16 fearResistance = creatureInfo->getFearResistance();
@@ -1564,12 +1585,14 @@ bool MenuMan::isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, in
activeGroup->_delayFleeingFromTarget = ((16 - fearResistance) << 2) / creatureInfo->_movementTicks;
retVal = true;
}
- _vm->_championMan->addSkillExperience(champIndex, kDMSkillInfluence, experience);
+ championMan.addSkillExperience(champIndex, kDMSkillInfluence, experience);
return retVal;
}
void MenuMan::printMessageAfterReplacements(const char *str) {
+ ChampionMan &championMan = *_vm->_championMan;
+
char outputString[128];
char *curCharacter = outputString;
*curCharacter++ = '\n'; /* New line */
@@ -1581,7 +1604,7 @@ void MenuMan::printMessageAfterReplacements(const char *str) {
*curCharacter++ = ' ';
if (*str == 'p') /* '@p' in the source string is replaced by the champion name followed by a space */
- replacementString = _vm->_championMan->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._name;
+ replacementString = championMan._champions[_vm->ordinalToIndex(championMan._actingChampionOrdinal)]._name;
*curCharacter = '\0';
strcat(outputString, replacementString);
@@ -1646,7 +1669,8 @@ void MenuMan::processCommands116To119_setActingChampion(uint16 champIndex) {
ActionSet(6, 11, 255, 0x80, 0x00)
};
- Champion *curChampion = &_vm->_championMan->_champions[champIndex];
+ ChampionMan &championMan = *_vm->_championMan;
+ Champion *curChampion = &championMan._champions[champIndex];
if (getFlag(curChampion->_attributes, kDMAttributeDisableAction) || !curChampion->_currHealth)
return;
@@ -1662,16 +1686,18 @@ void MenuMan::processCommands116To119_setActingChampion(uint16 champIndex) {
}
ActionSet *actionSet = &actionSets[actionSetIndex];
- _vm->_championMan->_actingChampionOrdinal = _vm->indexToOrdinal(champIndex);
+ championMan._actingChampionOrdinal = _vm->indexToOrdinal(champIndex);
setActionList(actionSet);
_actionAreaContainsIcons = false;
setFlag(curChampion->_attributes, kDMAttributeActionHand);
- _vm->_championMan->drawChampionState((ChampionIndex)champIndex);
+ championMan.drawChampionState((ChampionIndex)champIndex);
drawActionArea();
drawActionArea();
}
void MenuMan::setActionList(ActionSet *actionSet) {
+ ChampionMan &championMan = *_vm->_championMan;
+
_actionList._actionIndices[0] = (ChampionAction)actionSet->_actionIndices[0];
_actionList._minimumSkillLevel[0] = 1;
uint16 nextAvailableActionListIndex = 1;
@@ -1686,7 +1712,7 @@ void MenuMan::setActionList(ActionSet *actionSet) {
continue;
clearFlag(minimumSkillLevel, kDMActionMaskRequiresCharge);
- if (_vm->_championMan->getSkillLevel(_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal), _actionSkillIndex[actionIndex]) >= minimumSkillLevel) {
+ if (championMan.getSkillLevel(_vm->ordinalToIndex(championMan._actingChampionOrdinal), _actionSkillIndex[actionIndex]) >= minimumSkillLevel) {
_actionList._actionIndices[nextAvailableActionListIndex] = (ChampionAction)actionIndex;
_actionList._minimumSkillLevel[nextAvailableActionListIndex] = minimumSkillLevel;
nextAvailableActionListIndex++;
@@ -1699,7 +1725,8 @@ void MenuMan::setActionList(ActionSet *actionSet) {
}
int16 MenuMan::getActionObjectChargeCount() {
- Thing slotActionThing = _vm->_championMan->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._slots[kDMSlotActionHand];
+ ChampionMan &championMan = *_vm->_championMan;
+ Thing slotActionThing = championMan._champions[_vm->ordinalToIndex(championMan._actingChampionOrdinal)]._slots[kDMSlotActionHand];
Junk *junkData = (Junk *)_vm->_dungeonMan->getThingData(slotActionThing);
switch (slotActionThing.getType()) {
case kDMThingTypeWeapon: