From 0a0ddf2145fe87644889734d96f071ff389e21a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sun, 30 Oct 2022 13:10:53 +0100 Subject: [PATCH] Pass parameters by const reference instead of value when possible According to cppcheck's `passedByValue` error. --- src/game/client/components/ghost.cpp | 2 +- src/game/client/components/ghost.h | 2 +- src/tools/map_replace_area.cpp | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/game/client/components/ghost.cpp b/src/game/client/components/ghost.cpp index aefb66e1f..f75c3f56e 100644 --- a/src/game/client/components/ghost.cpp +++ b/src/game/client/components/ghost.cpp @@ -106,7 +106,7 @@ void CGhost::CGhostPath::SetSize(int Items) m_NumItems = Items; } -void CGhost::CGhostPath::Add(CGhostCharacter Char) +void CGhost::CGhostPath::Add(const CGhostCharacter &Char) { SetSize(m_NumItems + 1); *Get(m_NumItems - 1) = Char; diff --git a/src/game/client/components/ghost.h b/src/game/client/components/ghost.h index a51c5c7bd..808ff3d71 100644 --- a/src/game/client/components/ghost.h +++ b/src/game/client/components/ghost.h @@ -80,7 +80,7 @@ private: void SetSize(int Items); int Size() const { return m_NumItems; } - void Add(CGhostCharacter Char); + void Add(const CGhostCharacter &Char); CGhostCharacter *Get(int Index); }; diff --git a/src/tools/map_replace_area.cpp b/src/tools/map_replace_area.cpp index a5ea3880c..9506df4f0 100644 --- a/src/tools/map_replace_area.cpp +++ b/src/tools/map_replace_area.cpp @@ -43,12 +43,12 @@ bool AdaptVisiblePoint(const float[2][2][2], const float[2][2], const MapObject[ MapObject CreateMapObject(const CMapItemGroup *, int, int, int, int); void SetExtendedArea(MapObject &); -bool GetVisibleArea(const float[2][2], MapObject, float[2][2] = 0x0); -bool GetReplaceableArea(const float[2][2], MapObject, float[2][2]); +bool GetVisibleArea(const float[2][2], const MapObject &, float[2][2] = 0x0); +bool GetReplaceableArea(const float[2][2], const MapObject &, float[2][2]); void GetGameAreaDistance(const float[2][2][2], const MapObject[2], const float[2][2][2], float[2]); void GetGameAreaDistance(const float[2][2][2], const MapObject[2], const float[2][2], float[2]); -void GetSignificantScreenPos(MapObject, const float[2][2], const float[2][2], float[2]); +void GetSignificantScreenPos(const MapObject &, const float[2][2], const float[2][2], float[2]); void ConvertToTiles(const float[2][2], int[2][2]); bool GetLineIntersection(const float[2], const float[2], float[2] = 0x0); @@ -511,7 +511,7 @@ void SetExtendedArea(MapObject &Ob) } } -bool GetVisibleArea(const float aaGameArea[2][2], const MapObject Ob, float aaVisibleArea[2][2]) +bool GetVisibleArea(const float aaGameArea[2][2], const MapObject &Ob, float aaVisibleArea[2][2]) { if(IsInexistent((float *)Ob.m_aaExtendedArea, 4)) return false; @@ -543,7 +543,7 @@ bool GetVisibleArea(const float aaGameArea[2][2], const MapObject Ob, float aaVi return true; } -bool GetReplaceableArea(const float aaVisibleArea[2][2], const MapObject Ob, float aaReplaceableArea[2][2]) +bool GetReplaceableArea(const float aaVisibleArea[2][2], const MapObject &Ob, float aaReplaceableArea[2][2]) { SetInexistent((float *)aaReplaceableArea, 4); if(IsInexistent((float *)aaVisibleArea, 4)) @@ -599,7 +599,7 @@ void GetGameAreaDistance(const float aaaGameAreas[2][2][2], const MapObject aObs GetGameAreaDistance(aaaGameAreas, aObs, aaaVisibleAreas, aDistance); } -void GetSignificantScreenPos(const MapObject Ob, const float aaVisibleArea[2][2], const float aaReplaceableArea[2][2], float aScreen[2]) +void GetSignificantScreenPos(const MapObject &Ob, const float aaVisibleArea[2][2], const float aaReplaceableArea[2][2], float aScreen[2]) { for(int i = 0; i < 2; i++) {