Skip to content

Commit

Permalink
Mitigate nil addition in EGP.umsg.End
Browse files Browse the repository at this point in the history
  • Loading branch information
Denneisk committed Nov 14, 2023
1 parent 14d7d07 commit 7bda442
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lua/entities/gmod_wire_egp/lib/egplib/umsgsystem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
--------------------------------------------------------
local EGP = EGP

local CurSender
local CurSender = NULL
local LastErrorTime = 0
--[[ Transmit Sizes:
Angle = 12
Expand All @@ -21,7 +21,7 @@ local LastErrorTime = 0
EGP.umsg = {}

function EGP.umsg.Start( name, sender )

Check warning on line 23 in lua/entities/gmod_wire_egp/lib/egplib/umsgsystem.lua

View workflow job for this annotation

GitHub Actions / lint

"Deprecated"

Deprecated: Use net messages.
if CurSender then
if CurSender:IsValid() then
if (LastErrorTime + 1 < CurTime()) then
ErrorNoHalt("[EGP] Umsg error. It seems another umsg is already sending, but it occured over 1 second ago. Ending umsg.")
EGP.umsg.End()
Expand All @@ -40,10 +40,15 @@ function EGP.umsg.Start( name, sender )
end

function EGP.umsg.End()
if CurSender then
if CurSender:IsValid() then
if not EGP.IntervalCheck[CurSender] then EGP.IntervalCheck[CurSender] = { bytes = 0, time = 0 } end
EGP.IntervalCheck[CurSender].bytes = EGP.IntervalCheck[CurSender].bytes + net.BytesWritten()
local bytes = net.BytesWritten()
if bytes then
EGP.IntervalCheck[CurSender].bytes = EGP.IntervalCheck[CurSender].bytes + bytes
else
ErrorNoHalt("Tried to end EGP net message outside of net context?")
end
end
net.Broadcast()
CurSender = nil
CurSender = NULL
end

0 comments on commit 7bda442

Please sign in to comment.