Skip to content

Commit

Permalink
clang-tidy (#11082)
Browse files Browse the repository at this point in the history
* readability-inconsistent-declaration-parameter-name

* modernize-use-bool-literals

warning: converting integer literal to bool, use bool literal instead [modernize-use-bool-literals]

* readability-simplify-boolean-expr

* refractor
  • Loading branch information
JohnsterID authored Jul 6, 2024
1 parent 13683f4 commit 726456a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
6 changes: 3 additions & 3 deletions CvGameCoreDLL_Expansion2/CvBuilderTaskingAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ class CvBuilderTaskingAI
void LogDirective(BuilderDirective directive, int iWeight, bool bChosen = false);

void ConnectCitiesToCapital(CvCity* pPlayerCapital, CvCity* pTargetCity, BuildTypes eBuild, RouteTypes eRoute);
void ConnectCitiesForShortcuts(CvCity* pFirstCity, CvCity* pSecondCity, BuildTypes eBuild, RouteTypes eRoute);
void ConnectCitiesForScenario(CvCity* pFirstCity, CvCity* pSecondCity, BuildTypes eBuild, RouteTypes eRoute);
void ConnectCitiesForShortcuts(CvCity* pCity1, CvCity* pCity2, BuildTypes eBuild, RouteTypes eRoute);
void ConnectCitiesForScenario(CvCity* pCity1, CvCity* pCity2, BuildTypes eBuild, RouteTypes eRoute);
void ConnectPointsForStrategy(CvCity* pOriginCity, CvPlot* pTargetPlot, BuildTypes eBuild, RouteTypes eRoute);

void ShortcutConnectionHelper(CvCity* pCity1, CvCity* pCity2, BuildTypes eBuild, RouteTypes eRoute, int iPlotDistance, bool bUseRivers);
Expand All @@ -172,7 +172,7 @@ class CvBuilderTaskingAI
void AddRoutePlots(CvPlot* pStartPlot, CvPlot* pTargetPlot, RouteTypes eRoute, int iValue, const SPath& path, RoutePurpose ePurpose, bool bUseRivers);
int GetMoveCostWithRoute(const CvPlot* pFromPlot, const CvPlot* pToPlot, RouteTypes eFromPlotRoute, RouteTypes eToPlotRoute);
int GetPlotYieldModifierTimes100(CvPlot* pPlot, YieldTypes eYield);
void GetPathValues(const SPath& path, RouteTypes eRoute, int& iVillageBonusesIfCityConnected, int& iTotalMoveCost, int& iNumRoadsNeededToBuild);
void GetPathValues(const SPath& path, RouteTypes eRoute, int& iVillageBonusesIfCityConnected, int& iMovementBonus, int& iNumRoadsNeededToBuild);

int GetRouteBuildTime(PlannedRoute plannedRoute, const CvUnit* pUnit = (CvUnit*)NULL) const;
int GetRouteMissingTiles(PlannedRoute plannedRoute) const;
Expand Down
11 changes: 7 additions & 4 deletions CvGameCoreDLL_Expansion2/CvCity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8485,13 +8485,16 @@ bool CvCity::hasBuildingPrerequisites(BuildingTypes eBuilding) const
}
}

// Check if a specific prerequisite building is needed in this city
BuildingTypes ePrereqBuilding = static_cast<BuildingTypes>(pkBuildingInfo->GetNeedBuildingThisCity());
if (ePrereqBuilding != NO_BUILDING && !HasBuilding(ePrereqBuilding))
return false;

return true;
}
// Determine if no prerequisite building is needed or the prerequisite building is present
bool bNoPrereqBuilding = (ePrereqBuilding == NO_BUILDING);
bool bHasPrereqBuilding = HasBuilding(ePrereqBuilding);

// Return true if no specific prerequisite building is needed or it is present in the city
return bNoPrereqBuilding || bHasPrereqBuilding;
}

// --------------------------------------------------------------------------------
bool CvCity::canTrain(UnitTypes eUnit, bool bContinue, bool bTestVisible, bool bIgnoreCost, bool bWillPurchase, CvString* toolTipSink) const
Expand Down
5 changes: 1 addition & 4 deletions CvGameCoreDLL_Expansion2/CvCultureClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6914,10 +6914,7 @@ bool CvCityCulture::IsThemingBonusPossible(BuildingClassTypes eBuildingClass) co
{
const BuildingTypes eBuilding = m_pCity->GetBuildingTypeFromClass(eBuildingClass, true);
CvBuildingEntry* pkBuildingInfo = GC.getBuildingInfo(eBuilding);
if (pkBuildingInfo && pkBuildingInfo->GetThemingBonusInfo(0))
return true;

return false;
return pkBuildingInfo && pkBuildingInfo->GetThemingBonusInfo(0);
}

int CvCityCulture::GetThemingBonus(BuildingClassTypes eBuildingClass) const
Expand Down
2 changes: 1 addition & 1 deletion CvGameCoreDLL_Expansion2/CvMinorCivAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5737,7 +5737,7 @@ int CvMinorCivAI::GetNumThreateningMajors()
bool CvMinorCivAI::IsAnyBarbarianInBorders()
{
if (GetPlayer()->getCapitalCity() == NULL)
return 0;
return false;

int iLoop = 0;
for (CvUnit* pLoopUnit = GET_PLAYER(BARBARIAN_PLAYER).firstUnit(&iLoop); NULL != pLoopUnit; pLoopUnit = GET_PLAYER(BARBARIAN_PLAYER).nextUnit(&iLoop))
Expand Down
2 changes: 2 additions & 0 deletions CvGameCoreDLL_Expansion2/CvTeam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4298,9 +4298,11 @@ bool CvTeam::SetHasFoundPlayersTerritory(PlayerTypes ePlayer, bool bValue)

if (IsHasFoundPlayersTerritory(ePlayer) != bValue)
{
// Update the player's territory discovery status and return true indicating a change
m_abHasFoundPlayersTerritory[ePlayer] = bValue;
return true;
}
// Return false indicating no change
return false;
}

Expand Down
11 changes: 4 additions & 7 deletions CvGameCoreDLL_Expansion2/CvTradeClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,11 @@ bool CvGameTrade::HavePotentialTradePath(bool bWater, CvCity* pOriginCity, CvCit

int iCityPlotA = pOriginCity->plot()->GetPlotIndex();
int iCityPlotB = pDestCity->plot()->GetPlotIndex();
if (HaveTradePathInCache(cache, iCityPlotA, iCityPlotB))
{
if (pPathOut)
*pPathOut = cache[iCityPlotA][iCityPlotB];
return true;
}
bool hasPath = HaveTradePathInCache(cache, iCityPlotA, iCityPlotB);
if (hasPath && pPathOut)
*pPathOut = cache[iCityPlotA][iCityPlotB];

return false;
return hasPath;
}

void CvGameTrade::InvalidateTradePathCache()
Expand Down

0 comments on commit 726456a

Please sign in to comment.