diff options
author | Bendegúz Nagy | 2016-08-26 22:50:26 +0200 |
---|---|---|
committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 |
commit | 2c860f106977677f59c3843312ea19b24bfe5d31 (patch) | |
tree | e756e0802a0c00c6663ac0239414982281dfa2bf | |
parent | 2edabfae994014bcc27fb6f45760b5f67175ba6e (diff) | |
download | scummvm-rg350-2c860f106977677f59c3843312ea19b24bfe5d31.tar.gz scummvm-rg350-2c860f106977677f59c3843312ea19b24bfe5d31.tar.bz2 scummvm-rg350-2c860f106977677f59c3843312ea19b24bfe5d31.zip |
DM: Some soft refactoring, in order to silent some CppCheck warnings
-rw-r--r-- | engines/dm/dungeonman.cpp | 215 | ||||
-rw-r--r-- | engines/dm/eventman.cpp | 13 | ||||
-rw-r--r-- | engines/dm/inventory.cpp | 18 | ||||
-rw-r--r-- | engines/dm/movesens.cpp | 5 |
4 files changed, 127 insertions, 124 deletions
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 3b009c2e31..545b11f553 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -419,8 +419,6 @@ DungeonMan::~DungeonMan() { delete[] _g260_dungeonTextData; delete[] _g279_dungeonMapData; for (uint16 i = 0; i < 16; ++i) { - if (_g284_thingData[i]) - delete[] _g284_thingData[i][0]; delete[] _g284_thingData[i]; } } @@ -653,34 +651,34 @@ void DungeonMan::f434_loadDungeonFile() { continue; if (_g284_thingData[thingType]) { - delete[] _g284_thingData[thingType][0]; delete[] _g284_thingData[thingType]; } - _g284_thingData[thingType] = new uint16*[_g278_dungeonFileHeader._thingCounts[thingType]]; - _g284_thingData[thingType][0] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount]; - for (uint16 i = 0; i < _g278_dungeonFileHeader._thingCounts[thingType]; ++i) - _g284_thingData[thingType][i] = _g284_thingData[thingType][0] + i * thingStoreWordCount; + _g284_thingData[thingType] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount]; if (thingType == k4_GroupThingType) { - for (uint16 i = 0; i < thingCount; ++i) + for (uint16 i = 0; i < thingCount; ++i) { + uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount; for (uint16 j = 0; j < thingStoreWordCount; ++j) { if (j == 2 || j == 3) - _g284_thingData[thingType][i][j] = dunDataStream.readByte(); + nextSlot[j] = dunDataStream.readByte(); else - _g284_thingData[thingType][i][j] = dunDataStream.readUint16BE(); + nextSlot[j] = dunDataStream.readUint16BE(); } + } } else if (thingType == k14_ProjectileThingType) { for (uint16 i = 0; i < thingCount; ++i) { - _g284_thingData[thingType][i][0] = dunDataStream.readUint16BE(); - _g284_thingData[thingType][i][1] = dunDataStream.readUint16BE(); - _g284_thingData[thingType][i][2] = dunDataStream.readByte(); - _g284_thingData[thingType][i][3] = dunDataStream.readByte(); - _g284_thingData[thingType][i][4] = dunDataStream.readUint16BE(); + uint16 *nextSlot = _g284_thingData[thingType] + i * thingStoreWordCount; + nextSlot[0] = dunDataStream.readUint16BE(); + nextSlot[1] = dunDataStream.readUint16BE(); + nextSlot[2] = dunDataStream.readByte(); + nextSlot[3] = dunDataStream.readByte(); + nextSlot[4] = dunDataStream.readUint16BE(); } } else { for (uint16 i = 0; i < thingCount; ++i) { + uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount; for (uint16 j = 0; j < thingStoreWordCount; ++j) - _g284_thingData[thingType][i][j] = dunDataStream.readUint16BE(); + nextSlot[j] = dunDataStream.readUint16BE(); } } @@ -688,7 +686,7 @@ void DungeonMan::f434_loadDungeonFile() { if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType) _vm->_timeline->_g369_eventMaxCount += _g278_dungeonFileHeader._thingCounts[thingType]; for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) { - _g284_thingData[thingType][thingCount + i][0] = Thing::_none.toUint16(); + (_g284_thingData[thingType] + (thingCount + i) * thingStoreWordCount)[0] = Thing::_none.toUint16(); } } } @@ -757,33 +755,36 @@ void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) { Square DungeonMan::f151_getSquare(int16 mapX, int16 mapY) { - bool isInXBounds = (mapX >= 0) && (mapX < _g273_currMapWidth); - bool isInYBounds = (mapY >= 0) && (mapY < _g274_currMapHeight); - - if (isInXBounds && isInYBounds) - return Square(_g271_currMapData[mapX][mapY]); - - - Square tmpSquare; - if (isInYBounds) { - tmpSquare.set(_g271_currMapData[0][mapY]); - if (mapX == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) - return Square(k0_WallElemType).set(k0x0004_WallEastRandOrnAllowed); - - tmpSquare.set(_g271_currMapData[_g273_currMapWidth - 1][mapY]); - if (mapX == _g273_currMapWidth && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) - return Square(k0_WallElemType).set(k0x0001_WallWestRandOrnAllowed); - } else if (isInXBounds) { - tmpSquare.set(_g271_currMapData[mapX][0]); - if (mapY == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) - return Square(k0_WallElemType).set(k0x0002_WallSouthRandOrnAllowed); - - tmpSquare.set(_g271_currMapData[mapX][_g274_currMapHeight - 1]); - if (mapY == _g274_currMapHeight && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) - return Square((k0_WallElemType << 5) | k0x0008_WallNorthRandOrnAllowed); + int16 L0248_i_Multiple; +#define AL0248_B_IsMapXInBounds L0248_i_Multiple +#define AL0248_i_SquareType L0248_i_Multiple + int16 L0249_i_Multiple; +#define AL0249_B_IsMapYInBounds L0249_i_Multiple +#define AL0249_i_SquareType L0249_i_Multiple + + AL0249_B_IsMapYInBounds = (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight); + if ((AL0248_B_IsMapXInBounds = (mapX >= 0) && (mapX < _vm->_dungeonMan->_g273_currMapWidth)) && AL0249_B_IsMapYInBounds) { + return Square(_vm->_dungeonMan->_g271_currMapData[mapX][mapY]); } - return Square(k0_WallElemType); + if (AL0249_B_IsMapYInBounds) { + if (((mapX == -1) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[0][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) { + return Square(k0_ElementTypeWall, k0x0004_WallEastRandOrnAllowed); + } + if (((mapX == _vm->_dungeonMan->_g273_currMapWidth) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[_vm->_dungeonMan->_g273_currMapWidth - 1][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) { + return Square(k0_ElementTypeWall, k0x0001_WallWestRandOrnAllowed); + } + } else { + if (AL0248_B_IsMapXInBounds) { + if (((mapY == -1) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][0]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) { + return Square(k0_ElementTypeWall, k0x0002_WallSouthRandOrnAllowed); + } + if (((mapY == _vm->_dungeonMan->_g274_currMapHeight) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][_vm->_dungeonMan->_g274_currMapHeight - 1]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) { + return Square(k0_ElementTypeWall, k0x0008_WallNorthRandOrnAllowed); + } + } + } + return Square(k0_ElementTypeWall, 0); } Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { @@ -792,17 +793,23 @@ Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 st } int16 DungeonMan::f160_getSquareFirstThingIndex(int16 mapX, int16 mapY) { - if (mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight || !Square(_g271_currMapData[mapX][mapY]).get(k0x0010_ThingListPresent)) - return -1; + uint16 L0260_ui_ThingIndex; + int16 L0261_i_MapY; + register unsigned char* L0262_puc_Square; - int16 y = 0; - uint16 index = _g270_currMapColCumulativeSquareFirstThingCount[mapX]; - byte* square = _g271_currMapData[mapX]; - while (y++ != mapY) - if (Square(*square++).get(k0x0010_ThingListPresent)) - index++; - return index; + L0262_puc_Square = _vm->_dungeonMan->_g271_currMapData[mapX]; + if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight) || !getFlag(L0262_puc_Square[mapY], k0x0010_ThingListPresent)) { + return -1; + } + L0261_i_MapY = 0; + L0260_ui_ThingIndex = _vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount[mapX]; + while (L0261_i_MapY++ != mapY) { + if (getFlag(*L0262_puc_Square++, k0x0010_ThingListPresent)) { + L0260_ui_ThingIndex++; + } + } + return L0260_ui_ThingIndex; } Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) { @@ -959,31 +966,33 @@ T0172049_Footprints: aspectArray[k1_FirstGroupOrObjectAspect] = thing.toUint16(); } -void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, +void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir, int16 mapX, int16 mapY, bool isFakeWall) { - int16 ornCount = _g269_currMap->_randWallOrnCount; - - turnDirRight(dir); - aspectArray[k2_RightWallOrnOrdAspect] = f170_getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); - turnDirRight(dir); - aspectArray[k3_FrontWallOrnOrdAspect] = f170_getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); - turnDirRight(dir); - aspectArray[k4_LeftWallOrnOrdAspect] = f170_getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); - - if (isFakeWall || mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight) { - for (uint16 i = k2_RightWallOrnOrdAspect; i <= k4_LeftWallOrnOrdAspect; ++i) { - if (f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[i]))) - aspectArray[i] = 0; + int16 L0306_i_Multiple; +#define AL0306_i_RandomWallOrnamentCount L0306_i_Multiple +#define AL0306_i_SideIndex L0306_i_Multiple + + + AL0306_i_RandomWallOrnamentCount = _vm->_dungeonMan->_g269_currMap->_randWallOrnCount; + aspectArray[k2_RightWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(leftAllowed, AL0306_i_RandomWallOrnamentCount, mapX, ++mapY * (M21_normalizeModulo4(++dir) + 1), 30); + aspectArray[k3_FrontWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(frontAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY * (M21_normalizeModulo4(++dir) + 1), 30); + aspectArray[k4_LeftWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(rightAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY-- * (M21_normalizeModulo4(++dir) + 1), 30); + if (isFakeWall || (mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight)) { /* If square is a fake wall or is out of map bounds */ + for (AL0306_i_SideIndex = k2_RightWallOrnOrdAspect; AL0306_i_SideIndex <= k4_LeftWallOrnOrdAspect; AL0306_i_SideIndex++) { /* Loop to remove any random ornament that is an alcove */ + if (_vm->_dungeonMan->f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[AL0306_i_SideIndex]))) { + aspectArray[AL0306_i_SideIndex] = 0; + } } } } int16 DungeonMan::f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) { - int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1) - + (3000 + (_g272_currMapIndex << 6) + _g273_currMapWidth + _g274_currMapHeight) * 11 - + _g278_dungeonFileHeader._ornamentRandomSeed) >> 2) % modulo; - if (allowed && index < count) - return _vm->M0_indexToOrdinal(index); + int16 L0305_i_RandomOrnamentIndex; + + + if (allowed && ((L0305_i_RandomOrnamentIndex = f169_getRandomOrnamentIndex((int16)2000 + (mapX << 5) + mapY, (int16)3000 + (_vm->_dungeonMan->_g272_currMapIndex << (int16)6) + _vm->_dungeonMan->_g273_currMapWidth + _vm->_dungeonMan->_g274_currMapHeight, modulo)) < count)) { + return _vm->M0_indexToOrdinal(L0305_i_RandomOrnamentIndex); + } return 0; } @@ -997,7 +1006,7 @@ bool DungeonMan::f149_isWallOrnAnAlcove(int16 wallOrnIndex) { } uint16 *DungeonMan::f156_getThingData(Thing thing) { - return _g284_thingData[thing.getType()][thing.getIndex()]; + return _g284_thingData[thing.getType()] + thing.getIndex() * g235_ThingDataWordCount[thing.getType()]; } uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) { @@ -1005,7 +1014,7 @@ uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) { } Thing DungeonMan::f159_getNextThing(Thing thing) { - return Thing(f156_getThingData(thing)[0]); // :) + return Thing(f156_getThingData(thing)[0]); } char g255_MessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings @@ -1110,7 +1119,7 @@ char g257_InscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_ void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) { - TextString textString(_g284_thingData[k2_TextstringType][thing.getIndex()]); + TextString textString(_g284_thingData[k2_TextstringType] + thing.getIndex() * g235_ThingDataWordCount[k2_TextstringType]); if ((textString.isVisible()) || (type & k0x8000_DecodeEvenIfInvisible)) { type = (TextType)(type & ~k0x8000_DecodeEvenIfInvisible); char sepChar; @@ -1307,43 +1316,43 @@ void DungeonMan::f163_linkThingToList(Thing thingToLink, Thing thingInList, int1 if (thingToLink == Thing::_endOfList) return; - uint16 *rawObjPtr = f156_getThingData(thingToLink); - *rawObjPtr = Thing::_endOfList.toUint16(); - + Thing *L0269_ps_Generic = (Thing *)f156_getThingData(thingToLink); + *L0269_ps_Generic = Thing::_endOfList; + /* If mapX >= 0 then the thing is linked to the list of things on the specified square else it is linked at the end of the specified thing list */ if (mapX >= 0) { - Square *squarePtr = (Square*)&_g271_currMapData[mapX][mapY]; - if (squarePtr->get(k0x0010_ThingListPresent)) { + byte *L0268_puc_Square = &_g271_currMapData[mapX][mapY]; + if (getFlag(*L0268_puc_Square, k0x0010_ThingListPresent)) { thingInList = f161_getSquareFirstThing(mapX, mapY); } else { - squarePtr->set(k0x0010_ThingListPresent); - uint16 *cumulativeCount = &_g270_currMapColCumulativeSquareFirstThingCount[mapX + 1]; - uint16 column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1; - while (column--) { - (*cumulativeCount++)++; + setFlag(*L0268_puc_Square, k0x0010_ThingListPresent); + uint16 * tmp = _g270_currMapColCumulativeSquareFirstThingCount + mapX + 1; + uint16 AL0266_ui_Column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1; + while (AL0266_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is added */ + (*tmp++)++; /* Increment the cumulative first thing count */ } - uint16 mapYStep = 0; - squarePtr -= mapY; - uint16 squareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX]; - while (mapYStep++ != mapY) { - if (squarePtr->get(k0x0010_ThingListPresent)) { - squareFirstThingIndex++; + uint16 L0270_ui_MapY = 0; + L0268_puc_Square -= mapY; + uint16 AL0266_ui_SquareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX]; + while (L0270_ui_MapY++ != mapY) { + if (getFlag(*L0268_puc_Square++, k0x0010_ThingListPresent)) { + AL0266_ui_SquareFirstThingIndex++; } - squarePtr++; } - Thing* thingPtr = &_g283_squareFirstThings[squareFirstThingIndex]; - memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_g278_dungeonFileHeader._squareFirstThingCount - squareFirstThingIndex - 1)); - *thingPtr = thingToLink; + Thing *L0267_pT_Thing = &_g283_squareFirstThings[AL0266_ui_SquareFirstThingIndex]; + // the second '- 1' is for the loop initialization, > 0 is because we are copying from one behind + for (int16 i = _g278_dungeonFileHeader._squareFirstThingCount - AL0266_ui_SquareFirstThingIndex - 1 - 1; i > 0; --i) + L0267_pT_Thing[i] = L0267_pT_Thing[i - 1]; + + *L0267_pT_Thing = thingToLink; return; } } - - Thing thing = f159_getNextThing(thingInList); - while (thing != Thing::_endOfList) { - thing = f159_getNextThing(thing); - thingInList = thing; + Thing L0265_T_Thing = f159_getNextThing(thingInList); + while (L0265_T_Thing != Thing::_endOfList) { + L0265_T_Thing = f159_getNextThing(thingInList = L0265_T_Thing); } - rawObjPtr = f156_getThingData(thingInList); - *rawObjPtr = thingToLink.toUint16(); + L0269_ps_Generic = (Thing *)f156_getThingData(thingInList); + *L0269_ps_Generic = thingToLink; } WeaponInfo* DungeonMan::f158_getWeaponInfo(Thing thing) { @@ -1695,4 +1704,10 @@ Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) { } return L0295_T_Thing; } + +int16 DungeonMan::f169_getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo) { + return ((((((val1 * 31417) & 0xFFFF) >> 1) + ((val2 * 11) & 0xFFFF) + + _vm->_dungeonMan->_g278_dungeonFileHeader._ornamentRandomSeed) & 0xFFFF) >> 2) % modulo; /* Pseudorandom number generator */ +} + } diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 204a29640e..da7da401b0 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -351,14 +351,13 @@ void EventManager::f68_setPointerToObject(byte* bitmap) { 100, 110, 0, 130, 140, 150}; // @ G0044_auc_Graphic562_PaletteChanges_MousePointerIcon static Box g619_BoxMousePointerObjectShadow(2, 17, 2, 17); // @ G0619_s_Box_MousePointer_ObjectShadow static Box g620_BoxMousePointerObject(0, 15, 0, 15); // @ G0620_s_Box_MousePointer_Object - byte* L0051_puc_Bitmap; _gK100_preventBuildPointerScreenArea = true; _g600_useObjectAsMousePointerBitmap = true; _g601_useHandAsMousePointerBitmap = false; _g598_mousePointerBitmapUpdated = true; _vm->_displayMan->_g578_useByteBoxCoordinates = true; - L0051_puc_Bitmap = _g615_mousePointerOriginalColorsObject; + byte *L0051_puc_Bitmap = _g615_mousePointerOriginalColorsObject; memset(L0051_puc_Bitmap, 0, 32 * 18); /* @@ -367,6 +366,7 @@ void EventManager::f68_setPointerToObject(byte* bitmap) { _vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, g44_palChangesMousePointerIcon); _vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18); */ + warning("TODO - Call f129_blitToBitmapShrinkWithPalChange"); // dummy code _vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18); _vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18); @@ -376,15 +376,11 @@ void EventManager::f68_setPointerToObject(byte* bitmap) { } void EventManager::f71_mouseDropChampionIcon() { - bool L0057_B_UseByteBoxCoordinatesBackup; - uint16 L0058_ui_ChampionIconIndex; - - _gK100_preventBuildPointerScreenArea = true; - L0058_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap); + uint16 L0058_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap); _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone); _vm->_eventMan->_g598_mousePointerBitmapUpdated = true; - L0057_B_UseByteBoxCoordinatesBackup = _vm->_displayMan->_g578_useByteBoxCoordinates; + bool L0057_B_UseByteBoxCoordinatesBackup = _vm->_displayMan->_g578_useByteBoxCoordinates; _vm->_displayMan->f21_blitToScreen(_g613_mousePointerOriginalColorsChampionIcon, &g54_BoxChampionIcons[L0058_ui_ChampionIconIndex << 2], 16, k12_ColorDarkestGray, 18); _vm->_displayMan->_g578_useByteBoxCoordinates = L0057_B_UseByteBoxCoordinatesBackup; _gK100_preventBuildPointerScreenArea = false; @@ -394,7 +390,6 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY) uint16 L1577_i_ChampionIndex; int16 L1578_i_XOverChampionStatusBox; - // if (_gK100_preventBuildPointerScreenArea) // return; diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index b72be8a7f8..c1d2aedd8a 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -556,9 +556,6 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) { } void InventoryMan::f337_setDungeonViewPalette() { - int16 L1036_i_TotalLightAmount; - uint16 L1037_ui_TorchLightAmountMultiplier; - int16 L1038_i_Counter; uint16 L1039_ui_Multiple; #define AL1039_ui_SlotIndex L1039_ui_Multiple #define AL1039_ui_PaletteIndex L1039_ui_Multiple @@ -566,9 +563,6 @@ void InventoryMan::f337_setDungeonViewPalette() { int16* L1040_pi_Multiple; #define AL1040_pi_TorchLightPower L1040_pi_Multiple #define AL1040_pi_LightAmount L1040_pi_Multiple - int16* L1041_pi_TorchLightPower; - Weapon* L1042_ps_Weapon; - Champion* L1043_ps_Champion; uint16 L1044_ui_Multiple; #define AL1044_T_Thing L1044_ui_Multiple #define AL1044_ui_TorchLightPower L1044_ui_Multiple @@ -580,15 +574,15 @@ void InventoryMan::f337_setDungeonViewPalette() { _vm->_displayMan->_g304_dungeonViewPaletteIndex = 0; /* Brightest color palette index */ } else { /* Get torch light power from both hands of each champion in the party */ - L1038_i_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 */ - L1043_ps_Champion = _vm->_championMan->_gK71_champions; + int16 L1038_i_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 *L1043_ps_Champion = _vm->_championMan->_gK71_champions; AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower; while (L1038_i_Counter--) { AL1039_ui_SlotIndex = k1_ChampionSlotActionHand + 1; while (AL1039_ui_SlotIndex--) { if ((_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16())) >= k4_IconIndiceWeaponTorchUnlit) && (_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16())) <= k7_IconIndiceWeaponTorchLit)) { - L1042_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(Thing(AL1044_T_Thing)); + Weapon *L1042_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(Thing(AL1044_T_Thing)); *AL1040_pi_TorchLightPower = L1042_ps_Weapon->getChargeCount(); } else { *AL1040_pi_TorchLightPower = 0; @@ -602,7 +596,7 @@ void InventoryMan::f337_setDungeonViewPalette() { AL1039_ui_Counter = 0; while (AL1039_ui_Counter != 4) { L1038_i_Counter = 7 - AL1039_ui_Counter; - L1041_pi_TorchLightPower = &L1045_ai_TorchesLightPower[AL1039_ui_Counter + 1]; + int16 *L1041_pi_TorchLightPower = &L1045_ai_TorchesLightPower[AL1039_ui_Counter + 1]; while (L1038_i_Counter--) { if (*L1041_pi_TorchLightPower > *AL1040_pi_TorchLightPower) { AL1044_ui_TorchLightPower = *L1041_pi_TorchLightPower; @@ -615,9 +609,9 @@ void InventoryMan::f337_setDungeonViewPalette() { AL1039_ui_Counter++; } /* Get total light amount provided by the four torches with the highest light power values and by the fifth torch in the array which may be any one of the four torches with the smallest ligh power values */ - L1037_ui_TorchLightAmountMultiplier = 6; + uint16 L1037_ui_TorchLightAmountMultiplier = 6; AL1039_ui_Counter = 5; - L1036_i_TotalLightAmount = 0; + int16 L1036_i_TotalLightAmount = 0; AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower; while (AL1039_ui_Counter--) { if (*AL1040_pi_TorchLightPower) { diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index cb73d3f9a4..93d78ed5fa 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -1008,8 +1008,6 @@ void MovesensMan::f270_sensorTriggetLocalEffect(int16 localEffect, int16 effX, i } void MovesensMan::f269_sensorAddSkillExperience(int16 skillIndex, uint16 exp, bool leaderOnly) { - int16 L0730_i_ChampionIndex; - Champion* L0731_ps_Champion; if (leaderOnly) { if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) { @@ -1017,7 +1015,8 @@ void MovesensMan::f269_sensorAddSkillExperience(int16 skillIndex, uint16 exp, bo } } else { exp /= _vm->_championMan->_g305_partyChampionCount; - for (L0730_i_ChampionIndex = k0_ChampionFirst, L0731_ps_Champion = _vm->_championMan->_gK71_champions; L0730_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0730_i_ChampionIndex++, L0731_ps_Champion++) { + Champion *L0731_ps_Champion = _vm->_championMan->_gK71_champions; + for (int16 L0730_i_ChampionIndex = k0_ChampionFirst; L0730_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0730_i_ChampionIndex++, L0731_ps_Champion++) { if (L0731_ps_Champion->_currHealth) { _vm->_championMan->f304_addSkillExperience(L0730_i_ChampionIndex, skillIndex, exp); } |