mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Guard against integer underflow (#462)
This commit is contained in:
@@ -7151,15 +7151,16 @@ void InitializeGroup( const GROUP_TYPE groupType, const UINT8 groupSize, UINT8 &
|
||||
tankCount++;
|
||||
}
|
||||
|
||||
if ( gGameExternalOptions.fASDAssignsJeeps && ASDSoldierUpgradeToJeep( ) )
|
||||
if ( troopCount > 0 && gGameExternalOptions.fASDAssignsJeeps && ASDSoldierUpgradeToJeep( ) )
|
||||
{
|
||||
troopCount--;
|
||||
jeepCount++;
|
||||
}
|
||||
|
||||
if ( gGameExternalOptions.fASDAssignsRobots && ASDSoldierUpgradeToRobot() )
|
||||
if ( troopCount > 0 && gGameExternalOptions.fASDAssignsRobots && ASDSoldierUpgradeToRobot() )
|
||||
{
|
||||
const int numRobots = 1 + Random(difficultyMod);
|
||||
// Limit amount of robots, if randomized difficulty bonus would cause us to go over the troopCount amount
|
||||
const int numRobots = min( (1 + Random(difficultyMod)), troopCount);
|
||||
troopCount -= numRobots;
|
||||
robotCount += numRobots;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user