Resolved a Strategic AI.cpp assertion error resulting from army composition values totaling more then 100%.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2389 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
ChrisL
2008-10-30 16:03:40 +00:00
parent ef158c56cf
commit 8c437af085
3 changed files with 22 additions and 8 deletions
+14
View File
@@ -5653,6 +5653,20 @@ void CalcNumTroopsBasedOnComposition( UINT8 *pubNumTroops, UINT8 *pubNumElites,
(*pubNumElites)++;
}
}
//CHRISL: For some reason, it's possible for pubNumTroops + pubNumElites to be greater then ubTotal. It seems that in some
// cases, bTroopPercentage and bElitePercentage can add up to more then 100%. So we need an extra condition that makes
// sure we don't have more then ubTotal
while( *pubNumTroops + *pubNumElites > ubTotal)
{
if( Chance( gArmyComp[ iCompositionID ].bTroopPercentage ) )
{
(*pubNumTroops)--;
}
else
{
(*pubNumElites)--;
}
}
Assert( *pubNumTroops + *pubNumElites == ubTotal );
}