From 0f2590801da870461d4ea13348d0a6a23bef4db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sun, 30 Oct 2022 16:17:11 +0100 Subject: [PATCH] Clarify operator precedence According to cppcheck's `clarifyCalculation` error: ``` src\game\client\components\hud.cpp:196:49: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation] float ImageSize = GameFlags & GAMEFLAG_FLAGS ? 16.0f : Split; ^ src\game\editor\layer_tiles.cpp:544:94: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation] m_pTiles[y * m_Width + x].m_Flags ^= m_pTiles[y * m_Width + x].m_Flags & TILEFLAG_ROTATE ? TILEFLAG_HFLIP : TILEFLAG_VFLIP; ^ src\game\editor\layer_tiles.cpp:560:94: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation] m_pTiles[y * m_Width + x].m_Flags ^= m_pTiles[y * m_Width + x].m_Flags & TILEFLAG_ROTATE ? TILEFLAG_VFLIP : TILEFLAG_HFLIP; ^ ``` --- src/game/client/components/hud.cpp | 2 +- src/game/editor/layer_tiles.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index b49acc590..331ee80f2 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -193,7 +193,7 @@ void CHud::RenderScoreHud() static float s_TextWidth100 = TextRender()->TextWidth(0, 14.0f, "100", -1, -1.0f); float ScoreWidthMax = maximum(maximum(m_aScoreInfo[0].m_ScoreTextWidth, m_aScoreInfo[1].m_ScoreTextWidth), s_TextWidth100); float Split = 3.0f; - float ImageSize = GameFlags & GAMEFLAG_FLAGS ? 16.0f : Split; + float ImageSize = (GameFlags & GAMEFLAG_FLAGS) ? 16.0f : Split; for(int t = 0; t < 2; t++) { // draw box diff --git a/src/game/editor/layer_tiles.cpp b/src/game/editor/layer_tiles.cpp index 22ca9fc6a..261467fea 100644 --- a/src/game/editor/layer_tiles.cpp +++ b/src/game/editor/layer_tiles.cpp @@ -541,7 +541,7 @@ void CLayerTiles::BrushFlipX() if(!Rotate && !IsRotatableTile(m_pTiles[y * m_Width + x].m_Index)) m_pTiles[y * m_Width + x].m_Flags = 0; else - m_pTiles[y * m_Width + x].m_Flags ^= m_pTiles[y * m_Width + x].m_Flags & TILEFLAG_ROTATE ? TILEFLAG_HFLIP : TILEFLAG_VFLIP; + m_pTiles[y * m_Width + x].m_Flags ^= (m_pTiles[y * m_Width + x].m_Flags & TILEFLAG_ROTATE) ? TILEFLAG_HFLIP : TILEFLAG_VFLIP; } void CLayerTiles::BrushFlipY() @@ -557,7 +557,7 @@ void CLayerTiles::BrushFlipY() if(!Rotate && !IsRotatableTile(m_pTiles[y * m_Width + x].m_Index)) m_pTiles[y * m_Width + x].m_Flags = 0; else - m_pTiles[y * m_Width + x].m_Flags ^= m_pTiles[y * m_Width + x].m_Flags & TILEFLAG_ROTATE ? TILEFLAG_VFLIP : TILEFLAG_HFLIP; + m_pTiles[y * m_Width + x].m_Flags ^= (m_pTiles[y * m_Width + x].m_Flags & TILEFLAG_ROTATE) ? TILEFLAG_VFLIP : TILEFLAG_HFLIP; } void CLayerTiles::BrushRotate(float Amount)