Revert "Testing a possible fix for TeamUlysses/ulx#59"

This reverts commit 180d7370ef.
This commit is contained in:
Nayruden 2016-08-29 18:51:50 -05:00
parent 180d7370ef
commit 9f459dc083
6 changed files with 4 additions and 100 deletions

View File

@ -24,43 +24,6 @@ end
net.Receive( "URPC", ULibRPC )
local function ULibCompressedRPC()
local fn_string = net.ReadString()
local argn = net.ReadUInt(8)
local argv = {}
for i=1, argn do
local typ = net.ReadString()
local arg = nil
if typ == "string" or typ == "table" then
local bytes = net.ReadUInt(32)
arg = util.Decompress( net.ReadData( bytes ) )
end
if typ == "table" then
arg = util.JSONToTable( arg )
end
argv[i] = arg
end
local success, fn = ULib.findVar( fn_string )
if not success or type( fn ) ~= "function" then return error( "Received bad RPC, invalid function (" .. tostring( fn_string ) .. ")!" ) end
-- Since the table length operator can't always be trusted if there are holes in it, find the length by ourself
local max = 0
for k, v in pairs( argv ) do
local n = tonumber( k )
if n and n > max then
max = n
end
end
fn( unpack( argv, 1, max ) )
end
net.Receive( "URPCC", ULibCompressedRPC )
--[[
Function: umsgRcv

View File

@ -1060,7 +1060,7 @@ end
hook.Add( ULib.HOOK_UCLAUTH, "ULibSendAuthToClients", sendAuthToClients, HOOK_MONITOR_LOW )
local function sendUCLDataToClient( ply )
ULib.clientCompressedRPC( ply, "ULib.ucl.initClientUCL", ucl.authed, ucl.groups ) -- Send all UCL data (minus offline users) to all loaded users
ULib.clientRPC( ply, "ULib.ucl.initClientUCL", ucl.authed, ucl.groups ) -- Send all UCL data (minus offline users) to all loaded users
ULib.clientRPC( ply, "hook.Call", ULib.HOOK_UCLCHANGED ) -- Call hook on client
ULib.clientRPC( ply, "authPlayerIfReady", ply, ply:UserID() ) -- Call on client
end
@ -1077,7 +1077,7 @@ end
hook.Add( "PlayerDisconnected", "ULibUCLDisconnect", playerDisconnected, HOOK_MONITOR_HIGH )
local function UCLChanged()
ULib.clientCompressedRPC( _, "ULib.ucl.initClientUCL", ucl.authed, ucl.groups ) -- Send all UCL data (minus offline users) to all loaded users
ULib.clientRPC( _, "ULib.ucl.initClientUCL", ucl.authed, ucl.groups ) -- Send all UCL data (minus offline users) to all loaded users
ULib.clientRPC( _, "hook.Call", ULib.HOOK_UCLCHANGED ) -- Call hook on client
end
hook.Add( ULib.HOOK_UCLCHANGED, "ULibSendUCLToClients", UCLChanged )

View File

@ -14,7 +14,7 @@
Parameters:
plys - The Player object, table of Player objects for who you want to send this to, nil sends to everyone.
filter - The Player object, table of Player objects for who you want to send this to, nil sends to everyone.
fn - A string of the function to run on the client. Does *not* need to be in the global namespace, "myTable.myFunction" works too.
... - *Optional* The parameters to pass to the function.
@ -37,59 +37,6 @@ function ULib.clientRPC( plys, fn, ... )
end
--[[
Function: clientCompressedRPC
Just like <clientRPC()>, but all arguents are expected to be nils, strings, or simple tables (which will be converted to a string).
Arguments will be copressed and then decompressed on the client.
Parameters:
plys - The Player object, table of Player objects for who you want to send this to, nil sends to everyone.
fn - A string of the function to run on the client. Does *not* need to be in the global namespace, "myTable.myFunction" works too.
... - *Optional* The parameters to pass to the function.
Revisions:
v2.62 - Initial.
]]
function ULib.clientCompressedRPC( plys, fn, ... )
ULib.checkArg( 1, "ULib.clientRPC", {"nil","Player","table"}, plys )
ULib.checkArg( 2, "ULib.clientRPC", {"string"}, fn )
net.Start( "URPCC" )
net.WriteString( fn )
local argv = {...}
local argn = select( "#", ... ) -- This makes sure we get nil values
net.WriteInt(argn, 8)
for i=1, argn do
local arg = argv[i]
local payload = arg
net.WriteString(type(payload))
if type(payload) == "table" then
payload = util.TableToJSON(payload)
end
if type(payload) == "string" then
payload = util.Compress(payload)
net.WriteUInt(#payload, 32)
net.WriteData(payload, #payload)
end
end
if plys then
net.Send( plys )
else
net.Broadcast()
end
end
--[[
Function: umsgSend

View File

@ -276,5 +276,4 @@ end
]]
if SERVER then
util.AddNetworkString( "URPC" )
util.AddNetworkString( "URPCC" )
end

View File

@ -175,11 +175,6 @@ end
-- Client init stuff
if CLIENT then
function ucl.initClientUCL( authed, groups )
for k, v in pairs(authed) do
authed[k] = nil
authed[tostring(k)] = v
end
ucl.authed = authed
ucl.groups = groups
end

View File

@ -1 +1 @@
1472317822
1465756882