Skip to content

Commit

Permalink
clang-tidy (#10999)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
JohnsterID authored Jun 17, 2024
1 parent d105c45 commit 120a565
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 28 deletions.
7 changes: 1 addition & 6 deletions CvGameCoreDLL_Expansion2/CvCityStrategyAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions CvGameCoreDLL_Expansion2/CvDiplomacyAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion CvGameCoreDLL_Expansion2/CvHomelandAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
10 changes: 2 additions & 8 deletions CvGameCoreDLL_Expansion2/CvInfos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down Expand Up @@ -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);
}

//======================================================================================================
Expand Down
2 changes: 1 addition & 1 deletion CvGameCoreDLL_Expansion2/CvMinorCivAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion CvGameCoreDLL_Expansion2/CvPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
//--------
Expand Down
2 changes: 1 addition & 1 deletion CvGameCoreDLL_Expansion2/CvPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
7 changes: 1 addition & 6 deletions CvGameCoreDLL_Expansion2/CvUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

// --------------------------------------------------------------------------------
Expand Down

0 comments on commit 120a565

Please sign in to comment.