1
0
mirror of https://github.com/Earu/EasyChat.git synced 2025-03-04 03:13:20 -05:00

Revert "Reduce network usage for messages (#130)" (#131)

This reverts commit 4118edb928.
This commit is contained in:
Astralcircle 2024-10-25 21:13:27 +03:00 committed by GitHub
parent 4118edb928
commit 2605fdcdda
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -124,11 +124,10 @@ if SERVER then
net.Start(NET_BROADCAST_MSG)
net.WriteUInt(ply:UserID(), 16)
net.WriteString(ply:RichNick())
net.WriteString(msg)
net.WriteBool(is_dead)
net.WriteBool(is_team)
net.WriteBool(is_local)
net.WriteData(util.Compress(msg))
net.Send(filter)
if game.IsDedicated() and not is_local then
@ -230,9 +229,9 @@ if SERVER then
end
net.Receive(NET_SEND_MSG, function(_, ply)
local msg = net.ReadString()
local is_team = net.ReadBool()
local is_local = net.ReadBool()
local msg = util.Decompress(net.ReadData(net.BytesLeft()))
EasyChat.ReceiveGlobalMessage(ply, msg, is_team, is_local)
end)
@ -439,10 +438,10 @@ if CLIENT then
net.Receive(NET_BROADCAST_MSG, function()
local user_id = net.ReadUInt(16)
local user_name = net.ReadString()
local msg = net.ReadString()
local is_dead = net.ReadBool()
local is_team = net.ReadBool()
local is_local = net.ReadBool()
local msg = util.Decompress(net.ReadData(net.BytesLeft()))
local function receive(retries)
retries = retries or 0
@ -527,16 +526,16 @@ if CLIENT then
if not no_translate and EC_TRANSLATE_OUT_MSG:GetBool() and source_lang ~= target_lang then
EasyChat.Translator:Translate(msg, source_lang, target_lang, function(success, _, translation)
net.Start(NET_SEND_MSG)
net.WriteString(success and translation or msg)
net.WriteBool(is_team)
net.WriteBool(is_local)
net.WriteData(util.Compress(success and translation or msg))
net.SendToServer()
end)
else
net.Start(NET_SEND_MSG)
net.WriteString(msg)
net.WriteBool(is_team)
net.WriteBool(is_local)
net.WriteData(util.Compress(msg))
net.SendToServer()
end
end