Skip to content

Commit

Permalink
Adjust network library decompression
Browse files Browse the repository at this point in the history
  • Loading branch information
thecraftianman committed Nov 6, 2024
1 parent 845d08c commit 7924d9e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lua/acf/core/networking/networking_cl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ local function SendMessages()
local Compressed = Compress(ToJSON(Messages))

net.Start("ACF_Networking")
net.WriteUInt(#Compressed, 16)
net.WriteUInt(#Compressed, 12)
net.WriteData(Compressed)
net.SendToServer()

Expand Down Expand Up @@ -52,7 +52,7 @@ function Network.Send(Name, ...)
end

net.Receive("ACF_Networking", function(Bits)
local Bytes = net.ReadUInt(16)
local Bytes = net.ReadUInt(12)
local String = Decompress(net.ReadData(Bytes))
local Message = ToTable(String)

Expand Down
9 changes: 5 additions & 4 deletions lua/acf/core/networking/networking_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ local function SendMessages()
local Compressed = Compress(ToJSON(All))

net.Start("ACF_Networking")
net.WriteUInt(#Compressed, 16)
net.WriteUInt(#Compressed, 12)
net.WriteData(Compressed)
net.Broadcast()

Expand All @@ -43,7 +43,7 @@ local function SendMessages()
local Compressed = Compress(ToJSON(Data))

net.Start("ACF_Networking")
net.WriteUInt(#Compressed, 16)
net.WriteUInt(#Compressed, 12)
net.WriteData(Compressed)
net.Send(Target)

Expand Down Expand Up @@ -88,8 +88,9 @@ function Network.Send(Name, Player, ...)
end

net.Receive("ACF_Networking", function(_, Player)
local Bytes = net.ReadUInt(16)
local String = Decompress(net.ReadData(Bytes))
local Bytes = net.ReadUInt(12)
-- This decompression limit should only be as high as it absolutely needs to be
local String = Decompress(net.ReadData(Bytes), 256)
local Message = ToTable(String)

for Name, Data in pairs(Message) do
Expand Down

0 comments on commit 7924d9e

Please sign in to comment.