|
|
@ -59,22 +59,17 @@ local function CacheDatatableMethod( id, datatable, ply ) |
|
|
|
return { id = id, cont = datatable } |
|
|
|
return { id = id, cont = datatable } |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local function shortenDataTableMethod( datatable ) |
|
|
|
|
|
|
|
Quantum.Debug( "(" .. datatable.id .. ") Converting datatable '" .. tostring( datatable ) .. "' to json..." ) |
|
|
|
|
|
|
|
return util.TableToJSON( datatable, false ) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function initializeDatatable( id, datatable, ply ) |
|
|
|
local function initializeDatatable( id, datatable, ply ) |
|
|
|
Quantum.Debug( "(" .. tostring(ply) .. ") Initializing datatable for client net message.." ) |
|
|
|
Quantum.Debug( "(" .. tostring(ply) .. ") Initializing datatable for client net message.." ) |
|
|
|
return shortenDataTableMethod( CacheDatatableMethod( id, datatable, ply ) ) |
|
|
|
return CacheDatatableMethod( id, datatable, ply ) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local function SendDatatableToClient( client, dt, type ) |
|
|
|
local function SendDatatableToClient( client, dt, type ) |
|
|
|
local datatable = initializeDatatable( type, dt, client ) -- before we actually send the stuff, cache it and remove unneeded stuff |
|
|
|
local datatable = initializeDatatable( type, dt, client ) -- before we actually send the stuff, cache it and remove unneeded stuff |
|
|
|
local net_start = net.Start( "quantum_menu_net" ) |
|
|
|
local net_start = net.Start( "quantum_menu_net" ) |
|
|
|
if( net_start ) then Quantum.Debug( "Sending net message to " .. tostring(ply) .. "..." ) end |
|
|
|
if( net_start ) then Quantum.Debug( "Sending net message to " .. tostring(client) .. "..." ) end |
|
|
|
if( #datatable > 0 ) then -- if it's empty just dont send it because we will save 8 bits |
|
|
|
if( table.Count(datatable) > 0 ) then -- if it's empty just dont send it because we will save 8 bits |
|
|
|
net.WriteString( datatable ) -- send the data to the player |
|
|
|
net.WriteTable( datatable ) -- send the data to the player |
|
|
|
end |
|
|
|
end |
|
|
|
net.Send( client ) |
|
|
|
net.Send( client ) |
|
|
|
Quantum.Debug("Net message sent.") |
|
|
|
Quantum.Debug("Net message sent.") |
|
|
|