mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +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++;
|
tankCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( gGameExternalOptions.fASDAssignsJeeps && ASDSoldierUpgradeToJeep( ) )
|
if ( troopCount > 0 && gGameExternalOptions.fASDAssignsJeeps && ASDSoldierUpgradeToJeep( ) )
|
||||||
{
|
{
|
||||||
troopCount--;
|
troopCount--;
|
||||||
jeepCount++;
|
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;
|
troopCount -= numRobots;
|
||||||
robotCount += numRobots;
|
robotCount += numRobots;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user