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

Holo net improvements #3210

Merged
merged 6 commits into from
Dec 30, 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
24 changes: 12 additions & 12 deletions lua/entities/gmod_wire_expression2/core/hologram.lua
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,13 @@ local function flush_scale_queue(queue, recipient)
net.Start("wire_holograms_set_scale")
for _, plyqueue in pairs(queue) do
for Holo, scale in pairs(plyqueue) do
net.WriteUInt(Holo.ent:EntIndex(), 16)
net.WriteUInt(Holo.ent:EntIndex(), MAX_EDICT_BITS)
net.WriteFloat(scale.x)
net.WriteFloat(scale.y)
net.WriteFloat(scale.z)
end
end
net.WriteUInt(0, 16)
net.WriteUInt(0, MAX_EDICT_BITS)
if recipient then net.Send(recipient) else net.Broadcast() end
end

Expand All @@ -257,15 +257,15 @@ local function flush_bone_scale_queue(queue, recipient)
for _, plyqueue in pairs(queue) do
for Holo, holoqueue in pairs(plyqueue) do
for bone, scale in pairs(holoqueue) do
net.WriteUInt(Holo.ent:EntIndex(), 16)
net.WriteUInt(bone + 1, 16) -- using +1 to be able reset holo bones scale with -1 and not use signed int
net.WriteUInt(Holo.ent:EntIndex(), MAX_EDICT_BITS)
net.WriteUInt(bone + 1, 9) -- using +1 to be able reset holo bones scale with -1 and not use signed int
net.WriteFloat(scale.x)
net.WriteFloat(scale.y)
net.WriteFloat(scale.z)
end
end
end
net.WriteUInt(0, 16)
net.WriteUInt(0, MAX_EDICT_BITS)
net.WriteUInt(0, 16)
if recipient then net.Send(recipient) else net.Broadcast() end
end
Expand All @@ -279,7 +279,7 @@ local function flush_clip_queue(queue, recipient)
for Holo,holoqueue in pairs(plyqueue) do
for _, clip in pairs(holoqueue) do
if clip and clip.index then
net.WriteUInt(Holo.ent:EntIndex(), 16)
net.WriteUInt(Holo.ent:EntIndex(), MAX_EDICT_BITS)
net.WriteUInt(clip.index, 4) -- 4: absolute highest wire_holograms_max_clips is thus 16
if clip.enabled ~= nil then
net.WriteBool(true)
Expand All @@ -288,13 +288,13 @@ local function flush_clip_queue(queue, recipient)
net.WriteBool(false)
net.WriteVector(clip.origin)
net.WriteVector(clip.normal)
net.WriteUInt(clip.localentid, 16)
net.WriteUInt(clip.localentid, MAX_EDICT_BITS)
end
end
end
end
end
net.WriteUInt(0, 16)
net.WriteUInt(0, MAX_EDICT_BITS)
if recipient then net.Send(recipient) else net.Broadcast() end
end

Expand All @@ -305,10 +305,10 @@ local function flush_vis_queue()
if IsValid( ply ) and next(plyqueue) ~= nil then
net.Start("wire_holograms_set_visible")
for Holo,visible in pairs(plyqueue) do
net.WriteUInt(Holo.ent:EntIndex(), 16)
net.WriteUInt(Holo.ent:EntIndex(), MAX_EDICT_BITS)
net.WriteBit(visible)
end
net.WriteUInt(0, 16)
net.WriteUInt(0, MAX_EDICT_BITS)
net.Send(ply)
end
end
Expand All @@ -320,11 +320,11 @@ local function flush_player_color_queue()
net.Start("wire_holograms_set_player_color")
for _, plyqueue in pairs(player_color_queue) do
for Holo,color in pairs(plyqueue) do
net.WriteUInt(Holo.ent:EntIndex(), 16)
net.WriteUInt(Holo.ent:EntIndex(), MAX_EDICT_BITS)
net.WriteVector(color)
end
end
net.WriteUInt(0, 16)
net.WriteUInt(0, MAX_EDICT_BITS)
net.Broadcast()
end

Expand Down
26 changes: 12 additions & 14 deletions lua/entities/gmod_wire_hologram.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ if CLIENT then

