From 3aee8a3eeebd4c820b41b87f097ef39c11db7c14 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sun, 1 May 2016 17:07:39 +0200 Subject: [PATCH] - Fixed a mistake in GiveInventory refactoring. 'give item' stopped working because commit 7b35f32f3de012ccb0ccabe9086cffddcfe0bd00 and 6aca7604eb37ba8e436261015603b4c9a2f1d311 didn't take account that give cheat with zero amount should not touch the item amount. --- src/p_mobj.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index b7d8871951..ecd6b8d1c6 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -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(item)->SaveAmount *= amount; - } - else if (type->IsDescendantOf (RUNTIME_CLASS(ABasicArmorBonus))) - { - static_cast(item)->SaveAmount *= amount; - } - else - { - if (!givecheat) - item->Amount = amount; + if (type->IsDescendantOf (RUNTIME_CLASS(ABasicArmorPickup))) + { + static_cast(item)->SaveAmount *= amount; + } + else if (type->IsDescendantOf (RUNTIME_CLASS(ABasicArmorBonus))) + { + static_cast(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)) {