Skip to content

Commit

Permalink
Fix EGP would create objects on remove (#2879)
Browse files Browse the repository at this point in the history
  • Loading branch information
Denneisk authored Nov 20, 2023
1 parent 553aabf commit 817e473
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lua/entities/gmod_wire_egp/lib/egplib/queuesystem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,27 @@ 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())
Obj.index = v.index
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
Expand Down

0 comments on commit 817e473

Please sign in to comment.