net.Receive("wire_holograms_clip", function(netlen)
while true do
local entid = net.ReadUInt(16)
local entid = net.ReadUInt(MAX_EDICT_BITS)
if entid == 0 then return end -- stupid hack to not include amount of entities in the message. feel free to rework this.

local clipid = net.ReadUInt(4)

if net.ReadBool() then
SetClipEnabled(entid, clipid, net.ReadBool())
else
SetClip(entid, clipid, net.ReadVector(), net.ReadVector(), net.ReadUInt(16))
SetClip(entid, clipid, net.ReadVector(), net.ReadVector(), net.ReadUInt(MAX_EDICT_BITS))
end

local ent = Entity(entid)
Expand Down Expand Up @@ -270,22 +270,22 @@ if CLIENT then
end

net.Receive("wire_holograms_set_scale", function(netlen)
local index = net.ReadUInt(16)
local index = net.ReadUInt(MAX_EDICT_BITS)

while index ~= 0 do
SetScale(index, Vector(net.ReadFloat(), net.ReadFloat(), net.ReadFloat()))
index = net.ReadUInt(16)
index = net.ReadUInt(MAX_EDICT_BITS)
end
end)

net.Receive("wire_holograms_set_bone_scale", function(netlen)
local index = net.ReadUInt(16)
local bindex = net.ReadUInt(16) - 1 -- using -1 to get negative -1 for reset
local index = net.ReadUInt(MAX_EDICT_BITS)
local bindex = net.ReadUInt(9) - 1 -- using -1 to get negative -1 for reset

while index ~= 0 do
SetBoneScale(index, bindex, Vector(net.ReadFloat(), net.ReadFloat(), net.ReadFloat()))
index = net.ReadUInt(16)
bindex = net.ReadUInt(16) - 1
index = net.ReadUInt(MAX_EDICT_BITS)
bindex = net.ReadUInt(9) - 1
end
end)

Expand All @@ -301,7 +301,7 @@ if CLIENT then
end

net.Receive("wire_holograms_set_visible", function(netlen)
local index = net.ReadUInt(16)
local index = net.ReadUInt(MAX_EDICT_BITS)

while index ~= 0 do

Expand All @@ -312,7 +312,7 @@ if CLIENT then
vis_buffer[index] = net.ReadBit() == 0
end

index = net.ReadUInt(16)
index = net.ReadUInt(MAX_EDICT_BITS)
end
end)

Expand All @@ -333,12 +333,10 @@ if CLIENT then
SetPlayerColor(eidx, player_color_buffer[eidx])
player_color_buffer[eidx] = nil
end


end

net.Receive("wire_holograms_set_player_color", function(netlen)
local index = net.ReadUInt(16)
local index = net.ReadUInt(MAX_EDICT_BITS)

while index ~= 0 do
local ent = Entity(index)
Expand All @@ -348,7 +346,7 @@ if CLIENT then
player_color_buffer[index] = net.ReadVector()
end

index = net.ReadUInt(16)
index = net.ReadUInt(MAX_EDICT_BITS)
end
end)

Expand Down
8 changes: 5 additions & 3 deletions lua/wire/wireshared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ local string_sub = string.sub
local utf8_char = utf8.char
local hook = hook

MAX_EDICT_BITS = MAX_EDICT_BITS or 13 -- Delete once MAX_EDICT_BITS is fully out in base GMod

-- extra table functions

-- Returns a noniterable version of tbl. So indexing still works, but pairs(tbl) won't find anything
Expand Down Expand Up @@ -478,7 +480,7 @@ if SERVER then
if not DontSend then
net.Start("wire_ports")
net.WriteInt(-3, 8) -- set eid
net.WriteUInt(eid, 16) -- entity id
net.WriteUInt(eid, MAX_EDICT_BITS) -- entity id
if hasinputs then net.WriteInt(-1, 8) end -- delete inputs
if hasoutputs then net.WriteInt(-2, 8) end -- delete outputs
net.WriteInt(0, 8) -- break
Expand Down Expand Up @@ -559,7 +561,7 @@ if SERVER then
eid = msg[1]
writeCurrentStrings() -- We're switching to talking about a different entity, lets send port information
net.WriteInt(-3,8)
net.WriteUInt(eid,16)
net.WriteUInt(eid,MAX_EDICT_BITS)
end

local msgtype = msg[2]
Expand Down Expand Up @@ -635,7 +637,7 @@ elseif CLIENT then
elseif cmd == -2 then
ents_with_outputs[eid] = nil
elseif cmd == -3 then
eid = net.ReadUInt(16)
eid = net.ReadUInt(MAX_EDICT_BITS)
elseif cmd == -4 then
connections[#connections+1] = {eid, net.ReadUInt(8), net.ReadBit() ~= 0} -- Delay this process till after the loop
elseif cmd > 0 then
Expand Down
Loading