diff --git a/Source/DiabloUI/diabloui.cpp b/Source/DiabloUI/diabloui.cpp index 55b6dfd8d..2e6b11a2b 100644 --- a/Source/DiabloUI/diabloui.cpp +++ b/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(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 &items) { - for (auto &item : items) + for (const auto &item : items) RenderItem(item); } @@ -945,7 +945,7 @@ bool UiItemMouseEvents(SDL_Event *event, const std::vector &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 &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(item)); } diff --git a/Source/DiabloUI/dialogs.cpp b/Source/DiabloUI/dialogs.cpp index d286270f6..200058550 100644 --- a/Source/DiabloUI/dialogs.cpp +++ b/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(); diff --git a/Source/DiabloUI/mainmenu.cpp b/Source/DiabloUI/mainmenu.cpp index 8948f983b..458ba8bea 100644 --- a/Source/DiabloUI/mainmenu.cpp +++ b/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(); diff --git a/Source/DiabloUI/selconn.cpp b/Source/DiabloUI/selconn.cpp index 9ecf2b9ba..7d9879437 100644 --- a/Source/DiabloUI/selconn.cpp +++ b/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(); diff --git a/Source/DiabloUI/selgame.cpp b/Source/DiabloUI/selgame.cpp index 0c95182fb..5d9dabf93 100644 --- a/Source/DiabloUI/selgame.cpp +++ b/Source/DiabloUI/selgame.cpp @@ -44,12 +44,12 @@ std::vector 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(); diff --git a/Source/DiabloUI/selhero.cpp b/Source/DiabloUI/selhero.cpp index 9802c966e..74ce6e982 100644 --- a/Source/DiabloUI/selhero.cpp +++ b/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(); diff --git a/Source/DiabloUI/selok.cpp b/Source/DiabloUI/selok.cpp index 7a037ae72..efbff99a7 100644 --- a/Source/DiabloUI/selok.cpp +++ b/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(); diff --git a/Source/DiabloUI/selyesno.cpp b/Source/DiabloUI/selyesno.cpp index b90a0c82f..42e6c2052 100644 --- a/Source/DiabloUI/selyesno.cpp +++ b/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(); diff --git a/Source/DiabloUI/title.cpp b/Source/DiabloUI/title.cpp index 02580f570..b00b50ab3 100644 --- a/Source/DiabloUI/title.cpp +++ b/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(); diff --git a/Source/controls/keymapper.cpp b/Source/controls/keymapper.cpp index 6b023fe3b..f91dad603 100644 --- a/Source/controls/keymapper.cpp +++ b/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. diff --git a/Source/dead.cpp b/Source/dead.cpp index 35842f327..4dbf76704 100644 --- a/Source/dead.cpp +++ b/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(); diff --git a/Source/dvlnet/base.cpp b/Source/dvlnet/base.cpp index 1e755a6fa..a419356a0 100644 --- a/Source/dvlnet/base.cpp +++ b/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(data); + auto *rawMessage = reinterpret_cast(data); buffer_t message(rawMessage, rawMessage + size); if (playerID == plr_self || playerID == SNPLAYER_ALL) message_queue.emplace_back(plr_self, message); diff --git a/Source/items.cpp b/Source/items.cpp index f79374828..af5327cb1 100644 --- a/Source/items.cpp +++ b/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; diff --git a/Source/missiles.cpp b/Source/missiles.cpp index d6fa9e755..9c7c442ee 100644 --- a/Source/missiles.cpp +++ b/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; diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index a7201e1c2..02f63ecb3 100644 --- a/Source/scrollrt.cpp +++ b/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(m->_miAnimData); + const auto *frameTable = reinterpret_cast(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(monster[m].AnimInfo.pCelSprite->Data()); + const auto *frameTable = reinterpret_cast(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(pCelBuff); + const auto *frameTable = reinterpret_cast(pCelBuff); int frames = SDL_SwapLE32(frameTable[0]); int nCel = pDeadGuy->_deadFrame; if (nCel < 1 || frames > 50 || nCel > frames) {