diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index 27b13a5bc89c..18e60f1a6c67 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -291,7 +291,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( // Instantiate tgui panel tgui_panel = new(src) - tgui_panel?.send_connected() + tgui_panel.send_connected() GLOB.ahelp_tickets.ClientLogin(src) var/connecting_admin = FALSE //because de-admined admins connecting should be treated like admins. @@ -416,7 +416,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( // Initialize tgui panel tgui_panel.initialize() src << browse(file('html/statbrowser.html'), "window=statbrowser") - addtimer(CALLBACK(src, .proc/check_panel_loaded), 30 SECONDS) + addtimer(CALLBACK(src, .proc/check_panel_loaded), 5 SECONDS) if(alert_mob_dupe_login) @@ -1128,3 +1128,4 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( if(statbrowser_ready) return to_chat(src, span_userdanger("Statpanel failed to load, click here to reload the panel ")) + tgui_panel.initialize() \ No newline at end of file diff --git a/code/modules/tgui_panel/tgui_panel.dm b/code/modules/tgui_panel/tgui_panel.dm index e2b3df7552ab..fce5a9289513 100644 --- a/code/modules/tgui_panel/tgui_panel.dm +++ b/code/modules/tgui_panel/tgui_panel.dm @@ -12,6 +12,7 @@ var/datum/tgui_window/window var/broken = FALSE var/initialized_at + var/retries = 0 /datum/tgui_panel/New(client/client) src.client = client @@ -37,6 +38,9 @@ * Initializes tgui panel. */ /datum/tgui_panel/proc/initialize(force = FALSE) + set waitfor = FALSE + // Minimal sleep to defer initialization to after client constructor + sleep(1) initialized_at = world.time // Perform a clean initialization window.initialize(inline_assets = list( @@ -46,13 +50,34 @@ window.send_asset(get_asset_datum(/datum/asset/simple/namespaced/fontawesome)) window.send_asset(get_asset_datum(/datum/asset/spritesheet/chat)) request_telemetry() + if(!telemetry_connections && retries < 6) + addtimer(CALLBACK(src, .proc/check_telemetry), 2 SECONDS) addtimer(CALLBACK(src, .proc/on_initialize_timed_out), 2 SECONDS) +/datum/tgui_panel/proc/check_telemetry() + if(!telemetry_connections) /// Somethings fucked lets try again. + if(retries > 2) + if(client && istype(client)) + winset(client, null, "command=.reconnect") /// Kitchen Sink + qdel(client) + if(retries > 3) + qdel(client) + if(retries > 5) + return // I give up + if(retries < 6) + retries++ + src << browse(file('html/statbrowser.html'), "window=statbrowser") /// Reloads the statpanel as well + initialize() /// Lets just start again + var/mob/dead/new_player/M = client?.mob + if(istype(M)) + M.Login() + /** * private * * Called when initialization has timed out. */ + /datum/tgui_panel/proc/on_initialize_timed_out() // Currently does nothing but sending a message to old chat. SEND_TEXT(client, span_userdanger("Failed to load fancy chat, click HERE to attempt to reload it."))