Skip to content

Commit

Permalink
- Fixed a mistake in GiveInventory refactoring.
Browse files Browse the repository at this point in the history
'give item' stopped working because commit 7b35f32 and 6aca760 didn't take account that give cheat with zero amount should not touch the item amount.
  • Loading branch information
Edoardo Prezioso committed May 1, 2016
1 parent a17ec55 commit 3aee8a3
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/p_mobj.cpp
Expand Up @@ -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))
{
Expand Down

0 comments on commit 3aee8a3

Please sign in to comment.