Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mitigate nil addition in EGP.umsg.End #2934

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 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 @@ -20,8 +20,8 @@

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 @@ -35,15 +35,23 @@
end
CurSender = sender

net.Start( name )
net.Start(name)
return true
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
net.Broadcast()

else
net.Send(NULL)
end
net.Broadcast()
CurSender = nil
CurSender = NULL
end
Loading