Revert "Fixes some events, removes unused scripts related to TGS3, etc"

This commit is contained in:
Izac Joof Forsgren
2020-07-09 14:54:48 +02:00
committed by GitHub
parent 960b0e0e1c
commit 3cb9892fbc
9 changed files with 362 additions and 48 deletions

View File

@@ -188,8 +188,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
to_chat(world, "<span class='boldannounce'>[msg]</span>")
log_world(msg)
send2chat("Server Initialization completed! - Took [time] second[time == 1 ? "" : "s"].", "bot announce")
SERVER_TOOLS_CHAT_BROADCAST("Server Initialization completed!")
if (!current_runlevel)
SetRunLevel(RUNLEVEL_LOBBY)

View File

@@ -1,35 +0,0 @@
/**
* Sends a message to TGS chat channels.
*
* message - The message to send.
* channel_tag - Required. If "", the message with be sent to all connected (Game-type for TGS3) channels. Otherwise, it will be sent to TGS4 channels with that tag (Delimited by ','s).
*/
/proc/send2chat(message, channel_tag)
if(channel_tag == null || !world.TgsAvailable())
return
var/datum/tgs_version/version = world.TgsVersion()
if(channel_tag == "" || version.suite == 3)
world.TgsTargetedChatBroadcast(message, FALSE)
return
var/list/channels_to_use = list()
for(var/I in world.TgsChatChannelInfo())
var/datum/tgs_chat_channel/channel = I
var/list/applicable_tags = splittext(channel.tag, ",")
if(channel_tag in applicable_tags)
channels_to_use += channel
if(channels_to_use.len)
world.TgsChatBroadcast(message, channels_to_use)
/**
* Sends a message to TGS admin chat channels.
*
* category - The category of the mssage.
* message - The message to send.
*/
/proc/send2adminchat(category, message)
category = replacetext(replacetext(category, "\proper", ""), "\improper", "")
message = replacetext(replacetext(message, "\proper", ""), "\improper", "")
world.TgsTargetedChatBroadcast("[category] | [message]", TRUE)

View File

@@ -183,12 +183,12 @@ var/world_topic_spam_protect_time = world.timeofday
if(!positions["misc"])
positions["misc"] = list()
positions["misc"][name] = rank
for(var/datum/data/record/t in data_core.hidden_general)
var/name = t.fields["name"]
var/rank = t.fields["rank"]
var/real_rank = make_list_rank(t.fields["real_rank"])
var/datum/job/J = SSjob.get_job(real_rank)
if(J?.offmap_spawn)
if(!positions["off"])
@@ -651,11 +651,11 @@ proc/establish_old_db_connection()
if(!istype(GLOB.players_by_zlevel, /list))
GLOB.players_by_zlevel = new /list(world.maxz, 0)
GLOB.living_players_by_zlevel = new /list(world.maxz, 0)
while(GLOB.players_by_zlevel.len < world.maxz)
GLOB.players_by_zlevel.len++
GLOB.players_by_zlevel[GLOB.players_by_zlevel.len] = list()
GLOB.living_players_by_zlevel.len++
GLOB.living_players_by_zlevel[GLOB.living_players_by_zlevel.len] = list()
@@ -678,4 +678,15 @@ proc/establish_old_db_connection()
/world/proc/on_tickrate_change()
SStimer?.reset_buckets()
#undef FAILED_DB_CONNECTION_CUTOFF
#undef FAILED_DB_CONNECTION_CUTOFF
/world/New()
SERVER_TOOLS_ON_NEW
return ..()
/world/Reboot(var/reason)
SERVER_TOOLS_ON_REBOOT
return ..(reason)
/world/Topic(T, addr, master, key)
SERVER_TOOLS_ON_TOPIC
return ..(T, addr, master, key)

View File

