Skip to content

Commit

Permalink
Fixed local items not copying properties properly
Browse files Browse the repository at this point in the history
Revert "Fixed local items not copying properties properly"

This reverts commit 5f352df.

...
  • Loading branch information
Boondorl authored and coelckers committed Apr 15, 2024
1 parent 0328eca commit 70a165b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion wadsrc/static/zscript/actors/inventory/inventory.zs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Inventory : Actor

private bool bSharingItem; // Currently being shared (avoid infinite recursions).
private bool pickedUp[MAXPLAYERS]; // If items are set to local, track who already picked it up.
private bool bCreatingCopy; // Tells GoAway that it needs to return true so a new copy of the item is spawned.

deprecated("3.7") private int ItemFlags;
Actor Owner; // Who owns this item? NULL if it's still a pickup.
Expand Down Expand Up @@ -835,9 +836,11 @@ class Inventory : Actor
Inventory give = self;
if (localPickUp)
{
give = Inventory(Spawn(GetClass()));
give = CreateLocalCopy(toucher);
if (!give)
return;

localPickUp = give != self;
}

bool res;
Expand Down Expand Up @@ -1043,6 +1046,9 @@ class Inventory : Actor

protected bool GoAway ()
{
if (bCreatingCopy)
return true;

// Dropped items never stick around
if (bDropped)
{
Expand Down Expand Up @@ -1113,6 +1119,17 @@ class Inventory : Actor
pickedUp[pNum] = true;
DisableLocalRendering(pNum, true);
}

// Force spawn a new version of the item. This needs to use CreateCopy so that
// any transferrable properties on the item get correctly set.
Inventory CreateLocalCopy(Actor client)
{
bCreatingCopy = true;
let item = CreateCopy(client);
bCreatingCopy = false;

return item;
}

//===========================================================================
//
Expand Down

0 comments on commit 70a165b

Please sign in to comment.