Ports the TG globals controller and converts globals. (#18057)

* SDQL2 update

* fix that verb

* cl

* fix that

* toworld

* this is pointless

* update info

* siiiiick..

* vv edit update

* fix that

* fix editing vars

* fix VV

* Port the /TG/ globals controller.

* part 1

* part 2

* oops

* part 3

* Hollow Purple

* sadas

* bsbsdb

* muda na agaki ta

* ids 1-15

* 16-31

* 41-75

* bring me back to how things used to be before i lost it all

* the strength of mayhem

* final touches

* cl

* protect some vars

* update sdql2 to use glob

* stuff?

* forgot that is not defined there

* whoops

* observ

* but it never gets better

* a

---------

Co-authored-by: Matt Atlas <liermattia@gmail.com>
This commit is contained in:
Matt Atlas
2023-12-26 02:16:02 +01:00
committed by GitHub
parent 19292f01d3
commit cadd19beac
966 changed files with 4785 additions and 4784 deletions
+4 -4
View File
@@ -67,23 +67,23 @@
LOG_DEBUG("API: Throttling bypassed - Command [name] set to no_throttle")
return FALSE
if (config.api_rate_limit_whitelist[addr])
if (GLOB.config.api_rate_limit_whitelist[addr])
LOG_DEBUG("API: Throttling bypassed - IP [addr] is whitelisted.")
return FALSE
var/last_time = world_api_rate_limit[addr]
world_api_rate_limit[addr] = REALTIMEOFDAY
if (last_time != null && abs(last_time - REALTIMEOFDAY) < config.api_rate_limit)
if (last_time != null && abs(last_time - REALTIMEOFDAY) < GLOB.config.api_rate_limit)
return TRUE
return FALSE
/datum/topic_command/proc/_is_authorized_via_token(addr, auth_key)
if (!establish_db_connection(dbcon))
if (!establish_db_connection(GLOB.dbcon))
return FALSE
var/DBQuery/authquery = dbcon.NewQuery({"SELECT api_f.command
var/DBQuery/authquery = GLOB.dbcon.NewQuery({"SELECT api_f.command
FROM ss13_api_token_command as api_t_f, ss13_api_tokens as api_t, ss13_api_commands as api_f
WHERE api_t.id = api_t_f.token_id AND api_f.id = api_t_f.command_id
AND api_t.deleted_at IS NULL
+3 -3
View File
@@ -21,7 +21,7 @@
data = null
return TRUE
if(G.has_enabled_antagHUD && config.antag_hud_restricted && allow_antaghud == 0)
if(G.has_enabled_antagHUD && GLOB.config.antag_hud_restricted && allow_antaghud == 0)
statuscode = 409
response = "Ghost has used Antag Hud - Respawn Aborted"
data = null
@@ -84,7 +84,7 @@
var/client/C
var/req_ckey = ckey(queryparams["ckey"])
for(var/client/K in clients)
for(var/client/K in GLOB.clients)
if(K.ckey == req_ckey)
C = K
break
@@ -107,7 +107,7 @@
sound_to(C, 'sound/effects/adminhelp.ogg')
to_chat(C, message)
for(var/client/A in staff)
for(var/client/A in GLOB.staff)
if(A != C && check_rights(R_MOD|R_ADMIN, show_msg = FALSE, user = A.mob))
to_chat(A, amessage)
@@ -31,12 +31,12 @@
/datum/topic_command/api_get_authed_commands/run_command(queryparams)
var/list/commands = list()
//Check if DB Connection is established
if (!establish_db_connection(dbcon))
if (!establish_db_connection(GLOB.dbcon))
statuscode = 500
response = "DB Connection Unavailable"
return TRUE
var/DBQuery/commandsquery = dbcon.NewQuery({"SELECT api_f.command
var/DBQuery/commandsquery = GLOB.dbcon.NewQuery({"SELECT api_f.command
FROM ss13_api_token_command as api_t_f, ss13_api_tokens as api_t, ss13_api_commands as api_f
WHERE api_t.id = api_t_f.token_id AND api_f.id = api_t_f.command_id
AND (
@@ -55,7 +55,7 @@
if(commandsquery.item[1] == "_ANY")
statuscode = 200
response = "Authorized commands retrieved - ALL"
data = topic_commands_names
data = GLOB.topic_commands_names
return TRUE
@@ -74,7 +74,7 @@
)
/datum/topic_command/api_explain_command/run_command(queryparams)
var/datum/topic_command/apicommand = topic_commands[queryparams["command"]]
var/datum/topic_command/apicommand = GLOB.topic_commands[queryparams["command"]]
var/list/commanddata = list()
if (isnull(apicommand))
@@ -83,7 +83,7 @@
return TRUE
//Then query for auth
if (!establish_db_connection(dbcon))
if (!establish_db_connection(GLOB.dbcon))
statuscode = 500
response = "DB Connection Unavailable"
return TRUE
@@ -118,16 +118,16 @@
/datum/topic_command/update_command_database/proc/api_update_command_database()
LOG_DEBUG("API: DB Command Update Called")
//Check if DB Connection is established
if (!establish_db_connection(dbcon))
if (!establish_db_connection(GLOB.dbcon))
response = "Database connection lost, cannot update commands."
return FALSE //Error
var/DBQuery/commandinsertquery = dbcon.NewQuery({"INSERT INTO ss13_api_commands (command,description)
var/DBQuery/commandinsertquery = GLOB.dbcon.NewQuery({"INSERT INTO ss13_api_commands (command,description)
VALUES (:command_name:,:command_description:)
ON DUPLICATE KEY UPDATE description = :command_description:;"})
for(var/com in topic_commands)
var/datum/topic_command/command = topic_commands[com]
for(var/com in GLOB.topic_commands)
var/datum/topic_command/command = GLOB.topic_commands[com]
commandinsertquery.Execute(list("command_name" = command.name, "command_description" = command.description))
LOG_DEBUG("API: DB Command Update Executed")
+15 -15
View File
@@ -26,14 +26,14 @@
var/current_only = text2num(queryparams["current_only"])
var/admin_only = text2num(queryparams["admin_only"])
if(!establish_db_connection(dbcon))
if(!establish_db_connection(GLOB.dbcon))
statuscode = 500
response = "DB-Connection unavailable"
return TRUE
var/list/polldata = list()
var/DBQuery/select_query = dbcon.NewQuery("SELECT id, polltype, starttime, endtime, question, multiplechoiceoptions, adminonly FROM ss13_poll_question [(current_only || admin_only) ? "WHERE" : ""] [(admin_only ? "adminonly = true " : "")][(current_only && admin_only ? "AND " : "")][(current_only ? "Now() BETWEEN starttime AND endtime" : "")]")
var/DBQuery/select_query = GLOB.dbcon.NewQuery("SELECT id, polltype, starttime, endtime, question, multiplechoiceoptions, adminonly FROM ss13_poll_question [(current_only || admin_only) ? "WHERE" : ""] [(admin_only ? "adminonly = true " : "")][(current_only && admin_only ? "AND " : "")][(current_only ? "Now() BETWEEN starttime AND endtime" : "")]")
select_query.Execute()
while(select_query.NextRow())
polldata["[select_query.item[1]]"] = list(
@@ -63,13 +63,13 @@
/datum/topic_command/get_poll_info/run_command(queryparams)
var/poll_id = text2num(queryparams["poll_id"])
if(!establish_db_connection(dbcon))
if(!establish_db_connection(GLOB.dbcon))
statuscode = 500
response = "DB-Connection unavailable"
return TRUE
//Get general data about the poll
var/DBQuery/select_query = dbcon.NewQuery("SELECT id, polltype, starttime, endtime, question, multiplechoiceoptions, adminonly, publicresult, viewtoken FROM ss13_poll_question WHERE id = :poll_id:")
var/DBQuery/select_query = GLOB.dbcon.NewQuery("SELECT id, polltype, starttime, endtime, question, multiplechoiceoptions, adminonly, publicresult, viewtoken FROM ss13_poll_question WHERE id = :poll_id:")
select_query.Execute(list("poll_id"=poll_id))
//Check if the poll exists
@@ -90,15 +90,15 @@
)
//Lets add a WI link to the poll, if we have the WI configured
if(config.webint_url)
poll_data["link"]="[config.webint_url]server/poll/[select_query.item[1]]/[select_query.item[9]]"
if(GLOB.config.webint_url)
poll_data["link"]="[GLOB.config.webint_url]server/poll/[select_query.item[1]]/[select_query.item[9]]"
var/list/result_data = list()
/** Return different data based on the poll type: */
//If we have a option or a multiple choice poll, return the number of options
if(poll_data["polltype"] == "OPTION" || poll_data["polltype"] == "MULTICHOICE")
var/DBQuery/result_query = dbcon.NewQuery({"SELECT ss13_poll_vote.optionid, ss13_poll_option.text, COUNT(*) as option_count
var/DBQuery/result_query = GLOB.dbcon.NewQuery({"SELECT ss13_poll_vote.optionid, ss13_poll_option.text, COUNT(*) as option_count
FROM ss13_poll_vote
LEFT JOIN ss13_poll_option ON ss13_poll_vote.optionid = ss13_poll_option.id
WHERE ss13_poll_vote.pollid = :poll_id:
@@ -119,7 +119,7 @@
//If we have a numval poll, return the options with the min, max, and average
else if(poll_data["polltype"] == "NUMVAL")
var/DBQuery/result_query = dbcon.NewQuery({"SELECT ss13_poll_vote.optionid, ss13_poll_option.text, ss13_poll_option.minval, ss13_poll_option.maxval, ss13_poll_option.descmin, ss13_poll_option.descmid, ss13_poll_option.descmax, AVG(rating) as option_rating_avg, MIN(rating) as option_rating_min, MAX(rating) as option_rating_max
var/DBQuery/result_query = GLOB.dbcon.NewQuery({"SELECT ss13_poll_vote.optionid, ss13_poll_option.text, ss13_poll_option.minval, ss13_poll_option.maxval, ss13_poll_option.descmin, ss13_poll_option.descmid, ss13_poll_option.descmax, AVG(rating) as option_rating_avg, MIN(rating) as option_rating_min, MAX(rating) as option_rating_max
FROM ss13_poll_vote
LEFT JOIN ss13_poll_option ON ss13_poll_vote.optionid = ss13_poll_option.id
WHERE ss13_poll_vote.pollid = :poll_id:
@@ -146,7 +146,7 @@
//If we have a textpoll, return the number of answers
else if(poll_data["polltype"] == "TEXT")
var/DBQuery/result_query = dbcon.NewQuery({"SELECT COUNT(*) as count FROM ss13_poll_textreply WHERE pollid = :poll_id:"})
var/DBQuery/result_query = GLOB.dbcon.NewQuery({"SELECT COUNT(*) as count FROM ss13_poll_textreply WHERE pollid = :poll_id:"})
result_query.Execute(list("poll_id"=poll_id))
if(result_query.NextRow())
result_data = list(
@@ -192,14 +192,14 @@
response = "Somethnig went horribly wrong."
return TRUE
if(!config.external_auth)
if(!GLOB.config.external_auth)
statuscode = 500
response = "External auth is disalowed."
del(una.client)
del(una)
return TRUE
var/client/cl = directory[ckey(queryparams["key"])]
var/client/cl = GLOB.directory[ckey(queryparams["key"])]
if(cl)
to_chat(cl, "Another connection has been made using your login key. This session has been terminated.")
del(cl)
@@ -229,7 +229,7 @@
response = "Something went horribly wrong."
return TRUE
if(!config.external_auth)
if(!GLOB.config.external_auth)
statuscode = 403
response = "External auth is disallowed."
del(una.client)
@@ -250,10 +250,10 @@
/datum/topic_command/set_extenal_auth/run_command(queryparams)
if(queryparams["state"] == null)
config.external_auth = !config.external_auth
GLOB.config.external_auth = !GLOB.config.external_auth
else
config.external_auth = queryparams["state"]
GLOB.config.external_auth = queryparams["state"]
statuscode = 200
response = "External authentication state has been updated sucessfully."
data = config.external_auth
data = GLOB.config.external_auth
@@ -129,7 +129,7 @@
/datum/topic_command/broadcast_text/run_command(queryparams)
log_and_message_admins("AdminRanks: remote reload of the admins list initiated.")
if (config.use_forumuser_api)
if (GLOB.config.use_forumuser_api)
if (!update_admins_from_api(reload_once_done=FALSE))
statuscode = 500
response = "Updating admins from the forumuser API failed. Aborted."
+15 -15
View File
@@ -6,24 +6,24 @@
/datum/topic_command/get_serverstatus/run_command(queryparams)
var/list/s[] = list()
s["version"] = game_version
s["mode"] = master_mode
s["respawn"] = config.abandon_allowed
s["enter"] = config.enter_allowed
s["vote"] = config.allow_vote_mode
s["ai"] = config.allow_ai
s["version"] = GLOB.game_version
s["mode"] = GLOB.master_mode
s["respawn"] = GLOB.config.abandon_allowed
s["enter"] = GLOB.config.enter_allowed
s["vote"] = GLOB.config.allow_vote_mode
s["ai"] = GLOB.config.allow_ai
s["stationtime"] = worldtime2text()
s["roundduration"] = get_round_duration_formatted()
s["gameid"] = game_id
s["game_state"] = SSticker ? SSticker.current_state : 0
s["transferring"] = evacuation_controller?.is_evacuating()
s["players"] = clients.len
s["staff"] = staff.len
s["players"] = GLOB.clients.len
s["staff"] = GLOB.staff.len
var/admin_count = 0
for(var/S in staff)
for(var/S in GLOB.staff)
var/client/C = S
if(C.holder.fakekey)
continue
@@ -45,7 +45,7 @@
/datum/topic_command/get_stafflist/run_command(queryparams)
var/list/l_staff = list()
for (var/s in staff)
for (var/s in GLOB.staff)
var/client/C = s
l_staff[C] = C.holder.rank
@@ -91,7 +91,7 @@
var/list/ckeys_found = list()
for (var/client/client in clients)
for (var/client/client in GLOB.clients)
if (!client.holder)
continue
@@ -128,7 +128,7 @@
var/list/ckeys_found = list()
for (var/client/client in clients)
for (var/client/client in GLOB.clients)
if (!client.holder)
continue
@@ -154,7 +154,7 @@
/datum/topic_command/get_count_player/run_command(queryparams)
var/n = 0
for(var/mob/M in player_list)
for(var/mob/M in GLOB.player_list)
if(M.client)
n++
@@ -234,7 +234,7 @@
show_hidden_admins = text2num(queryparams["showadmins"])
var/list/players = list()
for (var/client/C in clients)
for (var/client/C in GLOB.clients)
if (!show_hidden_admins && C.holder?.fakekey)
players += ckey(C.holder.fakekey)
else
@@ -262,7 +262,7 @@
var/list/match = list()
for(var/mob/M in mob_list)
for(var/mob/M in GLOB.mob_list)
var/strings = list(M.name, M.ckey)
if(M.mind)
strings += M.mind.assigned_role
+4 -4
View File
@@ -7,14 +7,14 @@
response = "General tickets overview."
var/list/ticket_data = list(
"total" = tickets.len,
"total" = GLOB.tickets.len,
"assigned" = 0,
"unassigned" = 0,
"closed" = 0
)
for (var/id = tickets.len, id >= 1, id--)
var/datum/ticket/ticket = tickets[id]
for (var/id = GLOB.tickets.len, id >= 1, id--)
var/datum/ticket/ticket = GLOB.tickets[id]
switch (ticket.status)
if (TICKET_OPEN)
ticket_data["unassigned"]++
@@ -42,7 +42,7 @@
var/list/ticket_data = list()
for (var/datum/ticket/ticket in tickets)
for (var/datum/ticket/ticket in GLOB.tickets)
if (only_open && ticket.status == TICKET_CLOSED)
continue
+7 -7
View File
@@ -3,14 +3,14 @@
for (var/path in typesof(/datum/topic_command) - /datum/topic_command)
var/datum/topic_command/A = new path()
if(A != null)
topic_commands[A.name] = A
topic_commands_names.Add(A.name)
listclearnulls(topic_commands)
listclearnulls(topic_commands_names)
GLOB.topic_commands[A.name] = A
GLOB.topic_commands_names.Add(A.name)
listclearnulls(GLOB.topic_commands)
listclearnulls(GLOB.topic_commands_names)
if (config.api_rate_limit_whitelist.len)
if (GLOB.config.api_rate_limit_whitelist.len)
// To make the api_rate_limit_whitelist[addr] grabs actually work.
for (var/addr in config.api_rate_limit_whitelist)
config.api_rate_limit_whitelist[addr] = 1
for (var/addr in GLOB.config.api_rate_limit_whitelist)
GLOB.config.api_rate_limit_whitelist[addr] = 1
return 1