[MIRROR] Make config.sql_enabled actually respected in all cases || Chompadd, updates dependencies and dmapi (#8913)

Co-authored-by: Heroman3003 <31296024+Heroman3003@users.noreply.github.com>
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
Co-authored-by: Kashargul <KashL@t-online.de>
Co-authored-by: Razgriz <razgriz1032@gmail.com>
This commit is contained in:
CHOMPStation2
2024-09-23 08:21:07 -07:00
committed by GitHub
parent 9806006415
commit 6068fb44cd
19 changed files with 141 additions and 55 deletions

View File

@@ -3,7 +3,7 @@
version: 1 version: 1
# The BYOND version to use (kept in sync with dependencies.sh by the "TGS Test Suite" CI job) # The BYOND version to use (kept in sync with dependencies.sh by the "TGS Test Suite" CI job)
# Must be interpreted as a string, keep quoted # Must be interpreted as a string, keep quoted
byond: "515.1633" byond: "515.1642"
# Folders to create in "<instance_path>/Configuration/GameStaticFiles/" # Folders to create in "<instance_path>/Configuration/GameStaticFiles/"
static_files: static_files:
# Config directory should be static # Config directory should be static

View File

@@ -3,11 +3,11 @@
# This file has all the information on what versions of libraries are thrown into the code # This file has all the information on what versions of libraries are thrown into the code
#rust_g git tag #rust_g git tag
export RUST_G_VERSION=3.1.0 export RUST_G_VERSION=3.4.0
# byond version # byond version
export BYOND_MAJOR=515 export BYOND_MAJOR=515
export BYOND_MINOR=1633 export BYOND_MINOR=1642
export MACRO_COUNT=4 export MACRO_COUNT=4
# node version # node version

View File

@@ -1,18 +1,19 @@
// tgstation-server DMAPI // tgstation-server DMAPI
// The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in IETF RFC 2119.
#define TGS_DMAPI_VERSION "7.1.1" #define TGS_DMAPI_VERSION "7.3.0"
// All functions and datums outside this document are subject to change with any version and should not be relied on. // All functions and datums outside this document are subject to change with any version and should not be relied on.
// CONFIGURATION // CONFIGURATION
/// Create this define if you want to do TGS configuration outside of this file. /// Consumers SHOULD create this define if you want to do TGS configuration outside of this file.
#ifndef TGS_EXTERNAL_CONFIGURATION #ifndef TGS_EXTERNAL_CONFIGURATION
// Comment this out once you've filled in the below. // Consumers MUST comment this out once you've filled in the below and are not using [TGS_EXTERNAL_CONFIGURATION].
#error TGS API unconfigured #error TGS API unconfigured
// Uncomment this if you wish to allow the game to interact with TGS 3.. // Consumers MUST uncomment this if you wish to allow the game to interact with TGS version 3.
// This will raise the minimum required security level of your game to TGS_SECURITY_TRUSTED due to it utilizing call()(). // This will raise the minimum required security level of your game to TGS_SECURITY_TRUSTED due to it utilizing call()().
//#define TGS_V3_API //#define TGS_V3_API
@@ -52,7 +53,7 @@
#ifndef TGS_FILE2TEXT_NATIVE #ifndef TGS_FILE2TEXT_NATIVE
#ifdef file2text #ifdef file2text
#error Your codebase is re-defining the BYOND proc file2text. The DMAPI requires the native version to read the result of world.Export(). You can fix this by adding "#define TGS_FILE2TEXT_NATIVE file2text" before your override of file2text to allow the DMAPI to use the native version. This will only be used for world.Export(), not regular file accesses #error Your codebase is re-defining the BYOND proc file2text. The DMAPI requires the native version to read the result of world.Export(). You SHOULD fix this by adding "#define TGS_FILE2TEXT_NATIVE file2text" before your override of file2text to allow the DMAPI to use the native version. This will only be used for world.Export(), not regular file accesses
#endif #endif
#define TGS_FILE2TEXT_NATIVE file2text #define TGS_FILE2TEXT_NATIVE file2text
#endif #endif
@@ -152,16 +153,17 @@
//REQUIRED HOOKS //REQUIRED HOOKS
/** /**
* Call this somewhere in [/world/proc/New] that is always run. This function may sleep! * Consumers MUST call this somewhere in [/world/proc/New] that is always run. This function may sleep!
* *
* * event_handler - Optional user defined [/datum/tgs_event_handler]. * * event_handler - Optional user defined [/datum/tgs_event_handler].
* * minimum_required_security_level: The minimum required security level to run the game in which the DMAPI is integrated. Can be one of [TGS_SECURITY_ULTRASAFE], [TGS_SECURITY_SAFE], or [TGS_SECURITY_TRUSTED]. * * minimum_required_security_level: The minimum required security level to run the game in which the DMAPI is integrated. Can be one of [TGS_SECURITY_ULTRASAFE], [TGS_SECURITY_SAFE], or [TGS_SECURITY_TRUSTED].
* * http_handler - Optional user defined [/datum/tgs_http_handler].
*/ */
/world/proc/TgsNew(datum/tgs_event_handler/event_handler, minimum_required_security_level = TGS_SECURITY_TRUSTED) /world/proc/TgsNew(datum/tgs_event_handler/event_handler, minimum_required_security_level = TGS_SECURITY_ULTRASAFE, datum/tgs_http_handler/http_handler)
return return
/** /**
* Call this when your initializations are complete and your game is ready to play before any player interactions happen. * Consumers MUST call this when world initializations are complete and the game is ready to play before any player interactions happen.
* *
* This may use [/world/var/sleep_offline] to make this happen so ensure no changes are made to it while this call is running. * This may use [/world/var/sleep_offline] to make this happen so ensure no changes are made to it while this call is running.
* Afterwards, consider explicitly setting it to what you want to avoid this BYOND bug: http://www.byond.com/forum/post/2575184 * Afterwards, consider explicitly setting it to what you want to avoid this BYOND bug: http://www.byond.com/forum/post/2575184
@@ -170,13 +172,11 @@
/world/proc/TgsInitializationComplete() /world/proc/TgsInitializationComplete()
return return
/// Put this at the start of [/world/proc/Topic]. /// Consumers MUST run this macro at the start of [/world/proc/Topic].
#define TGS_TOPIC var/tgs_topic_return = TgsTopic(args[1]); if(tgs_topic_return) return tgs_topic_return #define TGS_TOPIC var/tgs_topic_return = TgsTopic(args[1]); if(tgs_topic_return) return tgs_topic_return
#define VGS_TOPIC var/vgs_topic_return = VgsTopic(args[1]); if(vgs_topic_return) return vgs_topic_return // VOREStation Edit - VGS #define VGS_TOPIC var/vgs_topic_return = VgsTopic(args[1]); if(vgs_topic_return) return vgs_topic_return // VOREStation Edit - VGS
/** /// Consumers MUST call this as late as possible in [world/proc/Reboot] (BEFORE ..()).
* Call this as late as possible in [world/proc/Reboot] (BEFORE ..()).
*/
/world/proc/TgsReboot() /world/proc/TgsReboot()
return return
@@ -270,7 +270,7 @@
/// The [/datum/tgs_chat_channel] the user was from. /// The [/datum/tgs_chat_channel] the user was from.
var/datum/tgs_chat_channel/channel var/datum/tgs_chat_channel/channel
/// User definable handler for TGS events. /// User definable handler for TGS events This abstract version SHOULD be overridden to be used.
/datum/tgs_event_handler /datum/tgs_event_handler
/// If the handler receieves [TGS_EVENT_HEALTH_CHECK] events. /// If the handler receieves [TGS_EVENT_HEALTH_CHECK] events.
var/receive_health_checks = FALSE var/receive_health_checks = FALSE
@@ -284,7 +284,41 @@
set waitfor = FALSE set waitfor = FALSE
return return
/// User definable chat command. /// User definable handler for HTTP calls. This abstract version MUST be overridden to be used.
/datum/tgs_http_handler
/**
* User definable callback for executing HTTP GET requests.
* MUST perform BYOND sleeps while the request is in flight.
* MUST return a [/datum/tgs_http_result].
* SHOULD log its own errors
*
* url - The full URL to execute the GET request for including query parameters.
*/
/datum/tgs_http_handler/proc/PerformGet(url)
CRASH("[type]/PerformGet not implemented!")
/// Result of a [/datum/tgs_http_handler] call. MUST NOT be overridden.
/datum/tgs_http_result
/// HTTP response as text
var/response_text
/// Boolean request success flag. Set for any 2XX response code.
var/success
/**
* Create a [/datum/tgs_http_result].
*
* * response_text - HTTP response as text. Must be provided in New().
* * success - Boolean request success flag. Set for any 2XX response code. Must be provided in New().
*/
/datum/tgs_http_result/New(response_text, success)
if(response_text && !istext(response_text))
CRASH("response_text was not text!")
src.response_text = response_text
src.success = success
/// User definable chat command. This abstract version MUST be overridden to be used.
/datum/tgs_chat_command /datum/tgs_chat_command
/// The string to trigger this command on a chat bot. e.g `@bot name ...` or `!tgs name ...`. /// The string to trigger this command on a chat bot. e.g `@bot name ...` or `!tgs name ...`.
var/name = "" var/name = ""
@@ -297,29 +331,36 @@
/** /**
* Process command activation. Should return a [/datum/tgs_message_content] to respond to the issuer with. * Process command activation. Should return a [/datum/tgs_message_content] to respond to the issuer with.
* MUST be implemented
* *
* sender - The [/datum/tgs_chat_user] who issued the command. * * sender - The [/datum/tgs_chat_user] who issued the command.
* params - The trimmed string following the command `/datum/tgs_chat_command/var/name]. * * params - The trimmed string following the command `/datum/tgs_chat_command/var/name].
*/ */
/datum/tgs_chat_command/proc/Run(datum/tgs_chat_user/sender, params) /datum/tgs_chat_command/proc/Run(datum/tgs_chat_user/sender, params)
CRASH("[type] has no implementation for Run()") CRASH("[type] has no implementation for Run()")
/// User definable chat message. /// User definable chat message. MUST NOT be overridden.
/datum/tgs_message_content /datum/tgs_message_content
/// The tring content of the message. Must be provided in New(). /// The string content of the message. Must be provided in New().
var/text var/text
/// The [/datum/tgs_chat_embed] to embed in the message. Not supported on all chat providers. /// The [/datum/tgs_chat_embed] to embed in the message. Not supported on all chat providers.
var/datum/tgs_chat_embed/structure/embed var/datum/tgs_chat_embed/structure/embed
/**
* Create a [/datum/tgs_message_content].
*
* * text - The string content of the message.
*/
/datum/tgs_message_content/New(text) /datum/tgs_message_content/New(text)
..()
if(!istext(text)) if(!istext(text))
TGS_ERROR_LOG("[/datum/tgs_message_content] created with no text!") TGS_ERROR_LOG("[/datum/tgs_message_content] created with no text!")
text = null text = null
src.text = text src.text = text
/// User definable chat embed. Currently mirrors Discord chat embeds. See https://discord.com/developers/docs/resources/channel#embed-object-embed-structure for details. /// User definable chat embed. Currently mirrors Discord chat embeds. See https://discord.com/developers/docs/resources/message#embed-object for details.
/datum/tgs_chat_embed/structure /datum/tgs_chat_embed/structure
var/title var/title
var/description var/description
@@ -331,13 +372,13 @@
/// Colour must be #AARRGGBB or #RRGGBB hex string. /// Colour must be #AARRGGBB or #RRGGBB hex string.
var/colour var/colour
/// See https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure for details. /// See https://discord.com/developers/docs/resources/message#embed-object-embed-image-structure for details.
var/datum/tgs_chat_embed/media/image var/datum/tgs_chat_embed/media/image
/// See https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure for details. /// See https://discord.com/developers/docs/resources/message#embed-object-embed-thumbnail-structure for details.
var/datum/tgs_chat_embed/media/thumbnail var/datum/tgs_chat_embed/media/thumbnail
/// See https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure for details. /// See https://discord.com/developers/docs/resources/message#embed-object-embed-video-structure for details.
var/datum/tgs_chat_embed/media/video var/datum/tgs_chat_embed/media/video
var/datum/tgs_chat_embed/footer/footer var/datum/tgs_chat_embed/footer/footer
@@ -346,7 +387,7 @@
var/list/datum/tgs_chat_embed/field/fields var/list/datum/tgs_chat_embed/field/fields
/// Common datum for similar discord embed medias. /// Common datum for similar Discord embed medias.
/datum/tgs_chat_embed/media /datum/tgs_chat_embed/media
/// Must be set in New(). /// Must be set in New().
var/url var/url
@@ -354,48 +395,58 @@
var/height var/height
var/proxy_url var/proxy_url
/// Create a [/datum/tgs_chat_embed].
/datum/tgs_chat_embed/media/New(url) /datum/tgs_chat_embed/media/New(url)
..()
if(!istext(url)) if(!istext(url))
CRASH("[/datum/tgs_chat_embed/media] created with no url!") CRASH("[/datum/tgs_chat_embed/media] created with no url!")
src.url = url src.url = url
/// See https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure for details. /// See https://discord.com/developers/docs/resources/message#embed-object-embed-footer-structure for details.
/datum/tgs_chat_embed/footer /datum/tgs_chat_embed/footer
/// Must be set in New(). /// Must be set in New().
var/text var/text
var/icon_url var/icon_url
var/proxy_icon_url var/proxy_icon_url
/// Create a [/datum/tgs_chat_embed/footer].
/datum/tgs_chat_embed/footer/New(text) /datum/tgs_chat_embed/footer/New(text)
..()
if(!istext(text)) if(!istext(text))
CRASH("[/datum/tgs_chat_embed/footer] created with no text!") CRASH("[/datum/tgs_chat_embed/footer] created with no text!")
src.text = text src.text = text
/// See https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure for details. /// See https://discord.com/developers/docs/resources/message#embed-object-embed-provider-structure for details.
/datum/tgs_chat_embed/provider /datum/tgs_chat_embed/provider
var/name var/name
var/url var/url
/// See https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure for details. Must have name set in New(). /// See https://discord.com/developers/docs/resources/message#embed-object-embed-author-structure for details. Must have name set in New().
/datum/tgs_chat_embed/provider/author /datum/tgs_chat_embed/provider/author
var/icon_url var/icon_url
var/proxy_icon_url var/proxy_icon_url
/// Create a [/datum/tgs_chat_embed/footer].
/datum/tgs_chat_embed/provider/author/New(name) /datum/tgs_chat_embed/provider/author/New(name)
..()
if(!istext(name)) if(!istext(name))
CRASH("[/datum/tgs_chat_embed/provider/author] created with no name!") CRASH("[/datum/tgs_chat_embed/provider/author] created with no name!")
src.name = name src.name = name
/// See https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure for details. Must have name and value set in New(). /// See https://discord.com/developers/docs/resources/message#embed-object-embed-field-structure for details.
/datum/tgs_chat_embed/field /datum/tgs_chat_embed/field
/// Must be set in New().
var/name var/name
/// Must be set in New().
var/value var/value
var/is_inline var/is_inline
/// Create a [/datum/tgs_chat_embed/field].
/datum/tgs_chat_embed/field/New(name, value) /datum/tgs_chat_embed/field/New(name, value)
..()
if(!istext(name)) if(!istext(name))
CRASH("[/datum/tgs_chat_embed/field] created with no name!") CRASH("[/datum/tgs_chat_embed/field] created with no name!")
@@ -511,7 +562,7 @@
/* /*
The MIT License The MIT License
Copyright (c) 2017-2023 Jordan Brown Copyright (c) 2017-2024 Jordan Brown
Permission is hereby granted, free of charge, Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and to any person obtaining a copy of this software and

View File

@@ -679,6 +679,8 @@ var/failed_old_db_connections = 0
return 1 return 1
/*/proc/setup_database_connection() CHOMPEdit TGSQL /*/proc/setup_database_connection() CHOMPEdit TGSQL
if(!config.sql_enabled)
return 0
if(failed_db_connections > FAILED_DB_CONNECTION_CUTOFF) //If it failed to establish a connection more than 5 times in a row, don't bother attempting to conenct anymore. if(failed_db_connections > FAILED_DB_CONNECTION_CUTOFF) //If it failed to establish a connection more than 5 times in a row, don't bother attempting to conenct anymore.
return 0 return 0
@@ -727,6 +729,8 @@ var/failed_old_db_connections = 0
//These two procs are for the old database, while it's being phased out. See the tgstation.sql file in the SQL folder for more information. //These two procs are for the old database, while it's being phased out. See the tgstation.sql file in the SQL folder for more information.
/*/proc/setup_old_database_connection() //CHOMPStation TGSQL /*/proc/setup_old_database_connection() //CHOMPStation TGSQL
if(!config.sql_enabled)
return 0
if(failed_old_db_connections > FAILED_DB_CONNECTION_CUTOFF) //If it failed to establish a connection more than 5 times in a row, don't bother attempting to conenct anymore. if(failed_old_db_connections > FAILED_DB_CONNECTION_CUTOFF) //If it failed to establish a connection more than 5 times in a row, don't bother attempting to conenct anymore.
return 0 return 0

View File

@@ -1,6 +1,6 @@
The MIT License The MIT License
Copyright (c) 2017-2023 Jordan Brown Copyright (c) 2017-2024 Jordan Brown
Permission is hereby granted, free of charge, Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and to any person obtaining a copy of this software and

View File

@@ -1,6 +1,6 @@
# DMAPI Internals # DMAPI Internals
This folder should be placed on it's own inside a codebase that wishes to use the TGS DMAPI. Warranty void if modified. This folder should be placed on its own inside a codebase that wishes to use the TGS DMAPI. Warranty void if modified.
- [includes.dm](./includes.dm) is the file that should be included by DM code, it handles including the rest. - [includes.dm](./includes.dm) is the file that should be included by DM code, it handles including the rest.
- The [core](./core) folder includes all code not directly part of any API version. - The [core](./core) folder includes all code not directly part of any API version.

View File

@@ -3,7 +3,7 @@
This folder contains all DMAPI code not directly involved in an API. This folder contains all DMAPI code not directly involved in an API.
- [_definitions.dm](./definitions.dm) contains defines needed across DMAPI internals. - [_definitions.dm](./definitions.dm) contains defines needed across DMAPI internals.
- [byond_world_export.dm](./byond_world_export.dm) contains the default `/datum/tgs_http_handler` implementation which uses `world.Export()`.
- [core.dm](./core.dm) contains the implementations of the `/world/proc/TgsXXX()` procs. Many map directly to the `/datum/tgs_api` functions. It also contains the /datum selection and setup code. - [core.dm](./core.dm) contains the implementations of the `/world/proc/TgsXXX()` procs. Many map directly to the `/datum/tgs_api` functions. It also contains the /datum selection and setup code.
- [datum.dm](./datum.dm) contains the `/datum/tgs_api` declarations that all APIs must implement. - [datum.dm](./datum.dm) contains the `/datum/tgs_api` declarations that all APIs must implement.
- [tgs_version.dm](./tgs_version.dm) contains the `/datum/tgs_version` definition - [tgs_version.dm](./tgs_version.dm) contains the `/datum/tgs_version` definition
-

View File

@@ -0,0 +1,22 @@
/datum/tgs_http_handler/byond_world_export
/datum/tgs_http_handler/byond_world_export/PerformGet(url)
// This is an infinite sleep until we get a response
var/export_response = world.Export(url)
TGS_DEBUG_LOG("byond_world_export: Export complete")
if(!export_response)
TGS_ERROR_LOG("byond_world_export: Failed request: [url]")
return new /datum/tgs_http_result(null, FALSE)
var/content = export_response["CONTENT"]
if(!content)
TGS_ERROR_LOG("byond_world_export: Failed request, missing content!")
return new /datum/tgs_http_result(null, FALSE)
var/response_json = TGS_FILE2TEXT_NATIVE(content)
if(!response_json)
TGS_ERROR_LOG("byond_world_export: Failed request, failed to load content!")
return new /datum/tgs_http_result(null, FALSE)
return new /datum/tgs_http_result(response_json, TRUE)

View File

@@ -1,4 +1,4 @@
/world/TgsNew(datum/tgs_event_handler/event_handler, minimum_required_security_level = TGS_SECURITY_ULTRASAFE) /world/TgsNew(datum/tgs_event_handler/event_handler, minimum_required_security_level = TGS_SECURITY_ULTRASAFE, datum/tgs_http_handler/http_handler = null)
var/current_api = TGS_READ_GLOBAL(tgs) var/current_api = TGS_READ_GLOBAL(tgs)
if(current_api) if(current_api)
TGS_ERROR_LOG("API datum already set (\ref[current_api] ([current_api]))! Was TgsNew() called more than once?") TGS_ERROR_LOG("API datum already set (\ref[current_api] ([current_api]))! Was TgsNew() called more than once?")
@@ -55,7 +55,10 @@
TGS_ERROR_LOG("Invalid parameter for event_handler: [event_handler]") TGS_ERROR_LOG("Invalid parameter for event_handler: [event_handler]")
event_handler = null event_handler = null
var/datum/tgs_api/new_api = new api_datum(event_handler, version) if(!http_handler)
http_handler = new /datum/tgs_http_handler/byond_world_export
var/datum/tgs_api/new_api = new api_datum(event_handler, version, http_handler)
TGS_WRITE_GLOBAL(tgs, new_api) TGS_WRITE_GLOBAL(tgs, new_api)

View File

@@ -6,8 +6,8 @@ TGS_DEFINE_AND_SET_GLOBAL(tgs, null)
var/list/warned_deprecated_command_runs var/list/warned_deprecated_command_runs
/datum/tgs_api/New(datum/tgs_event_handler/event_handler, datum/tgs_version/version) /datum/tgs_api/New(datum/tgs_event_handler/event_handler, datum/tgs_version/version, datum/tgs_http_handler/http_handler)
. = ..() ..()
src.event_handler = event_handler src.event_handler = event_handler
src.version = version src.version = version

View File

@@ -1,4 +1,5 @@
/datum/tgs_version/New(raw_parameter) /datum/tgs_version/New(raw_parameter)
..()
src.raw_parameter = raw_parameter src.raw_parameter = raw_parameter
deprefixed_parameter = replacetext(raw_parameter, "/tg/station 13 Server v", "") deprefixed_parameter = replacetext(raw_parameter, "/tg/station 13 Server v", "")
var/list/version_bits = splittext(deprefixed_parameter, ".") var/list/version_bits = splittext(deprefixed_parameter, ".")

View File

@@ -1,4 +1,5 @@
#include "core\_definitions.dm" #include "core\_definitions.dm"
#include "core\byond_world_export.dm"
#include "core\core.dm" #include "core\core.dm"
#include "core\datum.dm" #include "core\datum.dm"
#include "core\tgs_version.dm" #include "core\tgs_version.dm"

View File

@@ -1 +1 @@
"7.3.0" "5.10.0"

View File

@@ -98,6 +98,7 @@
#define DMAPI5_TOPIC_PARAMETER_NEW_SERVER_VERSION "newServerVersion" #define DMAPI5_TOPIC_PARAMETER_NEW_SERVER_VERSION "newServerVersion"
#define DMAPI5_TOPIC_PARAMETER_BROADCAST_MESSAGE "broadcastMessage" #define DMAPI5_TOPIC_PARAMETER_BROADCAST_MESSAGE "broadcastMessage"
#define DMAPI5_TOPIC_RESPONSE_CLIENT_COUNT "clientCount"
#define DMAPI5_TOPIC_RESPONSE_COMMAND_RESPONSE "commandResponse" #define DMAPI5_TOPIC_RESPONSE_COMMAND_RESPONSE "commandResponse"
#define DMAPI5_TOPIC_RESPONSE_COMMAND_RESPONSE_MESSAGE "commandResponseMessage" #define DMAPI5_TOPIC_RESPONSE_COMMAND_RESPONSE_MESSAGE "commandResponseMessage"
#define DMAPI5_TOPIC_RESPONSE_CHAT_RESPONSES "chatResponses" #define DMAPI5_TOPIC_RESPONSE_CHAT_RESPONSES "chatResponses"

View File

@@ -31,9 +31,12 @@
var/detached = FALSE var/detached = FALSE
/datum/tgs_api/v5/New() var/datum/tgs_http_handler/http_handler
/datum/tgs_api/v5/New(datum/tgs_event_handler/event_handler, datum/tgs_version/version, datum/tgs_http_handler/http_handler)
. = ..() . = ..()
interop_version = version interop_version = version
src.http_handler = http_handler
TGS_DEBUG_LOG("V5 API created: [json_encode(args)]") TGS_DEBUG_LOG("V5 API created: [json_encode(args)]")
/datum/tgs_api/v5/ApiVersion() /datum/tgs_api/v5/ApiVersion()
@@ -50,7 +53,9 @@
version = null // we want this to be the TGS version, not the interop version version = null // we want this to be the TGS version, not the interop version
// sleep once to prevent an issue where world.Export on the first tick can hang indefinitely // sleep once to prevent an issue where world.Export on the first tick can hang indefinitely
TGS_DEBUG_LOG("Starting Export bug prevention sleep tick. time:[world.time] sleep_offline:[world.sleep_offline]")
sleep(world.tick_lag) sleep(world.tick_lag)
TGS_DEBUG_LOG("Export bug prevention sleep complete")
var/list/bridge_response = Bridge(DMAPI5_BRIDGE_COMMAND_STARTUP, list(DMAPI5_BRIDGE_PARAMETER_MINIMUM_SECURITY_LEVEL = minimum_required_security_level, DMAPI5_BRIDGE_PARAMETER_VERSION = api_version.raw_parameter, DMAPI5_PARAMETER_CUSTOM_COMMANDS = ListCustomCommands(), DMAPI5_PARAMETER_TOPIC_PORT = GetTopicPort())) var/list/bridge_response = Bridge(DMAPI5_BRIDGE_COMMAND_STARTUP, list(DMAPI5_BRIDGE_PARAMETER_MINIMUM_SECURITY_LEVEL = minimum_required_security_level, DMAPI5_BRIDGE_PARAMETER_VERSION = api_version.raw_parameter, DMAPI5_PARAMETER_CUSTOM_COMMANDS = ListCustomCommands(), DMAPI5_PARAMETER_TOPIC_PORT = GetTopicPort()))
if(!istype(bridge_response)) if(!istype(bridge_response))

View File

@@ -78,27 +78,24 @@
WaitForReattach(FALSE) WaitForReattach(FALSE)
TGS_DEBUG_LOG("Bridge request start") TGS_DEBUG_LOG("Bridge request start")
// This is an infinite sleep until we get a response var/datum/tgs_http_result/result = http_handler.PerformGet(bridge_request)
var/export_response = world.Export(bridge_request)
TGS_DEBUG_LOG("Bridge request complete") TGS_DEBUG_LOG("Bridge request complete")
if(!export_response) if(isnull(result))
TGS_ERROR_LOG("Failed bridge request: [bridge_request]") TGS_ERROR_LOG("Failed bridge request, handler returned null!")
return return
var/content = export_response["CONTENT"] if(!istype(result) || result.type != /datum/tgs_http_result)
if(!content) TGS_ERROR_LOG("Failed bridge request, handler returned non-[/datum/tgs_http_result]!")
TGS_ERROR_LOG("Failed bridge request, missing content!")
return return
var/response_json = TGS_FILE2TEXT_NATIVE(content) if(!result.success)
if(!response_json) TGS_DEBUG_LOG("Failed bridge request, HTTP request failed!")
TGS_ERROR_LOG("Failed bridge request, failed to load content!")
return return
var/list/bridge_response = json_decode(response_json) var/list/bridge_response = json_decode(result.response_text)
if(!bridge_response) if(!bridge_response)
TGS_ERROR_LOG("Failed bridge request, bad json: [response_json]") TGS_ERROR_LOG("Failed bridge request, bad json: [result.response_text]")
return return
var/error = bridge_response[DMAPI5_RESPONSE_ERROR_MESSAGE] var/error = bridge_response[DMAPI5_RESPONSE_ERROR_MESSAGE]

View File

@@ -155,7 +155,9 @@
if(DMAPI5_TOPIC_COMMAND_HEALTHCHECK) if(DMAPI5_TOPIC_COMMAND_HEALTHCHECK)
if(event_handler && event_handler.receive_health_checks) if(event_handler && event_handler.receive_health_checks)
event_handler.HandleEvent(TGS_EVENT_HEALTH_CHECK) event_handler.HandleEvent(TGS_EVENT_HEALTH_CHECK)
return TopicResponse() var/list/health_check_response = TopicResponse()
health_check_response[DMAPI5_TOPIC_RESPONSE_CLIENT_COUNT] = TGS_CLIENT_COUNT
return health_check_response;
if(DMAPI5_TOPIC_COMMAND_WATCHDOG_REATTACH) if(DMAPI5_TOPIC_COMMAND_WATCHDOG_REATTACH)
detached = FALSE detached = FALSE

View File

@@ -98,6 +98,7 @@
#undef DMAPI5_TOPIC_PARAMETER_NEW_SERVER_VERSION #undef DMAPI5_TOPIC_PARAMETER_NEW_SERVER_VERSION
#undef DMAPI5_TOPIC_PARAMETER_BROADCAST_MESSAGE #undef DMAPI5_TOPIC_PARAMETER_BROADCAST_MESSAGE
#undef DMAPI5_TOPIC_RESPONSE_CLIENT_COUNT
#undef DMAPI5_TOPIC_RESPONSE_COMMAND_RESPONSE #undef DMAPI5_TOPIC_RESPONSE_COMMAND_RESPONSE
#undef DMAPI5_TOPIC_RESPONSE_COMMAND_RESPONSE_MESSAGE #undef DMAPI5_TOPIC_RESPONSE_COMMAND_RESPONSE_MESSAGE
#undef DMAPI5_TOPIC_RESPONSE_CHAT_RESPONSES #undef DMAPI5_TOPIC_RESPONSE_CHAT_RESPONSES

View File

@@ -197,8 +197,6 @@ try
{ {
Origin = new Uri($"http://github.com/{repoSlug}"), Origin = new Uri($"http://github.com/{repoSlug}"),
UpdateSubmodules = true, UpdateSubmodules = true,
AccessUser = "Testing",
AccessToken = gitHubToken
}, },
default); default);