mirror of
https://github.com/shadowscion/Prop2Mesh.git
synced 2025-03-04 03:13:03 -05:00
Wrap handler functions on cl/sv
This commit is contained in:
parent
3d180c524c
commit
e5af4c317f
@ -670,6 +670,36 @@ net.Receive("prop2mesh_sync", function(len)
|
||||
end)
|
||||
|
||||
prop2mesh.downloads = 0
|
||||
function prop2mesh.handleDownload(crc, data)
|
||||
if not crc or not isstring(data) then
|
||||
prop2mesh.downloads = math.max(0, prop2mesh.downloads - 1)
|
||||
return
|
||||
end
|
||||
|
||||
if not recycle[crc] then
|
||||
recycle[crc] = { users = {}, meshes = {} }
|
||||
end
|
||||
|
||||
if crc == util.CRC(data) then
|
||||
recycle[crc].zip = data
|
||||
|
||||
for user in pairs(recycle[crc].users) do
|
||||
if IsValid(user) then
|
||||
for k, info in pairs(user.prop2mesh_controllers) do
|
||||
if info.crc == crc then
|
||||
checkmesh(crc, info.uvs)
|
||||
end
|
||||
end
|
||||
else
|
||||
setuser(user, crc, false)
|
||||
end
|
||||
end
|
||||
else
|
||||
garbage[crc] = SysTime() + 500
|
||||
end
|
||||
|
||||
prop2mesh.downloads = math.max(0, prop2mesh.downloads - 1)
|
||||
end
|
||||
|
||||
net.Receive("prop2mesh_download", function(len)
|
||||
local crc = net.ReadString()
|
||||
@ -680,34 +710,7 @@ net.Receive("prop2mesh_download", function(len)
|
||||
prop2mesh.downloads = prop2mesh.downloads + 1
|
||||
|
||||
prop2mesh.ReadStream(nil, function(data)
|
||||
if not crc or not isstring(data) then
|
||||
prop2mesh.downloads = math.max(0, prop2mesh.downloads - 1)
|
||||
return
|
||||
end
|
||||
|
||||
if not recycle[crc] then
|
||||
recycle[crc] = { users = {}, meshes = {} }
|
||||
end
|
||||
|
||||
if crc == util.CRC(data) then
|
||||
recycle[crc].zip = data
|
||||
|
||||
for user in pairs(recycle[crc].users) do
|
||||
if IsValid(user) then
|
||||
for k, info in pairs(user.prop2mesh_controllers) do
|
||||
if info.crc == crc then
|
||||
checkmesh(crc, info.uvs)
|
||||
end
|
||||
end
|
||||
else
|
||||
setuser(user, crc, false)
|
||||
end
|
||||
end
|
||||
else
|
||||
garbage[crc] = SysTime() + 500
|
||||
end
|
||||
|
||||
prop2mesh.downloads = math.max(0, prop2mesh.downloads - 1)
|
||||
prop2mesh.handleDownload(crc, data)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
@ -16,10 +16,6 @@ util.AddNetworkString("prop2mesh_sync")
|
||||
util.AddNetworkString("prop2mesh_update")
|
||||
util.AddNetworkString("prop2mesh_download")
|
||||
|
||||
|
||||
--[[
|
||||
|
||||
]]
|
||||
--[[
|
||||
local download_wait = 0.1
|
||||
local download_time = SysTime()
|
||||
@ -116,10 +112,13 @@ end)
|
||||
]]
|
||||
|
||||
|
||||
--[[
|
||||
|
||||
]]
|
||||
local allow_disable = GetConVar("prop2mesh_disable_allowed")
|
||||
function prop2mesh.sendDownload(pl, self, crc)
|
||||
net.Start("prop2mesh_download")
|
||||
net.WriteString(crc)
|
||||
prop2mesh.WriteStream(self.prop2mesh_partlists[crc])
|
||||
net.Send(pl)
|
||||
end
|
||||
|
||||
net.Receive("prop2mesh_download", function(len, pl)
|
||||
if allow_disable:GetBool() and tobool(pl:GetInfoNum("prop2mesh_disable", 0)) then return end
|
||||
@ -134,11 +133,7 @@ net.Receive("prop2mesh_download", function(len, pl)
|
||||
return
|
||||
end
|
||||
|
||||
net.Start("prop2mesh_download")
|
||||
net.WriteString(crc)
|
||||
prop2mesh.WriteStream(self.prop2mesh_partlists[crc])
|
||||
net.Send(pl)
|
||||
--print("download", pl)
|
||||
prop2mesh.sendDownload(pl, self, crc)
|
||||
end)
|
||||
|
||||
net.Receive("prop2mesh_sync", function(len, pl)
|
||||
|
Loading…
Reference in New Issue
Block a user