From 7924d9e255fdb3df38e2a900c8909bae218fea7e Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Wed, 6 Nov 2024 15:27:48 -0500 Subject: [PATCH] Adjust network library decompression --- lua/acf/core/networking/networking_cl.lua | 4 ++-- lua/acf/core/networking/networking_sv.lua | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lua/acf/core/networking/networking_cl.lua b/lua/acf/core/networking/networking_cl.lua index 4467e59be..3258c05b0 100644 --- a/lua/acf/core/networking/networking_cl.lua +++ b/lua/acf/core/networking/networking_cl.lua @@ -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() @@ -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) diff --git a/lua/acf/core/networking/networking_sv.lua b/lua/acf/core/networking/networking_sv.lua index 55e451118..842185c4e 100644 --- a/lua/acf/core/networking/networking_sv.lua +++ b/lua/acf/core/networking/networking_sv.lua @@ -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() @@ -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) @@ -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