fix error when server has no client config (#51)

This commit is contained in:
Pierce Lally 2023-11-05 20:00:00 -05:00 committed by GitHub
parent abf9c40af5
commit 3a2b30e4e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 6 deletions

View File

@ -14,11 +14,12 @@ end
net.Receive( "CFCHTTP_ConfigUpdate", function()
local l = net.ReadDouble()
local config = util.JSONToTable( util.Decompress( net.ReadData( l ) ) )
CFCHTTP.networkedConfig = config
loadConfigsClient()
CFCHTTP.repopulateListPanel()
if l > 0 then
local config = util.JSONToTable( util.Decompress( net.ReadData( l ) ) )
CFCHTTP.networkedConfig = config
loadConfigsClient()
CFCHTTP.repopulateListPanel()
end
end )
loadConfigsClient()

View File

@ -2,6 +2,12 @@ util.AddNetworkString( "CFCHTTP_ConfigUpdate" )
util.AddNetworkString( "CFCHTTP_RequestConfig" )
local function sendClientConfig( ply )
if not CFCHTTP.networkedClientConfig then
net.Start( "CFCHTTP_ConfigUpdate" )
net.WriteDouble( 0 )
net.Send( ply )
end
local data = util.Compress( util.TableToJSON( CFCHTTP.networkedClientConfig ) )
net.Start( "CFCHTTP_ConfigUpdate" )
net.WriteDouble( #data )
@ -21,7 +27,7 @@ local function loadConfigsServer()
} )
local data = file.Read( CFCHTTP.filenames.serverClientJsonConfig, "DATA" )
CFCHTTP.networkedClientConfig = data and util.JSONToTable( data ) or {}
CFCHTTP.networkedClientConfig = data and util.JSONToTable( data )
end
local function addCSLuaConfigs( dir )