Little TakeInventory refactoring.
Introduce AActor::TakeInventory, which unifies DoTakeInv from ACS and DoTakeInventory from Decorate, and AInventory::DepleteOrDestroy, which is extracted from the DoTakeInv core function, and use both where they're needed. I don't know if the differences between DoTakeInv and DoTakeInventory were intentional, so I kept both behaviors.
This commit is contained in:
parent
a93c30238b
commit
b51fac344d
10 changed files with 92 additions and 107 deletions
|
|
@ -1783,31 +1783,7 @@ void DoTakeInventory(AActor * receiver, bool use_aaptr, DECLARE_PARAMINFO)
|
|||
COPY_AAPTR_NOT_NULL(receiver, receiver, setreceiver);
|
||||
}
|
||||
|
||||
bool res = false;
|
||||
|
||||
AInventory * inv = receiver->FindInventory(item);
|
||||
|
||||
if (inv && !inv->IsKindOf(RUNTIME_CLASS(AHexenArmor)))
|
||||
{
|
||||
if (inv->Amount > 0)
|
||||
{
|
||||
res = true;
|
||||
}
|
||||
// Do not take ammo if the "no take infinite/take as ammo depletion" flag is set
|
||||
// and infinite ammo is on
|
||||
if (flags & TIF_NOTAKEINFINITE &&
|
||||
((dmflags & DF_INFINITE_AMMO) || (receiver->player->cheats & CF_INFINITEAMMO)) &&
|
||||
inv->IsKindOf(RUNTIME_CLASS(AAmmo)))
|
||||
{
|
||||
// Nothing to do here, except maybe res = false;? Would it make sense?
|
||||
}
|
||||
else if (!amount || amount>=inv->Amount)
|
||||
{
|
||||
if (inv->ItemFlags&IF_KEEPDEPLETED) inv->Amount=0;
|
||||
else inv->Destroy();
|
||||
}
|
||||
else inv->Amount-=amount;
|
||||
}
|
||||
bool res = receiver->TakeInventory(item, amount, true, (flags & TIF_NOTAKEINFINITE) != 0);
|
||||
ACTION_SET_RESULT(res);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue