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

Dont use net.WriteTable for EGP #3141

Merged
merged 7 commits into from
Oct 28, 2024
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
53 changes: 30 additions & 23 deletions lua/entities/gmod_wire_egp/lib/egplib/transmitreceive.lua
Original file line number Diff line number Diff line change
Expand Up @@ -619,19 +619,36 @@ if (SERVER) then
DataToSend[#DataToSend+1] = { ID = obj.ID, index = obj.index, Settings = obj:DataStreamInfo() }
end

timer.Simple( k, function() -- send 1 second apart
timer.Simple( k - 1, function() -- send 1 second apart, send the first one instantly
wrefgtzweve marked this conversation as resolved.
Show resolved Hide resolved
local isLastScreen = ((k == #targets) and #targets or nil)
if silent then
isLastScreen = nil
end

local data = {
Ent = v,
Objects = DataToSend,
Filtering = v.GPU_texture_filtering,
IsLastScreen = isLastScreen -- Doubles as notifying the client that no more data will arrive, and tells them how many did arrive
}

local von = WireLib.von.serialize(data)
if #von > 60000 then
ply:ChatPrint("[EGP] Error: Data too large to send to client. (" .. math.Round( #von / 1024, 2 ) .. " kb)")
return
end

local compressed = util.Compress(von)
local compressedLength = #compressed

if compressedLength > 60000 then
wrefgtzweve marked this conversation as resolved.
Show resolved Hide resolved
ply:ChatPrint("[EGP] Error: Compressed data too large to send to client. (" .. math.Round( compressedLength / 1024, 2 ) .. " kb)")
return
end

net.Start("EGP_Request_Transmit")
net.WriteTable({
Ent = v,
Objects = DataToSend,
Filtering = v.GPU_texture_filtering,
IsLastScreen = isLastScreen -- Doubles as notifying the client that no more data will arrive, and tells them how many did arrive
})
net.WriteUInt( compressedLength, 16 )
net.WriteData( compressed, compressedLength )
net.Send(ply)
end)
sent = true
Expand All @@ -643,21 +660,7 @@ if (SERVER) then
return true, #targets
end
end

local function initspawn(ply)
timer.Simple(10,function()
if (ply and ply:IsValid()) then
local bool, msg = EGP:SendDataStream( ply )
if (bool == true) then
ply:ChatPrint("[EGP] " .. tostring(msg) .. " EGP Screens found on the server. Sending objects now...")
end
end
end)
end

hook.Add("PlayerInitialSpawn","EGP_SpawnFunc",initspawn)
Comment on lines -646 to -658
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wrefgtzweve Probably caused by removing this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that should probably only run for screens, it was entirely useless for huds. When i tried the regular streams managed fine and didnt cause me issues but i guess it slipped through

else

function EGP:ReceiveDataStream( decoded )
local Ent = decoded.Ent
local Objects = decoded.Objects
Expand All @@ -684,7 +687,11 @@ else
LocalPlayer():ChatPrint("[EGP] Received EGP object reload. " .. decoded.IsLastScreen .. " screens' objects were reloaded.")
end
end

net.Receive("EGP_Request_Transmit", function(len,ply)
EGP:ReceiveDataStream(net.ReadTable())
local amount = net.ReadUInt(16)
local data = net.ReadData(amount)
local tbl = WireLib.von.deserialize(util.Decompress(data, 60000))
EGP:ReceiveDataStream(tbl)
end)
end
end
Loading