From 8f70d70dd6514c2ed4e4aaf748dae555aaca697e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 31 Dec 2017 15:25:51 +0200 Subject: [PATCH] Generalized maximum amount for give cheat https://forum.zdoom.org/viewtopic.php?t=58930 --- src/p_mobj.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index c688f0b98b..d5c5e93ea6 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -831,9 +831,11 @@ bool AActor::GiveInventory(PClassActor *type, int amount, bool givecheat) { if (givecheat) { - item->Amount = MIN(amount, type->IsDescendantOf(NAME_Ammo) - ? item->IntVar("BackpackMaxAmount") - : item->MaxAmount); + const AInventory *const haveitem = FindInventory(type); + + item->Amount = MIN(amount, nullptr == haveitem + ? static_cast(GetDefaultByType(type))->MaxAmount + : haveitem->MaxAmount); } else {