Startup notifications

This commit is contained in:
AffectedArc07
2021-08-17 14:30:00 +01:00
parent e19a83f9be
commit fdcc88b7ca
5 changed files with 61 additions and 6 deletions
+41 -5
View File
@@ -3,6 +3,8 @@ SUBSYSTEM_DEF(instancing)
runlevels = RUNLEVEL_INIT | RUNLEVEL_LOBBY | RUNLEVEL_SETUP | RUNLEVEL_GAME | RUNLEVEL_POSTGAME
/// Have we announced startup yet
var/startup_announced = FALSE
/// Has our initial check complete? Used as part of the above
var/initial_check_complete = FALSE
/// Is a check currently running?
var/check_running = FALSE
@@ -13,6 +15,10 @@ SUBSYSTEM_DEF(instancing)
/datum/controller/subsystem/instancing/fire(resumed)
check_peers()
if(initial_check_complete && !startup_announced)
startup_announced = TRUE
var/startup_msg = "The server [GLOB.configuration.general.server_name] is now starting up. The map is [SSmapping.map_datum.fluff_name] ([SSmapping.map_datum.technical_name])"
INVOKE_ASYNC(src, .proc/message_all_peers, startup_msg) // Async
/**
@@ -21,8 +27,10 @@ SUBSYSTEM_DEF(instancing)
* Called periodically during fire() as well as when a new peer reports itself as online
* Only one instance of this proc may run at a time
*
* Arguments:
* * force - Do we want to force check all of them
*/
/datum/controller/subsystem/instancing/proc/check_peers()
/datum/controller/subsystem/instancing/proc/check_peers(force = FALSE)
set waitfor = FALSE // This has sleeps if it cant topic so we dont want to bog things down
if(check_running)
return
@@ -34,10 +42,13 @@ SUBSYSTEM_DEF(instancing)
for(var/datum/peer_server/PS in GLOB.configuration.instancing.peers)
// If the server hasnt been discovered and its been more than 5 minutes
if((!PS.discovered && PS.last_operation_time + 5 MINUTES > world.time))
continue
if(!force) // No, code review. This is not going in the same line.
continue
// Only run main operations once every minute anyway
if(PS.last_operation_time + 1 MINUTES > world.time)
continue // Only run main operations once every minute anyway
if(!force)
continue
var/peer_response = world.Export("byond://[PS.internal_ip]:[PS.server_port]?server_discovery&key=[PS.commskey]")
if(!peer_response)
@@ -58,6 +69,31 @@ SUBSYSTEM_DEF(instancing)
PS.last_operation_time = world.time
check_running = FALSE
initial_check_complete = TRUE
/datum/controller/subsystem/instancing/proc/message_all_peers(include_offline = FALSE)
return
/**
* Message all peers
*
* Wrapper for [topic_all_peers] to autoformat a message topic. Will send a server-wide announcement to the other servers
* including any relevant detail
* Arguments:
* * message - Message to send to the other servers
* * include_offline - Whether to topic offline servers on the off chance they came online
*/
/datum/controller/subsystem/instancing/proc/message_all_peers(message, include_offline = FALSE)
var/topic_string = "instance_announce&msg=[html_encode(message)]"
topic_all_peers(topic_string, include_offline)
/**
* Sends a topic to all peers
*
* Sends a raw topic to the other servers. WILL APPEND &key=[commskey] ON THE END. PLEASE ACCOUNT FOR THIS.
*
* Arguments:
* * raw_topic - The raw topic to send to the other servers
* * include_offline - Whether to topic offline servers on the off chance they came online
*/
/datum/controller/subsystem/instancing/proc/topic_all_peers(raw_topic, include_offline = FALSE)
for(var/datum/peer_server/PS in GLOB.configuration.instancing.peers)
if(PS.online || include_offline)
world.Export("byond://[PS.internal_ip]:[PS.server_port]?[raw_topic]&key=[PS.commskey]")
+2 -1
View File
@@ -138,7 +138,8 @@ GLOBAL_LIST_INIT(admin_verbs_server, list(
/client/proc/toggle_antagHUD_restrictions,
/client/proc/set_ooc,
/client/proc/reset_ooc,
/client/proc/set_next_map
/client/proc/set_next_map,
/client/proc/refresh_instances
))
GLOBAL_LIST_INIT(admin_verbs_debug, list(
/client/proc/cmd_admin_list_open_jobs,
@@ -20,3 +20,13 @@
// If we are here, we are online, so we can do a rich report
to_chat(usr, "ID [PS.server_id] - <font color='green'><b>ONLINE</b></font> (Players: [PS.playercount])")
/client/proc/refresh_instances()
set name = "Force Refresh Server Instances"
set desc = "Force refresh the local cache of server instances"
set category = "Server"
if(!check_rights(R_SERVER))
return
SSinstancing.check_peers(TRUE) // Force check
@@ -0,0 +1,7 @@
/datum/world_topic_handler/instance_announce
topic_key = "instance_announce"
requires_commskey = TRUE
/datum/world_topic_handler/instance_announce/execute(list/input, key_valid)
var/msg = input["msg"]
to_chat(world, "<span class='boldannounce'>Attention:</span> [msg]")
+1
View File
@@ -2509,6 +2509,7 @@
#include "code\modules\world_topic\_topic_base.dm"
#include "code\modules\world_topic\adminmsg.dm"
#include "code\modules\world_topic\announce.dm"
#include "code\modules\world_topic\instance_announce.dm"
#include "code\modules\world_topic\manifest.dm"
#include "code\modules\world_topic\ping.dm"
#include "code\modules\world_topic\players.dm"