Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed E2 spawn behavior to only run once ever #3215

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lua/entities/gmod_wire_expression2/core/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ local function dupefinished( TimedPasteData, TimedPasteDataCurrent )
v.dupefinished = true
v:Execute()
v.dupefinished = nil
v.duped = nil
end
end
end
Expand Down
29 changes: 23 additions & 6 deletions lua/entities/gmod_wire_expression2/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,6 @@ function ENT:Setup(buffer, includes, restore, forcecompile, filepath)
return
end

self.duped = false

if not restore then
self.first = true
self:Execute()
Expand Down Expand Up @@ -646,6 +644,28 @@ function ENT:TriggerOutputs(force)
end
end

--- Helper function that operates slightly differently if AdvDupe2 exists or not
local apply_duped
do
local function runDuped(e2)
e2.duped = true
e2:Execute()
e2:Think()
e2.duped = nil
end

---@diagnostic disable-next-line:undefined-global
if AdvDupe2 then -- Prevent duped() if dupeFinished() can be called instead
apply_duped = function(e2)
if not e2.directives.strict then
runDuped(e2)
end
end
else -- Always run duped() without AdvDupe(2)
apply_duped = runDuped
end
end

function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID, GetConstByID)
self:Setup(self.buffer, self.inc_files, true)

Expand All @@ -664,10 +684,7 @@ function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID, GetConstByID)
end
self.dupevars = nil

self.duped = true
self:Execute()
self:Think()
self.duped = false
apply_duped(self)
end

BaseClass.ApplyDupeInfo(self, ply, ent, info, GetEntByID, GetConstByID)
Expand Down
Loading