From 120a565f5ff9fbfc148ff570f0bbb8c0ee922e82 Mon Sep 17 00:00:00 2001 From: JohnsterID <69278611+JohnsterID@users.noreply.github.com> Date: Tue, 18 Jun 2024 01:44:57 +0930 Subject: [PATCH] clang-tidy (#10999) * Fix performance-unnecessary-value-param warning: the parameter 'strLogMessage' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] * Fix readability-isolate-declaration warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration] * Fix readability-inconsistent-declaration-parameter-name * Fix readability-simplify-boolean-expr * Revert CvTeam.cpp change --- CvGameCoreDLL_Expansion2/CvCityStrategyAI.cpp | 7 +------ CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp | 4 ++-- CvGameCoreDLL_Expansion2/CvDiplomacyAI.h | 4 ++-- CvGameCoreDLL_Expansion2/CvHomelandAI.cpp | 3 ++- CvGameCoreDLL_Expansion2/CvInfos.cpp | 10 ++-------- CvGameCoreDLL_Expansion2/CvMinorCivAI.h | 2 +- CvGameCoreDLL_Expansion2/CvPlayer.cpp | 3 ++- CvGameCoreDLL_Expansion2/CvPlot.cpp | 2 +- CvGameCoreDLL_Expansion2/CvUnit.cpp | 7 +------ 9 files changed, 14 insertions(+), 28 deletions(-) diff --git a/CvGameCoreDLL_Expansion2/CvCityStrategyAI.cpp b/CvGameCoreDLL_Expansion2/CvCityStrategyAI.cpp index 80fd2ac270..4b219f88ae 100644 --- a/CvGameCoreDLL_Expansion2/CvCityStrategyAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvCityStrategyAI.cpp @@ -3298,12 +3298,7 @@ bool CityStrategyAIHelpers::IsTestCityStrategy_GoodGPCity(CvCity* pCity) } } - if (iTotalGPPChange >= 2500) - { - return true; - } - - return false; + return iTotalGPPChange >= 2500; } bool CityStrategyAIHelpers::IsTestCityStrategy_NeedInternationalTradeRoute (CvCity* pCity, DomainTypes eDomain) diff --git a/CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp b/CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp index f7a2633961..eb14fd26f4 100644 --- a/CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp @@ -27104,7 +27104,7 @@ int CvDiplomacyAI::CountUnitsAroundEnemyCities(PlayerTypes ePlayer, int iTurnRan } /// Disables the possibility of AI making peace with a major civ & logs the reason why -void CvDiplomacyAI::RefusePeaceTreaty(PlayerTypes ePlayer, CvString strLogMessage) +void CvDiplomacyAI::RefusePeaceTreaty(PlayerTypes ePlayer, const CvString& strLogMessage) { SetTreatyWillingToOffer(ePlayer, NO_PEACE_TREATY_TYPE); SetTreatyWillingToAccept(ePlayer, NO_PEACE_TREATY_TYPE); @@ -27113,7 +27113,7 @@ void CvDiplomacyAI::RefusePeaceTreaty(PlayerTypes ePlayer, CvString strLogMessag } /// Logs the reason for a peace refusal or automatic peace offer by this AI -void CvDiplomacyAI::LogPeaceWillingnessReason(PlayerTypes ePlayer, CvString strLogMessage) +void CvDiplomacyAI::LogPeaceWillingnessReason(PlayerTypes ePlayer, const CvString& strLogMessage) { CvString strLogName = GC.getDiploPeaceLogFileName(GetPlayer()); CvString playerName = GetPlayer()->getCivilizationShortDescription(); diff --git a/CvGameCoreDLL_Expansion2/CvDiplomacyAI.h b/CvGameCoreDLL_Expansion2/CvDiplomacyAI.h index 5b9145943c..8f49a04b8e 100644 --- a/CvGameCoreDLL_Expansion2/CvDiplomacyAI.h +++ b/CvGameCoreDLL_Expansion2/CvDiplomacyAI.h @@ -1225,8 +1225,8 @@ class CvDiplomacyAI PeaceBlockReasons GetPeaceBlockReason(PlayerTypes ePlayer) const; void FmtPeaceBlockReasonLogStr(CvString& str, PlayerTypes eThisPlayer, PlayerTypes eAtWarPlayer, PeaceBlockReasons eReason); int CountUnitsAroundEnemyCities(PlayerTypes ePlayer, int iTurnRange) const; - void RefusePeaceTreaty(PlayerTypes ePlayer, CvString strLogMessage); - void LogPeaceWillingnessReason(PlayerTypes ePlayer, CvString strLogMessage); + void RefusePeaceTreaty(PlayerTypes ePlayer, const CvString& strLogMessage); + void LogPeaceWillingnessReason(PlayerTypes ePlayer, const CvString& strLogMessage); // ------------------------------------ // Vassal Taxation diff --git a/CvGameCoreDLL_Expansion2/CvHomelandAI.cpp b/CvGameCoreDLL_Expansion2/CvHomelandAI.cpp index 627d2a7ef5..2847a22e95 100644 --- a/CvGameCoreDLL_Expansion2/CvHomelandAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvHomelandAI.cpp @@ -1410,7 +1410,8 @@ void CvHomelandAI::PlotUpgradeMoves() if (GC.getLogging() && GC.getAILogging()) { CvString strLogString; - CvString strTemp1, strTemp2; + CvString strTemp1; + CvString strTemp2; strTemp1 = GC.getUnitInfo(pUnit->getUnitType())->GetDescription(); strTemp2 = GC.getUnitInfo(pNewUnit->getUnitType())->GetDescription(); strLogString.Format("Upgrading unit from type %s to type %s, X: %d, Y: %d", strTemp1.GetCString(), strTemp2.GetCString(), pNewUnit->getX(), pNewUnit->getY()); diff --git a/CvGameCoreDLL_Expansion2/CvInfos.cpp b/CvGameCoreDLL_Expansion2/CvInfos.cpp index edbf767345..b00eee916c 100644 --- a/CvGameCoreDLL_Expansion2/CvInfos.cpp +++ b/CvGameCoreDLL_Expansion2/CvInfos.cpp @@ -2945,10 +2945,7 @@ bool CvSmallAwardInfo::CacheResults(Database::Results& kResults, CvDatabaseUtili //====================================================================================================== bool CvHurryInfo::CacheResults(Database::Results& kResults, CvDatabaseUtility& kUtility) { - if(!CvBaseInfo::CacheResults(kResults, kUtility)) - return false; - - return true; + return CvBaseInfo::CacheResults(kResults, kUtility); } @@ -5845,10 +5842,7 @@ bool CvRouteInfo::CacheResults(Database::Results& kResults, CvDatabaseUtility& k //====================================================================================================== bool CvResourceClassInfo::CacheResults(Database::Results& kResults, CvDatabaseUtility& kUtility) { - if(!CvBaseInfo::CacheResults(kResults, kUtility)) - return false; - - return true; + return CvBaseInfo::CacheResults(kResults, kUtility); } //====================================================================================================== diff --git a/CvGameCoreDLL_Expansion2/CvMinorCivAI.h b/CvGameCoreDLL_Expansion2/CvMinorCivAI.h index f0e5eb9bd9..b7679c0aae 100644 --- a/CvGameCoreDLL_Expansion2/CvMinorCivAI.h +++ b/CvGameCoreDLL_Expansion2/CvMinorCivAI.h @@ -863,7 +863,7 @@ class CvMinorCivAI private: //return true if an actual change occurred bool SetAllyInternal(PlayerTypes eNewAlly); - void ProcessAllyChangeNotifications(PlayerTypes eOldAlly, PlayerTypes eNewAlly, bool bSuppressSelfNotification); + void ProcessAllyChangeNotifications(PlayerTypes eOldAlly, PlayerTypes eNewAlly, bool bSuppressDirectNotification); void DoSetBonus(PlayerTypes ePlayer, bool bAdd, bool bFriendChange, bool bAllyChange); CvPlayer* m_pPlayer; diff --git a/CvGameCoreDLL_Expansion2/CvPlayer.cpp b/CvGameCoreDLL_Expansion2/CvPlayer.cpp index 2b8eec3e9a..d8ddcca74f 100644 --- a/CvGameCoreDLL_Expansion2/CvPlayer.cpp +++ b/CvGameCoreDLL_Expansion2/CvPlayer.cpp @@ -47806,7 +47806,8 @@ CvPlot* CvPlayer::GetBestSettlePlot(const CvUnit* pUnit, CvAIOperation* pOpToIgn //-------- bool bLogging = (GC.getLogging() && GC.getAILogging()) || bForceLogging; std::stringstream dump; - int iDanger=0, iFertility=0; + int iDanger=0; + int iFertility=0; bLogging &= MOD_BALANCE_CORE_MILITARY_LOGGING; //-------- diff --git a/CvGameCoreDLL_Expansion2/CvPlot.cpp b/CvGameCoreDLL_Expansion2/CvPlot.cpp index 80101961f7..05cbc401eb 100644 --- a/CvGameCoreDLL_Expansion2/CvPlot.cpp +++ b/CvGameCoreDLL_Expansion2/CvPlot.cpp @@ -11438,7 +11438,7 @@ PlotVisibilityChangeResult CvPlot::changeVisibilityCount(TeamTypes eTeam, int iC } // We could se the plot before but not anymore // With delayed visibility we do this in setTurnActive() - else if (!MOD_CORE_DELAYED_VISIBILITY && bOldVisibility == true && !isVisible(eTeam)) + else if (!MOD_CORE_DELAYED_VISIBILITY && bOldVisibility && !isVisible(eTeam)) { eResult = VISIBILITY_CHANGE_TO_INVISIBLE; if (eTeam == GC.getGame().getActiveTeam()) diff --git a/CvGameCoreDLL_Expansion2/CvUnit.cpp b/CvGameCoreDLL_Expansion2/CvUnit.cpp index 097e7becf8..d3fc5316b9 100644 --- a/CvGameCoreDLL_Expansion2/CvUnit.cpp +++ b/CvGameCoreDLL_Expansion2/CvUnit.cpp @@ -12243,12 +12243,7 @@ bool CvUnit::canRepairFleet(const CvPlot* /*pPlot*/, bool /*bTestVisible*/) cons bool bHasSkill = !MOD_GLOBAL_SEPARATE_GREAT_ADMIRAL && IsGreatAdmiral(); bHasSkill = bHasSkill || (MOD_GLOBAL_SEPARATE_GREAT_ADMIRAL && m_pUnitInfo->IsCanRepairFleet()); - if (!bHasSkill) - { - return false; - } - - return true; + return bHasSkill; } // --------------------------------------------------------------------------------