@@ -0,0 +1,74 @@
//File DEFUNCT
/datum/server_tools_command
var/name = "" //the string to trigger this command on a chat bot. e.g. TGS3_BOT: do_this_command
var/help_text = "" //help text for this command
var/required_parameters = 0 //number of parameters required for this command
var/admin_only = FALSE //set to TRUE if this command should only be usable by registered chat admins
//override to implement command
//sender is the display name of who sent the command
//params is the trimmed string following the command name
/datum/server_tools_command/proc/Run(sender, params)
CRASH("[type] has no implementation for Run()")
/world/proc/ListServiceCustomCommands(warnings_only)
if(!warnings_only)
. = list()
var/list/command_name_types = list()
var/list/warned_command_names = warnings_only ? list() : null
for(var/I in typesof(/datum/server_tools_command) - /datum/server_tools_command)
var/datum/server_tools_command/stc = I
var/command_name = initial(stc.name)
var/static/list/warned_server_tools_names = list()
if(!command_name || findtext(command_name, " ") || findtext(command_name, "'") || findtext(command_name, "\""))
if(warnings_only && !warned_command_names[command_name])
SERVER_TOOLS_LOG("WARNING: Custom command [command_name] cannot be used as it is empty or contains illegal characters!")
warned_command_names[command_name] = TRUE
continue
if(command_name_types[command_name])
if(warnings_only)
SERVER_TOOLS_LOG("WARNING: Custom commands [command_name_types[command_name]] and [stc] have the same name only [command_name_types[command_name]] will be available!")
continue
command_name_types[stc] = command_name
if(!warnings_only)
.[command_name] = list(SERVICE_JSON_PARAM_HELPTEXT = initial(stc.help_text), SERVICE_JSON_PARAM_ADMINONLY = initial(stc.admin_only), SERVICE_JSON_PARAM_REQUIREDPARAMETERS = initial(stc.required_parameters))
/world/proc/HandleServiceCustomCommand(command, sender, params)
var/static/list/cached_custom_server_tools_commands
if(!cached_custom_server_tools_commands)
cached_custom_server_tools_commands = list()
for(var/I in typesof(/datum/server_tools_command) - /datum/server_tools_command)
var/datum/server_tools_command/stc = I
cached_custom_server_tools_commands[lowertext(initial(stc.name))] = stc
var/command_type = cached_custom_server_tools_commands[command]
if(!command_type)
return FALSE
var/datum/server_tools_command/stc = new command_type
return stc.Run(sender, params) || TRUE
/*
The MIT License
Copyright (c) 2017 Jordan Brown
Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and
associated documentation files (the "Software"), to
deal in the Software without restriction, including
without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom
the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

View File

@@ -0,0 +1,133 @@
//File DEFUNCT
SERVER_TOOLS_DEFINE_AND_SET_GLOBAL(reboot_mode, REBOOT_MODE_NORMAL)
SERVER_TOOLS_DEFINE_AND_SET_GLOBAL(server_tools_api_compatible, FALSE)
/proc/GetTestMerges()
if(RunningService(TRUE) && fexists(SERVICE_PR_TEST_JSON))
. = json_decode(file2text(SERVICE_PR_TEST_JSON))
if(.)
return
return list()
/world/proc/ServiceInit()
if(!RunningService(TRUE))
return
ListServiceCustomCommands(TRUE)
ExportService("[SERVICE_REQUEST_API_VERSION] [SERVER_TOOLS_API_VERSION]", TRUE)
/proc/RunningService(skip_compat_check = FALSE)
if(!skip_compat_check && !SERVER_TOOLS_READ_GLOBAL(server_tools_api_compatible))
return FALSE
. = world.params[SERVICE_WORLD_PARAM] != null
if(. && world.system_type != MS_WINDOWS)
SERVER_TOOLS_LOG("Warning: Server tools world parameter detected but not running on Windows. Aborting initialization!")
return FALSE
/proc/ServiceVersion()
if(RunningService(TRUE))
return world.params[SERVICE_VERSION_PARAM]
/proc/ServiceAPIVersion()
return SERVICE_API_VERSION_STRING
/world/proc/ExportService(command, skip_compat_check = FALSE)
. = FALSE
if(!RunningService(skip_compat_check))
return
if(skip_compat_check && !fexists(SERVICE_INTERFACE_DLL))
CRASH("Service parameter present but no interface DLL detected. This is symptomatic of running a service less than version 3.1! Please upgrade.")
var/instance = params[SERVICE_INSTANCE_PARAM]
if(!instance)
instance = "TG Station Server" //maybe just upgraded
call(SERVICE_INTERFACE_DLL, SERVICE_INTERFACE_FUNCTION)(instance, command) //trust no retval
return TRUE
/world/proc/ChatBroadcast(message)
ExportService("[SERVICE_REQUEST_IRC_BROADCAST] [message]")
/world/proc/AdminBroadcast(message)
ExportService("[SERVICE_REQUEST_IRC_ADMIN_CHANNEL_MESSAGE] [message]")
/world/proc/ServiceEndProcess(silent = FALSE)
SERVER_TOOLS_LOG("Sending shutdown request!");
sleep(world.tick_lag) //flush the buffers
ExportService(silent ? SERVICE_REQUEST_KILL_PROCESS_SILENT : SERVICE_REQUEST_KILL_PROCESS)
//called at the exact moment the world is supposed to reboot
/world/proc/ServiceReboot()
switch(SERVER_TOOLS_READ_GLOBAL(reboot_mode))
if(REBOOT_MODE_HARD)
SERVER_TOOLS_WORLD_ANNOUNCE("gay")//Hard reboot triggered, you will automatically reconnect...")
ServiceEndProcess()
if(REBOOT_MODE_SHUTDOWN)
SERVER_TOOLS_WORLD_ANNOUNCE("The server is shutting down...")
ServiceEndProcess()
else
ExportService(SERVICE_REQUEST_WORLD_REBOOT) //just let em know
/world/proc/ServiceCommand(list/params)
var/their_sCK = params[SERVICE_CMD_PARAM_KEY]
if(!their_sCK || !RunningService(TRUE))
return FALSE //continue world/Topic
var/sCK = world.params[SERVICE_WORLD_PARAM]
if(their_sCK != sCK)
return "Invalid comms key!";
var/command = params[SERVICE_CMD_PARAM_COMMAND]
if(!command)
return "No command!"
switch(command)
if(SERVICE_CMD_API_COMPATIBLE)
SERVER_TOOLS_WRITE_GLOBAL(server_tools_api_compatible, TRUE)
return SERVICE_RETURN_SUCCESS
if(SERVICE_CMD_HARD_REBOOT)
if(SERVER_TOOLS_READ_GLOBAL(reboot_mode) != REBOOT_MODE_HARD)
SERVER_TOOLS_WRITE_GLOBAL(reboot_mode, REBOOT_MODE_HARD)
SERVER_TOOLS_LOG("Hard reboot requested by service")
SERVER_TOOLS_NOTIFY_ADMINS("The world will hard reboot at the end of the game. Requested by service.")
if(SERVICE_CMD_GRACEFUL_SHUTDOWN)
if(SERVER_TOOLS_READ_GLOBAL(reboot_mode) != REBOOT_MODE_SHUTDOWN)
SERVER_TOOLS_WRITE_GLOBAL(reboot_mode, REBOOT_MODE_SHUTDOWN)
SERVER_TOOLS_LOG("Shutdown requested by service")
message_admins("The world will shutdown at the end of the game. Requested by service.")
if(SERVICE_CMD_WORLD_ANNOUNCE)
var/msg = params["message"]
if(!istext(msg) || !msg)
return "No message set!"
SERVER_TOOLS_WORLD_ANNOUNCE(msg)
return SERVICE_RETURN_SUCCESS
if(SERVICE_CMD_PLAYER_COUNT)
return "[SERVER_TOOLS_CLIENT_COUNT]"
if(SERVICE_CMD_LIST_CUSTOM)
return json_encode(ListServiceCustomCommands(FALSE))
else
var/custom_command_result = HandleServiceCustomCommand(lowertext(command), params[SERVICE_CMD_PARAM_SENDER], params[SERVICE_CMD_PARAM_CUSTOM])
if(custom_command_result)
return istext(custom_command_result) ? custom_command_result : SERVICE_RETURN_SUCCESS
return "Unknown command: [command]"
/*
The MIT License
Copyright (c) 2017 Jordan Brown
Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and
associated documentation files (the "Software"), to
deal in the Software without restriction, including
without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom
the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

View File

@@ -0,0 +1,133 @@
//File DEFUNCT
/datum/server_tools_command/status
name = "status" //the string to trigger this command on a chat bot. e.g. TGS3_BOT: do_this_command
help_text = "Will broadcast the current player count and other round information" //help text for this command
required_parameters = 0 //number of parameters required for this command
admin_only = FALSE //set to TRUE if this command should only be usable by registered chat admins
/datum/server_tools_command/status/Run(sender, params)
return "```PLAYERCOUNT: [SERVER_TOOLS_CLIENT_COUNT] ROUND DURATION: [roundduration2text()]```"
// - FAX
/datum/server_tools_command/readfax
name = "readfax"
help_text = "Reads a fax with specified faxid"
required_parameters = 1
admin_only = TRUE
/datum/server_tools_command/readfax/Run(sender, params)
var/list/all_params = splittext(params, " ")
var/faxid = all_params[1]
var/faxmsg = return_file_text("[config.fax_export_dir]/fax_[faxid].html")
return "FAX: ```[strip_html_properly(faxmsg)]```"
// - Staffwho
/datum/server_tools_command/staffwho
name = "staffwho"
help_text = "Shows the current online staff count"
required_parameters = 0
admin_only = TRUE
/datum/server_tools_command/staffwho/Run(datum/tgs_chat_user/sender, params)
var/message = "Current online staff:\n"
var/list/admin_keys = list()
var/list/mod_keys = list()
var/list/dev_keys = list()
var/list/other_keys = list()
var/count = 0
for(var/client/C in GLOB.admins)
count++
var/keymsg = "[C.key]"
if(C.is_afk())
keymsg += " (AFK)"
else if(C.holder.fakekey)
keymsg += " (Stealth)"
else if(isobserver(C.mob))
keymsg += " (Ghost)"
else if(isnewplayer(C.mob))
keymsg += " (Lobby)"
else
keymsg += " (Ingame)"
if(R_ADMIN & C.holder.rights && R_BAN & C.holder.rights) // R_ADMIN and R_BAN apparently an admin makes
admin_keys += keymsg
else if(R_MOD & C.holder.rights && !(R_SERVER & C.holder.rights)) // R_MOD but not R_SERVER makes a moderator
mod_keys += keymsg
else if(R_DEBUG & C.holder.rights) // R_SERVER makes a dev
dev_keys += keymsg
else // No R_ADMIN&&R_BAN, R_ADMIN!R_BAN, R_SERVER, must be a GM or something
other_keys += keymsg
var/admin_msg = english_list(admin_keys, "-None-")
var/mod_msg = english_list(mod_keys, "-None-")
var/dev_msg = english_list(dev_keys, "-None-")
var/other_msg = english_list(other_keys, "-None-")
message += "**Admins:** [admin_msg]\n**Mods:** [mod_msg]\n**Devs:** [dev_msg]\n**Other:** [other_msg]\n**Total:** [count] online"
return message
// - Discord register
/* Commented out until i can figure it out or until we update tgs
GLOBAL_LIST_EMPTY(pending_discord_registrations)
/datum/server_tools_command/register
name = "register"
help_text = "Registers your chat username with your Byond username"
required_parameters = 0
admin_only = FALSE
/datum/server_tools_command/register/Run(datum/tgs_chat_user/sender, params)
// Try to find if that ID is registered to someone already
var/sql_discord = sql_sanitize_text(sender.id)
var/DBQuery/query = dbcon.NewQuery("SELECT discord_id FROM erro_player WHERE discord_id = '[sql_discord]'")
query.Execute()
if(query.NextRow())
return "[sender.friendly_name], your Discord ID is already registered to a Byond username. Please contact an administrator if you changed your Byond username or Discord ID."
var/key_to_find = "[ckey(params)]"
// They didn't provide anything worth looking up.
if(!length(key_to_find))
return "[sender.friendly_name], you need to provide your Byond username at the end of the command. It can be in 'key' format (with spaces and characters) or 'ckey' format (without spaces or special characters)."
// Try to find their client.
var/client/user
for(var/client/C in GLOB.clients)
if(C.ckey == key_to_find)
user = C
break
// Couldn't find them logged in.
if(!user)
return "[sender.friendly_name], I couldn't find a logged-in user with the username of '[key_to_find]', which is what you provided after conversion to Byond's ckey format. Please connect to the game server and try again."
var/sql_ckey = sql_sanitize_text(key_to_find)
query = dbcon.NewQuery("SELECT discord_id FROM erro_player WHERE ckey = '[sql_ckey]'")
query.Execute()
// We somehow found their client, BUT they don't exist in the database
if(!query.NextRow())
return "[sender.friendly_name], the server's database is either not responding or there's no evidence you've ever logged in. Please contact an administrator."
// We found them in the database, AND they already have a discord ID assigned
if(query.item[1])
return "[sender.friendly_name], it appears you've already registered your chat and game IDs. If you've changed game or chat usernames, please contact an administrator for help."
// Okay. We found them, they're in the DB, and they have no discord ID set.
var/message = "<span class='notice'>A request has been sent from Discord to validate your Byond username, by '[sender.friendly_name]' in '[sender.channel.friendly_name]'</span>\
<br><span class='warning'>If you did not send this request, do not click the link below, and do notify an administrator in-game or on Discord ASAP.</span>\
<br><a href='byond://?src=\ref[user];discord_reg=[html_encode(sender.id)]'>Click Here</a> if you authorized this registration attempt. This link is valid for 10 minutes."
to_chat(user, message)
// To stifle href hacking
GLOB.pending_discord_registrations.len++
GLOB.pending_discord_registrations[GLOB.pending_discord_registrations.len] = list("ckey" = key_to_find, "id" = sender.id, "time" = world.realtime)
return "[sender.friendly_name], I've sent you a message in-game. Please verify your username there to complete your registration within 10 minutes."
*/

