Generalized maximum amount for give cheat

https://forum.zdoom.org/viewtopic.php?t=58930
This commit is contained in:
alexey.lysiuk 2017-12-31 15:25:51 +02:00
parent 294bf6ed53
commit 8f70d70dd6
1 changed files with 5 additions and 3 deletions

View File

@ -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<AInventory*>(GetDefaultByType(type))->MaxAmount
: haveitem->MaxAmount);
}
else
{