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

Lower net usage #330

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions lua/fpp/client/ownability.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ local reasons = {

local function receiveTouchData(len)
repeat
local entIndex = net.ReadUInt(32)
local ownerIndex = net.ReadUInt(32)
local entIndex = net.ReadUInt(13)
local ownerIndex = net.ReadUInt(8)
local touchability = net.ReadUInt(5)
local reason = net.ReadUInt(20)

Expand Down
12 changes: 7 additions & 5 deletions lua/fpp/server/ownability.lua
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,17 @@ end
Networking
---------------------------------------------------------------------------]]
util.AddNetworkString("FPP_TouchabilityData")
-- Sends 32 + 32 + 5 + 20 = 89 bits of ownership data per entity
-- Sends 13 + 8 + 5 + 20 = 46 bits of ownership data per entity
local function netWriteEntData(ply, ent)
-- EntIndex for when it's out of the PVS of the player
net.WriteUInt(ent:EntIndex(), 32)
net.WriteUInt(ent:EntIndex(), 13)

local owner = ent:CPPIGetOwner()
net.WriteUInt(IsValid(owner) and owner:EntIndex() or -1, 32)
net.WriteUInt(ent.FPPRestrictConstraint and ent.FPPRestrictConstraint[ply] or ent.FPPCanTouch[ply], 5) -- touchability information
net.WriteUInt(ent.FPPConstraintReasons and ent.FPPConstraintReasons[ply] or ent.FPPCanTouchWhy[ply], 20) -- reasons
net.WriteUInt(IsValid(owner) and owner:EntIndex() or -1, 8)

local entTable = ent:GetTable()
net.WriteUInt(entTable.FPPRestrictConstraint and entTable.FPPRestrictConstraint[ply] or entTable.FPPCanTouch[ply], 5) -- touchability information
net.WriteUInt(entTable.FPPConstraintReasons and entTable.FPPConstraintReasons[ply] or entTable.FPPCanTouchWhy[ply], 20) -- reasons
end

function FPP.plySendTouchData(ply, ents)
Expand Down
Loading