diff --git a/lua/entities/gmod_wire_expression2/core/hologram.lua b/lua/entities/gmod_wire_expression2/core/hologram.lua index ec984d4610..49b08b797b 100644 --- a/lua/entities/gmod_wire_expression2/core/hologram.lua +++ b/lua/entities/gmod_wire_expression2/core/hologram.lua @@ -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 @@ -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 @@ -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) @@ -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 @@ -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 @@ -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 diff --git a/lua/entities/gmod_wire_hologram.lua b/lua/entities/gmod_wire_hologram.lua index c789e4ce31..c176b5861b 100644 --- a/lua/entities/gmod_wire_hologram.lua +++ b/lua/entities/gmod_wire_hologram.lua @@ -182,7 +182,7 @@ 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) @@ -190,7 +190,7 @@ if CLIENT then 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) @@ -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) @@ -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 @@ -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) @@ -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) @@ -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) diff --git a/lua/wire/wireshared.lua b/lua/wire/wireshared.lua index 106989c7aa..08689d365b 100644 --- a/lua/wire/wireshared.lua +++ b/lua/wire/wireshared.lua @@ -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 @@ -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 @@ -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] @@ -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