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

Enhance disabled convar #48

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
33 changes: 25 additions & 8 deletions lua/entities/sent_prop2mesh/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,36 @@ end)


local allow_disable = GetConVar("prop2mesh_disable_allowed")
local function plyDisabledP2m(pl)
if not allow_disable:GetBool() then
return false
end

return tobool(pl:GetInfoNum("prop2mesh_disable", 0))
end

function prop2mesh.sendDownload(pl, self, crc)
net.Start("prop2mesh_download")
net.WriteString(crc)
prop2mesh.WriteStream(self.prop2mesh_partlists[crc])
net.Send(pl)
end

function prop2mesh.sendToInterested(plys)
plys = plys or player.GetAll()
local recipients = RecipientFilter()

for _, pl in ipairs(plys) do
if not plyDisabledP2m(pl) then
recipients:AddPlayer(pl)
end
end

net.Send(recipients)
end

net.Receive("prop2mesh_download", function(len, pl)
if allow_disable:GetBool() and tobool(pl:GetInfoNum("prop2mesh_disable", 0)) then return end
if plyDisabledP2m(pl) then return end

local self = net.ReadEntity()
if not prop2mesh.isValid(self) then
Expand Down Expand Up @@ -224,7 +245,7 @@ function ENT:Think()
end

net.WriteTable(self.prop2mesh_updates)
net.Broadcast()
prop2mesh.sendToInterested()

self.prop2mesh_updates = nil
else
Expand Down Expand Up @@ -318,7 +339,7 @@ function ENT:RemoveController(index)
table.remove(self.prop2mesh_controllers, index)

local keepdata
for k, info in pairs(self.prop2mesh_controllers) do
for _, info in pairs(self.prop2mesh_controllers) do
if info.crc == crc then
keepdata = true
break
Expand Down Expand Up @@ -396,11 +417,7 @@ function ENT:SendControllers(syncwith)
end
end

if syncwith then
net.Send(syncwith)
else
net.Broadcast()
end
prop2mesh.sendToInterested(syncwith)
end

function ENT:AddControllerUpdate(index, key)
Expand Down