From 70a165b566df1c10eb23c72f651d5400d386afed Mon Sep 17 00:00:00 2001 From: Boondorl Date: Sun, 14 Apr 2024 20:09:10 -0400 Subject: [PATCH] Fixed local items not copying properties properly Revert "Fixed local items not copying properties properly" This reverts commit 5f352df587c629545fafc09e80428e645f5e8df3. ... --- .../zscript/actors/inventory/inventory.zs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/wadsrc/static/zscript/actors/inventory/inventory.zs b/wadsrc/static/zscript/actors/inventory/inventory.zs index 4108650a4a9..c9890c699fc 100644 --- a/wadsrc/static/zscript/actors/inventory/inventory.zs +++ b/wadsrc/static/zscript/actors/inventory/inventory.zs @@ -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. @@ -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; @@ -1043,6 +1046,9 @@ class Inventory : Actor protected bool GoAway () { + if (bCreatingCopy) + return true; + // Dropped items never stick around if (bDropped) { @@ -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; + } //=========================================================================== //