diff options
author | Strangerke | 2016-09-26 21:12:51 +0200 |
---|---|---|
committer | Strangerke | 2016-09-26 21:15:04 +0200 |
commit | dc19419507240ba42650e671b4e379578f571d53 (patch) | |
tree | f9276bcaeab6dec6dd3ceeaf372f435efdbefde5 /engines/dm | |
parent | 53790e749725f92d43f1a09b342203eb5022c2fc (diff) | |
download | scummvm-rg350-dc19419507240ba42650e671b4e379578f571d53.tar.gz scummvm-rg350-dc19419507240ba42650e671b4e379578f571d53.tar.bz2 scummvm-rg350-dc19419507240ba42650e671b4e379578f571d53.zip |
DM: reduce some more redirections
Diffstat (limited to 'engines/dm')
-rw-r--r-- | engines/dm/champion.cpp | 53 | ||||
-rw-r--r-- | engines/dm/dungeonman.cpp | 9 | ||||
-rw-r--r-- | engines/dm/eventman.cpp | 13 | ||||
-rw-r--r-- | engines/dm/gfx.cpp | 13 | ||||
-rw-r--r-- | engines/dm/group.cpp | 87 | ||||
-rw-r--r-- | engines/dm/inventory.cpp | 75 | ||||
-rw-r--r-- | engines/dm/menus.cpp | 211 | ||||
-rw-r--r-- | engines/dm/timeline.cpp | 5 |
8 files changed, 263 insertions, 203 deletions
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 538b3d753b..616ea637b4 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -666,11 +666,13 @@ uint16 ChampionMan::getStrength(int16 champIndex, int16 slotIndex) { Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex) { Champion *curChampion = &_champions[champIndex]; DungeonMan &dungeon = *_vm->_dungeonMan; + InventoryMan &inventory = *_vm->_inventoryMan; + Thing curThing; if (slotIndex >= kDMSlotChest1) { - curThing = _vm->_inventoryMan->_chestSlots[slotIndex - kDMSlotChest1]; - _vm->_inventoryMan->_chestSlots[slotIndex - kDMSlotChest1] = Thing::_none; + curThing = inventory._chestSlots[slotIndex - kDMSlotChest1]; + inventory._chestSlots[slotIndex - kDMSlotChest1] = Thing::_none; } else { curThing = curChampion->_slots[slotIndex]; curChampion->_slots[slotIndex] = Thing::_none; @@ -679,7 +681,7 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex) if (curThing == Thing::_none) return Thing::_none; - bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal); + bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == inventory._inventoryChampionOrdinal); int16 curIconIndex = _vm->_objectMan->getIconIndex(curThing); // Remove object modifiers applyModifiersToStatistics(curChampion, slotIndex, curIconIndex, -1, curThing); @@ -689,7 +691,7 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex) if ((curIconIndex >= kDMIconIndiceJunkIllumuletUnequipped) && (curIconIndex <= kDMIconIndiceJunkIllumuletEquipped)) { ((Junk *)curWeapon)->setChargeCount(0); _party._magicalLightAmount -= _lightPowerToLightAmount[2]; - _vm->_inventoryMan->setDungeonViewPalette(); + inventory.setDungeonViewPalette(); } else if ((curIconIndex >= kDMIconIndiceJunkJewelSymalUnequipped) && (curIconIndex <= kDMIconIndiceJunkJewelSymalEquipped)) { ((Junk *)curWeapon)->setChargeCount(0); } @@ -713,14 +715,14 @@ Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex) if ((curIconIndex >= kDMIconIndiceWeaponTorchUnlit) && (curIconIndex <= kDMIconIndiceWeaponTorchLit)) { curWeapon->setLit(false); - _vm->_inventoryMan->setDungeonViewPalette(); + inventory.setDungeonViewPalette(); drawChangedObjectIcons(); } if (isInventoryChampion && (slotIndex == kDMSlotActionHand)) { switch (curIconIndex) { case kDMIconIndiceContainerChestClosed: - _vm->_inventoryMan->closeChest(); + inventory.closeChest(); // No break on purpose case kDMIconIndiceScrollOpen: case kDMIconIndiceScrollClosed: @@ -1126,12 +1128,12 @@ void ChampionMan::championPoison(int16 champIndex, uint16 attack) { if ((champIndex == kDMChampionNone) || (_vm->indexToOrdinal(champIndex) == _candidateChampionOrdinal)) return; + InventoryMan &inventory = *_vm->_inventoryMan; Champion *curChampion = &_champions[champIndex]; addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), kDMWoundNone, kDMAttackTypeNormal); setFlag(curChampion->_attributes, kDMAttributeStatistics); - if ((_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) && (_vm->_inventoryMan->_panelContent == kDMPanelContentFoodWaterPoisoned)) { + if ((_vm->indexToOrdinal(champIndex) == inventory._inventoryChampionOrdinal) && (inventory._panelContent == kDMPanelContentFoodWaterPoisoned)) setFlag(curChampion->_attributes, kDMAttributePanel); - } if (--attack) { curChampion->_poisonEventCount++; @@ -1321,17 +1323,18 @@ void ChampionMan::clickOnSlotBox(uint16 slotBoxIndex) { uint16 champIndex; uint16 slotIndex; + InventoryMan &inventory = *_vm->_inventoryMan; if (slotBoxIndex < kDMSlotBoxInventoryFirstSlot) { if (_candidateChampionOrdinal) return; champIndex = slotBoxIndex >> 1; - if ((champIndex >= _partyChampionCount) || (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) || !_champions[champIndex]._currHealth) + if ((champIndex >= _partyChampionCount) || (_vm->indexToOrdinal(champIndex) == inventory._inventoryChampionOrdinal) || !_champions[champIndex]._currHealth) return; slotIndex = getHandSlotIndex(slotBoxIndex); } else { - champIndex = _vm->ordinalToIndex(_vm->_inventoryMan->_inventoryChampionOrdinal); + champIndex = _vm->ordinalToIndex(inventory._inventoryChampionOrdinal); slotIndex = slotBoxIndex - kDMSlotBoxInventoryFirstSlot; } @@ -1339,7 +1342,7 @@ void ChampionMan::clickOnSlotBox(uint16 slotBoxIndex) { Thing leaderHandObject = _leaderHandObject; Thing slotThing; if (slotIndex >= kDMSlotChest1) - slotThing = _vm->_inventoryMan->_chestSlots[slotIndex - kDMSlotChest1]; + slotThing = inventory._chestSlots[slotIndex - kDMSlotChest1]; else slotThing = _champions[champIndex]._slots[slotIndex]; @@ -1483,10 +1486,10 @@ void ChampionMan::championKill(uint16 champIndex) { Champion *curChampion = &_champions[champIndex]; EventManager &evtMan = *_vm->_eventMan; DisplayMan &display = *_vm->_displayMan; - + InventoryMan &inventory = *_vm->_inventoryMan; curChampion->_currHealth = 0; setFlag(curChampion->_attributes, kDMAttributeStatusBox); - if (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) { + if (_vm->indexToOrdinal(champIndex) == inventory._inventoryChampionOrdinal) { if (_vm->_pressingEye) { _vm->_pressingEye = false; evtMan._ignoreMouseMovements = false; @@ -1501,7 +1504,7 @@ void ChampionMan::championKill(uint16 champIndex) { evtMan._hideMousePointerRequestCount = 1; evtMan.hideMouse(); } - _vm->_inventoryMan->toggleInventory(kDMChampionCloseInventory); + inventory.toggleInventory(kDMChampionCloseInventory); } dropAllObjects(champIndex); Thing unusedThing = dungeon.getUnusedThing(kDMMaskChampionBones | kDMThingTypeJunk); @@ -1611,6 +1614,8 @@ void ChampionMan::applyTimeEffects() { return; DungeonMan &dungeon = *_vm->_dungeonMan; + InventoryMan &inventory = *_vm->_inventoryMan; + Scent checkScent; checkScent.setMapX(dungeon._partyMapX); checkScent.setMapY(dungeon._partyMapY); @@ -1722,8 +1727,8 @@ void ChampionMan::applyTimeEffects() { setFlag(championPtr->_attributes, kDMAttributeIcon); } setFlag(championPtr->_attributes, kDMAttributeStatistics); - if (_vm->indexToOrdinal(championIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) { - if (_vm->_pressingMouth || _vm->_pressingEye || (_vm->_inventoryMan->_panelContent == kDMPanelContentFoodWaterPoisoned)) { + if (_vm->indexToOrdinal(championIndex) == inventory._inventoryChampionOrdinal) { + if (_vm->_pressingMouth || _vm->_pressingEye || (inventory._panelContent == kDMPanelContentFoodWaterPoisoned)) { setFlag(championPtr->_attributes, kDMAttributePanel); } } @@ -2167,12 +2172,13 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { EventManager &evtMan = *_vm->_eventMan; TextMan &txtMan = *_vm->_textMan; DisplayMan &display = *_vm->_displayMan; + InventoryMan &inventory = *_vm->_inventoryMan; uint16 championAttributes = curChampion->_attributes; if (!getFlag(championAttributes, kDMAttributeNameTitle | kDMAttributeStatistics | kDMAttributeLoad | kDMAttributeIcon | kDMAttributePanel | kDMAttributeStatusBox | kDMAttributeWounds | kDMAttributeViewport | kDMAttributeActionHand)) return; - bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal); + bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == inventory._inventoryChampionOrdinal); display._useByteBoxCoordinates = false; evtMan.showMouse(); if (getFlag(championAttributes, kDMAttributeStatusBox)) { @@ -2201,7 +2207,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { display.blitToScreen(display.getNativeBitmapOrGraphic(nativeBitmapIndices[borderCount]), &box, k40_byteWidth, kDMColorFlesh, 29); if (isInventoryChampion) { - _vm->_inventoryMan->drawStatusBoxPortrait(champIndex); + inventory.drawStatusBoxPortrait(champIndex); setFlag(championAttributes, kDMAttributeStatistics); } else setFlag(championAttributes, kDMAttributeNameTitle | kDMAttributeStatistics | kDMAttributeWounds | kDMAttributeActionHand); @@ -2322,12 +2328,12 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { } if (getFlag(championAttributes, kDMAttributePanel) && isInventoryChampion) { if (_vm->_pressingMouth) - _vm->_inventoryMan->drawPanelFoodWaterPoisoned(); + inventory.drawPanelFoodWaterPoisoned(); else if (_vm->_pressingEye) { if (_leaderEmptyHanded) - _vm->_inventoryMan->drawChampionSkillsAndStatistics(); + inventory.drawChampionSkillsAndStatistics(); } else - _vm->_inventoryMan->drawPanel(); + inventory.drawPanel(); setFlag(championAttributes, kDMAttributeViewport); } @@ -2358,9 +2364,10 @@ void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) { Champion *champ = &_champions[champIndex]; EventManager &evtMan = *_vm->_eventMan; DisplayMan &display = *_vm->_displayMan; + InventoryMan &inventory = *_vm->_inventoryMan; int16 nativeBitmapIndex = -1; - bool isInventoryChamp = (_vm->_inventoryMan->_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex)); + bool isInventoryChamp = (inventory._inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex)); uint16 slotBoxIndex; if (!isInventoryChamp) { @@ -2373,7 +2380,7 @@ void ChampionMan::drawSlot(uint16 champIndex, int16 slotIndex) { Thing thing; if (slotIndex >= kDMSlotChest1) - thing = _vm->_inventoryMan->_chestSlots[slotIndex - kDMSlotChest1]; + thing = inventory._chestSlots[slotIndex - kDMSlotChest1]; else thing = champ->getSlot((ChampionSlot)slotIndex); diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index bdc565b7a5..0c08caa4ae 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -867,6 +867,7 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, Direction dir, int16 mapX, #define AL0307_uc_ScentOrdinal L0307_uc_Multiple DisplayMan &displMan = *_vm->_displayMan; + ChampionMan &championMan = *_vm->_championMan; for (uint16 i = 0; i < 5; ++i) aspectArray[i] = 0; @@ -970,8 +971,8 @@ T0172010_ClosedFakeWall: curThing = getNextThing(curThing); } - AL0307_uc_ScentOrdinal = _vm->_championMan->getScentOrdinal(mapX, mapY); - if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_party._lastScentIndex)) + AL0307_uc_ScentOrdinal = championMan.getScentOrdinal(mapX, mapY); + if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal) && (--AL0307_uc_ScentOrdinal >= championMan._party._firstScentIndex) && (AL0307_uc_ScentOrdinal < championMan._party._lastScentIndex)) setFlag(aspectArray[kDMSquareAspectFloorOrn], kDMMaskFootprints); break; @@ -995,8 +996,8 @@ T0172010_ClosedFakeWall: while ((curThing != Thing::_endOfList) && (curThing.getType() <= kDMThingTypeSensor)) curThing = getNextThing(curThing); - AL0307_uc_ScentOrdinal = _vm->_championMan->getScentOrdinal(mapX, mapY); - if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal) && (--AL0307_uc_ScentOrdinal >= _vm->_championMan->_party._firstScentIndex) && (AL0307_uc_ScentOrdinal < _vm->_championMan->_party._lastScentIndex)) + AL0307_uc_ScentOrdinal = championMan.getScentOrdinal(mapX, mapY); + if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal) && (--AL0307_uc_ScentOrdinal >= championMan._party._firstScentIndex) && (AL0307_uc_ScentOrdinal < championMan._party._lastScentIndex)) setFlag(aspectArray[kDMSquareAspectFloorOrn], kDMMaskFootprints); break; } diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 1cd2c048c5..43f9bd8efc 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -725,6 +725,7 @@ void EventManager::processCommandQueue() { DisplayMan &displMan = *_vm->_displayMan; TextMan &txtMan = *_vm->_textMan; + InventoryMan &inventory = *_vm->_inventoryMan; _isCommandQueueLocked = true; if (_commandQueue.empty()) { /* If the command queue is empty */ @@ -787,14 +788,14 @@ void EventManager::processCommandQueue() { int16 championIndex = cmdType - kDMCommandToggleInventoryChampion0; if (((championIndex == kDMChampionCloseInventory) || (championIndex < _vm->_championMan->_partyChampionCount)) && !_vm->_championMan->_candidateChampionOrdinal) - _vm->_inventoryMan->toggleInventory((ChampionIndex)championIndex); + inventory.toggleInventory((ChampionIndex)championIndex); return; } if (cmdType == kDMCommandToggleInventoryLeader) { if (_vm->_championMan->_leaderIndex != kDMChampionNone) - _vm->_inventoryMan->toggleInventory(_vm->_championMan->_leaderIndex); + inventory.toggleInventory(_vm->_championMan->_leaderIndex); return; } @@ -814,12 +815,12 @@ void EventManager::processCommandQueue() { } if (cmdType == kDMCommandClickOnMouth) { - _vm->_inventoryMan->clickOnMouth(); + inventory.clickOnMouth(); return; } if (cmdType == kDMCommandClickOnEye) { - _vm->_inventoryMan->clickOnEye(); + inventory.clickOnEye(); return; } @@ -837,8 +838,8 @@ void EventManager::processCommandQueue() { if (cmdType == kDMCommandSleep) { if (!_vm->_championMan->_candidateChampionOrdinal) { - if (_vm->_inventoryMan->_inventoryChampionOrdinal) - _vm->_inventoryMan->toggleInventory(kDMChampionCloseInventory); + if (inventory._inventoryChampionOrdinal) + inventory.toggleInventory(kDMChampionCloseInventory); _vm->_menuMan->drawDisabledMenu(); _vm->_championMan->_partyIsSleeping = true; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index d0748e6610..3bc6b0e78a 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1108,6 +1108,7 @@ void DisplayMan::drawDoor(uint16 doorThingIndex, DoorState doorState, int16 *doo if (doorState == kDMDoorStateOpen) return; + ChampionMan &championMan = *_vm->_championMan; DoorFrames *doorFramesTemp = doorFrames; Door *door = (Door *)(_vm->_dungeonMan->_thingData[kDMThingTypeDoor]) + doorThingIndex; uint16 doorType = door->getType(); @@ -1121,7 +1122,7 @@ void DisplayMan::drawDoor(uint16 doorThingIndex, DoorState doorState, int16 *doo flipBitmapVertical(_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight); } - if ((doorFramesTemp == _doorFrameD1C) && _vm->_championMan->_party._event73Count_ThievesEye) + if ((doorFramesTemp == _doorFrameD1C) && championMan._party._event73Count_ThievesEye) drawDoorOrnament(_vm->indexToOrdinal(k16_DoorOrnThivesEyeMask), kDMDoorOrnamentD1LCR); if (doorState == kDMDoorStateClosed) @@ -1914,6 +1915,8 @@ void DisplayMan::drawSquareD1C(Direction dir, int16 posX, int16 posY) { static Frame frameCeilingPitD1C = Frame(32, 191, 8, 16, 80, 9, 0, 0); // @ G0156_s_Graphic558_Frame_CeilingPit_D1C static Box boxThievesEyeVisibleArea(0, 95, 0, 94); // @ G0107_s_Graphic558_Box_ThievesEye_VisibleArea + ChampionMan &championMan = *_vm->_championMan; + CellOrder order; uint16 squareAspect[5]; bool skip = false; @@ -1935,7 +1938,7 @@ void DisplayMan::drawSquareD1C(Direction dir, int16 posX, int16 posY) { _vm->_dungeonMan->_isFacingAlcove = false; _vm->_dungeonMan->_isFacingViAltar = false; _vm->_dungeonMan->_isFacingFountain = false; - if (_vm->_championMan->_party._event73Count_ThievesEye) { + if (championMan._party._event73Count_ThievesEye) { isDerivedBitmapInCache(kDMDerivedBitmapThievesEyeVisibleArea); blitToBitmap(_bitmapViewport, getDerivedBitmap(kDMDerivedBitmapThievesEyeVisibleArea), boxThievesEyeVisibleArea, _boxThievesEyeViewPortVisibleArea._rect.left, _boxThievesEyeViewPortVisibleArea._rect.top, @@ -1948,7 +1951,7 @@ void DisplayMan::drawSquareD1C(Direction dir, int16 posX, int16 posY) { if (isDrawnWallOrnAnAlcove(squareAspect[kDMSquareFrontWallOrnOrd], kDMViewWallD1CFront)) drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[kDMSquareAspectFirstGroupOrObject]), dir, posX, posY, kDMViewSquareD1C, kDMCellOrderAlcove); - if (_vm->_championMan->_party._event73Count_ThievesEye) { + if (championMan._party._event73Count_ThievesEye) { blitToBitmap(getDerivedBitmap(kDMDerivedBitmapThievesEyeVisibleArea), _bitmapViewport, _boxThievesEyeViewPortVisibleArea, 0, 0, 48, k112_byteWidthViewport, kDMColorGold, 95, k136_heightViewport); /* BUG0_74 */ @@ -2061,12 +2064,14 @@ void DisplayMan::drawSquareD0C(Direction dir, int16 posX, int16 posY) { static Frame frameCeilingPitD0C = Frame(16, 207, 0, 3, 96, 4, 0, 0); // @ G0159_s_Graphic558_Frame_CeilingPit_D0C static Box boxThievesEyeHoleInDoorFrame(0, 31, 19, 113); // @ G0108_s_Graphic558_Box_ThievesEye_HoleInDoorFrame + ChampionMan &championMan = *_vm->_championMan; + uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[kDMSquareAspectElement]) { case kDMElementTypeDoorSide: - if (_vm->_championMan->_party._event73Count_ThievesEye) { + if (championMan._party._event73Count_ThievesEye) { memmove(_tmpBitmap, _bitmapWallSetDoorFrameFront, 32 * 123); blitToBitmap(getNativeBitmapOrGraphic(kDMGraphicIdxHoleInWall), _tmpBitmap, boxThievesEyeHoleInDoorFrame, doorFrameD0C._box._rect.left - _boxThievesEyeViewPortVisibleArea._rect.left, diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 4f96befda1..c81ee32b73 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -593,6 +593,8 @@ void GroupMan::processEvents29to41(int16 eventMapX, int16 eventMapY, TimelineEve if (groupThing == Thing::_endOfList) return; + ChampionMan &championMan = *_vm->_championMan; + Group *curGroup = (Group *)_vm->_dungeonMan->getThingData(groupThing); CreatureInfo creatureInfo = _vm->_dungeonMan->_creatureInfos[curGroup->_type]; /* Update the event */ @@ -641,7 +643,7 @@ T0209005_AddEventAndReturn: if (movementTicks == kDMMovementTicksImmobile) movementTicks = 100; - if (_vm->_championMan->_party._freezeLifeTicks && !isArchEnemy) { /* If life is frozen and the creature is not Lord Chaos (Lord Chaos is immune to Freeze Life) then reschedule the event later (except for reactions which are ignored when life if frozen) */ + if (championMan._party._freezeLifeTicks && !isArchEnemy) { /* If life is frozen and the creature is not Lord Chaos (Lord Chaos is immune to Freeze Life) then reschedule the event later (except for reactions which are ignored when life if frozen) */ if (eventType < 0) return; nextEvent._type = eventType; @@ -1134,8 +1136,10 @@ int16 GroupMan::getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int16 de int16 GroupMan::groupGetDistanceToVisibleParty(Group *group, int16 creatureIndex, int16 mapX, int16 mapY) { uint16 groupDirections; + ChampionMan &championMan = *_vm->_championMan; + CreatureInfo *groupCreatureInfo = &_vm->_dungeonMan->_creatureInfos[group->_type]; - if (_vm->_championMan->_party._event71Count_Invisibility && !getFlag(groupCreatureInfo->_attributes, kDMCreatureMaskSeeInvisible)) + if (championMan._party._event71Count_Invisibility && !getFlag(groupCreatureInfo->_attributes, kDMCreatureMaskSeeInvisible)) return 0; bool alwaysSee = false; @@ -1365,14 +1369,16 @@ int16 GroupMan::getSmelledPartyPrimaryDirOrdinal(CreatureInfo *creatureInfo, int if (!smellRange) return 0; + ChampionMan &championMan = *_vm->_championMan; + if ((((smellRange + 1) >> 1) >= _currGroupDistanceToParty) && getDistanceBetweenUnblockedSquares(mapY, mapX, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, &GroupMan::isSmellPartyBlocked)) { _vm->_projexpl->_secondaryDirToOrFromParty = _currGroupSecondaryDirToParty; return _vm->indexToOrdinal(_currGroupPrimaryDirToParty); } - int16 scentOrdinal = _vm->_championMan->getScentOrdinal(mapY, mapX); - if (scentOrdinal && ((_vm->_championMan->_party._scentStrengths[_vm->ordinalToIndex(scentOrdinal)] + _vm->getRandomNumber(4)) > (30 - (smellRange << 1)))) { /* If there is a fresh enough party scent on the group square */ - return _vm->indexToOrdinal(getDirsWhereDestIsVisibleFromSource(mapY, mapX, _vm->_championMan->_party._scents[scentOrdinal].getMapX(), _vm->_championMan->_party._scents[scentOrdinal].getMapY())); + int16 scentOrdinal = championMan.getScentOrdinal(mapY, mapX); + if (scentOrdinal && ((championMan._party._scentStrengths[_vm->ordinalToIndex(scentOrdinal)] + _vm->getRandomNumber(4)) > (30 - (smellRange << 1)))) { /* If there is a fresh enough party scent on the group square */ + return _vm->indexToOrdinal(getDirsWhereDestIsVisibleFromSource(mapY, mapX, championMan._party._scents[scentOrdinal].getMapX(), championMan._party._scents[scentOrdinal].getMapY())); } return 0; } @@ -1424,6 +1430,8 @@ bool GroupMan::isArchenemyDoubleMovementPossible(CreatureInfo *info, int16 mapX, bool GroupMan::isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16 creatureIndex) { static const uint8 creatureAttackSounds[11] = { 3, 7, 14, 15, 19, 21, 29, 30, 31, 4, 16 }; /* Atari ST: { 3, 7, 14, 15, 19, 21, 4, 16 } */ + ChampionMan &championMan = *_vm->_championMan; + _vm->_projexpl->_lastCreatureAttackTime = _vm->_gameTime; ActiveGroup activeGroup = _activeGroups[group->getActiveGroupIndex()]; CreatureType creatureType = group->_type; @@ -1495,13 +1503,13 @@ bool GroupMan::isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16 if (getFlag(creatureInfo->_attributes, kDMCreatureMaskAttackAnyChamp)) { championIndex = _vm->getRandomNumber(4); int cpt; - for (cpt = 0; (cpt < 4) && !_vm->_championMan->_champions[championIndex]._currHealth; cpt++) + for (cpt = 0; (cpt < 4) && !championMan._champions[championIndex]._currHealth; cpt++) championIndex = _vm->turnDirRight(championIndex); if (cpt == 4) return false; } else { - championIndex = _vm->_championMan->getTargetChampionIndex(mapX, mapY, targetCell); + championIndex = championMan.getTargetChampionIndex(mapX, mapY, targetCell); if (championIndex < 0) return false; } @@ -1510,7 +1518,7 @@ bool GroupMan::isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16 stealFromChampion(group, championIndex); else { int16 damage = getChampionDamage(group, championIndex) + 1; - Champion *damagedChampion = &_vm->_championMan->_champions[championIndex]; + Champion *damagedChampion = &championMan._champions[championIndex]; if (damage > damagedChampion->_maximumDamageReceived) { damagedChampion->_maximumDamageReceived = damage; damagedChampion->_directionMaximumDamageReceived = _vm->returnOppositeDir((Direction)primaryDirectionToParty); @@ -1547,12 +1555,13 @@ void GroupMan::setOrderedCellsToAttack(signed char *orderedCellsToAttack, int16 void GroupMan::stealFromChampion(Group *group, uint16 championIndex) { static unsigned char G0394_auc_StealFromSlotIndices[8]; /* Initialized with 0 bytes by C loader */ + ChampionMan &championMan = *_vm->_championMan; bool objectStolen = false; - Champion *champion = &_vm->_championMan->_champions[championIndex]; - int16 percentage = 100 - _vm->_championMan->getDexterity(champion); + Champion *champion = &championMan._champions[championIndex]; + int16 percentage = 100 - championMan.getDexterity(champion); uint16 slotIdx = _vm->getRandomNumber(8); - while ((percentage > 0) && !_vm->_championMan->isLucky(champion, percentage)) { + while ((percentage > 0) && !championMan.isLucky(champion, percentage)) { uint16 stealFromSlotIndex = G0394_auc_StealFromSlotIndices[slotIdx]; if (stealFromSlotIndex == kDMSlotBackpackLine1_1) stealFromSlotIndex += _vm->getRandomNumber(17); /* Select a random slot in the backpack */ @@ -1560,7 +1569,7 @@ void GroupMan::stealFromChampion(Group *group, uint16 championIndex) { Thing slotThing = champion->_slots[stealFromSlotIndex]; if ((slotThing != Thing::_none)) { objectStolen = true; - slotThing = _vm->_championMan->getObjectRemovedFromSlot(championIndex, stealFromSlotIndex); + slotThing = championMan.getObjectRemovedFromSlot(championIndex, stealFromSlotIndex); if (group->_slot == Thing::_endOfList) { group->_slot = slotThing; /* BUG0_12 An object is cloned and appears at two different locations in the dungeon and/or inventory. The game may crash when interacting with this object. If a Giggler with no possessions steals an object that was previously in a chest and was not the last object in the chest then the objects that followed it are cloned. In the chest, the object is part of a linked list of objects that is not reset when the object is removed from the chest and placed in the inventory (but not in the dungeon), nor when it is stolen and added as the first Giggler possession. If the Giggler already has a possession before stealing the object then this does not create a cloned object. @@ -1569,7 +1578,7 @@ void GroupMan::stealFromChampion(Group *group, uint16 championIndex) { } else { _vm->_dungeonMan->linkThingToList(slotThing, group->_slot, kDMMapXNotOnASquare, 0); } - _vm->_championMan->drawChampionState((ChampionIndex)championIndex); + championMan.drawChampionState((ChampionIndex)championIndex); } ++slotIdx; slotIdx &= 0x0007; @@ -1583,21 +1592,22 @@ void GroupMan::stealFromChampion(Group *group, uint16 championIndex) { int16 GroupMan::getChampionDamage(Group *group, uint16 champIndex) { unsigned char allowedWoundMasks[4] = {32, 16, 8, 4}; // @ G0024_auc_Graphic562_WoundProbabilityIndexToWoundMask + ChampionMan &championMan = *_vm->_championMan; - Champion *curChampion = &_vm->_championMan->_champions[champIndex]; - if (champIndex >= _vm->_championMan->_partyChampionCount) + Champion *curChampion = &championMan._champions[champIndex]; + if (champIndex >= championMan._partyChampionCount) return 0; if (!curChampion->_currHealth) return 0; - if (_vm->_championMan->_partyIsSleeping) - _vm->_championMan->wakeUp(); + if (championMan._partyIsSleeping) + championMan.wakeUp(); int16 doubledMapDifficulty = _vm->_dungeonMan->_currMap->_difficulty << 1; CreatureInfo creatureInfo = _vm->_dungeonMan->_creatureInfos[group->_type]; - _vm->_championMan->addSkillExperience(champIndex, kDMSkillParry, creatureInfo.getExperience()); - if (_vm->_championMan->_partyIsSleeping || (((_vm->_championMan->getDexterity(curChampion) < (_vm->getRandomNumber(32) + creatureInfo._dexterity + doubledMapDifficulty - 16)) || !_vm->getRandomNumber(4)) && !_vm->_championMan->isLucky(curChampion, 60))) { + championMan.addSkillExperience(champIndex, kDMSkillParry, creatureInfo.getExperience()); + if (championMan._partyIsSleeping || (((championMan.getDexterity(curChampion) < (_vm->getRandomNumber(32) + creatureInfo._dexterity + doubledMapDifficulty - 16)) || !_vm->getRandomNumber(4)) && !championMan.isLucky(curChampion, 60))) { uint16 allowedWound; uint16 woundTest = _vm->getRandomNumber(65536); if (woundTest & 0x0070) { @@ -1611,7 +1621,7 @@ int16 GroupMan::getChampionDamage(Group *group, uint16 champIndex) { } else allowedWound = woundTest & 0x0001; /* 0 (Ready hand) or 1 (action hand) */ - int16 attack = (_vm->getRandomNumber(16) + creatureInfo._attack + doubledMapDifficulty) - (_vm->_championMan->getSkillLevel(champIndex, kDMSkillParry) << 1); + int16 attack = (_vm->getRandomNumber(16) + creatureInfo._attack + doubledMapDifficulty) - (championMan.getSkillLevel(champIndex, kDMSkillParry) << 1); if (attack <= 1) { if (_vm->getRandomNumber(2)) return 0; @@ -1626,15 +1636,15 @@ int16 GroupMan::getChampionDamage(Group *group, uint16 champIndex) { if (_vm->getRandomNumber(2)) attack -= _vm->getRandomNumber((attack >> 1) + 1) - 1; - int16 damage = _vm->_championMan->addPendingDamageAndWounds_getDamage(champIndex, attack, allowedWound, creatureInfo._attackType); + int16 damage = championMan.addPendingDamageAndWounds_getDamage(champIndex, attack, allowedWound, creatureInfo._attackType); if (damage) { _vm->_sound->requestPlay(kDMSoundIndexChampion0Damaged + champIndex, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kDMSoundModePlayOneTickLater); uint16 poisonAttack = creatureInfo._poisonAttack; if (poisonAttack && _vm->getRandomNumber(2)) { - poisonAttack = _vm->_championMan->getStatisticAdjustedAttack(curChampion, kDMStatVitality, poisonAttack); + poisonAttack = championMan.getStatisticAdjustedAttack(curChampion, kDMStatVitality, poisonAttack); if (poisonAttack >= 0) - _vm->_championMan->championPoison(champIndex, poisonAttack); + championMan.championPoison(champIndex, poisonAttack); } return damage; } @@ -1812,10 +1822,12 @@ int16 GroupMan::getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16 int16 GroupMan::getMeleeActionDamage(Champion *champ, int16 champIndex, Group *group, int16 creatureIndex, int16 mapX, int16 mapY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex) { int16 L0565_i_Damage = 0; int16 L0566_i_Damage = 0; - int16 L0568_i_Defense; + int16 defense; int16 L0569_i_Outcome; - if (champIndex >= _vm->_championMan->_partyChampionCount) + ChampionMan &championMan = *_vm->_championMan; + + if (champIndex >= championMan._partyChampionCount) return 0; if (!champ->_currHealth) @@ -1829,23 +1841,22 @@ int16 GroupMan::getMeleeActionDamage(Champion *champ, int16 champIndex, Group *g clearFlag(actionHitProbability, kDMActionMaskHitNonMaterialCreatures); if ((!getFlag(creatureInfo->_attributes, kDMCreatureMaskNonMaterial) || actionHitsNonMaterialCreatures) && - ((_vm->_championMan->getDexterity(champ) > (_vm->getRandomNumber(32) + creatureInfo->_dexterity + doubledMapDifficulty - 16)) || - (!_vm->getRandomNumber(4)) || - (_vm->_championMan->isLucky(champ, 75 - actionHitProbability)))) { + ((championMan.getDexterity(champ) > (_vm->getRandomNumber(32) + creatureInfo->_dexterity + doubledMapDifficulty - 16)) || + (!_vm->getRandomNumber(4)) || (championMan.isLucky(champ, 75 - actionHitProbability)))) { - L0565_i_Damage = _vm->_championMan->getStrength(champIndex, kDMSlotActionHand); + L0565_i_Damage = championMan.getStrength(champIndex, kDMSlotActionHand); if (!(L0565_i_Damage)) goto T0231009; L0565_i_Damage += _vm->getRandomNumber((L0565_i_Damage >> 1) + 1); L0565_i_Damage = ((long)L0565_i_Damage * (long)actionDamageFactor) >> 5; - L0568_i_Defense = _vm->getRandomNumber(32) + creatureInfo->_defense + doubledMapDifficulty; + defense = _vm->getRandomNumber(32) + creatureInfo->_defense + doubledMapDifficulty; if (actionHandObjectIconIndex == kDMIconIndiceWeaponDiamondEdge) - L0568_i_Defense -= L0568_i_Defense >> 2; + defense -= defense >> 2; else if (actionHandObjectIconIndex == kDMIconIndiceWeaponHardcleaveExecutioner) - L0568_i_Defense -= L0568_i_Defense >> 3; + defense -= defense >> 3; - L0565_i_Damage += _vm->getRandomNumber(32) - L0568_i_Defense; + L0565_i_Damage += _vm->getRandomNumber(32) - defense; L0566_i_Damage = L0565_i_Damage; if (L0566_i_Damage <= 1) { T0231009: @@ -1872,20 +1883,20 @@ T0231009: && !(L0565_i_Damage >>= 1)) goto T0231015; - if (_vm->getRandomNumber(64) < _vm->_championMan->getSkillLevel(champIndex, skillIndex)) + if (_vm->getRandomNumber(64) < championMan.getSkillLevel(champIndex, skillIndex)) L0565_i_Damage += L0565_i_Damage + 10; L0569_i_Outcome = groupGetDamageCreatureOutcome(group, creatureIndex, mapX, mapY, L0565_i_Damage, true); - _vm->_championMan->addSkillExperience(champIndex, skillIndex, (L0565_i_Damage * creatureInfo->getExperience() >> 4) + 3); - _vm->_championMan->decrementStamina(champIndex, _vm->getRandomNumber(4) + 4); + championMan.addSkillExperience(champIndex, skillIndex, (L0565_i_Damage * creatureInfo->getExperience() >> 4) + 3); + championMan.decrementStamina(champIndex, _vm->getRandomNumber(4) + 4); goto T0231016; } T0231015: L0565_i_Damage = 0; L0569_i_Outcome = kDMKillOutcomeNoCreaturesInGroup; - _vm->_championMan->decrementStamina(champIndex, _vm->getRandomNumber(2) + 2); + championMan.decrementStamina(champIndex, _vm->getRandomNumber(2) + 2); T0231016: - _vm->_championMan->drawChampionState((ChampionIndex)champIndex); + championMan.drawChampionState((ChampionIndex)champIndex); if (L0569_i_Outcome != kDMKillOutcomeAllCreaturesInGroup) { processEvents29to41(mapX, mapY, kDMEventTypeCreateReactionPartyIsAdjacent, 0); } diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 184ece7efa..5cb861397d 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -88,8 +88,9 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { static Box boxFloppyZzzCross(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross DisplayMan &display = *_vm->_displayMan; + ChampionMan &championMan = *_vm->_championMan; - if ((championIndex != kDMChampionCloseInventory) && !_vm->_championMan->_champions[championIndex]._currHealth) + if ((championIndex != kDMChampionCloseInventory) && !championMan._champions[championIndex]._currHealth) return; if (_vm->_pressingMouth || _vm->_pressingEye) @@ -104,12 +105,12 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { if (inventoryChampionOrdinal) { _inventoryChampionOrdinal = _vm->indexToOrdinal(kDMChampionNone); closeChest(); - Champion *champion = &_vm->_championMan->_champions[_vm->ordinalToIndex(inventoryChampionOrdinal)]; - if (champion->_currHealth && !_vm->_championMan->_candidateChampionOrdinal) { + Champion *champion = &championMan._champions[_vm->ordinalToIndex(inventoryChampionOrdinal)]; + if (champion->_currHealth && !championMan._candidateChampionOrdinal) { setFlag(champion->_attributes, kDMAttributeStatusBox); - _vm->_championMan->drawChampionState((ChampionIndex)_vm->ordinalToIndex(inventoryChampionOrdinal)); + championMan.drawChampionState((ChampionIndex)_vm->ordinalToIndex(inventoryChampionOrdinal)); } - if (_vm->_championMan->_partyIsSleeping) { + if (championMan._partyIsSleeping) { _vm->_eventMan->hideMouse(); return; } @@ -129,9 +130,9 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { if (!inventoryChampionOrdinal) display.shadeScreenBox(&display._boxMovementArrows, kDMColorBlack); - Champion *champion = &_vm->_championMan->_champions[championIndex]; + Champion *champion = &championMan._champions[championIndex]; display.loadIntoBitmap(kDMGraphicIdxInventory, display._bitmapViewport); - if (_vm->_championMan->_candidateChampionOrdinal) + if (championMan._candidateChampionOrdinal) display.fillBoxBitmap(display._bitmapViewport, boxFloppyZzzCross, kDMColorDarkestGray, k112_byteWidthViewport, k136_heightViewport); switch (_vm->getGameLanguage()) { // localized @@ -153,10 +154,10 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { _vm->_textMan->printToViewport(5, 132, kDMColorLightestGray, "MANA"); for (uint16 i = kDMSlotReadyHand; i < kDMSlotChest1; i++) - _vm->_championMan->drawSlot(championIndex, i); + championMan.drawSlot(championIndex, i); setFlag(champion->_attributes, kDMAttributeViewport | kDMAttributeStatusBox | kDMAttributePanel | kDMAttributeLoad | kDMAttributeStatistics | kDMAttributeNameTitle); - _vm->_championMan->drawChampionState(championIndex); + championMan.drawChampionState(championIndex); _vm->_eventMan->_mousePointerBitmapUpdated = true; _vm->_eventMan->hideMouse(); _vm->_eventMan->_secondaryMouseInput = _vm->_eventMan->_secondaryMouseInputChampionInventory; @@ -687,13 +688,14 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { void InventoryMan::setDungeonViewPalette() { static const int16 palIndexToLightAmmount[6] = {99, 75, 50, 25, 1, 0}; // @ G0040_ai_Graphic562_PaletteIndexToLightAmount DisplayMan &display = *_vm->_displayMan; + ChampionMan &championMan = *_vm->_championMan; if (_vm->_dungeonMan->_currMap->_difficulty == 0) { display._dungeonViewPaletteIndex = 0; /* Brightest color palette index */ } else { /* Get torch light power from both hands of each champion in the party */ int16 counter = 4; /* BUG0_01 Coding error without consequence. The hands of four champions are inspected even if there are less champions in the party. No consequence as the data in unused champions is set to 0 and _vm->_objectMan->f32_getObjectType then returns -1 */ - Champion *curChampion = _vm->_championMan->_champions; + Champion *curChampion = championMan._champions; int16 torchesLightPower[8]; int16 *curTorchLightPower = torchesLightPower; while (counter--) { @@ -735,12 +737,12 @@ void InventoryMan::setDungeonViewPalette() { curTorchLightPower = torchesLightPower; while (torchIndex--) { if (*curTorchLightPower) { - totalLightAmount += (_vm->_championMan->_lightPowerToLightAmount[*curTorchLightPower] << torchLightAmountMultiplier) >> 6; + totalLightAmount += (championMan._lightPowerToLightAmount[*curTorchLightPower] << torchLightAmountMultiplier) >> 6; torchLightAmountMultiplier = MAX(0, torchLightAmountMultiplier - 1); } curTorchLightPower++; } - totalLightAmount += _vm->_championMan->_party._magicalLightAmount; + totalLightAmount += championMan._party._magicalLightAmount; /* Select palette corresponding to the total light amount */ const int16 *curLightAmount = palIndexToLightAmmount; int16 paletteIndex; @@ -758,12 +760,13 @@ void InventoryMan::setDungeonViewPalette() { } void InventoryMan::decreaseTorchesLightPower() { + ChampionMan &championMan = *_vm->_championMan; bool torchChargeCountChanged = false; - int16 championCount = _vm->_championMan->_partyChampionCount; - if (_vm->_championMan->_candidateChampionOrdinal) + int16 championCount = championMan._partyChampionCount; + if (championMan._candidateChampionOrdinal) championCount--; - Champion *curChampion = _vm->_championMan->_champions; + Champion *curChampion = championMan._champions; while (championCount--) { int16 slotIndex = kDMSlotActionHand + 1; while (slotIndex--) { @@ -783,7 +786,7 @@ void InventoryMan::decreaseTorchesLightPower() { if (torchChargeCountChanged) { setDungeonViewPalette(); - _vm->_championMan->drawChangedObjectIcons(); + championMan.drawChangedObjectIcons(); } } @@ -793,6 +796,7 @@ void InventoryMan::drawChampionSkillsAndStatistics() { static const char *statisticNamesFR[7] = {"L", "FORCE", "DEXTERITE", "SAGESSE", "VITALITE", "ANTI-MAGIE", "ANTI-FEU"}; DisplayMan &display = *_vm->_displayMan; + ChampionMan &championMan = *_vm->_championMan; const char **statisticNames; switch (_vm->getGameLanguage()) { // localized @@ -809,11 +813,11 @@ void InventoryMan::drawChampionSkillsAndStatistics() { closeChest(); uint16 championIndex = _vm->ordinalToIndex(_inventoryChampionOrdinal); - Champion *curChampion = &_vm->_championMan->_champions[championIndex]; + Champion *curChampion = &championMan._champions[championIndex]; display.blitToViewport(display.getNativeBitmapOrGraphic(kDMGraphicIdxPanelEmpty), _boxPanel, k72_byteWidth, kDMColorRed, 73); int16 textPosY = 58; for (uint16 idx = kDMSkillFighter; idx <= kDMSkillWizard; idx++) { - int16 skillLevel = MIN((uint16)16, _vm->_championMan->getSkillLevel(championIndex, idx | kDMIgnoreTemporaryExperience)); + int16 skillLevel = MIN((uint16)16, championMan.getSkillLevel(championIndex, idx | kDMIgnoreTemporaryExperience)); if (skillLevel == 1) continue; @@ -822,10 +826,10 @@ void InventoryMan::drawChampionSkillsAndStatistics() { switch (_vm->getGameLanguage()) { // localized case Common::FR_FRA: // Fix original bug: Due to a copy&paste error, the string was concatenate then overwritten be the last part - displayString = Common::String::format("%s %s", _vm->_championMan->_baseSkillName[idx], _skillLevelNames[skillLevel - 2]); + displayString = Common::String::format("%s %s", championMan._baseSkillName[idx], _skillLevelNames[skillLevel - 2]); break; default: // English and German versions are built the same way - displayString = Common::String::format("%s %s", _skillLevelNames[skillLevel - 2], _vm->_championMan->_baseSkillName[idx]); + displayString = Common::String::format("%s %s", _skillLevelNames[skillLevel - 2], championMan._baseSkillName[idx]); break; } _vm->_textMan->printToViewport(108, textPosY, kDMColorLightestGray, displayString.c_str()); @@ -844,8 +848,8 @@ void InventoryMan::drawChampionSkillsAndStatistics() { else statisticColor = kDMColorLightestGray; - _vm->_textMan->printToViewport(174, textPosY, (Color)statisticColor, _vm->_championMan->getStringFromInteger(statisticCurrentValue, true, 3).c_str()); - Common::String displayString = "/" + _vm->_championMan->getStringFromInteger(statisticMaximumValue, true, 3); + _vm->_textMan->printToViewport(174, textPosY, (Color)statisticColor, championMan.getStringFromInteger(statisticCurrentValue, true, 3).c_str()); + Common::String displayString = "/" + championMan.getStringFromInteger(statisticMaximumValue, true, 3); _vm->_textMan->printToViewport(192, textPosY, kDMColorLightestGray, displayString.c_str()); textPosY += 7; } @@ -886,8 +890,9 @@ void InventoryMan::clickOnMouth() { }; DisplayMan &display = *_vm->_displayMan; + ChampionMan &championMan = *_vm->_championMan; - if (_vm->_championMan->_leaderEmptyHanded) { + if (championMan._leaderEmptyHanded) { if (_panelContent == kDMPanelContentFoodWaterPoisoned) return; @@ -906,10 +911,10 @@ void InventoryMan::clickOnMouth() { return; } - if (_vm->_championMan->_candidateChampionOrdinal) + if (championMan._candidateChampionOrdinal) return; - Thing handThing = _vm->_championMan->_leaderHandObject; + Thing handThing = championMan._leaderHandObject; if (!getFlag(_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(handThing)]._allowedSlots, kDMMaskMouth)) return; @@ -917,7 +922,7 @@ void InventoryMan::clickOnMouth() { uint16 handThingType = handThing.getType(); uint16 handThingWeight = _vm->_dungeonMan->getObjectWeight(handThing); uint16 championIndex = _vm->ordinalToIndex(_inventoryChampionOrdinal); - Champion *curChampion = &_vm->_championMan->_champions[championIndex]; + Champion *curChampion = &championMan._champions[championIndex]; Junk *junkData = (Junk *)_vm->_dungeonMan->getThingData(handThing); bool removeObjectFromLeaderHand; if ((iconIndex >= kDMIconIndiceJunkWater) && (iconIndex <= kDMIconIndiceJunkWaterSkin)) { @@ -935,7 +940,7 @@ void InventoryMan::clickOnMouth() { } _vm->_eventMan->showMouse(); if (removeObjectFromLeaderHand) - _vm->_championMan->getObjectRemovedFromLeaderHand(); + championMan.getObjectRemovedFromLeaderHand(); if (handThingType == kDMThingTypePotion) { uint16 potionPower = ((Potion *)junkData)->getPower(); @@ -956,7 +961,7 @@ void InventoryMan::clickOnMouth() { adjustStatisticCurrentValue(curChampion, kDMStatVitality, adjustedPotionPower); break; case kDMPotionTypeAntivenin: - _vm->_championMan->unpoison(championIndex); + championMan.unpoison(championIndex); break; case kDMPotionTypeMon: curChampion->_currStamina += MIN(curChampion->_maxStamina - curChampion->_currStamina, curChampion->_maxStamina / counter); @@ -1025,9 +1030,9 @@ void InventoryMan::clickOnMouth() { display.updateScreen(); } } else { - _vm->_championMan->drawChangedObjectIcons(); - _vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._load += _vm->_dungeonMan->getObjectWeight(handThing) - handThingWeight; - setFlag(_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._attributes, kDMAttributeLoad); + championMan.drawChangedObjectIcons(); + championMan._champions[championMan._leaderIndex]._load += _vm->_dungeonMan->getObjectWeight(handThing) - handThingWeight; + setFlag(championMan._champions[championMan._leaderIndex]._attributes, kDMAttributeLoad); } _vm->_sound->requestPlay(kDMSoundIndexSwallow, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, kDMSoundModePlayImmediately); setFlag(curChampion->_attributes, kDMAttributeStatistics); @@ -1035,7 +1040,7 @@ void InventoryMan::clickOnMouth() { if (_panelContent == kDMPanelContentFoodWaterPoisoned) setFlag(curChampion->_attributes, kDMAttributePanel); - _vm->_championMan->drawChampionState((ChampionIndex)championIndex); + championMan.drawChampionState((ChampionIndex)championIndex); _vm->_eventMan->hideMouse(); } @@ -1058,6 +1063,8 @@ void InventoryMan::adjustStatisticCurrentValue(Champion *champ, uint16 statIndex } void InventoryMan::clickOnEye() { + ChampionMan &championMan = *_vm->_championMan; + _vm->_eventMan->_ignoreMouseMovements = true; _vm->_pressingEye = true; if (!_vm->_eventMan->isMouseButtonDown(kDMMouseButtonLeft)) { @@ -1072,11 +1079,11 @@ void InventoryMan::clickOnEye() { _vm->_eventMan->hideMouse(); _vm->delay(8); drawIconToViewport(kDMIconIndiceEyeLooking, 12, 13); - if (_vm->_championMan->_leaderEmptyHanded) + if (championMan._leaderEmptyHanded) drawChampionSkillsAndStatistics(); else { _vm->_objectMan->clearLeaderObjectName(); - drawPanelObject(_vm->_championMan->_leaderHandObject, true); + drawPanelObject(championMan._leaderHandObject, true); } _vm->_displayMan->drawViewport(k0_viewportNotDungeonView); } 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: diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 97d590f4c3..c6a77ece46 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -868,14 +868,15 @@ bool Timeline::hasWeaponMovedSlot(int16 champIndex, Champion *champ, uint16 sour } void Timeline::processEventHideDamageReceived(uint16 champIndex) { + InventoryMan &inventory = *_vm->_inventoryMan; Champion *curChampion = &_vm->_championMan->_champions[champIndex]; curChampion->_hideDamageReceivedIndex = -1; if (!curChampion->_currHealth) return; - if (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal) { + if (_vm->indexToOrdinal(champIndex) == inventory._inventoryChampionOrdinal) { _vm->_eventMan->showMouse(); - _vm->_inventoryMan->drawStatusBoxPortrait((ChampionIndex)champIndex); + inventory.drawStatusBoxPortrait((ChampionIndex)champIndex); _vm->_eventMan->hideMouse(); } else { setFlag(curChampion->_attributes, kDMAttributeNameTitle); |