diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index 9d48dcae3..b84d6b8fd 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -1920,19 +1920,19 @@ void drlg_l1_crypt_rndset(const BYTE *miniset, int rndper) // BUGFIX: accesses to dungeon can go out of bounds (fixed) // BUGFIX: Comparisons vs 100 should use same tile as comparisons vs 84 - NOT A BUG - "fixing" this breaks crypt - constexpr auto comparison_with_bounds_check = [](Point p1, Point p2) { + constexpr auto ComparisonWithBoundsCheck = [](Point p1, Point p2) { return (p1.x >= 0 && p1.x < DMAXX && p1.y >= 0 && p1.y < DMAXY) && (p2.x >= 0 && p2.x < DMAXX && p2.y >= 0 && p2.y < DMAXY) && (dungeon[p1.x][p1.y] >= 84 && dungeon[p2.x][p2.y] <= 100); }; - if (comparison_with_bounds_check({ sx - 1, sy }, { sx - 1, sy })) { + if (ComparisonWithBoundsCheck({ sx - 1, sy }, { sx - 1, sy })) { found = false; } - if (comparison_with_bounds_check({ sx + 1, sy }, { sx - 1, sy })) { + if (ComparisonWithBoundsCheck({ sx + 1, sy }, { sx - 1, sy })) { found = false; } - if (comparison_with_bounds_check({ sx, sy + 1 }, { sx - 1, sy })) { + if (ComparisonWithBoundsCheck({ sx, sy + 1 }, { sx - 1, sy })) { found = false; } - if (comparison_with_bounds_check({ sx, sy - 1 }, { sx - 1, sy })) { + if (ComparisonWithBoundsCheck({ sx, sy - 1 }, { sx - 1, sy })) { found = false; } } diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index 6d14c6cc9..25e9a69a0 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -1527,7 +1527,7 @@ static bool DRLG_L3Spawn(int x, int y, int *totarea) */ static void DRLG_L3Pool() { - constexpr uint8_t poolsub[15] = { 0, 35, 26, 36, 25, 29, 34, 7, 33, 28, 27, 37, 32, 31, 30 }; + constexpr uint8_t Poolsub[15] = { 0, 35, 26, 36, 25, 29, 34, 7, 33, 28, 27, 37, 32, 31, 30 }; for (int duny = 0; duny < DMAXY; duny++) { for (int dunx = 0; dunx < DMAXY; dunx++) { @@ -1563,7 +1563,7 @@ static void DRLG_L3Pool() if ((dungeon[i][j] & 0x80) != 0) { dungeon[i][j] &= ~0x80; if (totarea > 4 && poolchance < 25 && !found) { - uint8_t k = poolsub[dungeon[i][j]]; + uint8_t k = Poolsub[dungeon[i][j]]; if (k != 0 && k <= 37) { dungeon[i][j] = k; } diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 962139698..1245bf0b4 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -804,7 +804,7 @@ static void LoadPortal(LoadHelper *file, int i) _item_indexes RemapItemIdxFromDiablo(_item_indexes i) { - constexpr auto getItemIdValue = [](int i) -> int { + constexpr auto GetItemIdValue = [](int i) -> int { if (i == IDI_SORCERER) { return 166; } @@ -821,12 +821,12 @@ _item_indexes RemapItemIdxFromDiablo(_item_indexes i) return i; }; - return static_cast<_item_indexes>(getItemIdValue(i)); + return static_cast<_item_indexes>(GetItemIdValue(i)); } _item_indexes RemapItemIdxToDiablo(_item_indexes i) { - constexpr auto getItemIdValue = [](int i) -> int { + constexpr auto GetItemIdValue = [](int i) -> int { if (i == 166) { return IDI_SORCERER; } @@ -843,12 +843,12 @@ _item_indexes RemapItemIdxToDiablo(_item_indexes i) return i; }; - return static_cast<_item_indexes>(getItemIdValue(i)); + return static_cast<_item_indexes>(GetItemIdValue(i)); } _item_indexes RemapItemIdxFromSpawn(_item_indexes i) { - constexpr auto getItemIdValue = [](int i) { + constexpr auto GetItemIdValue = [](int i) { if (i >= 62) { i += 9; // Medium and heavy armors } @@ -874,12 +874,12 @@ _item_indexes RemapItemIdxFromSpawn(_item_indexes i) return i; }; - return static_cast<_item_indexes>(getItemIdValue(i)); + return static_cast<_item_indexes>(GetItemIdValue(i)); } _item_indexes RemapItemIdxToSpawn(_item_indexes i) { - constexpr auto getItemIdValue = [](int i) { + constexpr auto GetItemIdValue = [](int i) { if (i >= 104) { i -= 1; // Scroll of Apocalypse } @@ -905,7 +905,7 @@ _item_indexes RemapItemIdxToSpawn(_item_indexes i) return i; }; - return static_cast<_item_indexes>(getItemIdValue(i)); + return static_cast<_item_indexes>(GetItemIdValue(i)); } bool IsHeaderValid(uint32_t magicNumber) diff --git a/Source/missiles.cpp b/Source/missiles.cpp index baa002391..fdc2b1fd0 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -1604,8 +1604,8 @@ void AddRuneExplosion(int mi, Point src, Point /*dst*/, int /*midir*/, int8_t mi missile[mi]._midam = dmg; - constexpr Displacement offsets[] = { { -1, -1 }, { 0, -1 }, { 1, -1 }, { -1, 0 }, { 0, 0 }, { 1, 0 }, { -1, 1 }, { 0, 1 }, { 1, 1 } }; - for (Displacement offset : offsets) + constexpr Displacement Offsets[] = { { -1, -1 }, { 0, -1 }, { 1, -1 }, { -1, 0 }, { 0, 0 }, { 1, 0 }, { -1, 1 }, { 0, 1 }, { 1, 1 } }; + for (Displacement offset : Offsets) CheckMissileCol(mi, dmg, dmg, false, missile[mi].position.tile + offset, true); } missile[mi]._mlid = AddLight(src, 8); @@ -4590,10 +4590,10 @@ void MI_Cbolt(int i) missile[i]._mirange--; if (missile[i]._miAnimType != MFILE_LGHNING) { if (missile[i]._miVar3 == 0) { - constexpr int bpath[16] = { -1, 0, 1, -1, 0, 1, -1, -1, 0, 0, 1, 1, 0, 1, -1, 0 }; + constexpr int BPath[16] = { -1, 0, 1, -1, 0, 1, -1, -1, 0, 0, 1, 1, 0, 1, -1, 0 }; auto md = static_cast(missile[i]._miVar2); - switch (bpath[missile[i]._mirnd]) { + switch (BPath[missile[i]._mirnd]) { case -1: md = left[md]; break; diff --git a/Source/monster.cpp b/Source/monster.cpp index 8d626b11a..f300f0f8b 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -4032,8 +4032,8 @@ void MAI_Counselor(int i) } else if (Monst->_mgoal == MGOAL_NORMAL) { if (abs(mx) >= 2 || abs(my) >= 2) { if (v < 5 * (Monst->_mint + 10) && LineClearMissile(Monst->position.tile, { fx, fy })) { - constexpr missile_id counsmiss[4] = { MIS_FIREBOLT, MIS_CBOLT, MIS_LIGHTCTRL, MIS_FIREBALL }; - M_StartRAttack(i, counsmiss[Monst->_mint], Monst->mMinDamage + GenerateRnd(Monst->mMaxDamage - Monst->mMinDamage + 1)); + constexpr missile_id MissileTypes[4] = { MIS_FIREBOLT, MIS_CBOLT, MIS_LIGHTCTRL, MIS_FIREBALL }; + M_StartRAttack(i, MissileTypes[Monst->_mint], Monst->mMinDamage + GenerateRnd(Monst->mMaxDamage - Monst->mMinDamage + 1)); } else if (GenerateRnd(100) < 30) { Monst->_mgoal = MGOAL_MOVE; Monst->_mgoalvar1 = 0; diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index 362037527..1ce356d15 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -536,8 +536,8 @@ static bool mpqapi_write_file_contents(const char *pszName, const byte *pbData, pszName = tmp + 1; Hash(pszName, 3); - constexpr size_t sectorSize = 4096; - const uint32_t num_sectors = (dwLen + (sectorSize - 1)) / sectorSize; + constexpr size_t SectorSize = 4096; + const uint32_t num_sectors = (dwLen + (SectorSize - 1)) / SectorSize; const uint32_t offset_table_bytesize = sizeof(uint32_t) * (num_sectors + 1); pBlk->offset = mpqapi_find_free_block(dwLen + offset_table_bytesize, &pBlk->sizealloc); pBlk->sizefile = dwLen; @@ -572,10 +572,10 @@ static bool mpqapi_write_file_contents(const char *pszName, const byte *pbData, #endif uint32_t destsize = offset_table_bytesize; - byte mpq_buf[sectorSize]; + byte mpq_buf[SectorSize]; std::size_t cur_sector = 0; while (true) { - uint32_t len = std::min(dwLen, sectorSize); + uint32_t len = std::min(dwLen, SectorSize); memcpy(mpq_buf, pbData, len); pbData += len; len = PkwareCompress(mpq_buf, len); @@ -583,8 +583,8 @@ static bool mpqapi_write_file_contents(const char *pszName, const byte *pbData, return false; sectoroffsettable[cur_sector++] = SDL_SwapLE32(destsize); destsize += len; // compressed length - if (dwLen > sectorSize) - dwLen -= sectorSize; + if (dwLen > SectorSize) + dwLen -= SectorSize; else break; } diff --git a/Source/player.cpp b/Source/player.cpp index 155583a1c..48dd1dbee 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -102,7 +102,7 @@ void WalkSides(int pnum, const DirectionSettings &walkParams) player.position.temp = player.position.future; } -constexpr std::array directionSettings { { +constexpr std::array WalkSettings { { // clang-format off { DIR_S, { 1, 1 }, { 0, -32 }, { 0, 0 }, SDIR_S, PM_WALK2, WalkDownwards }, { DIR_SW, { 0, 1 }, { 32, -16 }, { 0, 0 }, SDIR_SW, PM_WALK2, WalkDownwards }, @@ -160,7 +160,7 @@ bool PlrDirOK(int pnum, Direction dir) void HandleWalkMode(int pnum, Displacement vel, Direction dir) { auto &player = plr[pnum]; - const auto &dirModeParams = directionSettings[dir]; + const auto &dirModeParams = WalkSettings[dir]; SetPlayerOld(player); if (!PlrDirOK(pnum, dir)) { return; @@ -206,7 +206,7 @@ void StartWalk(int pnum, Displacement vel, Direction dir, bool pmWillBeCalled) StartWalkAnimation(player, dir, pmWillBeCalled); if (pnum == myplr) { - ScrollViewPort(player, directionSettings[dir].scrollDir); + ScrollViewPort(player, WalkSettings[dir].scrollDir); } } } // namespace @@ -503,16 +503,16 @@ int PlayerStruct::GetMaximumAttributeValue(CharacterAttribute attribute) const Point PlayerStruct::GetTargetPosition() const { // clang-format off - constexpr int directionOffsetX[8] = { 0,-1, 1, 0,-1, 1, 1,-1 }; - constexpr int directionOffsetY[8] = { -1, 0, 0, 1,-1,-1, 1, 1 }; + constexpr int DirectionOffsetX[8] = { 0,-1, 1, 0,-1, 1, 1,-1 }; + constexpr int DirectionOffsetY[8] = { -1, 0, 0, 1,-1,-1, 1, 1 }; // clang-format on Point target = position.future; for (auto step : walkpath) { if (step == WALK_NONE) break; if (step > 0) { - target.x += directionOffsetX[step - 1]; - target.y += directionOffsetY[step - 1]; + target.x += DirectionOffsetX[step - 1]; + target.y += DirectionOffsetY[step - 1]; } } return target; diff --git a/Source/qol/xpbar.cpp b/Source/qol/xpbar.cpp index 0aec723bf..18f00bc4a 100644 --- a/Source/qol/xpbar.cpp +++ b/Source/qol/xpbar.cpp @@ -20,14 +20,14 @@ namespace devilution { namespace { -constexpr int BAR_WIDTH = 307; +constexpr int BarWidth = 307; using ColorGradient = std::array; -constexpr ColorGradient GOLD_GRADIENT = { 0xCF, 0xCE, 0xCD, 0xCC, 0xCB, 0xCA, 0xC9, 0xC8, 0xC7, 0xC6, 0xC5, 0xC4 }; -constexpr ColorGradient SILVER_GRADIENT = { 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8, 0xF7, 0xF6, 0xF5, 0xF4, 0xF3 }; +constexpr ColorGradient GoldGradient = { 0xCF, 0xCE, 0xCD, 0xCC, 0xCB, 0xCA, 0xC9, 0xC8, 0xC7, 0xC6, 0xC5, 0xC4 }; +constexpr ColorGradient SilverGradient = { 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8, 0xF7, 0xF6, 0xF5, 0xF4, 0xF3 }; -constexpr int BACK_WIDTH = 313; -constexpr int BACK_HEIGHT = 9; +constexpr int BackWidth = 313; +constexpr int BackHeight = 9; Art xpbarArt; @@ -84,7 +84,7 @@ void DrawXPBar(const CelOutputBuffer &out) if (charLevel == MAXCHARLEVEL - 1) { // Draw a nice golden bar for max level characters. - DrawBar(out, xPos, yPos, BAR_WIDTH, GOLD_GRADIENT); + DrawBar(out, xPos, yPos, BarWidth, GoldGradient); return; } @@ -95,19 +95,19 @@ void DrawXPBar(const CelOutputBuffer &out) uint64_t prevXpDelta_1 = player._pExperience - prevXp; uint64_t prevXpDelta = ExpLvlsTbl[charLevel] - prevXp; - uint64_t fullBar = BAR_WIDTH * prevXpDelta_1 / prevXpDelta; + uint64_t fullBar = BarWidth * prevXpDelta_1 / prevXpDelta; // Figure out how much to fill the last pixel of the XP bar, to make it gradually appear with gained XP - uint64_t onePx = prevXpDelta / BAR_WIDTH + 1; - uint64_t lastFullPx = fullBar * prevXpDelta / BAR_WIDTH; + uint64_t onePx = prevXpDelta / BarWidth + 1; + uint64_t lastFullPx = fullBar * prevXpDelta / BarWidth; - const uint64_t fade = (prevXpDelta_1 - lastFullPx) * (SILVER_GRADIENT.size() - 1) / onePx; + const uint64_t fade = (prevXpDelta_1 - lastFullPx) * (SilverGradient.size() - 1) / onePx; // Draw beginning of bar full brightness - DrawBar(out, xPos, yPos, fullBar, SILVER_GRADIENT); + DrawBar(out, xPos, yPos, fullBar, SilverGradient); // End pixels appear gradually - DrawEndCap(out, { xPos + static_cast(fullBar), yPos }, fade, SILVER_GRADIENT); + DrawEndCap(out, { xPos + static_cast(fullBar), yPos }, fade, SilverGradient); } bool CheckXPBarInfo() @@ -118,7 +118,7 @@ bool CheckXPBarInfo() const int backX = PANEL_LEFT + PANEL_WIDTH / 2 - 155; const int backY = PANEL_TOP + PANEL_HEIGHT - 11; - if (MousePosition.x < backX || MousePosition.x >= backX + BACK_WIDTH || MousePosition.y < backY || MousePosition.y >= backY + BACK_HEIGHT) + if (MousePosition.x < backX || MousePosition.x >= backX + BackWidth || MousePosition.y < backY || MousePosition.y >= backY + BackHeight) return false; const auto &player = plr[myplr]; diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index f62e9d627..476289662 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -131,27 +131,27 @@ Displacement GetOffsetForWalking(const AnimationInfo &animationInfo, const Direc { // clang-format off // DIR_S, DIR_SW, DIR_W, DIR_NW, DIR_N, DIR_NE, DIR_E, DIR_SE, - constexpr Displacement startOffset[8] = { { 0, -32 }, { 32, -16 }, { 32, -16 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { -32, -16 }, { -32, -16 } }; - constexpr Displacement movingOffset[8] = { { 0, 32 }, { -32, 16 }, { -64, 0 }, { -32, -16 }, { 0, -32 }, { 32, -16 }, { 64, 0 }, { 32, 16 } }; - constexpr bool isDiagionalWalk[8] = { false, true, false, true, false, true, false, true }; + constexpr Displacement StartOffset[8] = { { 0, -32 }, { 32, -16 }, { 32, -16 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { -32, -16 }, { -32, -16 } }; + constexpr Displacement MovingOffset[8] = { { 0, 32 }, { -32, 16 }, { -64, 0 }, { -32, -16 }, { 0, -32 }, { 32, -16 }, { 64, 0 }, { 32, 16 } }; + constexpr bool IsDiagionalWalk[8] = { false, true, false, true, false, true, false, true }; // clang-format on float fAnimationProgress = animationInfo.GetAnimationProgress(); - Displacement offset = movingOffset[dir]; + Displacement offset = MovingOffset[dir]; offset *= fAnimationProgress; // In diagonal walks the offset for y is smaller than x. // This means that sometimes x is updated but y not. // That results in a small stuttering. // To fix this we disallow odd x as this is the only case where y is not updated. - if (isDiagionalWalk[dir] && ((offset.deltaX % 2) != 0)) { + if (IsDiagionalWalk[dir] && ((offset.deltaX % 2) != 0)) { offset.deltaX -= offset.deltaX > 0 ? 1 : -1; } if (cameraMode) { offset = -offset; } else { - offset += startOffset[dir]; + offset += StartOffset[dir]; } return offset;