Browse Source

Clang-tidy: readability-qualified-auto

pull/2243/head
Anders Jenbo 5 years ago
parent
commit
de4ced7e4f
  1. 10
      Source/DiabloUI/diabloui.cpp
  2. 2
      Source/DiabloUI/dialogs.cpp
  3. 4
      Source/DiabloUI/mainmenu.cpp
  4. 4
      Source/DiabloUI/selconn.cpp
  5. 4
      Source/DiabloUI/selgame.cpp
  6. 6
      Source/DiabloUI/selhero.cpp
  7. 4
      Source/DiabloUI/selok.cpp
  8. 4
      Source/DiabloUI/selyesno.cpp
  9. 2
      Source/DiabloUI/title.cpp
  10. 2
      Source/controls/keymapper.cpp
  11. 2
      Source/dead.cpp
  12. 2
      Source/dvlnet/base.cpp
  13. 8
      Source/items.cpp
  14. 2
      Source/missiles.cpp
  15. 6
      Source/scrollrt.cpp

10
Source/DiabloUI/diabloui.cpp

@ -99,7 +99,7 @@ void UiInitList(int count, void (*fnFocus)(int value), void (*fnSelect)(int valu
SDL_StopTextInput(); // input is enabled by default
#endif
textInputActive = false;
for (auto &item : items) {
for (const auto &item : items) {
if (item->m_type == UI_EDIT) {
auto *pItemUIEdit = static_cast<UiEdit *>(item);
SDL_SetTextInputRect(&item->m_rect);
@ -578,7 +578,7 @@ bool UiValidPlayerName(const char *name)
for (size_t i = 0, n = strlen(tmpname); i < n; i++)
tmpname[i]++;
for (auto bannedName : bannedNames) {
for (const auto *bannedName : bannedNames) {
if (strstr(tmpname, bannedName) != nullptr)
return false;
}
@ -929,7 +929,7 @@ void LoadPalInMem(const SDL_Color *pPal)
void UiRenderItems(const std::vector<UiItemBase *> &items)
{
for (auto &item : items)
for (const auto &item : items)
RenderItem(item);
}
@ -945,7 +945,7 @@ bool UiItemMouseEvents(SDL_Event *event, const std::vector<UiItemBase *> &items)
#endif
bool handled = false;
for (auto &item : items) {
for (const auto &item : items) {
if (HandleMouseEvent(*event, item)) {
handled = true;
break;
@ -954,7 +954,7 @@ bool UiItemMouseEvents(SDL_Event *event, const std::vector<UiItemBase *> &items)
if (event->type == SDL_MOUSEBUTTONUP && event->button.button == SDL_BUTTON_LEFT) {
scrollBarState.downArrowPressed = scrollBarState.upArrowPressed = false;
for (auto &item : items) {
for (const auto &item : items) {
if (item->m_type == UI_BUTTON)
HandleGlobalMouseUpButton(static_cast<UiButton *>(item));
}

2
Source/DiabloUI/dialogs.cpp

@ -215,7 +215,7 @@ void Deinit()
if (!fontWasLoaded)
UnloadTtfFont();
for (auto pUIItem : vecOkDialog) {
for (auto *pUIItem : vecOkDialog) {
delete pUIItem;
}
vecOkDialog.clear();

4
Source/DiabloUI/mainmenu.cpp

@ -69,12 +69,12 @@ void MainmenuFree()
ArtBackgroundWidescreen.Unload();
ArtBackground.Unload();
for (auto pUIItem : vecMainMenuDialog) {
for (auto *pUIItem : vecMainMenuDialog) {
delete pUIItem;
}
vecMainMenuDialog.clear();
for (auto pUIMenuItem : vecMenuItems) {
for (auto *pUIMenuItem : vecMenuItems) {
delete pUIMenuItem;
}
vecMenuItems.clear();

4
Source/DiabloUI/selconn.cpp

@ -83,12 +83,12 @@ void SelconnFree()
{
ArtBackground.Unload();
for (auto pUIItem : vecConnItems) {
for (auto *pUIItem : vecConnItems) {
delete pUIItem;
}
vecConnItems.clear();
for (auto pUIMenuItem : vecSelConnDlg) {
for (auto *pUIMenuItem : vecSelConnDlg) {
delete pUIMenuItem;
}
vecSelConnDlg.clear();

4
Source/DiabloUI/selgame.cpp

@ -44,12 +44,12 @@ std::vector<UiItemBase *> vecSelGameDialog;
void selgame_FreeVectors()
{
for (auto pUIItem : vecSelGameDlgItems) {
for (auto *pUIItem : vecSelGameDlgItems) {
delete pUIItem;
}
vecSelGameDlgItems.clear();
for (auto pUIItem : vecSelGameDialog) {
for (auto *pUIItem : vecSelGameDialog) {
delete pUIItem;
}
vecSelGameDialog.clear();

6
Source/DiabloUI/selhero.cpp

@ -66,7 +66,7 @@ void SelheroUiFocusNavigationYesNo()
void SelheroFreeListItems()
{
for (auto pUIItem : vecSelHeroDlgItems) {
for (auto *pUIItem : vecSelHeroDlgItems) {
delete pUIItem;
}
vecSelHeroDlgItems.clear();
@ -74,7 +74,7 @@ void SelheroFreeListItems()
void SelheroFreeDlgItems()
{
for (auto pUIItem : vecSelDlgItems) {
for (auto *pUIItem : vecSelDlgItems) {
delete pUIItem;
}
vecSelDlgItems.clear();
@ -84,7 +84,7 @@ void SelheroFree()
{
ArtBackground.Unload();
for (auto pUIItem : vecSelHeroDialog) {
for (auto *pUIItem : vecSelHeroDialog) {
delete pUIItem;
}
vecSelHeroDialog.clear();

4
Source/DiabloUI/selok.cpp

@ -24,12 +24,12 @@ void selok_Free()
{
ArtBackground.Unload();
for (auto pUIListItem : vecSelOkDialogItems) {
for (auto *pUIListItem : vecSelOkDialogItems) {
delete pUIListItem;
}
vecSelOkDialogItems.clear();
for (auto pUIItem : vecSelOkDialog) {
for (auto *pUIItem : vecSelOkDialog) {
delete pUIItem;
}
vecSelOkDialog.clear();

4
Source/DiabloUI/selyesno.cpp

@ -21,12 +21,12 @@ void SelyesnoFree()
{
ArtBackground.Unload();
for (auto pUIListItem : vecSelYesNoDialogItems) {
for (auto *pUIListItem : vecSelYesNoDialogItems) {
delete pUIListItem;
}
vecSelYesNoDialogItems.clear();
for (auto pUIItem : vecSelYesNoDialog) {
for (auto *pUIItem : vecSelYesNoDialog) {
delete pUIItem;
}
vecSelYesNoDialog.clear();

2
Source/DiabloUI/title.cpp

@ -25,7 +25,7 @@ void TitleFree()
ArtBackgroundWidescreen.Unload();
ArtLogos[LOGO_BIG].Unload();
for (auto pUIItem : vecTitleScreen) {
for (auto *pUIItem : vecTitleScreen) {
delete pUIItem;
}
vecTitleScreen.clear();

2
Source/controls/keymapper.cpp

@ -50,7 +50,7 @@ void Keymapper::keyPressed(int key) const
if (it == keyIDToAction.end())
return; // Ignore unmapped keys.
auto &action = it->second;
const auto &action = it->second;
// Check that the action can be triggered and that the chat textbox is not
// open.

2
Source/dead.cpp

@ -19,7 +19,7 @@ namespace {
void InitDeadAnimationFromMonster(DeadStruct &d, const CMonster &mon)
{
int i = 0;
for (auto &celSprite : mon.Anims[MA_DEATH].CelSpritesForDirections)
for (const auto &celSprite : mon.Anims[MA_DEATH].CelSpritesForDirections)
d._deadData[i++] = celSprite->Data();
d._deadFrame = mon.Anims[MA_DEATH].Frames;
d._deadWidth = mon.Anims[MA_DEATH].CelSpritesForDirections[0]->Width();

2
Source/dvlnet/base.cpp

@ -124,7 +124,7 @@ bool base::SNetSendMessage(int playerID, void *data, unsigned int size)
if (playerID != SNPLAYER_ALL && playerID != SNPLAYER_OTHERS
&& (playerID < 0 || playerID >= MAX_PLRS))
abort();
auto rawMessage = reinterpret_cast<unsigned char *>(data);
auto *rawMessage = reinterpret_cast<unsigned char *>(data);
buffer_t message(rawMessage, rawMessage + size);
if (playerID == plr_self || playerID == SNPLAYER_ALL)
message_queue.emplace_back(plr_self, message);

8
Source/items.cpp

@ -4264,7 +4264,7 @@ static void SpawnOnePremium(int i, int plvl, int myplr)
case ITYPE_LARMOR:
case ITYPE_MARMOR:
case ITYPE_HARMOR: {
const auto mostValuablePlayerArmor = myPlayer.GetMostValuableItem(
const auto *const mostValuablePlayerArmor = myPlayer.GetMostValuableItem(
[](const ItemStruct &item) {
return item._itype == ITYPE_LARMOR
|| item._itype == ITYPE_MARMOR
@ -4283,7 +4283,7 @@ static void SpawnOnePremium(int i, int plvl, int myplr)
case ITYPE_STAFF:
case ITYPE_RING:
case ITYPE_AMULET: {
const auto mostValuablePlayerItem = myPlayer.GetMostValuableItem(
const auto *const mostValuablePlayerItem = myPlayer.GetMostValuableItem(
[](const ItemStruct &item) { return item._itype == items[0]._itype; });
ivalue = mostValuablePlayerItem == nullptr ? 0 : mostValuablePlayerItem->_iIvalue;
@ -4517,7 +4517,7 @@ void SpawnBoy(int lvl)
case ITYPE_LARMOR:
case ITYPE_MARMOR:
case ITYPE_HARMOR: {
const auto mostValuablePlayerArmor = myPlayer.GetMostValuableItem(
const auto *const mostValuablePlayerArmor = myPlayer.GetMostValuableItem(
[](const ItemStruct &item) {
return item._itype == ITYPE_LARMOR
|| item._itype == ITYPE_MARMOR
@ -4536,7 +4536,7 @@ void SpawnBoy(int lvl)
case ITYPE_STAFF:
case ITYPE_RING:
case ITYPE_AMULET: {
const auto mostValuablePlayerItem = myPlayer.GetMostValuableItem(
const auto *const mostValuablePlayerItem = myPlayer.GetMostValuableItem(
[itemType](const ItemStruct &item) { return item._itype == itemType; });
ivalue = mostValuablePlayerItem == nullptr ? 0 : mostValuablePlayerItem->_iIvalue;

2
Source/missiles.cpp

@ -2368,7 +2368,7 @@ void InitMissileAnimationFromMonster(MissileStruct &mis, int midir, const Monste
const AnimStruct &anim = mon.MType->Anims[graphic];
mis._mimfnum = midir;
mis._miAnimFlags = 0;
auto &celSprite = *anim.CelSpritesForDirections[midir];
const auto &celSprite = *anim.CelSpritesForDirections[midir];
mis._miAnimData = celSprite.Data();
mis._miAnimDelay = anim.Rate;
mis._miAnimLen = anim.Frames;

6
Source/scrollrt.cpp

@ -250,7 +250,7 @@ void DrawMissilePrivate(const CelOutputBuffer &out, MissileStruct *m, int sx, in
return;
}
int nCel = m->_miAnimFrame;
auto frameTable = reinterpret_cast<const uint32_t *>(m->_miAnimData);
const auto *frameTable = reinterpret_cast<const uint32_t *>(m->_miAnimData);
int frames = SDL_SwapLE32(frameTable[0]);
if (nCel < 1 || frames > 50 || nCel > frames) {
Log("Draw Missile 2: frame {} of {}, missile type=={}", nCel, frames, m->_mitype);
@ -321,7 +321,7 @@ static void DrawMonster(const CelOutputBuffer &out, int x, int y, int mx, int my
}
int nCel = monster[m].AnimInfo.GetFrameToUseForRendering();
auto frameTable = reinterpret_cast<const uint32_t *>(monster[m].AnimInfo.pCelSprite->Data());
const auto *frameTable = reinterpret_cast<const uint32_t *>(monster[m].AnimInfo.pCelSprite->Data());
int frames = SDL_SwapLE32(frameTable[0]);
if (nCel < 1 || frames > 50 || nCel > frames) {
const char *szMode = "unknown action";
@ -786,7 +786,7 @@ static void scrollrt_draw_dungeon(const CelOutputBuffer &out, int sx, int sy, in
int px = dx - CalculateWidth2(pDeadGuy->_deadWidth);
const byte *pCelBuff = pDeadGuy->_deadData[dd];
assert(pCelBuff != nullptr);
auto frameTable = reinterpret_cast<const uint32_t *>(pCelBuff);
const auto *frameTable = reinterpret_cast<const uint32_t *>(pCelBuff);
int frames = SDL_SwapLE32(frameTable[0]);
int nCel = pDeadGuy->_deadFrame;
if (nCel < 1 || frames > 50 || nCel > frames) {

Loading…
Cancel
Save