Rename commands, hooks, net messages and timers to conform to guidelines
This commit is contained in:
parent
e61bc43386
commit
735b0c73af
@ -1,6 +1,6 @@
|
||||
util.AddNetworkString( "cfc_di_ping" )
|
||||
util.AddNetworkString( "cfc_di_loaded" )
|
||||
util.AddNetworkString( "cfc_di_shutdown" )
|
||||
util.AddNetworkString( "CFC_DisconnectInterface_Ping" )
|
||||
util.AddNetworkString( "CFC_DisconnectInterface_Loaded" )
|
||||
util.AddNetworkString( "CFC_DisconnectInterface_Shutdown" )
|
||||
|
||||
CreateConVar( "cfc_disconnect_interface_status_endpoint", "https://nanny.cfcservers.org/cfc3-ping", FCVAR_REPLICATED + FCVAR_ARCHIVE + FCVAR_PROTECTED )
|
||||
CreateConVar( "cfc_disconnect_interface_restart_time", 180, FCVAR_REPLICATED + FCVAR_ARCHIVE + FCVAR_PROTECTED )
|
||||
|
@ -56,18 +56,18 @@ function api.getState()
|
||||
return api.stateOverride or api.state
|
||||
end
|
||||
|
||||
concommand.Add( "cfc_di_testcrash", function()
|
||||
concommand.Add( "cfc_disconnect_interface_test_crash", function()
|
||||
api.stateOverride = api.SERVER_DOWN
|
||||
end )
|
||||
|
||||
concommand.Add( "cfc_di_testnointernet", function()
|
||||
concommand.Add( "cfc_disconnect_interface_test_nointernet", function()
|
||||
api.stateOverride = api.NO_INTERNET
|
||||
end )
|
||||
|
||||
concommand.Add( "cfc_di_testrestart", function()
|
||||
concommand.Add( "cfc_disconnect_interface_test_restart", function()
|
||||
api.stateOverride = api.SERVER_UP
|
||||
end )
|
||||
|
||||
concommand.Add( "cfc_di_testrecover", function()
|
||||
concommand.Add( "cfc_disconnect_interface_test_recover", function()
|
||||
api.stateOverride = nil
|
||||
end )
|
||||
|
@ -34,7 +34,7 @@ function dTimer.Simple( delay, f )
|
||||
dTimer.idCounter = dTimer.idCounter + 1
|
||||
end
|
||||
|
||||
hook.Add( "Think", "cfc_di_detatched_timer", function()
|
||||
hook.Add( "Think", "CFC_DisconnectInterface_DetatchedTimer", function()
|
||||
local time = SysTime()
|
||||
for id, curTimer in pairs( dTimer.timers ) do
|
||||
|
||||
|
@ -66,19 +66,19 @@ local function secondsAsTime( s )
|
||||
end
|
||||
|
||||
local function rejoin()
|
||||
timer.Simple( 1, function()
|
||||
dTimer.Simple( 1, function()
|
||||
RunConsoleCommand( "snd_restart" ) -- Restarts sound engine, good practice?
|
||||
RunConsoleCommand( "retry" )
|
||||
end )
|
||||
end
|
||||
|
||||
local function leave()
|
||||
timer.Simple( 1, function()
|
||||
dTimer.Simple( 1, function()
|
||||
RunConsoleCommand( "disconnect" )
|
||||
end )
|
||||
end
|
||||
|
||||
hook.Add( "InitPostEntity", "cfc_di_getGame", async( function()
|
||||
hook.Add( "InitPostEntity", "CFC_DisconnectInterface_GetGame", async( function()
|
||||
repeat
|
||||
success, GAME_CODE = await( NP.http.fetch( GAME_URL ) )
|
||||
GAME_CODE = success and GAME_CODE
|
||||
@ -281,7 +281,7 @@ local function addButtonsBar( frame )
|
||||
else
|
||||
hideMessage()
|
||||
|
||||
timer.Simple( 0.25, function()
|
||||
dTimer.Simple( 0.25, function()
|
||||
showMessage( "You'll have the option to respawn your props when you rejoin." )
|
||||
end )
|
||||
|
||||
@ -451,7 +451,7 @@ local function createInterface()
|
||||
end
|
||||
end
|
||||
|
||||
hook.Add( "cfc_di_crashTick", "cfc_di_interfaceUpdate", function( isCrashing, _timeDown, _apiState )
|
||||
hook.Add( "CFC_CrashTick", "CFC_DisconnectInterface_InterfaceUpdate", function( isCrashing, _timeDown, _apiState )
|
||||
timeDown = _timeDown
|
||||
if _apiState ~= CFCCrashAPI.PINGING_API then
|
||||
apiState = _apiState
|
||||
|
@ -10,7 +10,7 @@ local lastPong
|
||||
local pongerStatus = false
|
||||
local pingLoopRunning = false
|
||||
|
||||
net.Receive( "cfc_di_ping", function()
|
||||
net.Receive( "CFC_DisconnectInterface_Ping", function()
|
||||
if CFCCrashAPI.stateOverride then return end
|
||||
|
||||
if PING_MISS > 0 then -- Allow some pings before actually starting crash systems. ( Avoid bugs on join stutter. )
|
||||
@ -21,12 +21,12 @@ net.Receive( "cfc_di_ping", function()
|
||||
end )
|
||||
|
||||
local function shutdown()
|
||||
dTimer.Remove( "cfc_di_startup" )
|
||||
hook.Remove( "Tick", "cfc_di_tick" )
|
||||
dTimer.Remove( "CFC_DisconnectInterface_Startup" )
|
||||
hook.Remove( "Tick", "CFC_DisconnectInterface_CrashChecker" )
|
||||
end
|
||||
|
||||
net.Receive( "cfc_di_shutdown", shutdown )
|
||||
hook.Add( "ShutDown", "cfc_di_shutdown", shutdown )
|
||||
net.Receive( "CFC_DisconnectInterface_Shutdown", shutdown )
|
||||
hook.Add( "ShutDown", "CFC_DisconnectInterface_Cleanup", shutdown )
|
||||
|
||||
local function _pingLoop()
|
||||
if pingLoopRunning then return end
|
||||
@ -55,18 +55,18 @@ local function checkCrashTick()
|
||||
pingLoop()
|
||||
end
|
||||
|
||||
hook.Run( "cfc_di_crashTick", pongerStatus, timedown, CFCCrashAPI.getState() )
|
||||
hook.Run( "CFC_CrashTick", pongerStatus, timedown, CFCCrashAPI.getState() )
|
||||
end
|
||||
|
||||
-- Ping the server when the client is ready.
|
||||
dTimer.Create( "cfc_di_startup", 0.01, 0, function()
|
||||
dTimer.Create( "CFC_DisconnectInterface_Startup", 0.01, 0, function()
|
||||
if LocalPlayer():IsValid() then
|
||||
dTimer.Remove( "cfc_di_startup" )
|
||||
dTimer.Remove( "CFC_DisconnectInterface_Startup" )
|
||||
|
||||
net.Start( "cfc_di_loaded" )
|
||||
net.Start( "CFC_DisconnectInterface_Loaded" )
|
||||
net.SendToServer()
|
||||
|
||||
print( "cfc_disconnect_interface loaded." )
|
||||
hook.Add( "Tick", "cfc_di_tick", checkCrashTick )
|
||||
hook.Add( "Tick", "CFC_DisconnectInterface_CrashChecker", checkCrashTick )
|
||||
end
|
||||
end )
|
||||
|
@ -3,25 +3,25 @@ local PING_TIME = 1
|
||||
local players = {}
|
||||
|
||||
local function ping( ply )
|
||||
net.Start( "cfc_di_ping" )
|
||||
net.Start( "CFC_DisconnectInterface_Ping" )
|
||||
net.Send( ply or players )
|
||||
end
|
||||
|
||||
net.Receive( "cfc_di_loaded", function( len, ply )
|
||||
net.Receive( "CFC_DisconnectInterface_Loaded", function( len, ply )
|
||||
if not IsValid( ply ) then return end
|
||||
if not table.HasValue( players, ply ) then
|
||||
table.insert( players, ply )
|
||||
end
|
||||
end )
|
||||
|
||||
hook.Add( "PlayerDisconnected", "crashsys", function( ply )
|
||||
hook.Add( "PlayerDisconnected", "CFC_DisconnectInterface_UnregisterPlayer", function( ply )
|
||||
ping( ply ) -- Stop menu popping up while they are leaving
|
||||
table.RemoveByValue( players, ply )
|
||||
end )
|
||||
|
||||
timer.Create( "cfc_di_pingTimer", PING_TIME, 0, ping )
|
||||
timer.Create( "CFC_DisconnectInterface_PingTimer", PING_TIME, 0, ping )
|
||||
|
||||
hook.Add( "ShutDown", "cfc_di", function()
|
||||
net.Start( "cfc_di_shutdown" )
|
||||
hook.Add( "ShutDown", "CFC_DisconnectInterface_ForwardShutdown", function()
|
||||
net.Start( "CFC_DisconnectInterface_Shutdown" )
|
||||
net.Send( players )
|
||||
end )
|
||||
|
Loading…
Reference in New Issue
Block a user