- Fixed a mistake in GiveInventory refactoring.

'give item' stopped working because commit 7b35f32f3d and 6aca7604eb didn't take account that give cheat with zero amount should not touch the item amount.
This commit is contained in:
Edoardo Prezioso 2016-05-01 17:07:39 +02:00
parent a17ec55d0d
commit 3aee8a3eee
1 changed files with 15 additions and 12 deletions

View File

@ -638,20 +638,23 @@ bool AActor::GiveInventory(PClassInventory *type, int amount, bool givecheat)
// This shouldn't count for the item statistics!
item->ClearCounters();
if (type->IsDescendantOf (RUNTIME_CLASS(ABasicArmorPickup)))
if (!givecheat || amount > 0)
{
static_cast<ABasicArmorPickup*>(item)->SaveAmount *= amount;
}
else if (type->IsDescendantOf (RUNTIME_CLASS(ABasicArmorBonus)))
{
static_cast<ABasicArmorBonus*>(item)->SaveAmount *= amount;
}
else
{
if (!givecheat)
item->Amount = amount;
if (type->IsDescendantOf (RUNTIME_CLASS(ABasicArmorPickup)))
{
static_cast<ABasicArmorPickup*>(item)->SaveAmount *= amount;
}
else if (type->IsDescendantOf (RUNTIME_CLASS(ABasicArmorBonus)))
{
static_cast<ABasicArmorBonus*>(item)->SaveAmount *= amount;
}
else
item->Amount = MIN (amount, item->MaxAmount);
{
if (!givecheat)
item->Amount = amount;
else
item->Amount = MIN (amount, item->MaxAmount);
}
}
if (!item->CallTryPickup (this))
{