- check for overflows when giving inventory items.

SVN r3515 (trunk)
This commit is contained in:
Christoph Oelckers 2012-04-03 09:16:19 +00:00
parent 64f0e0e984
commit 9f58a15e28
1 changed files with 17 additions and 2 deletions

View File

@ -86,7 +86,14 @@ bool AAmmo::HandlePickup (AInventory *item)
}
int oldamount = Amount;
Amount += receiving;
if (Amount > 0 && Amount + receiving < 0)
{
Amount = 0x7fffffff;
}
else
{
Amount += receiving;
}
if (Amount > MaxAmount && !sv_unlimited_pickup)
{
Amount = MaxAmount;
@ -538,7 +545,15 @@ bool AInventory::HandlePickup (AInventory *item)
{
if (Amount < MaxAmount || sv_unlimited_pickup)
{
Amount += item->Amount;
if (Amount > 0 && Amount + item->Amount < 0)
{
Amount = 0x7fffffff;
}
else
{
Amount += item->Amount;
}
if (Amount > MaxAmount && !sv_unlimited_pickup)
{
Amount = MaxAmount;