Skip to content

Commit 005e7dc

Browse files
committed
chore: clang-tidy cleanup part 1
1 parent 35b8c54 commit 005e7dc

File tree

98 files changed

+442
-468
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+442
-468
lines changed

Source/DiabloUI/credits.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void CreditsRenderer::Render()
131131
ScaleOutputRect(&viewport);
132132

133133
// We use unscaled coordinates for calculation throughout.
134-
Sint16 destY = static_cast<Sint16>(uiPosition.y + VIEWPORT.y - (offsetY - linesBegin * LINE_H));
134+
auto destY = static_cast<Sint16>(uiPosition.y + VIEWPORT.y - (offsetY - linesBegin * LINE_H));
135135
for (std::size_t i = linesBegin; i < linesEnd; ++i, destY += LINE_H) {
136136
const Sint16 destX = uiPosition.x + VIEWPORT.x + 31;
137137

Source/DiabloUI/diabloui.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,12 @@ void UiFocusPageUp()
357357

358358
void UiFocusPageDown()
359359
{
360-
if (listOffset + ListViewportSize > static_cast<std::size_t>(SelectedItemMax)) {
360+
if (listOffset + ListViewportSize > SelectedItemMax) {
361361
UiFocus(SelectedItemMax, false, true);
362362
} else {
363363
const std::size_t relpos = SelectedItem - listOffset;
364364
std::size_t nextPageEnd = SelectedItem + (ListViewportSize - relpos - 1);
365-
if (nextPageEnd + ListViewportSize <= static_cast<std::size_t>(SelectedItemMax))
365+
if (nextPageEnd + ListViewportSize <= SelectedItemMax)
366366
nextPageEnd += ListViewportSize;
367367
else
368368
nextPageEnd = SelectedItemMax;

Source/DiabloUI/hero/selhero.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void SelheroListSelect(size_t value)
175175
vecSelHeroDlgItems.clear();
176176
int itemH = 33;
177177
for (size_t i = 0; i < GetNumPlayerClasses(); ++i) {
178-
const HeroClass heroClass = static_cast<HeroClass>(i);
178+
const auto heroClass = static_cast<HeroClass>(i);
179179

180180
if (heroClass == HeroClass::Monk && !gbIsHellfire) {
181181
continue;
@@ -194,7 +194,7 @@ void SelheroListSelect(size_t value)
194194
}
195195
if (vecSelHeroDlgItems.size() > 4)
196196
itemH = 26;
197-
const int itemY = static_cast<int>(246 + (176 - std::min<size_t>(vecSelHeroDlgItems.size(), 6) * itemH) / 2);
197+
const int itemY = static_cast<int>(246 + ((176 - std::min<size_t>(vecSelHeroDlgItems.size(), 6) * itemH) / 2));
198198
vecSelDlgItems.push_back(std::make_unique<UiList>(vecSelHeroDlgItems, std::min<size_t>(vecSelHeroDlgItems.size(), 6), uiPosition.x + 264, (uiPosition.y + itemY), 320, itemH, UiFlags::AlignCenter | UiFlags::FontSize24 | UiFlags::ColorUiGold));
199199

200200
const SDL_Rect rectScrollBar = { (Sint16)(uiPosition.x + 585), (Sint16)(uiPosition.y + 244), 25, 178 };

Source/DiabloUI/multi/selconn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void SelconnLoad()
6969

7070
const Point uiPosition = GetUIRectangle().position;
7171

72-
const SDL_Rect rect1 = { (Sint16)(uiPosition.x + 24), (Sint16)(Sint16)(uiPosition.y + 161), 590, 35 };
72+
const SDL_Rect rect1 = { (Sint16)(uiPosition.x + 24), ((Sint16)(uiPosition.y + 161)), 590, 35 };
7373
vecSelConnDlg.push_back(std::make_unique<UiArtText>(_("Multi Player Game").data(), rect1, UiFlags::AlignCenter | UiFlags::FontSize30 | UiFlags::ColorUiSilver, 3));
7474

7575
const SDL_Rect rect2 = { (Sint16)(uiPosition.x + 35), (Sint16)(uiPosition.y + 218), DESCRIPTION_WIDTH, 21 };

Source/DiabloUI/settingsmenu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void UpdatePadEntryTimerText()
167167
StopPadEntryTimer();
168168
return;
169169
}
170-
padEntryTimerText = StrCat(_("Press gamepad buttons to change."), " ", 10 - elapsed / 1000);
170+
padEntryTimerText = StrCat(_("Press gamepad buttons to change."), " ", 10 - (elapsed / 1000));
171171
vecDialogItems[IndexPadTimerText]->m_text = padEntryTimerText;
172172
}
173173

Source/automap.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void DrawMapVerticalDoor(const Surface &out, Point center, AutomapTile neTile, u
216216
default:
217217
app_fatal("Invalid leveltype");
218218
}
219-
if (!(neTile.hasFlag(AutomapTile::Flags::VerticalPassage) && leveltype == DTYPE_CATHEDRAL))
219+
if (!neTile.hasFlag(AutomapTile::Flags::VerticalPassage) || leveltype != DTYPE_CATHEDRAL)
220220
DrawMapLineNE(out, center + AmOffset(lWidthOffset, lHeightOffset), AmLine(length), colorDim);
221221
DrawDiamond(out, center + AmOffset(dWidthOffset, dHeightOffset), colorBright);
222222
}
@@ -265,7 +265,7 @@ void DrawMapHorizontalDoor(const Surface &out, Point center, AutomapTile nwTile,
265265
default:
266266
app_fatal("Invalid leveltype");
267267
}
268-
if (!(nwTile.hasFlag(AutomapTile::Flags::HorizontalPassage) && leveltype == DTYPE_CATHEDRAL))
268+
if (!nwTile.hasFlag(AutomapTile::Flags::HorizontalPassage) || leveltype != DTYPE_CATHEDRAL)
269269
DrawMapLineSE(out, center + AmOffset(lWidthOffset, lHeightOffset), AmLine(length), colorDim);
270270
DrawDiamond(out, center + AmOffset(dWidthOffset, dHeightOffset), colorBright);
271271
}
@@ -747,7 +747,7 @@ void DrawVertical(const Surface &out, Point center, AutomapTile tile, AutomapTil
747747
* @brief Draw half-tile length lines to connect walls to any walls to the south-west and/or south-east
748748
* (For caves the horizontal/vertical flags are swapped)
749749
*/
750-
void DrawCaveWallConnections(const Surface &out, Point center, AutomapTile sTile, AutomapTile swTile, AutomapTile seTile, uint8_t colorDim)
750+
void DrawCaveWallConnections(const Surface &out, Point center, AutomapTile swTile, AutomapTile seTile, uint8_t colorDim)
751751
{
752752
if (IsAnyOf(swTile.type, AutomapTile::Types::CaveVerticalWallLava, AutomapTile::Types::CaveVertical, AutomapTile::Types::CaveVerticalWood, AutomapTile::Types::CaveCross, AutomapTile::Types::CaveWoodCross, AutomapTile::Types::CaveRightWoodCross, AutomapTile::Types::CaveLeftWoodCross, AutomapTile::Types::CaveRightCorner)) {
753753
DrawMapLineNE(out, center + AmOffset(AmWidthOffset::QuarterTileLeft, AmHeightOffset::ThreeQuartersTileDown), AmLine(AmLineLength::HalfTile), colorDim);
@@ -850,7 +850,7 @@ void DrawMapEllipse(const Surface &out, Point from, int radius, uint8_t colorInd
850850
SetMapPixel(out, { from.x, from.y - b }, colorIndex);
851851

852852
// Initialize the parameters
853-
int p1 = (b * b) - (a * a * b) + (a * a) / 4;
853+
int p1 = (b * b) - (a * a * b) + ((a * a) / 4);
854854

855855
// Region 1
856856
while ((b * b * x) < (a * a * y)) {
@@ -1056,7 +1056,7 @@ void DrawAutomapTile(const Surface &out, Point center, Point map)
10561056

10571057
if (!noConnect) {
10581058
if (IsAnyOf(leveltype, DTYPE_TOWN, DTYPE_CAVES, DTYPE_NEST)) {
1059-
DrawCaveWallConnections(out, center, sTile, swTile, seTile, colorDim);
1059+
DrawCaveWallConnections(out, center, swTile, seTile, colorDim);
10601060
}
10611061
DrawWallConnections(out, center, tile, nwTile, neTile, colorBright, colorDim);
10621062
}
@@ -1259,8 +1259,8 @@ Displacement GetAutomapScreen()
12591259

12601260
if (GetAutomapType() == AutomapType::Minimap) {
12611261
screen = {
1262-
MinimapRect.position.x + MinimapRect.size.width / 2,
1263-
MinimapRect.position.y + MinimapRect.size.height / 2
1262+
MinimapRect.position.x + (MinimapRect.size.width / 2),
1263+
MinimapRect.position.y + (MinimapRect.size.height / 2)
12641264
};
12651265
} else {
12661266
screen = {
@@ -1298,12 +1298,12 @@ void SearchAutomapItem(const Surface &out, const Displacement &myPlayerOffset, i
12981298
if (!highlightTile({ i, j }))
12991299
continue;
13001300

1301-
const int px = i - 2 * AutomapOffset.deltaX - ViewPosition.x;
1302-
const int py = j - 2 * AutomapOffset.deltaY - ViewPosition.y;
1301+
const int px = i - (2 * AutomapOffset.deltaX) - ViewPosition.x;
1302+
const int py = j - (2 * AutomapOffset.deltaY) - ViewPosition.y;
13031303

13041304
Point screen = {
1305-
(myPlayerOffset.deltaX * scale / 100 / 2) + (px - py) * AmLine(AmLineLength::DoubleTile),
1306-
(myPlayerOffset.deltaY * scale / 100 / 2) + (px + py) * AmLine(AmLineLength::FullTile),
1305+
(myPlayerOffset.deltaX * scale / 100 / 2) + ((px - py) * AmLine(AmLineLength::DoubleTile)),
1306+
(myPlayerOffset.deltaY * scale / 100 / 2) + ((px + py) * AmLine(AmLineLength::FullTile)),
13071307
};
13081308

13091309
screen += GetAutomapScreen();
@@ -1345,8 +1345,8 @@ void DrawAutomapPlr(const Surface &out, const Displacement &myPlayerOffset, cons
13451345

13461346
const Point tile = player.position.tile;
13471347

1348-
const int px = tile.x - 2 * AutomapOffset.deltaX - ViewPosition.x;
1349-
const int py = tile.y - 2 * AutomapOffset.deltaY - ViewPosition.y;
1348+
const int px = tile.x - (2 * AutomapOffset.deltaX) - ViewPosition.x;
1349+
const int py = tile.y - (2 * AutomapOffset.deltaY) - ViewPosition.y;
13501350

13511351
Displacement playerOffset = {};
13521352
if (player.isWalking())
@@ -1355,8 +1355,8 @@ void DrawAutomapPlr(const Surface &out, const Displacement &myPlayerOffset, cons
13551355
const int scale = (GetAutomapType() == AutomapType::Minimap) ? MinimapScale : AutoMapScale;
13561356

13571357
Point base = {
1358-
((playerOffset.deltaX + myPlayerOffset.deltaX) * scale / 100 / 2) + (px - py) * AmLine(AmLineLength::DoubleTile),
1359-
((playerOffset.deltaY + myPlayerOffset.deltaY) * scale / 100 / 2) + (px + py) * AmLine(AmLineLength::FullTile) + AmOffset(AmWidthOffset::None, AmHeightOffset::HalfTileUp).deltaY
1358+
((playerOffset.deltaX + myPlayerOffset.deltaX) * scale / 100 / 2) + ((px - py) * AmLine(AmLineLength::DoubleTile)),
1359+
((playerOffset.deltaY + myPlayerOffset.deltaY) * scale / 100 / 2) + ((px + py) * AmLine(AmLineLength::FullTile)) + AmOffset(AmWidthOffset::None, AmHeightOffset::HalfTileUp).deltaY
13601360
};
13611361

13621362
base += GetAutomapScreen();
@@ -1775,7 +1775,7 @@ void DrawAutomap(const Surface &out)
17751775

17761776
const int scale = (GetAutomapType() == AutomapType::Minimap) ? MinimapScale : AutoMapScale;
17771777
const int d = (scale * 64) / 100;
1778-
int cells = 2 * (gnScreenWidth / 2 / d) + 1;
1778+
int cells = (2 * (gnScreenWidth / 2 / d)) + 1;
17791779
if (((gnScreenWidth / 2) % d) != 0)
17801780
cells++;
17811781
if (((gnScreenWidth / 2) % d) >= (scale * 32) / 100)

Source/control/control_chat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void DrawChatBox(const Surface &out)
127127
continue;
128128

129129
const UiFlags color = player.friendlyMode ? UiFlags::ColorWhitegold : UiFlags::ColorRed;
130-
const Point talkPanPosition = mainPanelPosition + Displacement { 172, 84 + 18 * talkBtn };
130+
const Point talkPanPosition = mainPanelPosition + Displacement { 172, 84 + (18 * talkBtn) };
131131
if (WhisperList[i]) {
132132
// the normal (unpressed) voice button is pre-rendered on the panel, only need to draw over it when the button is held
133133
if (TalkButtonsDown[talkBtn]) {
@@ -149,7 +149,7 @@ void DrawChatBox(const Surface &out)
149149
RenderClxSprite(out, (*TalkButton)[TalkButtonsDown[talkBtn] ? 1 : 0], talkPanPosition + Displacement { 4, -15 });
150150
}
151151
if (player.plractive) {
152-
DrawString(out, player._pName, { { x, y + 60 + talkBtn * 18 }, { 204, 0 } }, { .flags = color });
152+
DrawString(out, player._pName, { { x, y + 60 + (talkBtn * 18) }, { 204, 0 } }, { .flags = color });
153153
}
154154

155155
talkBtn++;

Source/control/control_chat_commands.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ bool IsQuestEnabled(const Quest &quest)
173173
}
174174
}
175175

176-
std::string TextCmdLevelSeed(const std::string_view parameter)
176+
std::string TextCmdLevelSeed(const std::string_view /*parameter*/)
177177
{
178178
const std::string_view levelType = setlevel ? "set level" : "dungeon level";
179179

Source/control/control_infobox.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@ int GetHoverSpriteHeight()
211211
&& pcursinvitem < INVITEM_INV_FIRST + InventoryGridCells) {
212212
const int idx = pcursinvitem - INVITEM_INV_FIRST;
213213
auto &it = (*InspectPlayer).InvList[idx];
214-
return GetInventorySize(it).height * (InventorySlotSizeInPixels.height + 1)
214+
return (GetInventorySize(it).height * (InventorySlotSizeInPixels.height + 1))
215215
- InventorySlotSizeInPixels.height;
216216
}
217217
if (pcursinvitem >= INVITEM_BELT_FIRST
218218
&& pcursinvitem < INVITEM_BELT_FIRST + MaxBeltItems) {
219219
const int idx = pcursinvitem - INVITEM_BELT_FIRST;
220220
auto &it = (*InspectPlayer).SpdList[idx];
221-
return GetInventorySize(it).height * (InventorySlotSizeInPixels.height + 1)
221+
return (GetInventorySize(it).height * (InventorySlotSizeInPixels.height + 1))
222222
- InventorySlotSizeInPixels.height - 1;
223223
}
224224
if (pcursstashitem != StashStruct::EmptyCell) {
@@ -236,7 +236,7 @@ int GetHoverSpriteHeight()
236236
int ClampAboveOrBelow(int anchorY, int spriteH, int boxH, int pad, int linePad)
237237
{
238238
const int yAbove = anchorY - spriteH - boxH - pad;
239-
const int yBelow = anchorY + linePad / 2 + pad;
239+
const int yBelow = anchorY + (linePad / 2) + pad;
240240
return (yAbove >= 0) ? yAbove : yBelow;
241241
}
242242

@@ -267,7 +267,7 @@ void PrintFloatingInfo(const Surface &out)
267267
SpeakText(FloatingInfoString);
268268

269269
for (int i = 0; i < 3; i++)
270-
DrawHalfTransparentRectTo(out, floatingInfoBox.position.x - hPadding, floatingInfoBox.position.y - vPadding, floatingInfoBox.size.width + hPadding * 2, floatingInfoBox.size.height + vPadding * 2);
270+
DrawHalfTransparentRectTo(out, floatingInfoBox.position.x - hPadding, floatingInfoBox.position.y - vPadding, floatingInfoBox.size.width + (hPadding * 2), floatingInfoBox.size.height + (vPadding * 2));
271271
DrawHalfTransparentVerticalLine(out, { floatingInfoBox.position.x - hPadding - 1, floatingInfoBox.position.y - vPadding - 1 }, floatingInfoBox.size.height + (vPadding * 2) + 2, PAL16_GRAY + 10);
272272
DrawHalfTransparentVerticalLine(out, { floatingInfoBox.position.x + hPadding + floatingInfoBox.size.width, floatingInfoBox.position.y - vPadding - 1 }, floatingInfoBox.size.height + (vPadding * 2) + 2, PAL16_GRAY + 10);
273273
DrawHalfTransparentHorizontalLine(out, { floatingInfoBox.position.x - hPadding, floatingInfoBox.position.y - vPadding - 1 }, floatingInfoBox.size.width + (hPadding * 2), PAL16_GRAY + 10);

Source/control/control_panel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ tl::expected<void, std::string> InitMainPanel()
378378
if (!HeadlessMode) {
379379
{
380380
ASSIGN_OR_RETURN(const OwnedClxSpriteList sprite, LoadCelWithStatus("ctrlpan\\talkpanl", GetMainPanel().size.width));
381-
ClxDraw(*BottomBuffer, { 0, (GetMainPanel().size.height + PanelPaddingHeight) * 2 - 1 }, sprite[0]);
381+
ClxDraw(*BottomBuffer, { 0, ((GetMainPanel().size.height + PanelPaddingHeight) * 2) - 1 }, sprite[0]);
382382
}
383383
multiButtons = LoadCel("ctrlpan\\p8but2", 33);
384384
talkButtons = LoadCel("ctrlpan\\talkbutt", 61);
@@ -794,7 +794,7 @@ void DrawDeathText(const Surface &out)
794794
};
795795
std::string text;
796796
const int verticalPadding = 42;
797-
Point linePosition { 0, gnScreenHeight / 2 - (verticalPadding * 2) };
797+
Point linePosition { 0, (gnScreenHeight / 2) - (verticalPadding * 2) };
798798

799799
text = _("You have died");
800800
DrawString(out, text, linePosition, largeTextOptions);

0 commit comments

Comments
 (0)