From 129342d07a26c10a77c6318d287a4959a205bd61 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 2 Jul 2021 22:51:38 +0200 Subject: [PATCH] Clang-tidy: GlobalConstantCase --- Source/drlg_l2.cpp | 14 +++++++------- Source/gamemenu.cpp | 8 ++++---- Source/monster.cpp | 17 ++++++++--------- Source/monster.h | 5 +++-- Source/multi.cpp | 8 ++++---- Source/objects.cpp | 4 ++-- Source/plrmsg.cpp | 4 ++-- Source/qol/itemlabels.cpp | 26 +++++++++++++------------- Source/quests.cpp | 4 ++-- Source/scrollrt.cpp | 8 ++++---- Source/sound.cpp | 8 ++++---- 11 files changed, 53 insertions(+), 53 deletions(-) diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index bd3a3ab92..7ad0f668a 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -34,8 +34,8 @@ std::list HallList; int Area_Min = 2; int Room_Max = 10; int Room_Min = 4; -const int Dir_Xadd[5] = { 0, 0, 1, 0, -1 }; -const int Dir_Yadd[5] = { 0, -1, 0, 1, 0 }; +const int DirXadd[5] = { 0, 0, 1, 0, -1 }; +const int DirYadd[5] = { 0, -1, 0, 1, 0 }; const ShadowStruct SPATSL2[2] = { { 6, 3, 0, 3, 48, 0, 50 }, { 9, 3, 0, 3, 48, 0, 50 } }; //short word_48489A = 0; @@ -2095,8 +2095,8 @@ static void ConnectHall(const HALLNODE &node) CreateDoorType(nX1, nY1); CreateDoorType(nX2, nY2); int nCurrd = nHd; - nX2 -= Dir_Xadd[nCurrd]; - nY2 -= Dir_Yadd[nCurrd]; + nX2 -= DirXadd[nCurrd]; + nY2 -= DirYadd[nCurrd]; predungeon[nX2][nY2] = 44; bool fInroom = false; @@ -2125,11 +2125,11 @@ static void ConnectHall(const HALLNODE &node) if (predungeon[nX1][nY1] == 65 && (nCurrd == 2 || nCurrd == 3)) { nCurrd = 4; } - nX1 += Dir_Xadd[nCurrd]; - nY1 += Dir_Yadd[nCurrd]; + nX1 += DirXadd[nCurrd]; + nY1 += DirYadd[nCurrd]; if (predungeon[nX1][nY1] == 32) { if (fInroom) { - CreateDoorType(nX1 - Dir_Xadd[nCurrd], nY1 - Dir_Yadd[nCurrd]); + CreateDoorType(nX1 - DirXadd[nCurrd], nY1 - DirYadd[nCurrd]); } else { if (fMinusFlag < 50) { if (nCurrd != 1 && nCurrd != 3) { diff --git a/Source/gamemenu.cpp b/Source/gamemenu.cpp index fdaf4c927..21cf48f0f 100644 --- a/Source/gamemenu.cpp +++ b/Source/gamemenu.cpp @@ -66,12 +66,12 @@ TMenuItem sgOptionsMenu[] = { // clang-format on }; /** Specifies the menu names for music enabled and disabled. */ -const char *const music_toggle_names[] = { +const char *const MusicToggleNames[] = { N_("Music"), N_("Music Disabled"), }; /** Specifies the menu names for sound enabled and disabled. */ -const char *const sound_toggle_names[] = { +const char *const SoundToggleNames[] = { N_("Sound"), N_("Sound Disabled"), }; @@ -138,12 +138,12 @@ int gamemenu_slider_music_sound(TMenuItem *menu_item) void gamemenu_get_music() { - gamemenu_sound_music_toggle(music_toggle_names, sgOptionsMenu, sound_get_or_set_music_volume(1)); + gamemenu_sound_music_toggle(MusicToggleNames, sgOptionsMenu, sound_get_or_set_music_volume(1)); } void gamemenu_get_sound() { - gamemenu_sound_music_toggle(sound_toggle_names, &sgOptionsMenu[1], sound_get_or_set_sound_volume(1)); + gamemenu_sound_music_toggle(SoundToggleNames, &sgOptionsMenu[1], sound_get_or_set_sound_volume(1)); } void gamemenu_get_gamma() diff --git a/Source/monster.cpp b/Source/monster.cpp index 0ebe25156..06f31bb7c 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -26,6 +26,7 @@ #include "missiles.h" #include "movie.h" #include "options.h" +#include "spelldat.h" #include "storm/storm.h" #include "themes.h" #include "towners.h" @@ -60,9 +61,6 @@ int monstimgtot; int uniquetrans; int nummtypes; -/** Maps from monster intelligence factor to missile type. */ -const BYTE counsmiss[4] = { MIS_FIREBOLT, MIS_CBOLT, MIS_LIGHTCTRL, MIS_FIREBALL }; - /* data */ /** Maps from monster walk animation frame num to monster velocity. */ @@ -1488,7 +1486,7 @@ void M_StartAttack(int i) monster[i]._mdir = md; } -void M_StartRAttack(int i, int missile_type, int dam) +void M_StartRAttack(int i, missile_id missile_type, int dam) { Direction md = M_GetDir(i); NewMonsterAnim(i, &monster[i].MType->Anims[MA_ATTACK], md, AnimationDistributionFlags::ProcessAnimationPending); @@ -1501,7 +1499,7 @@ void M_StartRAttack(int i, int missile_type, int dam) monster[i]._mdir = md; } -void M_StartRSpAttack(int i, int missile_type, int dam) +void M_StartRSpAttack(int i, missile_id missile_type, int dam) { Direction md = M_GetDir(i); int distributeFramesBeforeFrame = 0; @@ -3459,7 +3457,7 @@ void MAI_GoatMc(int i) MAI_Round(i, true); } -void MAI_Ranged(int i, int missile_type, bool special) +void MAI_Ranged(int i, missile_id missile_type, bool special) { int fx, fy, mx, my; MonsterStruct *Monst; @@ -3680,7 +3678,7 @@ void MAI_Garg(int i) MAI_Round(i, false); } -void MAI_RoundRanged(int i, int missile_type, bool checkdoors, int dam, int lessmissiles) +void MAI_RoundRanged(int i, missile_id missile_type, bool checkdoors, int dam, int lessmissiles) { MonsterStruct *Monst; int mx, my; @@ -3765,7 +3763,7 @@ void MAI_Diablo(int i) MAI_RoundRanged(i, MIS_DIABAPOCA, false, 40, 0); } -void MAI_RR2(int i, int mistype, int dam) +void MAI_RR2(int i, missile_id mistype, int dam) { MonsterStruct *Monst; int mx, my, fx, fy; @@ -4147,6 +4145,7 @@ 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)); } else if (GenerateRnd(100) < 30) { Monst->_mgoal = MGOAL_MOVE; @@ -4162,7 +4161,7 @@ void MAI_Counselor(int i) M_StartFadeout(i, md, false); } else if (Monst->_mVar1 == MM_DELAY || GenerateRnd(100) < 2 * Monst->_mint + 20) { - M_StartRAttack(i, -1, 0); + M_StartRAttack(i, MIS_NULL, 0); AddMissile(Monst->position.tile, { 0, 0 }, Monst->_mdir, MIS_FLASH, TARGET_PLAYERS, i, 4, 0); AddMissile(Monst->position.tile, { 0, 0 }, Monst->_mdir, MIS_FLASH2, TARGET_PLAYERS, i, 4, 0); } else diff --git a/Source/monster.h b/Source/monster.h index a8b21db58..a7ba86a01 100644 --- a/Source/monster.h +++ b/Source/monster.h @@ -16,6 +16,7 @@ #include "miniwin/miniwin.h" #include "utils/stdcompat/optional.hpp" #include "monstdat.h" +#include "spelldat.h" #include "textdat.h" #ifndef NOSOUND @@ -254,7 +255,7 @@ void MAI_Fallen(int i); void MAI_Cleaver(int i); void MAI_Round(int i, bool special); void MAI_GoatMc(int i); -void MAI_Ranged(int i, int missile_type, bool special); +void MAI_Ranged(int i, missile_id missile_type, bool special); void MAI_GoatBow(int i); void MAI_Succ(int i); void MAI_Lich(int i); @@ -266,7 +267,7 @@ void MAI_Firebat(int i); void MAI_Torchant(int i); void MAI_Scav(int i); void MAI_Garg(int i); -void MAI_RoundRanged(int i, int missile_type, bool checkdoors, int dam, int lessmissiles); +void MAI_RoundRanged(int i, missile_id missile_type, bool checkdoors, int dam, int lessmissiles); void MAI_Magma(int i); void MAI_Storm(int i); void MAI_BoneDemon(int i); diff --git a/Source/multi.cpp b/Source/multi.cpp index 5f4e1c015..724f8c85c 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -60,7 +60,7 @@ uint32_t player_state[MAX_PLRS]; * Contains the set of supported event types supported by the multiplayer * event handler. */ -const event_type event_types[3] = { +const event_type EventTypes[3] = { EVENT_TYPE_PLAYER_LEAVE_GAME, EVENT_TYPE_PLAYER_CREATE_GAME, EVENT_TYPE_PLAYER_MESSAGE @@ -650,13 +650,13 @@ static void multi_handle_events(_SNETEVENT *pEvt) static void multi_event_handler(bool add) { - for (auto event_type : event_types) { + for (auto eventType : EventTypes) { if (add) { - if (!SNetRegisterEventHandler(event_type, multi_handle_events)) { + if (!SNetRegisterEventHandler(eventType, multi_handle_events)) { app_fatal("SNetRegisterEventHandler:\n%s", SDL_GetError()); } } else { - SNetUnregisterEventHandler(event_type); + SNetUnregisterEventHandler(eventType); } } } diff --git a/Source/objects.cpp b/Source/objects.cpp index 8b6b23a35..215d98689 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -90,7 +90,7 @@ int bxadd[8] = { -1, 0, 1, -1, 1, -1, 0, 1 }; /** Specifies the Y-coordinate delta between barrels. */ int byadd[8] = { -1, -1, -1, 0, 0, 1, 1, 1 }; /** Maps from shrine_id to shrine name. */ -const char *const shrinestrs[] = { +const char *const ShrineNames[] = { // TRANSLATORS: Shrine Name Block N_("Mysterious"), N_("Hidden"), @@ -5337,7 +5337,7 @@ void GetObjectStr(int i) break; case OBJ_SHRINEL: case OBJ_SHRINER: - strcpy(tempstr, fmt::format(_(/* TRANSLATORS: {:s} will be a name from the Shrine block above */ "{:s} Shrine"), _(shrinestrs[object[i]._oVar1])).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: {:s} will be a name from the Shrine block above */ "{:s} Shrine"), _(ShrineNames[object[i]._oVar1])).c_str()); strcpy(infostr, tempstr); break; case OBJ_SKELBOOK: diff --git a/Source/plrmsg.cpp b/Source/plrmsg.cpp index 23e3465ce..42641b1be 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -20,7 +20,7 @@ static BYTE plr_msg_slot; _plrmsg plr_msgs[PMSG_COUNT]; /** Maps from player_num to text color, as used in chat messages. */ -const uint16_t text_color_from_player_num[MAX_PLRS + 1] = { UIS_SILVER, UIS_SILVER, UIS_SILVER, UIS_SILVER, UIS_GOLD }; +const UiFlags TextColorFromPlayerId[MAX_PLRS + 1] = { UIS_SILVER, UIS_SILVER, UIS_SILVER, UIS_SILVER, UIS_GOLD }; void plrmsg_delay(bool delay) { @@ -125,7 +125,7 @@ void DrawPlrMsg(const CelOutputBuffer &out) pMsg = plr_msgs; for (i = 0; i < PMSG_COUNT; i++) { if (pMsg->str[0] != '\0') - PrintPlrMsg(out, x, y, width, pMsg->str, text_color_from_player_num[pMsg->player]); + PrintPlrMsg(out, x, y, width, pMsg->str, TextColorFromPlayerId[pMsg->player]); pMsg++; y += 35; } diff --git a/Source/qol/itemlabels.cpp b/Source/qol/itemlabels.cpp index ef63bc851..2df92eb20 100644 --- a/Source/qol/itemlabels.cpp +++ b/Source/qol/itemlabels.cpp @@ -31,11 +31,11 @@ bool isLabelHighlighted = false; std::array, ITEMTYPES> labelCenterOffsets; bool invertHighlightToggle = false; -const int borderX = 4; // minimal horizontal space between labels -const int borderY = 2; // minimal vertical space between labels -const int marginX = 2; // horizontal margins between text and edges of the label -const int marginY = 1; // vertical margins between text and edges of the label -const int height = 11 + marginY * 2; // going above 13 scatters labels of items that are next to each other +const int BorderX = 4; // minimal horizontal space between labels +const int BorderY = 2; // minimal vertical space between labels +const int MarginX = 2; // horizontal margins between text and edges of the label +const int MarginY = 1; // vertical margins between text and edges of the label +const int Height = 11 + MarginY * 2; // going above 13 scatters labels of items that are next to each other } // namespace @@ -74,7 +74,7 @@ void AddItemToLabelQueue(int id, int x, int y) } int nameWidth = GetLineWidth(textOnGround); - nameWidth += marginX * 2; + nameWidth += MarginX * 2; int index = ItemCAnimTbl[it->_iCurs]; if (!labelCenterOffsets[index]) { std::pair itemBounds = MeasureSolidHorizontalBounds(*it->AnimInfo.pCelSprite, it->AnimInfo.CurrentFrame); @@ -123,9 +123,9 @@ void DrawItemNameLabels(const CelOutputBuffer &out) for (unsigned int j = 0; j < i; ++j) { itemLabel &a = labelQueue[i]; itemLabel &b = labelQueue[j]; - if (abs(b.pos.y - a.pos.y) < height + borderY) { - int widthA = a.width + borderX + marginX * 2; - int widthB = b.width + borderX + marginX * 2; + if (abs(b.pos.y - a.pos.y) < Height + BorderY) { + int widthA = a.width + BorderX + MarginX * 2; + int widthB = b.width + BorderX + MarginX * 2; int newpos = b.pos.x; if (b.pos.x >= a.pos.x && b.pos.x - a.pos.x < widthA) { newpos -= widthA; @@ -148,7 +148,7 @@ void DrawItemNameLabels(const CelOutputBuffer &out) for (const itemLabel &label : labelQueue) { ItemStruct &itm = items[label.id]; - if (MousePosition.x >= label.pos.x && MousePosition.x < label.pos.x + label.width && MousePosition.y >= label.pos.y - height + marginY && MousePosition.y < label.pos.y + marginY) { + if (MousePosition.x >= label.pos.x && MousePosition.x < label.pos.x + label.width && MousePosition.y >= label.pos.y - Height + MarginY && MousePosition.y < label.pos.y + MarginY) { if (!gmenu_is_active() && PauseMode == 0 && !deathflag && IsMouseOverGameArea()) { isLabelHighlighted = true; cursmx = itm.position.x; @@ -157,10 +157,10 @@ void DrawItemNameLabels(const CelOutputBuffer &out) } } if (pcursitem == label.id) - FillRect(out, label.pos.x, label.pos.y - height + marginY, label.width, height, PAL8_BLUE + 6); + FillRect(out, label.pos.x, label.pos.y - Height + MarginY, label.width, Height, PAL8_BLUE + 6); else - DrawHalfTransparentRectTo(out, label.pos.x, label.pos.y - height + marginY, label.width, height); - DrawString(out, label.text.c_str(), { label.pos.x + marginX, label.pos.y, label.width, height }, itm.getTextColor()); + DrawHalfTransparentRectTo(out, label.pos.x, label.pos.y - Height + MarginY, label.width, Height); + DrawString(out, label.text.c_str(), { label.pos.x + MarginX, label.pos.y, label.width, Height }, itm.getTextColor()); } labelQueue.clear(); } diff --git a/Source/quests.cpp b/Source/quests.cpp index 3f3fe1cd3..0d67bf990 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -79,7 +79,7 @@ char questxoff[7] = { 0, -1, 0, -1, -2, -1, -2 }; * which the hover text of the cursor will be visible. */ char questyoff[7] = { 0, 0, -1, -1, -1, -2, -2 }; -const char *const questtrigstr[5] = { +const char *const QuestTriggerNames[5] = { N_(/* TRANSLATORS: Quest Map*/ "King Leoric's Tomb"), N_(/* TRANSLATORS: Quest Map*/ "The Chamber of Bone"), N_(/* TRANSLATORS: Quest Map*/ "Maze"), @@ -276,7 +276,7 @@ bool ForceQuests() for (int j = 0; j < 7; j++) { if (qx + questxoff[j] == cursmx && qy + questyoff[j] == cursmy) { - strcpy(infostr, fmt::format(_(/* TRANSLATORS: Used for Quest Portals. {:s} is a Map Name */ "To {:s}"), _(questtrigstr[ql])).c_str()); + strcpy(infostr, fmt::format(_(/* TRANSLATORS: Used for Quest Portals. {:s} is a Map Name */ "To {:s}"), _(QuestTriggerNames[ql])).c_str()); cursmx = qx; cursmy = qy; return true; diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 2ad0f2d05..dd4f7cc1a 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -91,7 +91,7 @@ int framestart; /* data */ -const char *const szMonModeAssert[] = { +const char *const MonsterModeNames[] = { "standing", "walking (1)", "walking (2)", @@ -112,7 +112,7 @@ const char *const szMonModeAssert[] = { "talking" }; -const char *const szPlrModeAssert[] = { +const char *const PlayerModeNames[] = { "standing", "walking (1)", "walking (2)", @@ -326,7 +326,7 @@ static void DrawMonster(const CelOutputBuffer &out, int x, int y, int mx, int my if (nCel < 1 || frames > 50 || nCel > frames) { const char *szMode = "unknown action"; if (monster[m]._mmode <= 17) - szMode = szMonModeAssert[monster[m]._mmode]; + szMode = MonsterModeNames[monster[m]._mmode]; Log( "Draw Monster \"{}\" {}: facing {}, frame {} of {}", monster[m].mName, @@ -430,7 +430,7 @@ static void DrawPlayer(const CelOutputBuffer &out, int pnum, int x, int y, int p if (nCel < 1 || frames > 50 || nCel > frames) { const char *szMode = "unknown action"; if (player._pmode <= PM_QUIT) - szMode = szPlrModeAssert[player._pmode]; + szMode = PlayerModeNames[player._pmode]; Log( "Drawing player {} \"{}\" {}: facing {}, frame {} of {}", pnum, diff --git a/Source/sound.cpp b/Source/sound.cpp index 35649313e..765b3c884 100644 --- a/Source/sound.cpp +++ b/Source/sound.cpp @@ -102,7 +102,7 @@ bool gbMusicOn = true; bool gbSoundOn = true; /** Maps from track ID to track name in spawn. */ -const char *const sgszSpawnMusicTracks[NUM_MUSIC] = { +const char *const SpawnMusicTracks[NUM_MUSIC] = { "Music\\sTowne.wav", "Music\\sLvlA.wav", "Music\\sLvlA.wav", @@ -113,7 +113,7 @@ const char *const sgszSpawnMusicTracks[NUM_MUSIC] = { "Music\\sintro.wav", }; /** Maps from track ID to track name. */ -const char *const sgszMusicTracks[NUM_MUSIC] = { +const char *const MusicTracks[NUM_MUSIC] = { "Music\\DTowne.wav", "Music\\DLvlA.wav", "Music\\DLvlB.wav", @@ -249,9 +249,9 @@ void music_start(uint8_t nTrack) music_stop(); if (gbMusicOn) { if (spawn_mpq != nullptr) - trackPath = sgszSpawnMusicTracks[nTrack]; + trackPath = SpawnMusicTracks[nTrack]; else - trackPath = sgszMusicTracks[nTrack]; + trackPath = MusicTracks[nTrack]; HANDLE handle; success = SFileOpenFile(trackPath, &handle); if (!success) {