Skip to content

Commit

Permalink
Fix AreaCopy when used with the CopyOutside param (#466)
Browse files Browse the repository at this point in the history
* Fix AreaCopy when used with the CopyOutside param

* Adjust param order

* Fix call parameters
  • Loading branch information
brandonsturgeon authored Apr 25, 2024
1 parent 19eb222 commit 94c6f4a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions lua/advdupe2/sv_clipboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,9 @@ AdvDupe2.duplicator.Copy = Copy
--[[
Name: AreaCopy
Desc: Copy based on a box
Params: <entity> Entity
Returns: <table> Entities, <table> Constraints
]]
function AdvDupe2.duplicator.AreaCopy(Entities, Offset, CopyOutside)
function AdvDupe2.duplicator.AreaCopy(ply, Entities, Offset, CopyOutside)
local Constraints, EntTable, ConstraintTable = {}, {}, {}
local index, add, AddEnts, AddConstrs, ConstTable, EntTab

Expand Down Expand Up @@ -492,7 +491,7 @@ function AdvDupe2.duplicator.AreaCopy(Entities, Offset, CopyOutside)
else -- Copy entities and constraints outside of the box that are constrained to entities inside the box
ConstraintTable[_] = ConstTable
for k, v in pairs(EntTab) do
Copy(v, EntTable, ConstraintTable, Offset)
Copy(ply, v, EntTable, ConstraintTable, Offset)
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lua/weapons/gmod_tool/stools/advdupe2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ if(SERVER) then
HeadEnt.Index = Ent:EntIndex()
HeadEnt.Pos = Ent:GetPos()

Entities, Constraints = AdvDupe2.duplicator.AreaCopy(Ents, HeadEnt.Pos, tobool(ply:GetInfo("advdupe2_copy_outside")))
Entities, Constraints = AdvDupe2.duplicator.AreaCopy(ply, Ents, HeadEnt.Pos, tobool(ply:GetInfo("advdupe2_copy_outside")))

self:SetStage(0)
AdvDupe2.RemoveSelectBox(ply)
Expand Down Expand Up @@ -348,7 +348,7 @@ if(SERVER) then
HeadEnt.Index = Ent:EntIndex()
HeadEnt.Pos = Ent:GetPos()

Entities, Constraints = AdvDupe2.duplicator.AreaCopy(Entities, HeadEnt.Pos, tobool(ply:GetInfo("advdupe2_copy_outside")))
Entities, Constraints = AdvDupe2.duplicator.AreaCopy(ply, Entities, HeadEnt.Pos, tobool(ply:GetInfo("advdupe2_copy_outside")))
end
end

Expand Down Expand Up @@ -782,7 +782,7 @@ if(SERVER) then
})

Tab.HeadEnt.Z = WorldTrace.Hit and math.abs(Tab.HeadEnt.Pos.Z - WorldTrace.HitPos.Z) or 0
Tab.Entities, Tab.Constraints = AdvDupe2.duplicator.AreaCopy(Entities, Tab.HeadEnt.Pos, dupe.AutoSaveOutSide)
Tab.Entities, Tab.Constraints = AdvDupe2.duplicator.AreaCopy(ply, Entities, Tab.HeadEnt.Pos, dupe.AutoSaveOutSide)
end
Tab.Constraints = GetSortedConstraints(ply, Tab.Constraints)
Tab.Description = dupe.AutoSaveDesc
Expand Down Expand Up @@ -830,7 +830,7 @@ if(SERVER) then
})

Tab.HeadEnt.Z = WorldTrace.Hit and math.abs(Tab.HeadEnt.Pos.Z - WorldTrace.HitPos.Z) or 0
Tab.Entities, Tab.Constraints = AdvDupe2.duplicator.AreaCopy(Entities, Tab.HeadEnt.Pos, true)
Tab.Entities, Tab.Constraints = AdvDupe2.duplicator.AreaCopy(ply, Entities, Tab.HeadEnt.Pos, true)
Tab.Constraints = GetSortedConstraints(ply, Tab.Constraints)

Tab.Map = true
Expand Down

0 comments on commit 94c6f4a

Please sign in to comment.