Skip to content

Commit

Permalink
fix CS giving default units of unused unit classes in 4UC (and other …
Browse files Browse the repository at this point in the history
…modmods) (#11027)
  • Loading branch information
azum4roll authored Jun 22, 2024
1 parent b488e3d commit a7f41c4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion CvGameCoreDLL_Expansion2/CvPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51021,7 +51021,16 @@ UnitTypes CvPlayer::GetCompetitiveSpawnUnitType(const bool bIncludeRanged, const

CvUnitClassInfo* pUnitClassInfo = GC.getUnitClassInfo(eUnitClass);
if (!bIncludeUUs)
eUnit = static_cast<UnitTypes>(pUnitClassInfo->getDefaultUnitIndex());
{
UnitTypes eReplaceUnit = static_cast<UnitTypes>(pUnitClassInfo->getDefaultUnitIndex());
CvUnitEntry* pUnitInfo = GC.getUnitInfo(eReplaceUnit);

// Cross check in case mods forget to change unit classes after repurposing default units
if (pUnitInfo->GetUnitClassType() != eUnitClass)
continue;

eUnit = eReplaceUnit;
}

CvUnitEntry* pUnitInfo = GC.getUnitInfo(eUnit);
if (!pUnitInfo)
Expand Down

0 comments on commit a7f41c4

Please sign in to comment.