mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-30 15:37:36 +01:00
world/Topic Refactor (#14850)
* world/Topic Refactor * These arent needed anymore * How could I forget this * Biggest edit ever * Forgot this * Mini refactor
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
/datum/world_topic_handler
|
||||
/// Key which invokes this topic
|
||||
var/topic_key
|
||||
/// Set this to TRUE if the topic handler needs an authorised comms key
|
||||
var/requires_commskey = FALSE
|
||||
|
||||
|
||||
/**
|
||||
* Invokes the world/Topic handler
|
||||
*
|
||||
* This includes sanity checking for if the key is required, as well as other sanity checks
|
||||
* DO NOT OVERRIDE
|
||||
* Arguments:
|
||||
* * input - The list of topic data, sent from [world/Topic]
|
||||
*/
|
||||
/datum/world_topic_handler/proc/invoke(list/input)
|
||||
SHOULD_NOT_OVERRIDE(TRUE)
|
||||
var/authorised = (config.comms_password && input["key"] == config.comms_password) // No password means no comms, not any password
|
||||
if(requires_commskey && !authorised)
|
||||
// Try keep all returns in JSON unless absolutely necessary (?ping for example)
|
||||
return(json_encode(list("error" = "Invalid Key")))
|
||||
|
||||
return execute(input, authorised)
|
||||
|
||||
/**
|
||||
* Actually executes the user's topic
|
||||
*
|
||||
* Override this to do your work in subtypes of this topic
|
||||
*
|
||||
* Arguments:
|
||||
* * input - The list of topic data, sent from [world/Topic]
|
||||
* * key_valid - Has the user entered the correct auth key
|
||||
*/
|
||||
/datum/world_topic_handler/proc/execute(list/input, key_valid = FALSE)
|
||||
PRIVATE_PROC(TRUE) // Ensures no one can call this arbitrarily without checking key auth
|
||||
CRASH("execute() not implemented/overridden for [type]")
|
||||
Reference in New Issue
Block a user