Improve pac editor networking logic (#1250)

* Dont send editor data when editor isn't open

* Add ratelimit logic
This commit is contained in:
Redox 2022-10-29 23:32:14 +02:00 committed by GitHub
parent ce9f378911
commit 3f7def5f09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -361,6 +361,7 @@ do
local lastViewPos, lastViewAngle, lastTargetPos
timer.Create("pac_in_editor", 0.25, 0, function()
if not pace.Active then return end
if not pace.current_part:IsValid() then return end
local pos, ang = pace.GetViewPos(), pace.GetViewAngles()
local target_pos = pace.mctrl.GetWorldPosition()
@ -380,7 +381,7 @@ do
net.Receive("pac_in_editor_posang", function()
local ply = net.ReadEntity()
if not ply:IsValid() then return end
if not IsValid( ply ) then return end
local pos = net.ReadVector()
local ang = net.ReadAngle()

View File

@ -69,6 +69,12 @@ do
util.AddNetworkString("pac_in_editor_posang")
net.Receive("pac_in_editor_posang", function(_, ply)
if not ply.pac_last_editor_message then
ply.pac_last_editor_message = 0
end
if ply.pac_last_editor_message > CurTime() then return end
ply.pac_last_editor_message = CurTime() + 0.2
local pos = net.ReadVector()
local ang = net.ReadAngle()
local part_pos = net.ReadVector()
@ -85,4 +91,4 @@ end
CreateConVar("has_pac3_editor", "1", {FCVAR_NOTIFY})
resource.AddSingleFile("materials/icon64/pac3.png")
resource.AddSingleFile("materials/icon64/pac3.png")