Skip to content

Commit

Permalink
Make proxy table a global variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ceifa committed Nov 9, 2020
1 parent c0a2504 commit e56c2cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lua/awlib/modules/network/sh_netsync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ Aw.SyncFlag = {}
Aw.SyncFlag.InitialValue = 0
Aw.SyncFlag.Merge = 1

local tableSyncProxies = {}
Aw.TableSyncProxies = Aw.TableSyncProxies or {}
function Aw.Net:SetTableSyncProxy(sIdentifier, fCallback)
tableSyncProxies[sIdentifier] = tableSyncProxies[sIdentifier] or {}
table.insert(tableSyncProxies[sIdentifier], fCallback)
Aw.TableSyncProxies[sIdentifier] = Aw.TableSyncProxies[sIdentifier] or {}
table.insert(Aw.TableSyncProxies[sIdentifier], fCallback)
end

function Aw.Net:CallProxies(sIdentifier, pPlayer, tValue, nType)
local proxies = tableSyncProxies[sIdentifier] or {}
local proxies = Aw.TableSyncProxies[sIdentifier] or {}

for k, callback in ipairs(proxies) do
local proxyResult = callback(pPlayer, tValue, nType)
Expand Down
2 changes: 1 addition & 1 deletion lua/awlib/modules/network/sv_netsync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function Aw.Net:SyncTable(sIdentifier, tValue)
end

local proxiesResult = Aw.Net:CallProxies(sIdentifier, ply, value, type)
if istable(proxiesResult) and table.Count(proxiesResult) > 0 then
if istable(proxiesResult) and not table.IsEmpty(proxiesResult) then
net.Start("AW.SyncTable")
net.WriteString(sIdentifier)
net.WriteUInt(type, 2)
Expand Down

0 comments on commit e56c2cf

Please sign in to comment.