From 817e4733946cf9222f646fd7f9057af8830b2a53 Mon Sep 17 00:00:00 2001 From: Denneisk <20892685+Denneisk@users.noreply.github.com> Date: Mon, 20 Nov 2023 17:44:11 -0500 Subject: [PATCH] Fix EGP would create objects on remove (#2879) --- lua/entities/gmod_wire_egp/lib/egplib/queuesystem.lua | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lua/entities/gmod_wire_egp/lib/egplib/queuesystem.lua b/lua/entities/gmod_wire_egp/lib/egplib/queuesystem.lua index 215e2f1f4d..16acff3cc0 100644 --- a/lua/entities/gmod_wire_egp/lib/egplib/queuesystem.lua +++ b/lua/entities/gmod_wire_egp/lib/egplib/queuesystem.lua @@ -11,15 +11,12 @@ function EGP:AddQueueObject( Ent, ply, Function, Object ) if (n > 0) then local LastItem = self.Queue[ply][n] if (LastItem.Ent == Ent and LastItem.Action == "Object") then - local found = false for k,v in ipairs( LastItem.Args[1] ) do if (v.index == Object.index) then - --self:EditObject( v, Object ) if (Object.remove) then -- The object has been removed table.remove( LastItem.Args[1], k ) elseif (v.ID ~= Object.ID) then -- Not the same kind of object, create new - found = true if (v.OnRemove) then v:OnRemove() end local Obj = self:GetObjectByID( Object.ID ) Obj:EditObject(Object:DataStreamInfo()) @@ -27,16 +24,14 @@ function EGP:AddQueueObject( Ent, ply, Function, Object ) if (Obj.OnCreate) then Obj:OnCreate() end LastItem.Args[1][k] = Obj else -- Edit - found = true v:EditObject(Object:DataStreamInfo()) end - break + return end end - if not found then - LastItem.Args[1][#LastItem.Args[1]+1] = Object - end + -- Not found, add it to queue + LastItem.Args[1][#LastItem.Args[1]+1] = Object else self:AddQueue( Ent, ply, Function, "Object", { Object } ) end