Fix dissapearing parts, mysterious transmition failures

etc
This commit is contained in:
DBotThePony 2018-11-08 18:31:33 +07:00
parent 94255a3110
commit c616e15e98
No known key found for this signature in database
GPG Key ID: DCC23B5715498507
5 changed files with 30 additions and 12 deletions

View File

@ -1,5 +1,5 @@
-- VLL_CURR_FILE is local to each file
if CLIENT and pac and not VLL_CURR_FILE then return end
if CLIENT and pac and not VLL_CURR_FILE and not VLL2_FILEDEF then return end
if SERVER then
local function add_files(dir)

View File

@ -1,5 +1,5 @@
-- VLL_CURR_FILE is local to each file
if CLIENT and pac and pace and not VLL_CURR_FILE then return end
if CLIENT and pac and pace and not VLL_CURR_FILE and not VLL2_FILEDEF then return end
if not pac then
include("autorun/pac_core_init.lua")

View File

@ -1,5 +1,5 @@
-- VLL_CURR_FILE is local to each file
if CLIENT and pac and pace and pacx and not VLL_CURR_FILE then return end
if CLIENT and pac and pace and pacx and not VLL_CURR_FILE and not VLL2_FILEDEF then return end
if not pace then
include("autorun/pac_editor_init.lua")

View File

@ -26,13 +26,18 @@ function pace.WearParts(file, clear)
local transmissionID = math.random(1, math.pow(2, 31) - 1)
for key, part in pairs(pac.GetLocalParts()) do
if not part:HasParent() and part.show_in_editor ~= false then
if not part:HasParent() and part.show_in_editor ~= false and pace.IsPartSendable(part) then
table.insert(toWear, part)
end
end
for i, part in ipairs(toWear) do
pace.SendPartToServer(part, {partID = i, totalParts = #toWear, transmissionID = transmissionID})
-- anti network overflow
timer.Simple(i * 0.2, function()
if part:IsValid() then
pace.SendPartToServer(part, {partID = i, totalParts = #toWear, transmissionID = transmissionID})
end
end)
end
end

View File

@ -48,17 +48,30 @@ do -- to server
timer.Create('pac_update_playerfilter', 5, 0, updatePlayerList)
function pace.IsPartSendable(part, extra)
local allowed, reason = pac.CallHook("CanWearParts", LocalPlayer())
if allowed == false then
return false
end
if part.ClassName == "group" and not part:HasChildren() then return false end
if not part.show_in_editor == false then return false end
return true
end
function pace.SendPartToServer(part, extra)
local allowed, reason = pac.CallHook("CanWearParts", LocalPlayer())
if allowed == false then
pac.Message(reason or "the server doesn't want you to wear parts for some reason")
return
return false
end
-- if it's (ok not very exact) the "my outfit" part without anything added to it, don't bother sending it
if part.ClassName == "group" and not part:HasChildren() then return end
if not part.show_in_editor == false then return end
if part.ClassName == "group" and not part:HasChildren() then return false end
if not part.show_in_editor == false then return false end
local data = {part = part:ToTable()}
@ -199,13 +212,13 @@ do
end
end)
timer.Create('pac3_transmissions_ttl', 10, 0, function()
timer.Create('pac3_transmissions_ttl', 1, 0, function()
local time = RealTime()
for transmissionID, data in pairs(transmissions) do
if data.activity + 60 < time then
if data.activity + 10 < time then
transmissions[transmissionID] = nil
pac.Message('Marking transmission session with id ', transmissionID, ' as dead, cleaning up... Dropped ', data.total, ' parts')
pac.Message('Marking transmission session with id ', transmissionID, ' as dead. Received ', #data.list, ' out from ', data.total, ' parts.')
end
end
end)
@ -276,7 +289,7 @@ do
data.totalParts = nil
data.partID = nil
table.insert(trData.list, data)
-- trData.activity = RealTime()
trData.activity = RealTime()
if #trData.list == trData.total then
local funcs = {}