From 8cddfcdef0915239be6aab5249131c8e647b129b Mon Sep 17 00:00:00 2001 From: Kyle Spier-Swenson Date: Fri, 17 Apr 2020 16:01:20 -0700 Subject: [PATCH] Adds format=json support to world/topic (#50446) random fact: the original game banners from erro used a custom url decoder. It wasn't until a year or two in to me being host that i caught on and fixed this. --- code/datums/world_topic.dm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/code/datums/world_topic.dm b/code/datums/world_topic.dm index 786a100ca4f..d62a605e1c9 100644 --- a/code/datums/world_topic.dm +++ b/code/datums/world_topic.dm @@ -27,11 +27,16 @@ /datum/world_topic/proc/TryRun(list/input) key_valid = config && (CONFIG_GET(string/comms_key) == input["key"]) - if(require_comms_key && !key_valid) - return "Bad Key" input -= "key" - . = Run(input) - if(islist(.)) + if(require_comms_key && !key_valid) + . = "Bad Key" + if (input["format"] == "json") + . = list("error" = .) + else + . = Run(input) + if (input["format"] == "json") + . = json_encode(.) + else if(islist(.)) . = list2params(.) /datum/world_topic/proc/Run(list/input)