Browse Source

Clang-tidy: GlobalConstantCase

pull/2283/head
Anders Jenbo 5 years ago
parent
commit
129342d07a
  1. 14
      Source/drlg_l2.cpp
  2. 8
      Source/gamemenu.cpp
  3. 17
      Source/monster.cpp
  4. 5
      Source/monster.h
  5. 8
      Source/multi.cpp
  6. 4
      Source/objects.cpp
  7. 4
      Source/plrmsg.cpp
  8. 26
      Source/qol/itemlabels.cpp
  9. 4
      Source/quests.cpp
  10. 8
      Source/scrollrt.cpp
  11. 8
      Source/sound.cpp

14
Source/drlg_l2.cpp

@ -34,8 +34,8 @@ std::list<HALLNODE> 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) {

8
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()

17
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

5
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);

8
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);
}
}
}

4
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:

4
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;
}

26
Source/qol/itemlabels.cpp

@ -31,11 +31,11 @@ bool isLabelHighlighted = false;
std::array<std::optional<int>, 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<int, int> 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();
}

4
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;

8
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,

8
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) {

Loading…
Cancel
Save