View File

@@ -189,10 +189,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
var/list/adm = get_admin_counts()
var/list/activemins = adm["present"]
var activeMins = activemins.len
if(is_bwoink)
world.TgsTargetedChatBroadcast("ADMINHELP: FROM: [key_name_admin(usr)] TO [initiator_ckey]/[initiator_key_name] - MSG: **[msg]** - Heard by [activeMins] NON-AFK staff members.", TRUE)
else
world.TgsTargetedChatBroadcast("ADMINHELP: FROM: [initiator_ckey]/[initiator_key_name] - MSG: **[msg]** - Heard by [activeMins] NON-AFK staff members.", TRUE)
SERVER_TOOLS_RELAY_BROADCAST("ADMINHELP: FROM: [initiator_ckey]/[initiator_key_name] - MSG: **[msg]** - Heard by [activeMins] NON-AFK staff members.")
//YW EDIT END
GLOB.ahelp_tickets.active_tickets += src

View File

@@ -47,7 +47,7 @@
query_string += "&sentname=[url_encode(sent.name)]"
world.Export("[config.chat_webhook_url]?[query_string]")
//YW EDIT
world.TgsTargetedChatBroadcast("FAX: [sanitize(faxname)] / [sanitize(sent.name)] - SENT BY: [sanitize(sender.name)] - FAXID: **[sanitize(faxid)]**", TRUE)
SERVER_TOOLS_RELAY_BROADCAST("FAX: [sanitize(faxname)] / [sanitize(sent.name)] - SENT BY: [sanitize(sender.name)] - FAXID: **[sanitize(faxid)]**")
//YW EDIT END
//

View File

@@ -247,7 +247,6 @@
#include "code\controllers\subsystems\character_setup.dm"
#include "code\controllers\subsystems\chat.dm"
#include "code\controllers\subsystems\circuits.dm"
#include "code\controllers\subsystems\discord.dm"
#include "code\controllers\subsystems\events.dm"
#include "code\controllers\subsystems\garbage.dm"
#include "code\controllers\subsystems\holomaps.dm"
@@ -2030,6 +2029,9 @@
#include "code\modules\detectivework\tools\storage.dm"
#include "code\modules\detectivework\tools\swabs.dm"
#include "code\modules\detectivework\tools\uvlight.dm"
#include "code\modules\DMAPI\st_commands.dm"
#include "code\modules\DMAPI\st_interface.dm"
#include "code\modules\DMAPI\yawnDMAPI.dm"
#include "code\modules\economy\Accounts.dm"
#include "code\modules\economy\Accounts_DB.dm"
#include "code\modules\economy\ATM.dm"