mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-15 16:51:31 +00:00
Moved and rearranged transfer task
- Some inventory pickup conditions weren't properly covered
This commit is contained in:
parent
de4097cc7b
commit
1e0a1466a3
2 changed files with 29 additions and 26 deletions
|
@ -1372,6 +1372,8 @@ bool AInventory::TryPickupRestricted (AActor *&toucher)
|
||||||
|
|
||||||
bool AInventory::CallTryPickup (AActor *toucher, AActor **toucher_return)
|
bool AInventory::CallTryPickup (AActor *toucher, AActor **toucher_return)
|
||||||
{
|
{
|
||||||
|
TObjPtr<AInventory> Invstack = Inventory; // A pointer of the inventories item stack.
|
||||||
|
|
||||||
// unmorphed versions of a currently morphed actor cannot pick up anything.
|
// unmorphed versions of a currently morphed actor cannot pick up anything.
|
||||||
if (toucher->flags & MF_UNMORPHED) return false;
|
if (toucher->flags & MF_UNMORPHED) return false;
|
||||||
|
|
||||||
|
@ -1392,7 +1394,33 @@ bool AInventory::CallTryPickup (AActor *toucher, AActor **toucher_return)
|
||||||
GoAwayAndDie();
|
GoAwayAndDie();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res) GiveQuest(toucher);
|
if (res)
|
||||||
|
{
|
||||||
|
GiveQuest(toucher);
|
||||||
|
|
||||||
|
// Transfer all inventory accross that the old object had, if requested.
|
||||||
|
if ((ItemFlags & IF_TRANSFER))
|
||||||
|
{
|
||||||
|
while (Invstack)
|
||||||
|
{
|
||||||
|
AInventory* titem = Invstack;
|
||||||
|
Invstack = titem->Inventory;
|
||||||
|
if (titem->Owner == this)
|
||||||
|
{
|
||||||
|
Printf("Crantech: %s::CallTryPickup doing transfer of %s\n", GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars());
|
||||||
|
if (!titem->CallTryPickup(toucher)) // The object no longer can exist
|
||||||
|
{
|
||||||
|
Printf("Crantech: %s::CallTryPickup, %s is now being destroyed\n", GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars());
|
||||||
|
titem->Destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Printf("Crantech: %s::CallTryPickup, %s didn't belong to this object\n", GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -551,17 +551,12 @@ void AActor::AddInventory (AInventory *item)
|
||||||
{
|
{
|
||||||
// Is it attached to us?
|
// Is it attached to us?
|
||||||
if (item->Owner == this)
|
if (item->Owner == this)
|
||||||
{
|
|
||||||
Printf("Crantech: AddInventory->%s->Owner was Owner\n", item->GetClass()->TypeName.GetChars());
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// No, then remove it from the other actor first
|
// No, then remove it from the other actor first
|
||||||
item->Owner->RemoveInventory (item);
|
item->Owner->RemoveInventory (item);
|
||||||
Printf("Crantech: AddInventory->%s->Owner was nonNULL\n", item->GetClass()->TypeName.GetChars());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TObjPtr<AInventory> Invstack = item->Inventory;
|
|
||||||
item->Owner = this;
|
item->Owner = this;
|
||||||
item->Inventory = Inventory;
|
item->Inventory = Inventory;
|
||||||
Inventory = item;
|
Inventory = item;
|
||||||
|
@ -572,26 +567,6 @@ void AActor::AddInventory (AInventory *item)
|
||||||
// run sometime in the future, so by the time it runs, the inventory
|
// run sometime in the future, so by the time it runs, the inventory
|
||||||
// might not be in the same state as it was when DEM_INVUSE was sent.
|
// might not be in the same state as it was when DEM_INVUSE was sent.
|
||||||
Inventory->InventoryID = InventoryID++;
|
Inventory->InventoryID = InventoryID++;
|
||||||
|
|
||||||
// If the flag exists, transfer all inventory accross that the old object had.
|
|
||||||
if ((item->ItemFlags & IF_TRANSFER))
|
|
||||||
{
|
|
||||||
while (Invstack)
|
|
||||||
{
|
|
||||||
AInventory* titem = Invstack;
|
|
||||||
Invstack = titem->Inventory;
|
|
||||||
|
|
||||||
Printf("Crantech: AddInventory->%s doing transfer of %s\n", item->GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars());
|
|
||||||
bool success = titem->CallTryPickup(this);
|
|
||||||
if (!success)
|
|
||||||
{
|
|
||||||
Printf("Crantech: AddInventory->%s, %s is now being destroyed\n", item->GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars());
|
|
||||||
titem->Destroy();
|
|
||||||
}
|
|
||||||
//AddInventory(item->Inventory); // Adds current inventory item to present index
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
Loading…
Reference in a new issue