Migrates SSinstancing to Redis from world.Export() (#17679)

This commit is contained in:
AffectedArc07
2022-05-03 04:29:56 +01:00
committed by GitHub
parent d5e5d9e62b
commit 7bc1bee63a
10 changed files with 136 additions and 93 deletions

View File

@@ -0,0 +1,18 @@
/datum/server_command/gsay
command_name = "gsay"
/datum/server_command/gsay/execute(source, command_args)
var/message = command_args["msg"]
var/user = command_args["usr"]
// Send to online admins
for(var/client/C in GLOB.admins)
if(C.holder.rights & R_ADMIN)
to_chat(C, "<span class='admin_channel'>GSAY: [user]@[source]: [message]</span>")
/datum/server_command/gsay/custom_dispatch(ackey, message)
var/list/cmd_args = list()
cmd_args["usr"] = ackey
cmd_args["msg"] = message
dispatch(cmd_args)

View File

@@ -0,0 +1,20 @@
/datum/server_command/new_round_announce
command_name = "new_round_announce"
/datum/server_command/new_round_announce/execute(source, command_args)
var/server_name = command_args["sname"]
var/map_name = command_args["mname"]
var/map_fluff = command_args["mfluff"]
var/startup_msg = "The server <code>[server_name] ([source])</code> is now starting up. The map is [map_fluff] ([map_name]). You can connect with the <code>Switch Server</code> verb."
to_chat(world, "<center><span class='boldannounce'><big>Attention</big></span></center><hr>[startup_msg]<hr>")
SEND_SOUND(world, sound('sound/misc/notice2.ogg')) // Same as captains priority announce
/datum/server_command/new_round_announce/custom_dispatch(sname, mname, mfluff)
var/list/cmd_args = list()
cmd_args["sname"] = sname
cmd_args["mname"] = mname
cmd_args["mfluff"] = mfluff
dispatch(cmd_args)

View File

@@ -0,0 +1,38 @@
/**
* # Server Command
*
* Datum to handle both sending and receiving of server commands
*
* This datum is an extension of the redis callback and is designed for tighter integration with the BYOND servers.
* This list is registered and managed by SSintancing, not SSredis.
* NOTE: These commands are "fire and forget". If you need specific data from each server, use world/Topic still
*/
/datum/server_command
/// Does the sending server want to ignore this command? This is almost always yes unless you are doing testing stuff
var/ignoreself = TRUE
/// The source BYOND server for this message
var/source = null
/// The command name (must be unique)
var/command_name = null
/// Associative list of command args
var/list/command_args = list()
/datum/server_command/proc/execute(source, command_args)
CRASH("execute(source, command_args) not overriden for [type]!")
/datum/server_command/proc/dispatch(command_args)
SHOULD_NOT_OVERRIDE(TRUE) // No messing with
// Aight get serializing
var/list/serializeable_data = list()
serializeable_data["src"] = GLOB.configuration.system.instance_id
serializeable_data["cmd"] = command_name
serializeable_data["args"] = command_args
var/payload = json_encode(serializeable_data)
SSredis.publish(SERVER_MESSAGES_REDIS_CHANNEL, payload)
// Override this if you want a cleaner method for putting together dispatch args
/datum/server_command/proc/custom_dispatch()
CRASH("custom_dispatch() not overriden for [type]!")