diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 17b23901e3..cc4860ce31 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -63,7 +63,7 @@ jobs:
if: ( !contains(github.event.head_commit.message, '[ci skip]') )
name: Integration Tests
# needs: ['run_linters', 'dreamchecker']
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Ensure +x on CI directory
@@ -78,6 +78,7 @@ jobs:
run: |
sudo dpkg --add-architecture i386
sudo apt update || true
+ sudo apt install gcc-multilib
sudo apt install zlib1g-dev:i386 libssl-dev:i386
ldd librust_g.so
- name: Unit Tests
diff --git a/_build_dependencies.sh b/_build_dependencies.sh
index c0873b3860..f96e0c27c7 100644
--- a/_build_dependencies.sh
+++ b/_build_dependencies.sh
@@ -2,6 +2,9 @@
# This file has all the information on what versions of libraries are thrown into the code
+#rust_g git tag
+export RUST_G_VERSION=3.1.0
+
# byond version
export BYOND_MAJOR=514
export BYOND_MINOR=1589
diff --git a/code/__defines/database.dm b/code/__defines/database.dm
new file mode 100644
index 0000000000..3d20b3b9a3
--- /dev/null
+++ b/code/__defines/database.dm
@@ -0,0 +1,6 @@
+/// When a query has been queued up for execution/is being executed
+#define DB_QUERY_STARTED 0
+/// When a query is finished executing
+#define DB_QUERY_FINISHED 1
+/// When there was a problem with the execution of a query.
+#define DB_QUERY_BROKEN 2
diff --git a/code/__defines/rust_g.dm b/code/__defines/rust_g.dm
index 378ee27d1b..5404cebed9 100644
--- a/code/__defines/rust_g.dm
+++ b/code/__defines/rust_g.dm
@@ -38,61 +38,105 @@
#define RUST_G (__rust_g || __detect_rust_g())
#endif
-// CHOMPedit Start - Rust http
// Handle 515 call() -> call_ext() changes
#if DM_VERSION >= 515
#define RUSTG_CALL call_ext
#else
#define RUSTG_CALL call
#endif
-// CHOMPedit End - Rust http
-#define RUSTG_JOB_NO_RESULTS_YET "NO RESULTS YET"
-#define RUSTG_JOB_NO_SUCH_JOB "NO SUCH JOB"
-#define RUSTG_JOB_ERROR "JOB PANICKED"
+/// Gets the version of rust_g
+/proc/rustg_get_version() return RUSTG_CALL(RUST_G, "get_version")()
-#define rustg_dmi_strip_metadata(fname) LIBCALL(RUST_G, "dmi_strip_metadata")(fname)
-#define rustg_dmi_create_png(path, width, height, data) LIBCALL(RUST_G, "dmi_create_png")(path, width, height, data)
-#define rustg_noise_get_at_coordinates(seed, x, y) LIBCALL(RUST_G, "noise_get_at_coordinates")(seed, x, y)
+/**
+ * Sets up the Aho-Corasick automaton with its default options.
+ *
+ * The search patterns list and the replacements must be of the same length when replace is run, but an empty replacements list is allowed if replacements are supplied with the replace call
+ * Arguments:
+ * * key - The key for the automaton, to be used with subsequent rustg_acreplace/rustg_acreplace_with_replacements calls
+ * * patterns - A non-associative list of strings to search for
+ * * replacements - Default replacements for this automaton, used with rustg_acreplace
+ */
+#define rustg_setup_acreplace(key, patterns, replacements) RUSTG_CALL(RUST_G, "setup_acreplace")(key, json_encode(patterns), json_encode(replacements))
-#define rustg_file_read(fname) LIBCALL(RUST_G, "file_read")(fname)
-#define rustg_file_exists(fname) LIBCALL(RUST_G, "file_exists")(fname)
-#define rustg_file_write(text, fname) LIBCALL(RUST_G, "file_write")(text, fname)
-#define rustg_file_append(text, fname) LIBCALL(RUST_G, "file_append")(text, fname)
+/**
+ * Sets up the Aho-Corasick automaton using supplied options.
+ *
+ * The search patterns list and the replacements must be of the same length when replace is run, but an empty replacements list is allowed if replacements are supplied with the replace call
+ * Arguments:
+ * * key - The key for the automaton, to be used with subsequent rustg_acreplace/rustg_acreplace_with_replacements calls
+ * * options - An associative list like list("anchored" = 0, "ascii_case_insensitive" = 0, "match_kind" = "Standard"). The values shown on the example are the defaults, and default values may be omitted. See the identically named methods at https://docs.rs/aho-corasick/latest/aho_corasick/struct.AhoCorasickBuilder.html to see what the options do.
+ * * patterns - A non-associative list of strings to search for
+ * * replacements - Default replacements for this automaton, used with rustg_acreplace
+ */
+#define rustg_setup_acreplace_with_options(key, options, patterns, replacements) RUSTG_CALL(RUST_G, "setup_acreplace")(key, json_encode(options), json_encode(patterns), json_encode(replacements))
+
+/**
+ * Run the specified replacement engine with the provided haystack text to replace, returning replaced text.
+ *
+ * Arguments:
+ * * key - The key for the automaton
+ * * text - Text to run replacements on
+ */
+#define rustg_acreplace(key, text) RUSTG_CALL(RUST_G, "acreplace")(key, text)
+
+/**
+ * Run the specified replacement engine with the provided haystack text to replace, returning replaced text.
+ *
+ * Arguments:
+ * * key - The key for the automaton
+ * * text - Text to run replacements on
+ * * replacements - Replacements for this call. Must be the same length as the set-up patterns
+ */
+#define rustg_acreplace_with_replacements(key, text, replacements) RUSTG_CALL(RUST_G, "acreplace_with_replacements")(key, text, json_encode(replacements))
+
+/**
+ * This proc generates a cellular automata noise grid which can be used in procedural generation methods.
+ *
+ * Returns a single string that goes row by row, with values of 1 representing an alive cell, and a value of 0 representing a dead cell.
+ *
+ * Arguments:
+ * * percentage: The chance of a turf starting closed
+ * * smoothing_iterations: The amount of iterations the cellular automata simulates before returning the results
+ * * birth_limit: If the number of neighboring cells is higher than this amount, a cell is born
+ * * death_limit: If the number of neighboring cells is lower than this amount, a cell dies
+ * * width: The width of the grid.
+ * * height: The height of the grid.
+ */
+#define rustg_cnoise_generate(percentage, smoothing_iterations, birth_limit, death_limit, width, height) \
+ RUSTG_CALL(RUST_G, "cnoise_generate")(percentage, smoothing_iterations, birth_limit, death_limit, width, height)
+
+#define rustg_dmi_strip_metadata(fname) RUSTG_CALL(RUST_G, "dmi_strip_metadata")(fname)
+#define rustg_dmi_create_png(path, width, height, data) RUSTG_CALL(RUST_G, "dmi_create_png")(path, width, height, data)
+#define rustg_dmi_resize_png(path, width, height, resizetype) RUSTG_CALL(RUST_G, "dmi_resize_png")(path, width, height, resizetype)
+/**
+ * input: must be a path, not an /icon; you have to do your own handling if it is one, as icon objects can't be directly passed to rustg.
+ *
+ * output: json_encode'd list. json_decode to get a flat list with icon states in the order they're in inside the .dmi
+ */
+#define rustg_dmi_icon_states(fname) RUSTG_CALL(RUST_G, "dmi_icon_states")(fname)
+
+#define rustg_file_read(fname) RUSTG_CALL(RUST_G, "file_read")(fname)
+#define rustg_file_exists(fname) (RUSTG_CALL(RUST_G, "file_exists")(fname) == "true")
+#define rustg_file_write(text, fname) RUSTG_CALL(RUST_G, "file_write")(text, fname)
+#define rustg_file_append(text, fname) RUSTG_CALL(RUST_G, "file_append")(text, fname)
+#define rustg_file_get_line_count(fname) text2num(RUSTG_CALL(RUST_G, "file_get_line_count")(fname))
+#define rustg_file_seek_line(fname, line) RUSTG_CALL(RUST_G, "file_seek_line")(fname, "[line]")
#ifdef RUSTG_OVERRIDE_BUILTINS
-#define file2text(fname) rustg_file_read("[fname]")
-#define text2file(text, fname) rustg_file_append(text, "[fname]")
+ #define file2text(fname) rustg_file_read("[fname]")
+ #define text2file(text, fname) rustg_file_append(text, "[fname]")
#endif
-#define rustg_git_revparse(rev) LIBCALL(RUST_G, "rg_git_revparse")(rev)
-#define rustg_git_commit_date(rev) LIBCALL(RUST_G, "rg_git_commit_date")(rev)
+/// Returns the git hash of the given revision, ex. "HEAD".
+#define rustg_git_revparse(rev) RUSTG_CALL(RUST_G, "rg_git_revparse")(rev)
-#define rustg_hash_string(algorithm, text) LIBCALL(RUST_G, "hash_string")(algorithm, text)
-#define rustg_hash_file(algorithm, fname) LIBCALL(RUST_G, "hash_file")(algorithm, fname)
-
-#define RUSTG_HASH_MD5 "md5"
-#define RUSTG_HASH_SHA1 "sha1"
-#define RUSTG_HASH_SHA256 "sha256"
-#define RUSTG_HASH_SHA512 "sha512"
-
-#ifdef RUSTG_OVERRIDE_BUILTINS
-#define md5(thing) (isfile(thing) ? rustg_hash_file(RUSTG_HASH_MD5, "[thing]") : rustg_hash_string(RUSTG_HASH_MD5, thing))
-#endif
-
-#define rustg_json_is_valid(text) (LIBCALL(RUST_G, "json_is_valid")(text) == "true")
-
-#define rustg_log_write(fname, text, format) LIBCALL(RUST_G, "log_write")(fname, text, format)
-/proc/rustg_log_close_all() return LIBCALL(RUST_G, "log_close_all")()
-
-#define rustg_url_encode(text) LIBCALL(RUST_G, "url_encode")(text)
-#define rustg_url_decode(text) LIBCALL(RUST_G, "url_decode")(text)
-
-#ifdef RUSTG_OVERRIDE_BUILTINS
-#define url_encode(text) rustg_url_encode(text)
-#define url_decode(text) rustg_url_decode(text)
-#endif
+/**
+ * Returns the date of the given revision in the format YYYY-MM-DD.
+ * Returns null if the revision is invalid.
+ */
+#define rustg_git_commit_date(rev) RUSTG_CALL(RUST_G, "rg_git_commit_date")(rev)
#define RUSTG_HTTP_METHOD_GET "get"
#define RUSTG_HTTP_METHOD_PUT "put"
@@ -100,13 +144,59 @@
#define RUSTG_HTTP_METHOD_PATCH "patch"
#define RUSTG_HTTP_METHOD_HEAD "head"
#define RUSTG_HTTP_METHOD_POST "post"
-#define rustg_http_request_blocking(method, url, body, headers, options) RUSTG_CALL(RUST_G, "http_request_blocking")(method, url, body, headers, options) // CHOMPedit - Rust HTTP Requests
-#define rustg_http_request_async(method, url, body, headers, options) RUSTG_CALL(RUST_G, "http_request_async")(method, url, body, headers, options) // CHOMPedit - Rust HTTP Requests
-#define rustg_http_check_request(req_id) LIBCALL(RUST_G, "http_check_request")(req_id)
+#define rustg_http_request_blocking(method, url, body, headers, options) RUSTG_CALL(RUST_G, "http_request_blocking")(method, url, body, headers, options)
+#define rustg_http_request_async(method, url, body, headers, options) RUSTG_CALL(RUST_G, "http_request_async")(method, url, body, headers, options)
+#define rustg_http_check_request(req_id) RUSTG_CALL(RUST_G, "http_check_request")(req_id)
+
+#define RUSTG_JOB_NO_RESULTS_YET "NO RESULTS YET"
+#define RUSTG_JOB_NO_SUCH_JOB "NO SUCH JOB"
+#define RUSTG_JOB_ERROR "JOB PANICKED"
+
+#define rustg_json_is_valid(text) (RUSTG_CALL(RUST_G, "json_is_valid")(text) == "true")
+
+#define rustg_log_write(fname, text, format) RUSTG_CALL(RUST_G, "log_write")(fname, text, format)
+/proc/rustg_log_close_all() return RUSTG_CALL(RUST_G, "log_close_all")()
+
+#define rustg_noise_get_at_coordinates(seed, x, y) RUSTG_CALL(RUST_G, "noise_get_at_coordinates")(seed, x, y)
+
+#define rustg_sql_connect_pool(options) RUSTG_CALL(RUST_G, "sql_connect_pool")(options)
+#define rustg_sql_query_async(handle, query, params) RUSTG_CALL(RUST_G, "sql_query_async")(handle, query, params)
+#define rustg_sql_query_blocking(handle, query, params) RUSTG_CALL(RUST_G, "sql_query_blocking")(handle, query, params)
+#define rustg_sql_connected(handle) RUSTG_CALL(RUST_G, "sql_connected")(handle)
+#define rustg_sql_disconnect_pool(handle) RUSTG_CALL(RUST_G, "sql_disconnect_pool")(handle)
+#define rustg_sql_check_query(job_id) RUSTG_CALL(RUST_G, "sql_check_query")("[job_id]")
+
+#define rustg_time_microseconds(id) text2num(RUSTG_CALL(RUST_G, "time_microseconds")(id))
+#define rustg_time_milliseconds(id) text2num(RUSTG_CALL(RUST_G, "time_milliseconds")(id))
+#define rustg_time_reset(id) RUSTG_CALL(RUST_G, "time_reset")(id)
+
+/// Returns the timestamp as a string
+/proc/rustg_unix_timestamp()
+ return RUSTG_CALL(RUST_G, "unix_timestamp")()
+
+#define rustg_raw_read_toml_file(path) json_decode(RUSTG_CALL(RUST_G, "toml_file_to_json")(path) || "null")
+
+/proc/rustg_read_toml_file(path)
+ var/list/output = rustg_raw_read_toml_file(path)
+ if (output["success"])
+ return json_decode(output["content"])
+ else
+ CRASH(output["content"])
+
+#define rustg_raw_toml_encode(value) json_decode(RUSTG_CALL(RUST_G, "toml_encode")(json_encode(value)))
+
+/proc/rustg_toml_encode(value)
+ var/list/output = rustg_raw_toml_encode(value)
+ if (output["success"])
+ return output["content"]
+ else
+ CRASH(output["content"])
+
+#define rustg_url_encode(text) RUSTG_CALL(RUST_G, "url_encode")("[text]")
+#define rustg_url_decode(text) RUSTG_CALL(RUST_G, "url_decode")(text)
+
+#ifdef RUSTG_OVERRIDE_BUILTINS
+ #define url_encode(text) rustg_url_encode(text)
+ #define url_decode(text) rustg_url_decode(text)
+#endif
-#define rustg_sql_connect_pool(options) LIBCALL(RUST_G, "sql_connect_pool")(options)
-#define rustg_sql_query_async(handle, query, params) LIBCALL(RUST_G, "sql_query_async")(handle, query, params)
-#define rustg_sql_query_blocking(handle, query, params) LIBCALL(RUST_G, "sql_query_blocking")(handle, query, params)
-#define rustg_sql_connected(handle) LIBCALL(RUST_G, "sql_connected")(handle)
-#define rustg_sql_disconnect_pool(handle) LIBCALL(RUST_G, "sql_disconnect_pool")(handle)
-#define rustg_sql_check_query(job_id) LIBCALL(RUST_G, "sql_check_query")("[job_id]")
diff --git a/code/__defines/tgs.dm b/code/__defines/tgs.dm
index 3565238195..ad12bcdb27 100644
--- a/code/__defines/tgs.dm
+++ b/code/__defines/tgs.dm
@@ -1,6 +1,6 @@
// tgstation-server DMAPI
-#define TGS_DMAPI_VERSION "6.0.3"
+#define TGS_DMAPI_VERSION "7.0.1"
// All functions and datums outside this document are subject to change with any version and should not be relied on.
@@ -12,8 +12,8 @@
// Comment this out once you've filled in the below.
#error TGS API unconfigured
-// Uncomment this if you wish to allow the game to interact with TGS 3.
-// This will raise the minimum required security level of your game to TGS_SECURITY_TRUSTED due to it utilizing call()()
+// Uncomment this if you wish to allow the game to interact with TGS 3..
+// This will raise the minimum required security level of your game to TGS_SECURITY_TRUSTED due to it utilizing call()().
//#define TGS_V3_API
// Required interfaces (fill in with your codebase equivalent):
@@ -52,44 +52,46 @@
// EVENT CODES
-/// Before a reboot mode change, extras parameters are the current and new reboot mode enums
+/// Before a reboot mode change, extras parameters are the current and new reboot mode enums.
#define TGS_EVENT_REBOOT_MODE_CHANGE -1
-/// Before a port change is about to happen, extra parameters is new port
+/// Before a port change is about to happen, extra parameters is new port.
#define TGS_EVENT_PORT_SWAP -2
-/// Before the instance is renamed, extra parameter is the new name
+/// Before the instance is renamed, extra parameter is the new name.
#define TGS_EVENT_INSTANCE_RENAMED -3
-/// After the watchdog reattaches to DD, extra parameter is the new [/datum/tgs_version] of the server
+/// After the watchdog reattaches to DD, extra parameter is the new [/datum/tgs_version] of the server.
#define TGS_EVENT_WATCHDOG_REATTACH -4
+/// When the watchdog sends a health check to DD. No parameters.
+#define TGS_EVENT_HEALTH_CHECK -5
-/// When the repository is reset to its origin reference. Parameters: Reference name, Commit SHA
+/// When the repository is reset to its origin reference. Parameters: Reference name, Commit SHA.
#define TGS_EVENT_REPO_RESET_ORIGIN 0
-/// When the repository performs a checkout. Parameters: Checkout git object
+/// When the repository performs a checkout. Parameters: Checkout git object.
#define TGS_EVENT_REPO_CHECKOUT 1
-/// When the repository performs a fetch operation. No parameters
+/// When the repository performs a fetch operation. No parameters.
#define TGS_EVENT_REPO_FETCH 2
-/// When the repository test merges. Parameters: PR Number, PR Sha, (Nullable) Comment made by TGS user
+/// When the repository test merges. Parameters: PR Number, PR Sha, (Nullable) Comment made by TGS user.
#define TGS_EVENT_REPO_MERGE_PULL_REQUEST 3
-/// Before the repository makes a sychronize operation. Parameters: Absolute repostiory path
+/// Before the repository makes a sychronize operation. Parameters: Absolute repostiory path.
#define TGS_EVENT_REPO_PRE_SYNCHRONIZE 4
-/// Before a BYOND install operation begins. Parameters: [/datum/tgs_version] of the installing BYOND
-#define TGS_EVENT_BYOND_INSTALL_START 5
-/// When a BYOND install operation fails. Parameters: Error message
-#define TGS_EVENT_BYOND_INSTALL_FAIL 6
-/// When the active BYOND version changes. Parameters: (Nullable) [/datum/tgs_version] of the current BYOND, [/datum/tgs_version] of the new BYOND
-#define TGS_EVENT_BYOND_ACTIVE_VERSION_CHANGE 7
-/// When the compiler starts running. Parameters: Game directory path, origin commit SHA
+/// Before a engine install operation begins. Parameters: Version string of the installing engine.
+#define TGS_EVENT_ENGINE_INSTALL_START 5
+/// When a engine install operation fails. Parameters: Error message
+#define TGS_EVENT_ENGINE_INSTALL_FAIL 6
+/// When the active engine version changes. Parameters: (Nullable) Version string of the current engine, version string of the new engine.
+#define TGS_EVENT_ENGINE_ACTIVE_VERSION_CHANGE 7
+/// When the compiler starts running. Parameters: Game directory path, origin commit SHA.
#define TGS_EVENT_COMPILE_START 8
-/// When a compile is cancelled. No parameters
+/// When a compile is cancelled. No parameters.
#define TGS_EVENT_COMPILE_CANCELLED 9
-/// When a compile fails. Parameters: Game directory path, [TRUE]/[FALSE] based on if the cause for failure was DMAPI validation
+/// When a compile fails. Parameters: Game directory path, [TRUE]/[FALSE] based on if the cause for failure was DMAPI validation.
#define TGS_EVENT_COMPILE_FAILURE 10
-/// When a compile operation completes. Note, this event fires before the new .dmb is loaded into the watchdog. Consider using the [TGS_EVENT_DEPLOYMENT_COMPLETE] instead. Parameters: Game directory path
+/// When a compile operation completes. Note, this event fires before the new .dmb is loaded into the watchdog. Consider using the [TGS_EVENT_DEPLOYMENT_COMPLETE] instead. Parameters: Game directory path.
#define TGS_EVENT_COMPILE_COMPLETE 11
-/// When an automatic update for the current instance begins. No parameters
+/// When an automatic update for the current instance begins. No parameters.
#define TGS_EVENT_INSTANCE_AUTO_UPDATE_START 12
-/// When the repository encounters a merge conflict: Parameters: Base SHA, target SHA, base reference, target reference
+/// When the repository encounters a merge conflict: Parameters: Base SHA, target SHA, base reference, target reference.
#define TGS_EVENT_REPO_MERGE_CONFLICT 13
-/// When a deployment completes. No Parameters
+/// When a deployment completes. No Parameters.
#define TGS_EVENT_DEPLOYMENT_COMPLETE 14
/// Before the watchdog shuts down. Not sent for graceful shutdowns. No parameters.
#define TGS_EVENT_WATCHDOG_SHUTDOWN 15
@@ -102,6 +104,14 @@
// #define TGS_EVENT_WORLD_REBOOT 20
/// Watchdog event when TgsInitializationComplete() is called. No parameters.
#define TGS_EVENT_WORLD_PRIME 21
+// DMAPI also doesnt implement this
+// #define TGS_EVENT_DREAM_DAEMON_LAUNCH 22
+/// After a single submodule update is performed. Parameters: Updated submodule name.
+#define TGS_EVENT_REPO_SUBMODULE_UPDATE 23
+/// After CodeModifications are applied, before DreamMaker is run. Parameters: Game directory path, origin commit sha, version string of the used engine.
+#define TGS_EVENT_PRE_DREAM_MAKER 24
+/// Whenever a deployment folder is deleted from disk. Parameters: Game directory path.
+#define TGS_EVENT_DEPLOYMENT_CLEANUP 25
// OTHER ENUMS
@@ -112,6 +122,7 @@
/// The watchdog will restart on reboot.
#define TGS_REBOOT_MODE_RESTART 2
+// Note that security levels are currently meaningless in OpenDream
/// DreamDaemon Trusted security level.
#define TGS_SECURITY_TRUSTED 0
/// DreamDaemon Safe security level.
@@ -119,6 +130,18 @@
/// DreamDaemon Ultrasafe security level.
#define TGS_SECURITY_ULTRASAFE 2
+/// DreamDaemon public visibility level.
+#define TGS_VISIBILITY_PUBLIC 0
+/// DreamDaemon private visibility level.
+#define TGS_VISIBILITY_PRIVATE 1
+/// DreamDaemon invisible visibility level.
+#define TGS_VISIBILITY_INVISIBLE 2
+
+/// The Build Your Own Net Dream engine.
+#define TGS_ENGINE_TYPE_BYOND 0
+/// The OpenDream engine.
+#define TGS_ENGINE_TYPE_OPENDREAM 1
+
//REQUIRED HOOKS
/**
@@ -127,7 +150,7 @@
* * 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].
*/
-/world/proc/TgsNew(datum/tgs_event_handler/event_handler, minimum_required_security_level = TGS_SECURITY_ULTRASAFE)
+/world/proc/TgsNew(datum/tgs_event_handler/event_handler, minimum_required_security_level = TGS_SECURITY_TRUSTED)
return
/**
@@ -145,7 +168,7 @@
#define VGS_TOPIC var/vgs_topic_return = VgsTopic(args[1]); if(vgs_topic_return) return vgs_topic_return // VOREStation Edit - VGS
/**
- * Call this as late as possible in [world/proc/Reboot].
+ * Call this as late as possible in [world/proc/Reboot] (BEFORE ..()).
*/
/world/proc/TgsReboot()
return
@@ -157,28 +180,28 @@
/datum/tgs_revision_information
/// Full SHA of the commit.
var/commit
- /// ISO 8601 timestamp of when the commit was created
+ /// ISO 8601 timestamp of when the commit was created.
var/timestamp
/// Full sha of last known remote commit. This may be null if the TGS repository is not currently tracking a remote branch.
var/origin_commit
/// Represents a version.
/datum/tgs_version
- /// The suite/major version number
+ /// The suite/major version number.
var/suite
- // This group of variables can be null to represent a wild card
- /// The minor version number. null for wildcards
+ // This group of variables can be null to represent a wild card.
+ /// The minor version number. null for wildcards.
var/minor
- /// The patch version number. null for wildcards
+ /// The patch version number. null for wildcards.
var/patch
- /// Legacy version number. Generally null
+ /// Legacy version number. Generally null.
var/deprecated_patch
- /// Unparsed string value
+ /// Unparsed string value.
var/raw_parameter
- /// String value minus prefix
+ /// String value minus prefix.
var/deprefixed_parameter
/**
@@ -224,40 +247,49 @@
var/is_admin_channel
/// [TRUE]/[FALSE] if the channel is a private message channel for a [/datum/tgs_chat_user].
var/is_private_channel
- /// Tag string associated with the channel in TGS
+ /// Tag string associated with the channel in TGS.
var/custom_tag
+ /// [TRUE]/[FALSE] if the channel supports embeds.
+ var/embeds_supported
// Represents a chat user
/datum/tgs_chat_user
/// TGS internal user ID.
var/id
- // The user's display name.
+ /// The user's display name.
var/friendly_name
- // The string to use to ping this user in a message.
+ /// The string to use to ping this user in a message.
var/mention
- /// The [/datum/tgs_chat_channel] the user was from
+ /// The [/datum/tgs_chat_channel] the user was from.
var/datum/tgs_chat_channel/channel
+/// User definable handler for TGS events.
+/datum/tgs_event_handler
+ /// If the handler receieves [TGS_EVENT_HEALTH_CHECK] events.
+ var/receive_health_checks = FALSE
+
/**
* User definable callback for handling TGS events.
*
- * event_code - One of the TGS_EVENT_ defines. Extra parameters will be documented in each
+ * event_code - One of the TGS_EVENT_ defines. Extra parameters will be documented in each.
*/
/datum/tgs_event_handler/proc/HandleEvent(event_code, ...)
set waitfor = FALSE
return
-/// User definable chat command
+/// User definable 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 = ""
- /// The help text displayed for this command
+ /// The help text displayed for this command.
var/help_text = ""
- /// If this command should be available to game administrators only
+ /// If this command should be available to game administrators only.
var/admin_only = FALSE
+ /// A subtype of [/datum/tgs_chat_command] that is ignored when enumerating available commands. Use this to create shared base /datums for commands.
+ var/ignore_type
/**
- * Process command activation. Should return a string to respond to the issuer with.
+ * Process command activation. Should return a [/datum/tgs_message_content] to respond to the issuer with.
*
* sender - The [/datum/tgs_chat_user] who issued the command.
* params - The trimmed string following the command `/datum/tgs_chat_command/var/name].
@@ -265,6 +297,107 @@
/datum/tgs_chat_command/proc/Run(datum/tgs_chat_user/sender, params)
CRASH("[type] has no implementation for Run()")
+/// User definable chat message.
+/datum/tgs_message_content
+ /// The tring content of the message. Must be provided in New().
+ var/text
+
+ /// The [/datum/tgs_chat_embed] to embed in the message. Not supported on all chat providers.
+ var/datum/tgs_chat_embed/structure/embed
+
+/datum/tgs_message_content/New(text)
+ if(!istext(text))
+ TGS_ERROR_LOG("[/datum/tgs_message_content] created with no text!")
+ text = null
+
+ 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.
+/datum/tgs_chat_embed/structure
+ var/title
+ var/description
+ var/url
+
+ /// Timestamp must be encoded as: time2text(world.timeofday, "YYYY-MM-DD hh:mm:ss"). Use the active timezone.
+ var/timestamp
+
+ /// Colour must be #AARRGGBB or #RRGGBB hex string.
+ var/colour
+
+ /// See https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure for details.
+ var/datum/tgs_chat_embed/media/image
+
+ /// See https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure for details.
+ var/datum/tgs_chat_embed/media/thumbnail
+
+ /// See https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure for details.
+ var/datum/tgs_chat_embed/media/video
+
+ var/datum/tgs_chat_embed/footer/footer
+ var/datum/tgs_chat_embed/provider/provider
+ var/datum/tgs_chat_embed/provider/author/author
+
+ var/list/datum/tgs_chat_embed/field/fields
+
+/// Common datum for similar discord embed medias.
+/datum/tgs_chat_embed/media
+ /// Must be set in New().
+ var/url
+ var/width
+ var/height
+ var/proxy_url
+
+/datum/tgs_chat_embed/media/New(url)
+ if(!istext(url))
+ CRASH("[/datum/tgs_chat_embed/media] created with no url!")
+
+ src.url = url
+
+/// See https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure for details.
+/datum/tgs_chat_embed/footer
+ /// Must be set in New().
+ var/text
+ var/icon_url
+ var/proxy_icon_url
+
+/datum/tgs_chat_embed/footer/New(text)
+ if(!istext(text))
+ CRASH("[/datum/tgs_chat_embed/footer] created with no text!")
+
+ src.text = text
+
+/// See https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure for details.
+/datum/tgs_chat_embed/provider
+ var/name
+ var/url
+
+/// See https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure for details. Must have name set in New().
+/datum/tgs_chat_embed/provider/author
+ var/icon_url
+ var/proxy_icon_url
+
+/datum/tgs_chat_embed/provider/author/New(name)
+ if(!istext(name))
+ CRASH("[/datum/tgs_chat_embed/provider/author] created with no 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().
+/datum/tgs_chat_embed/field
+ var/name
+ var/value
+ var/is_inline
+
+/datum/tgs_chat_embed/field/New(name, value)
+ if(!istext(name))
+ CRASH("[/datum/tgs_chat_embed/field] created with no name!")
+
+ if(!istext(value))
+ CRASH("[/datum/tgs_chat_embed/field] created with no value!")
+
+ src.name = name
+ src.value = value
+
// API FUNCTIONS
/// Returns the maximum supported [/datum/tgs_version] of the DMAPI.
@@ -284,75 +417,81 @@
// No function below this succeeds if it TgsAvailable() returns FALSE or if TgsNew() has yet to be called.
/**
- * Forces a hard reboot of DreamDaemon by ending the process.
+ * Forces a hard reboot of DreamDaemon by ending the process. This function may sleep!
*
* Unlike del(world) clients will try to reconnect.
- * If TGS has not requested a [TGS_REBOOT_MODE_SHUTDOWN] DreamDaemon will be launched again
+ * If TGS has not requested a [TGS_REBOOT_MODE_SHUTDOWN] DreamDaemon will be launched again.
*/
/world/proc/TgsEndProcess()
return
/**
- * Send a message to connected chats.
+ * Send a message to connected chats. This function may sleep!
*
- * message - The string to send.
+ * message - The [/datum/tgs_message_content] to send.
* admin_only: If [TRUE], message will be sent to admin connected chats. Vice-versa applies.
*/
-/world/proc/TgsTargetedChatBroadcast(message, admin_only = FALSE)
+/world/proc/TgsTargetedChatBroadcast(datum/tgs_message_content/message, admin_only = FALSE)
return
/**
- * Send a private message to a specific user.
+ * Send a private message to a specific user. This function may sleep!
*
- * message - The string to send.
+ * message - The [/datum/tgs_message_content] to send.
* user: The [/datum/tgs_chat_user] to PM.
*/
-/world/proc/TgsChatPrivateMessage(message, datum/tgs_chat_user/user)
+/world/proc/TgsChatPrivateMessage(datum/tgs_message_content/message, datum/tgs_chat_user/user)
return
-// The following functions will sleep if a call to TgsNew() is sleeping
-
/**
- * Send a message to connected chats that are flagged as game-related in TGS.
+ * Send a message to connected chats that are flagged as game-related in TGS. This function may sleep!
*
- * message - The string to send.
+ * message - The [/datum/tgs_message_content] to send.
* channels - Optional list of [/datum/tgs_chat_channel]s to restrict the message to.
*/
-/world/proc/TgsChatBroadcast(message, list/channels = null)
+/world/proc/TgsChatBroadcast(datum/tgs_message_content/message, list/channels = null)
return
-/// Returns the current [/datum/tgs_version] of TGS if it is running the server, null otherwise.
+/// Returns the current [/datum/tgs_version] of TGS if it is running the server, null otherwise. This function may sleep if the call to [/world/proc/TgsNew] is sleeping!
/world/proc/TgsVersion()
return
-/// Returns the current [/datum/tgs_version] of the DMAPI being used if it was activated, null otherwise.
+/// Returns the running engine type
+/world/proc/TgsEngine()
+ return
+
+/// Returns the current [/datum/tgs_version] of the DMAPI being used if it was activated, null otherwise. This function may sleep if the call to [/world/proc/TgsNew] is sleeping!
/world/proc/TgsApiVersion()
return
-/// Returns the name of the TGS instance running the game if TGS is present, null otherwise.
+/// Returns the name of the TGS instance running the game if TGS is present, null otherwise. This function may sleep if the call to [/world/proc/TgsNew] is sleeping!
/world/proc/TgsInstanceName()
return
-/// Return the current [/datum/tgs_revision_information] of the running server if TGS is present, null otherwise.
+/// Return the current [/datum/tgs_revision_information] of the running server if TGS is present, null otherwise. This function may sleep if the call to [/world/proc/TgsNew] is sleeping!
/world/proc/TgsRevision()
return
-/// Returns the current BYOND security level as a TGS_SECURITY_ define if TGS is present, null otherwise.
+/// Returns the current BYOND security level as a TGS_SECURITY_ define if TGS is present, null otherwise. This function may sleep if the call to [/world/proc/TgsNew] is sleeping!
/world/proc/TgsSecurityLevel()
return
-/// Returns a list of active [/datum/tgs_revision_information/test_merge]s if TGS is present, null otherwise.
+/// Returns the current BYOND visibility level as a TGS_VISIBILITY_ define if TGS is present, null otherwise. Requires TGS to be using interop API version 5 or higher otherwise the string "___unimplemented" wil be returned. This function may sleep if the call to [/world/proc/TgsNew] is sleeping!
+/world/proc/TgsVisibility()
+ return
+
+/// Returns a list of active [/datum/tgs_revision_information/test_merge]s if TGS is present, null otherwise. This function may sleep if the call to [/world/proc/TgsNew] is sleeping!
/world/proc/TgsTestMerges()
return
-/// Returns a list of connected [/datum/tgs_chat_channel]s if TGS is present, null otherwise.
+/// Returns a list of connected [/datum/tgs_chat_channel]s if TGS is present, null otherwise. This function may sleep if the call to [/world/proc/TgsNew] is sleeping!
/world/proc/TgsChatChannelInfo()
return
/*
The MIT License
-Copyright (c) 2017 Jordan Brown
+Copyright (c) 2017-2023 Jordan Brown
Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and
diff --git a/code/_helpers/logging.dm b/code/_helpers/logging.dm
index 76a1e03eeb..34d74853bc 100644
--- a/code/_helpers/logging.dm
+++ b/code/_helpers/logging.dm
@@ -79,7 +79,7 @@
establish_db_connection()
if(!SSdbcore.IsConnected())
return null
- var/DBQuery/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
+ var/datum/db_query/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
list("sender_ckey" = speaker.ckey, "sender_mob" = speaker.real_name, "message_type" = "say", "message_content" = text))
if(!query_insert.Execute())
log_debug("Error during logging: "+query_insert.ErrorMsg())
@@ -96,7 +96,7 @@
establish_db_connection()
if(!SSdbcore.IsConnected())
return null
- var/DBQuery/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
+ var/datum/db_query/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
list("sender_ckey" = user.ckey, "sender_mob" = user.mob.real_name, "message_type" = "ooc", "message_content" = text))
if(!query_insert.Execute())
log_debug("Error during logging: "+query_insert.ErrorMsg())
@@ -112,7 +112,7 @@
establish_db_connection()
if(!SSdbcore.IsConnected())
return null
- var/DBQuery/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
+ var/datum/db_query/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
list("sender_ckey" = user.ckey, "sender_mob" = user.mob.real_name, "message_type" = "aooc", "message_content" = text))
if(!query_insert.Execute())
log_debug("Error during logging: "+query_insert.ErrorMsg())
@@ -128,7 +128,7 @@
establish_db_connection()
if(!SSdbcore.IsConnected())
return null
- var/DBQuery/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
+ var/datum/db_query/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
list("sender_ckey" = user.ckey, "sender_mob" = user.mob.real_name, "message_type" = "looc", "message_content" = text))
if(!query_insert.Execute())
log_debug("Error during logging: "+query_insert.ErrorMsg())
@@ -148,7 +148,7 @@
establish_db_connection()
if(!SSdbcore.IsConnected())
return null
- var/DBQuery/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
+ var/datum/db_query/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
list("sender_ckey" = speaker.ckey, "sender_mob" = speaker.real_name, "message_type" = "whisper", "message_content" = text))
if(!query_insert.Execute())
log_debug("Error during logging: "+query_insert.ErrorMsg())
@@ -167,7 +167,7 @@
establish_db_connection()
if(!SSdbcore.IsConnected())
return null
- var/DBQuery/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
+ var/datum/db_query/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
list("sender_ckey" = speaker.ckey, "sender_mob" = speaker.real_name, "message_type" = "emote", "message_content" = text))
if(!query_insert.Execute())
log_debug("Error during logging: "+query_insert.ErrorMsg())
@@ -201,7 +201,7 @@
establish_db_connection()
if(!SSdbcore.IsConnected())
return null
- var/DBQuery/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
+ var/datum/db_query/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
list("sender_ckey" = speaker.ckey, "sender_mob" = speaker.real_name, "message_type" = "deadsay", "message_content" = text))
if(!query_insert.Execute())
log_debug("Error during logging: "+query_insert.ErrorMsg())
@@ -222,7 +222,7 @@
establish_db_connection()
if(!SSdbcore.IsConnected())
return null
- var/DBQuery/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
+ var/datum/db_query/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
list("sender_ckey" = speaker.ckey, "sender_mob" = speaker.real_name, "message_type" = "deademote", "message_content" = text))
if(!query_insert.Execute())
log_debug("Error during logging: "+query_insert.ErrorMsg())
@@ -244,7 +244,7 @@
establish_db_connection()
if(!SSdbcore.IsConnected())
return null
- var/DBQuery/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
+ var/datum/db_query/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
list("sender_ckey" = speaker.ckey, "sender_mob" = speaker.real_name, "message_type" = "pda", "message_content" = text))
if(!query_insert.Execute())
log_debug("Error during logging: "+query_insert.ErrorMsg())
diff --git a/code/_helpers/logging_vr.dm b/code/_helpers/logging_vr.dm
index 7771b49482..4b984f5171 100644
--- a/code/_helpers/logging_vr.dm
+++ b/code/_helpers/logging_vr.dm
@@ -7,7 +7,7 @@
establish_db_connection()
if(!SSdbcore.IsConnected())
return null
- var/DBQuery/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
+ var/datum/db_query/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
list("sender_ckey" = speaker.ckey, "sender_mob" = speaker.real_name, "message_type" = "nsay", "message_content" = text))
if(!query_insert.Execute())
log_debug("Error during logging: "+query_insert.ErrorMsg())
@@ -25,7 +25,7 @@
establish_db_connection()
if(!SSdbcore.IsConnected())
return null
- var/DBQuery/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
+ var/datum/db_query/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
list("sender_ckey" = speaker.ckey, "sender_mob" = speaker.real_name, "message_type" = "nme", "message_content" = text))
if(!query_insert.Execute())
log_debug("Error during logging: "+query_insert.ErrorMsg())
@@ -43,7 +43,7 @@
establish_db_connection()
if(!SSdbcore.IsConnected())
return null
- var/DBQuery/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
+ var/datum/db_query/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, type, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_type, :message_content)", \
list("sender_ckey" = speaker.ckey, "sender_mob" = speaker.real_name, "message_type" = "subtle", "message_content" = text))
if(!query_insert.Execute())
log_debug("Error during logging: "+query_insert.ErrorMsg())
diff --git a/code/_helpers/mobs.dm b/code/_helpers/mobs.dm
index a0f7189634..42359c6e7a 100644
--- a/code/_helpers/mobs.dm
+++ b/code/_helpers/mobs.dm
@@ -123,17 +123,19 @@ Proc for attack log creation, because really why not
if(ismob(user)) //CHOMPEdit Begin
if(SSdbcore.Connect())
user.attack_log += text("\[[time_stamp()]\] [span_red("Attacked [target_str]: [what_done]")]")
- var/DBQuery/query_insert = SSdbcore.NewQuery("INSERT INTO erro_attacklog (id, time, ckey, mob, message) VALUES (null, NOW(), :t_ckey, :t_mob, :t_content)", list("t_ckey" = user.ckey, "t_mob" = user.real_name, "t_content" = "Attacked [target_str]: [what_done]"))
- query_insert.Execute(async=use_async)
- qdel(query_insert)
+ var/datum/db_query/query_insert = SSdbcore.NewQuery("INSERT INTO erro_attacklog (id, time, ckey, mob, message) VALUES (null, NOW(), :t_ckey, :t_mob, :t_content)", list("t_ckey" = user.ckey, "t_mob" = user.real_name, "t_content" = "Attacked [target_str]: [what_done]"))
+ spawn() //Change this to a spawn so it doesn't hold us up
+ query_insert.Execute(async=use_async)
+ qdel(query_insert)
//if(SSdbcore.Connect())
// rustg_sql_query_async(SSdbcore.connection, "INSERT INTO erro_attacklog (id, time, ckey, mob, message) VALUES (null, NOW(), :t_ckey, :t_mob, :t_content)", json_encode(list("t_ckey" = user.ckey, "t_mob" = user.real_name, "t_content" = "Attacked [target_str]: [what_done]")))
if(ismob(target))
if(SSdbcore.Connect())
target.attack_log += text("\[[time_stamp()]\] [span_orange("Attacked by [user_str]: [what_done]")]")
- var/DBQuery/query_insert = SSdbcore.NewQuery("INSERT INTO erro_attacklog (id, time, ckey, mob, message) VALUES (null, NOW(), :t_ckey, :t_mob, :t_content)", list("t_ckey" = target.ckey, "t_mob" = target.real_name, "t_content" = "Attacked by [user_str]: [what_done]"))
- query_insert.Execute(async=use_async)
- qdel(query_insert)
+ var/datum/db_query/query_insert = SSdbcore.NewQuery("INSERT INTO erro_attacklog (id, time, ckey, mob, message) VALUES (null, NOW(), :t_ckey, :t_mob, :t_content)", list("t_ckey" = target.ckey, "t_mob" = target.real_name, "t_content" = "Attacked by [user_str]: [what_done]"))
+ spawn() //Change this to a spawn so it doesn't hold us up
+ query_insert.Execute(async=use_async)
+ qdel(query_insert)
//if(SSdbcore.Connect())
// rustg_sql_query_async(SSdbcore.connection, "INSERT INTO erro_attacklog (id, time, ckey, mob, message) VALUES (null, NOW(), :t_ckey, :t_mob, :t_content)", json_encode(list("t_ckey" = target.ckey, "t_mob" = target.real_name, "t_content" = "Attacked by [user_str]: [what_done]")))
//CHOMPEdit End
diff --git a/code/controllers/subsystems/dbcore.dm b/code/controllers/subsystems/dbcore.dm
index c649211a4d..77b1187043 100644
--- a/code/controllers/subsystems/dbcore.dm
+++ b/code/controllers/subsystems/dbcore.dm
@@ -1,8 +1,9 @@
SUBSYSTEM_DEF(dbcore)
name = "Database"
- flags = SS_BACKGROUND
- wait = 1 MINUTES
+ flags = SS_TICKER
+ wait = 10 // Not seconds because we're running on SS_TICKER
init_order = INIT_ORDER_DBCORE
+
var/failed_connection_timeout = 0
var/schema_mismatch = 0
@@ -11,38 +12,183 @@ SUBSYSTEM_DEF(dbcore)
var/failed_connections = 0
var/last_error
- var/list/active_queries = list()
+
+ var/max_concurrent_queries = 25
+
+ /// Number of all queries, reset to 0 when logged in SStime_track. Used by SStime_track
+ var/all_queries_num = 0
+ /// Number of active queries, reset to 0 when logged in SStime_track. Used by SStime_track
+ var/queries_active_num = 0
+ /// Number of standby queries, reset to 0 when logged in SStime_track. Used by SStime_track
+ var/queries_standby_num = 0
+
+ /// All the current queries that exist.
+ var/list/all_queries = list()
+ /// Queries being checked for timeouts.
+ var/list/processing_queries
+
+ /// Queries currently being handled by database driver
+ var/list/datum/db_query/queries_active = list()
+ /// Queries pending execution, mapped to complete arguments
+ var/list/datum/db_query/queries_standby = list()
+
+ /// We are in the process of shutting down and should not allow more DB connections
+ var/shutting_down = FALSE
+
var/connection // Arbitrary handle returned from rust_g.
+ //var/db_daemon_started = FALSE
+
/datum/controller/subsystem/dbcore/Initialize()
return ..()
-/datum/controller/subsystem/dbcore/fire()
- for(var/I in active_queries)
- var/DBQuery/Q = I
- if(world.time - Q.last_activity_time > (5 MINUTES))
- message_admins("Found undeleted query, please check the server logs and notify coders.")
- log_debug("Undeleted query: \"[Q.sql]\" LA: [Q.last_activity] LAT: [Q.last_activity_time]")
- qdel(Q)
+/datum/controller/subsystem/dbcore/stat_entry(msg)
+ msg = "P:[length(all_queries)]|Active:[length(queries_active)]|Standby:[length(queries_standby)]"
+ return ..()
+
+/// Resets the tracking numbers on the subsystem. Used by SStime_track.
+/datum/controller/subsystem/dbcore/proc/reset_tracking()
+ all_queries_num = 0
+ queries_active_num = 0
+ queries_standby_num = 0
+
+/datum/controller/subsystem/dbcore/fire(resumed = FALSE)
+ if(!IsConnected())
+ return
+
+ if(!resumed)
+ if(!length(queries_active) && !length(queries_standby) && !length(all_queries))
+ processing_queries = null
+ return
+ processing_queries = all_queries.Copy()
+
+ // First handle the already running queries
+ for (var/datum/db_query/query in queries_active)
+ if(!process_query(query))
+ queries_active -= query
+
+ // Now lets pull in standby queries if we have room.
+ if (length(queries_standby) > 0 && length(queries_active) < max_concurrent_queries)
+ var/list/queries_to_activate = queries_standby.Copy(1, min(length(queries_standby), max_concurrent_queries) + 1)
+
+ for (var/datum/db_query/query in queries_to_activate)
+ queries_standby.Remove(query)
+ create_active_query(query)
+
+ // And finally, let check queries for undeleted queries, check ticking if there is a lot of work to do.
+ while(length(processing_queries))
+ var/datum/db_query/query = popleft(processing_queries)
+ if(world.time - query.last_activity_time > (5 MINUTES))
+ stack_trace("Found undeleted query, check the sql.log for the undeleted query and add a delete call to the query datum.")
+ log_debug("Undeleted query: \"[query.sql]\" LA: [query.last_activity] LAT: [query.last_activity_time]")
+ qdel(query)
if(MC_TICK_CHECK)
return
+
+/// Helper proc for handling activating queued queries
+/datum/controller/subsystem/dbcore/proc/create_active_query(datum/db_query/query)
+ PRIVATE_PROC(TRUE)
+ SHOULD_NOT_SLEEP(TRUE)
+ if(IsAdminAdvancedProcCall())
+ return FALSE
+ run_query(query)
+ queries_active_num++
+ queries_active += query
+ return query
+
+/datum/controller/subsystem/dbcore/proc/process_query(datum/db_query/query)
+ PRIVATE_PROC(TRUE)
+ SHOULD_NOT_SLEEP(TRUE)
+ if(IsAdminAdvancedProcCall())
+ return FALSE
+ if(QDELETED(query))
+ return FALSE
+ if(query.process((TICKS2DS(wait)) / 10))
+ queries_active -= query
+ return FALSE
+ return TRUE
+
+/datum/controller/subsystem/dbcore/proc/run_query_sync(datum/db_query/query)
+ if(IsAdminAdvancedProcCall())
+ return
+ run_query(query)
+ UNTIL(query.process())
+ return query
+
+/datum/controller/subsystem/dbcore/proc/run_query(datum/db_query/query)
+ if(IsAdminAdvancedProcCall())
+ return
+ query.job_id = rustg_sql_query_async(connection, query.sql, json_encode(query.arguments))
+
+/datum/controller/subsystem/dbcore/proc/queue_query(datum/db_query/query)
+ if(IsAdminAdvancedProcCall())
+ return
+
+ if (!length(queries_standby) && length(queries_active) < max_concurrent_queries)
+ create_active_query(query)
+ return
+
+ queries_standby_num++
+ queries_standby |= query
+
/datum/controller/subsystem/dbcore/Recover()
connection = SSdbcore.connection
/datum/controller/subsystem/dbcore/Shutdown()
+ shutting_down = TRUE
+ log_debug("Clearing DB queries standby:[length(queries_standby)] active: [length(queries_active)] all: [length(all_queries)]")
//This is as close as we can get to the true round end before Disconnect() without changing where it's called, defeating the reason this is a subsystem
+ if(SSdbcore.Connect())
+ //Execute all waiting queries
+ for(var/datum/db_query/query in queries_standby)
+ run_query_sync(query)
+ queries_standby -= query
+ for(var/datum/db_query/query in queries_active)
+ //Finish any remaining active qeries
+ UNTIL(query.process())
+ queries_active -= query
+
+ /*var/datum/db_query/query_round_shutdown = SSdbcore.NewQuery(
+ "UPDATE [format_table_name("round")] SET shutdown_datetime = Now(), end_state = :end_state WHERE id = :round_id",
+ list("end_state" = SSticker.end_state, "round_id" = GLOB.round_id),
+ TRUE
+ )*/
+ //query_round_shutdown.Execute(FALSE)
+ //qdel(query_round_shutdown)
+
+ log_debug("Done clearing DB queries standby:[length(queries_standby)] active: [length(queries_active)] all: [length(all_queries)]")
if(IsConnected())
Disconnect()
+ //stop_db_daemon()
//nu
/datum/controller/subsystem/dbcore/can_vv_get(var_name)
- return var_name != NAMEOF(src, connection) && var_name != NAMEOF(src, active_queries) && ..()
+ if(var_name == NAMEOF(src, connection))
+ return FALSE
+ if(var_name == NAMEOF(src, all_queries))
+ return FALSE
+ if(var_name == NAMEOF(src, queries_active))
+ return FALSE
+ if(var_name == NAMEOF(src, queries_standby))
+ return FALSE
+ if(var_name == NAMEOF(src, processing_queries))
+ return FALSE
+
+ return ..()
/datum/controller/subsystem/dbcore/vv_edit_var(var_name, var_value)
if(var_name == NAMEOF(src, connection))
return FALSE
+ if(var_name == NAMEOF(src, all_queries))
+ return FALSE
+ if(var_name == NAMEOF(src, queries_active))
+ return FALSE
+ if(var_name == NAMEOF(src, queries_standby))
+ return FALSE
+ if(var_name == NAMEOF(src, processing_queries))
+ return FALSE
return ..()
/datum/controller/subsystem/dbcore/proc/Connect()
@@ -52,13 +198,15 @@ SUBSYSTEM_DEF(dbcore)
if(failed_connection_timeout <= world.time) //it's been more than 5 seconds since we failed to connect, reset the counter
failed_connections = 0
- if(failed_connections > 5) //If it failed to establish a connection more than 5 times in a row, don't bother attempting to connect for 5 seconds.
+ if(failed_connections > 5) //If it failed to establish a connection more than 5 times in a row, don't bother attempting to connect for 5 seconds.
failed_connection_timeout = world.time + 50
return FALSE
if(!config.sql_enabled)
return FALSE
+ //start_db_daemon()
+
var/user = sqlfdbklogin
var/pass = sqlfdbkpass
var/db = sqlfdbkdb
@@ -83,7 +231,7 @@ SUBSYSTEM_DEF(dbcore)
else
connection = null
last_error = result["data"]
- log_world("Connect() failed | [last_error]")
+ log_debug("Connect() failed | [last_error]")
++failed_connections
/datum/controller/subsystem/dbcore/proc/CheckSchemaVersion()
@@ -98,19 +246,19 @@ SUBSYSTEM_DEF(dbcore)
/datum/controller/subsystem/dbcore/proc/InitializeRound()
if(!Connect())
return
- var/DBQuery/query_round_initialize = SSdbcore.NewQuery(
+ var/datum/db_query/query_round_initialize = SSdbcore.NewQuery(
//"INSERT INTO [format_table_name("round")] (initialize_datetime, server_ip, server_port) VALUES (Now(), INET_ATON(:internet_address), :port)",
"INSERT INTO round (initialize_datetime, server_ip, server_port) VALUES (Now(), INET_ATON(:internet_address), :port)",
list("internet_address" = world.internet_address || "0", "port" = "[world.port]")
)
query_round_initialize.Execute(async = FALSE)
- GLOB.round_id = "[query_round_initialize.last_insert_id]"
+ //GLOB.round_id = "[query_round_initialize.last_insert_id]"
qdel(query_round_initialize)
/datum/controller/subsystem/dbcore/proc/SetRoundStart()
if(!Connect())
return
- var/DBQuery/query_round_start = SSdbcore.NewQuery(
+ var/datum/db_query/query_round_start = SSdbcore.NewQuery(
//"UPDATE [format_table_name("round")] SET start_datetime = Now() WHERE id = :round_id",
"UPDATE round SET start_datetime = Now() WHERE id = :round_id",
list("round_id" = GLOB.round_id)
@@ -121,7 +269,7 @@ SUBSYSTEM_DEF(dbcore)
/datum/controller/subsystem/dbcore/proc/SetRoundEnd()
if(!Connect())
return
- var/DBQuery/query_round_end = SSdbcore.NewQuery(
+ var/datum/db_query/query_round_end = SSdbcore.NewQuery(
//"UPDATE [format_table_name("round")] SET end_datetime = Now(), game_mode_result = :game_mode_result, station_name = :station_name WHERE id = :round_id",
"UPDATE round SET end_datetime = Now(), game_mode_result = :game_mode_result, station_name = :station_name WHERE id = :round_id",
//list("game_mode_result" = SSticker.mode_result, "station_name" = station_name(), "round_id" = GLOB.round_id)
@@ -151,28 +299,45 @@ SUBSYSTEM_DEF(dbcore)
/datum/controller/subsystem/dbcore/proc/ReportError(error)
last_error = error
-/datum/controller/subsystem/dbcore/proc/NewQuery(sql_query, arguments)
+/datum/controller/subsystem/dbcore/proc/NewQuery(sql_query, arguments, allow_during_shutdown=FALSE)
+ //If the subsystem is shutting down, disallow new queries
+ if(!allow_during_shutdown && shutting_down)
+ CRASH("Attempting to create a new db query during the world shutdown")
+
if(IsAdminAdvancedProcCall())
+ log_admin("ERROR: Advanced admin proc call led to sql query: [sql_query]. Query has been blocked")
message_admins("ERROR: Advanced admin proc call led to sql query. Query has been blocked")
return FALSE
- return new /DBQuery(connection, sql_query, arguments)
+ return new /datum/db_query(connection, sql_query, arguments)
-/datum/controller/subsystem/dbcore/proc/QuerySelect(list/querys, warn = FALSE, qdel = FALSE)
- if (!islist(querys))
- if (!istype(querys, /DBQuery))
- CRASH("Invalid query passed to QuerySelect: [querys]")
- querys = list(querys)
+/** QuerySelect
+ Run a list of query datums in parallel, blocking until they all complete.
+ * queries - List of queries or single query datum to run.
+ * warn - Controls rather warn_execute() or Execute() is called.
+ * qdel - If you don't care about the result or checking for errors, you can have the queries be deleted afterwards.
+ This can be combined with invoke_async as a way of running queries async without having to care about waiting for them to finish so they can be deleted.
+*/
+/datum/controller/subsystem/dbcore/proc/QuerySelect(list/queries, warn = FALSE, qdel = FALSE)
+ if (!islist(queries))
+ if (!istype(queries, /datum/db_query))
+ CRASH("Invalid query passed to QuerySelect: [queries]")
+ queries = list(queries)
+ else
+ queries = queries.Copy() //we don't want to hide bugs in the parent caller by removing invalid values from this list.
+
+ for (var/datum/db_query/query as anything in queries)
+ if (!istype(query))
+ queries -= query
+ stack_trace("Invalid query passed to QuerySelect: `[query]` [REF(query)]")
+ continue
- for (var/thing in querys)
- var/DBQuery/query = thing
if (warn)
- INVOKE_ASYNC(query, /DBQuery.proc/warn_execute)
+ INVOKE_ASYNC(query, TYPE_PROC_REF(/datum/db_query, warn_execute))
else
- INVOKE_ASYNC(query, /DBQuery.proc/Execute)
+ INVOKE_ASYNC(query, TYPE_PROC_REF(/datum/db_query, Execute))
- for (var/thing in querys)
- var/DBQuery/query = thing
- UNTIL(!query.in_progress)
+ for (var/datum/db_query/query as anything in queries)
+ query.sync()
if (qdel)
qdel(query)
@@ -186,11 +351,8 @@ The duplicate_key arg can be true to automatically generate this part of the que
or set to a string that is appended to the end of the query
Ignore_errors instructes mysql to continue inserting rows if some of them have errors.
the erroneous row(s) aren't inserted and there isn't really any way to know why or why errored
-Delayed insert mode was removed in mysql 7 and only works with MyISAM type tables,
- It was included because it is still supported in mariadb.
- It does not work with duplicate_key and the mysql server ignores it in those cases
*/
-/datum/controller/subsystem/dbcore/proc/MassInsert(table, list/rows, duplicate_key = FALSE, ignore_errors = FALSE, delayed = FALSE, warn = FALSE, async = TRUE, special_columns = null)
+/datum/controller/subsystem/dbcore/proc/MassInsert(table, list/rows, duplicate_key = FALSE, ignore_errors = FALSE, warn = FALSE, async = TRUE, special_columns = null)
if (!table || !rows || !istype(rows))
return
@@ -207,8 +369,6 @@ Delayed insert mode was removed in mysql 7 and only works with MyISAM type table
// Prepare SQL query full of placeholders
var/list/query_parts = list("INSERT")
- if (delayed)
- query_parts += " DELAYED"
if (ignore_errors)
query_parts += " IGNORE"
query_parts += " INTO "
@@ -243,21 +403,70 @@ Delayed insert mode was removed in mysql 7 and only works with MyISAM type table
else if (duplicate_key != FALSE)
query_parts += duplicate_key
- var/DBQuery/Query = NewQuery(query_parts.Join(), arguments)
+ var/datum/db_query/Query = NewQuery(query_parts.Join(), arguments)
if (warn)
. = Query.warn_execute(async)
else
. = Query.Execute(async)
qdel(Query)
-/DBQuery
+/*
+/datum/controller/subsystem/dbcore/proc/start_db_daemon()
+ set waitfor = FALSE
+
+ if (db_daemon_started)
+ return
+
+ db_daemon_started = TRUE
+
+ var/daemon = CONFIG_GET(string/db_daemon)
+ if (!daemon)
+ return
+
+ ASSERT(fexists(daemon))
+
+ var/list/result = world.shelleo("echo \"Starting ezdb daemon, do not close this window\" && [daemon]")
+ var/result_code = result[1]
+ if (!result_code || result_code == 1)
+ return
+
+ stack_trace("Failed to start DB daemon: [result_code]\n[result[3]]")
+
+/datum/controller/subsystem/dbcore/proc/stop_db_daemon()
+ set waitfor = FALSE
+
+ if (!db_daemon_started)
+ return
+
+ db_daemon_started = FALSE
+
+ var/daemon = CONFIG_GET(string/db_daemon)
+ if (!daemon)
+ return
+
+ switch (world.system_type)
+ if (MS_WINDOWS)
+ var/list/result = world.shelleo("Get-Process | ? { $_.Path -eq '[daemon]' } | Stop-Process")
+ ASSERT(result[1])
+ if (UNIX)
+ var/list/result = world.shelleo("kill $(pgrep -f '[daemon]')")
+ ASSERT(result[1])
+*/
+
+/datum/db_query
// Inputs
var/connection
var/sql
var/arguments
+ var/datum/callback/success_callback
+ var/datum/callback/fail_callback
+
// Status information
- var/in_progress
+ /// Current status of the query.
+ var/status
+ /// Job ID of the query passed by rustg.
+ var/job_id
var/last_error
var/last_activity
var/last_activity_time
@@ -270,8 +479,9 @@ Delayed insert mode was removed in mysql 7 and only works with MyISAM type table
var/list/item //list of data values populated by NextRow()
-/DBQuery/New(connection, sql, arguments)
- SSdbcore.active_queries[src] = TRUE
+/datum/db_query/New(connection, sql, arguments)
+ SSdbcore.all_queries += src
+ SSdbcore.all_queries_num++
Activity("Created")
item = list()
@@ -279,27 +489,29 @@ Delayed insert mode was removed in mysql 7 and only works with MyISAM type table
src.sql = sql
src.arguments = arguments
-/DBQuery/Destroy()
+/datum/db_query/Destroy()
Close()
- SSdbcore.active_queries -= src
+ SSdbcore.all_queries -= src
+ SSdbcore.queries_standby -= src
+ SSdbcore.queries_active -= src
return ..()
-/DBQuery/CanProcCall(proc_name)
+/datum/db_query/CanProcCall(proc_name)
//fuck off kevinz
return FALSE
-/DBQuery/proc/Activity(activity)
+/datum/db_query/proc/Activity(activity)
last_activity = activity
last_activity_time = world.time
-/DBQuery/proc/warn_execute(async = TRUE)
+/datum/db_query/proc/warn_execute(async = TRUE)
. = Execute(async)
if(!.)
- to_chat(usr, "A SQL error occurred during this operation, check the server logs.")
+ to_chat(usr, span_danger("A SQL error occurred during this operation, check the server logs."))
-/DBQuery/proc/Execute(async = TRUE, log_error = TRUE)
+/datum/db_query/proc/Execute(async = TRUE, log_error = TRUE)
Activity("Execute")
- if(in_progress)
+ if(status == DB_QUERY_STARTED)
CRASH("Attempted to start a new query while waiting on the old one")
if(!SSdbcore.IsConnected())
@@ -310,7 +522,19 @@ Delayed insert mode was removed in mysql 7 and only works with MyISAM type table
if(!async)
start_time = REALTIMEOFDAY
Close()
- . = run_query(async)
+ status = DB_QUERY_STARTED
+ if(async)
+ /*if(!MC_RUNNING(SSdbcore.init_stage))
+ SSdbcore.run_query_sync(src)
+ else
+ SSdbcore.queue_query(src)*/
+ SSdbcore.run_query_sync(src)
+ sync()
+ else
+ var/job_result_str = rustg_sql_query_blocking(connection, sql, json_encode(arguments))
+ store_data(json_decode(job_result_str))
+
+ . = (status != DB_QUERY_BROKEN)
var/timed_out = !. && findtext(last_error, "Operation timed out")
if(!. && log_error)
log_debug("[last_error] | Query used: [sql] | Arguments: [json_encode(arguments)]")
@@ -321,42 +545,45 @@ Delayed insert mode was removed in mysql 7 and only works with MyISAM type table
log_debug("Query used: [sql]")
slow_query_check()
-/DBQuery/proc/run_query(async)
- var/job_result_str
+/// Sleeps until execution of the query has finished.
+/datum/db_query/proc/sync()
+ while(status < DB_QUERY_FINISHED)
+ stoplag()
- if (async)
- var/job_id = rustg_sql_query_async(connection, sql, json_encode(arguments))
- in_progress = TRUE
- UNTIL((job_result_str = rustg_sql_check_query(job_id)) != RUSTG_JOB_NO_RESULTS_YET)
- in_progress = FALSE
+/datum/db_query/process(seconds_per_tick)
+ if(status >= DB_QUERY_FINISHED)
+ return TRUE // we are done processing after all
- if (job_result_str == RUSTG_JOB_ERROR)
- last_error = job_result_str
- return FALSE
- else
- job_result_str = rustg_sql_query_blocking(connection, sql, json_encode(arguments))
+ status = DB_QUERY_STARTED
+ var/job_result = rustg_sql_check_query(job_id)
+ if(job_result == RUSTG_JOB_NO_RESULTS_YET)
+ return FALSE //no results yet
- var/result = json_decode(job_result_str)
- switch (result["status"])
- if ("ok")
+ store_data(json_decode(job_result))
+ return TRUE
+
+/datum/db_query/proc/store_data(result)
+ switch(result["status"])
+ if("ok")
rows = result["rows"]
affected = result["affected"]
last_insert_id = result["last_insert_id"]
- return TRUE
- if ("err")
+ status = DB_QUERY_FINISHED
+ return
+ if("err")
last_error = result["data"]
- return FALSE
- if ("offline")
- last_error = "offline"
- return FALSE
+ status = DB_QUERY_BROKEN
+ return
+ if("offline")
+ last_error = "CONNECTION OFFLINE"
+ status = DB_QUERY_BROKEN
+ return
-/DBQuery/proc/RowCount()
- return rows.len
-/DBQuery/proc/slow_query_check()
- message_admins("HEY! A database query timed out.")
+/datum/db_query/proc/slow_query_check()
+ message_admins("HEY! A database query timed out. Did the server just hang? \[YES\]|\[NO\]")
-/DBQuery/proc/NextRow(async = TRUE)
+/datum/db_query/proc/NextRow(async = TRUE)
Activity("NextRow")
if (rows && next_row_to_take <= rows.len)
@@ -366,9 +593,9 @@ Delayed insert mode was removed in mysql 7 and only works with MyISAM type table
else
return FALSE
-/DBQuery/proc/ErrorMsg()
+/datum/db_query/proc/ErrorMsg()
return last_error
-/DBQuery/proc/Close()
+/datum/db_query/proc/Close()
rows = null
item = null
diff --git a/code/controllers/subsystems/persist_vr.dm b/code/controllers/subsystems/persist_vr.dm
index 0bde0599cb..5e3d2d1ab1 100644
--- a/code/controllers/subsystems/persist_vr.dm
+++ b/code/controllers/subsystems/persist_vr.dm
@@ -86,7 +86,7 @@ SUBSYSTEM_DEF(persist)
var/sql_bal = text2num("[C.department_hours[department_earning]]")
var/sql_total = text2num("[C.play_hours[department_earning]]")
var/list/sqlargs = list("t_ckey" = sql_ckey, "t_department" = sql_dpt) //CHOMPEdit TGSQL
- var/DBQuery/query = SSdbcore.NewQuery("INSERT INTO vr_player_hours (ckey, department, hours, total_hours) VALUES (:t_ckey, :t_department, [sql_bal], [sql_total]) ON DUPLICATE KEY UPDATE hours = VALUES(hours), total_hours = VALUES(total_hours)", sqlargs) //CHOMPEdit TGSQL
+ var/datum/db_query/query = SSdbcore.NewQuery("INSERT INTO vr_player_hours (ckey, department, hours, total_hours) VALUES (:t_ckey, :t_department, [sql_bal], [sql_total]) ON DUPLICATE KEY UPDATE hours = VALUES(hours), total_hours = VALUES(total_hours)", sqlargs) //CHOMPEdit TGSQL
if(!query.Execute()) //CHOMPEdit
log_admin(query.ErrorMsg()) //CHOMPEdit
qdel(query) //CHOMPEdit TGSQL
@@ -106,4 +106,4 @@ SUBSYSTEM_DEF(persist)
// They have a custom title, aren't crew, or someone deleted their record, so we need a fallback method.
// Let's check the mind.
if(M.mind && M.mind.assigned_role)
- . = job_master.GetJob(M.mind.assigned_role)
\ No newline at end of file
+ . = job_master.GetJob(M.mind.assigned_role)
diff --git a/code/defines/procs/dbcore.dm b/code/defines/procs/dbcore.dm
index e0f8ab94af..51c9934c17 100644
--- a/code/defines/procs/dbcore.dm
+++ b/code/defines/procs/dbcore.dm
@@ -77,10 +77,10 @@ var/DB_PORT = 3306 // This is the port your MySQL server is running on (3306 is
if(IsConnected()) Disconnect()
//return Connect("[dbi?"[dbi]":"dbi:mysql:[database_name]:[DB_SERVER]:[DB_PORT]"]",user,password)
return Connect("[dbi?"[dbi]":"dbi:mysql:[database_name]:[sqladdress]:[sqlport]"]",user,password)
-/DBConnection/proc/NewQuery(sql_query,cursor_handler=src.default_cursor) return new/DBQuery(sql_query,src,cursor_handler)
+/DBConnection/proc/NewQuery(sql_query,cursor_handler=src.default_cursor) return new/datum/db_query(sql_query,src,cursor_handler)
-/DBQuery/New(sql_query,DBConnection/connection_handler,cursor_handler)
+/datum/db_query/New(sql_query,DBConnection/connection_handler,cursor_handler)
if(sql_query) src.sql = sql_query
if(connection_handler) src.db_connection = connection_handler
if(cursor_handler) src.default_cursor = cursor_handler
@@ -88,7 +88,7 @@ var/DB_PORT = 3306 // This is the port your MySQL server is running on (3306 is
return ..()
-/DBQuery
+/datum/db_query
var/sql // The sql query being executed.
var/default_cursor
var/list/columns //list of DB Columns populated by Columns()
@@ -98,26 +98,26 @@ var/DB_PORT = 3306 // This is the port your MySQL server is running on (3306 is
var/DBConnection/db_connection
var/_db_query
-/DBQuery/proc/Connect(DBConnection/connection_handler) src.db_connection = connection_handler
+/datum/db_query/proc/Connect(DBConnection/connection_handler) src.db_connection = connection_handler
-/DBQuery/proc/Execute(sql_query=src.sql,cursor_handler=default_cursor)
+/datum/db_query/proc/Execute(sql_query=src.sql,cursor_handler=default_cursor)
Close()
return _dm_db_execute(_db_query,sql_query,db_connection._db_con,cursor_handler,null)
-/DBQuery/proc/NextRow() return _dm_db_next_row(_db_query,item,conversions)
+/datum/db_query/proc/NextRow() return _dm_db_next_row(_db_query,item,conversions)
-/DBQuery/proc/RowsAffected() return _dm_db_rows_affected(_db_query)
+/datum/db_query/proc/RowsAffected() return _dm_db_rows_affected(_db_query)
-/DBQuery/proc/RowCount() return _dm_db_row_count(_db_query)
+/datum/db_query/proc/RowCount() return _dm_db_row_count(_db_query)
-/DBQuery/proc/ErrorMsg() return _dm_db_error_msg(_db_query)
+/datum/db_query/proc/ErrorMsg() return _dm_db_error_msg(_db_query)
-/DBQuery/proc/Columns()
+/datum/db_query/proc/Columns()
if(!columns)
columns = _dm_db_columns(_db_query,/DBColumn)
return columns
-/DBQuery/proc/GetRowData()
+/datum/db_query/proc/GetRowData()
var/list/columns = Columns()
var/list/results
if(columns.len)
@@ -128,16 +128,16 @@ var/DB_PORT = 3306 // This is the port your MySQL server is running on (3306 is
results[C] = src.item[(cur_col.position+1)]
return results
-/DBQuery/proc/Close()
+/datum/db_query/proc/Close()
item.len = 0
columns = null
conversions = null
return _dm_db_close(_db_query)
-/DBQuery/proc/Quote(str)
+/datum/db_query/proc/Quote(str)
return db_connection.Quote(str)
-/DBQuery/proc/SetConversion(column,conversion)
+/datum/db_query/proc/SetConversion(column,conversion)
if(istext(column)) column = columns.Find(column)
if(!conversions) conversions = new/list(column)
else if(conversions.len < column) conversions.len = column
diff --git a/code/defines/procs/statistics.dm b/code/defines/procs/statistics.dm
index bc33fb2e5a..816e23df56 100644
--- a/code/defines/procs/statistics.dm
+++ b/code/defines/procs/statistics.dm
@@ -11,7 +11,7 @@
log_game("SQL ERROR during population polling. Failed to connect.")
else
var/sqltime = time2text(world.realtime, "YYYY-MM-DD hh:mm:ss")
- var/DBQuery/query = SSdbcore.NewQuery("INSERT INTO `population` (`playercount`, `admincount`, `time`) VALUES ([playercount], [admincount], '[sqltime]')") //CHOMPEdit TGSQL
+ var/datum/db_query/query = SSdbcore.NewQuery("INSERT INTO `population` (`playercount`, `admincount`, `time`) VALUES ([playercount], [admincount], '[sqltime]')") //CHOMPEdit TGSQL
if(!query.Execute())
var/err = query.ErrorMsg()
log_game("SQL ERROR during population polling. Error : \[[err]\]\n")
@@ -54,7 +54,7 @@
if(!SSdbcore.IsConnected()) //CHOMPEdit TGSQL
log_game("SQL ERROR during death reporting. Failed to connect.")
else
- var/DBQuery/query = SSdbcore.NewQuery("INSERT INTO death (name, byondkey, job, special, pod, tod, laname, lakey, gender, bruteloss, fireloss, brainloss, oxyloss, coord) VALUES (:t_name, :t_byondkey, :t_job, :t_special, :t_pod, '[sqltime]', :t_laname, :t_lakey, '[H.gender]', [H.getBruteLoss()], [H.getFireLoss()], [H.brainloss], [H.getOxyLoss()], '[coord]')", list("t_name" = sqlname,"t_byondkey" = sqlkey, "t_job" = sqljob, "t_special" = sqlspecial, "t_pod" = sqlpod, "t_laname" = laname, "t_lakey" = lakey)) //CHOMPEdit TGSQL
+ var/datum/db_query/query = SSdbcore.NewQuery("INSERT INTO death (name, byondkey, job, special, pod, tod, laname, lakey, gender, bruteloss, fireloss, brainloss, oxyloss, coord) VALUES (:t_name, :t_byondkey, :t_job, :t_special, :t_pod, '[sqltime]', :t_laname, :t_lakey, '[H.gender]', [H.getBruteLoss()], [H.getFireLoss()], [H.brainloss], [H.getOxyLoss()], '[coord]')", list("t_name" = sqlname,"t_byondkey" = sqlkey, "t_job" = sqljob, "t_special" = sqlspecial, "t_pod" = sqlpod, "t_laname" = laname, "t_lakey" = lakey)) //CHOMPEdit TGSQL
if(!query.Execute())
var/err = query.ErrorMsg()
log_game("SQL ERROR during death reporting. Error : \[[err]\]\n")
@@ -89,7 +89,7 @@
if(!SSdbcore.IsConnected()) //CHOMPEdit TGSQL
log_game("SQL ERROR during death reporting. Failed to connect.")
else
- var/DBQuery/query = SSdbcore.NewQuery("INSERT INTO death (name, byondkey, job, special, pod, tod, laname, lakey, gender, bruteloss, fireloss, brainloss, oxyloss, coord) VALUES (:t_name, :t_byondkey, :t_job, :t_special, :t_pod, '[sqltime]', :t_laname, :t_lakey, '[H.gender]', [H.getBruteLoss()], [H.getFireLoss()], [H.brainloss], [H.getOxyLoss()], '[coord]')", list("t_name" = sqlname,"t_byondkey" = sqlkey, "t_job" = sqljob, "t_special" = sqlspecial, "t_pod" = sqlpod, "t_laname" = laname, "t_lakey" = lakey)) //CHOMPEdit TGSQL
+ var/datum/db_query/query = SSdbcore.NewQuery("INSERT INTO death (name, byondkey, job, special, pod, tod, laname, lakey, gender, bruteloss, fireloss, brainloss, oxyloss, coord) VALUES (:t_name, :t_byondkey, :t_job, :t_special, :t_pod, '[sqltime]', :t_laname, :t_lakey, '[H.gender]', [H.getBruteLoss()], [H.getFireLoss()], [H.brainloss], [H.getOxyLoss()], '[coord]')", list("t_name" = sqlname,"t_byondkey" = sqlkey, "t_job" = sqljob, "t_special" = sqlspecial, "t_pod" = sqlpod, "t_laname" = laname, "t_lakey" = lakey)) //CHOMPEdit TGSQL
if(!query.Execute())
var/err = query.ErrorMsg()
log_game("SQL ERROR during death reporting. Error : \[[err]\]\n")
@@ -122,7 +122,7 @@
log_game("SQL ERROR during feedback reporting. Failed to connect.")
else
- var/DBQuery/max_query = SSdbcore.NewQuery("SELECT MAX(roundid) AS max_round_id FROM erro_feedback") //CHOMPEdit TGSQL
+ var/datum/db_query/max_query = SSdbcore.NewQuery("SELECT MAX(roundid) AS max_round_id FROM erro_feedback") //CHOMPEdit TGSQL
max_query.Execute()
var/newroundid
@@ -142,7 +142,7 @@
var/variable = item.get_variable()
var/value = item.get_value()
- var/DBQuery/query = SSdbcore.NewQuery("INSERT INTO erro_feedback (id, roundid, time, variable, value) VALUES (null, [newroundid], Now(), '[variable]', '[value]')") //CHOMPEdit TGSQL
+ var/datum/db_query/query = SSdbcore.NewQuery("INSERT INTO erro_feedback (id, roundid, time, variable, value) VALUES (null, [newroundid], Now(), '[variable]', '[value]')") //CHOMPEdit TGSQL
if(!query.Execute())
var/err = query.ErrorMsg()
log_game("SQL ERROR during death reporting. Error : \[[err]\]\n")
diff --git a/code/game/machinery/records_scanner.dm b/code/game/machinery/records_scanner.dm
index b80548e876..f829237740 100644
--- a/code/game/machinery/records_scanner.dm
+++ b/code/game/machinery/records_scanner.dm
@@ -51,7 +51,7 @@
var/age = user.age
var/gender = user.gender
/* no dbstuff yet
- var/DBQuery/cquery = dbcon.NewQuery("SELECT * from jobban WHERE ckey='[user.ckey]'")
+ var/datum/db_query/cquery = dbcon.NewQuery("SELECT * from jobban WHERE ckey='[user.ckey]'")
if(!cquery.Execute()) return
else
while(cquery.NextRow())
diff --git a/code/game/magic/archived_book.dm b/code/game/magic/archived_book.dm
index b0595ec589..5ef639fd67 100644
--- a/code/game/magic/archived_book.dm
+++ b/code/game/magic/archived_book.dm
@@ -57,7 +57,7 @@ var/global/datum/book_manager/book_mgr = new()
if(!SSdbcore.IsConnected()) //CHOMP Edit
dat += "ERROR: Unable to contact External Archive. Please contact your system administrator for assistance."
else
- var/DBQuery/query = dbcon.NewQuery("DELETE FROM library WHERE id=[isbn]")
+ var/datum/db_query/query = dbcon.NewQuery("DELETE FROM library WHERE id=[isbn]")
if(!query.Execute())
to_chat(usr,query.ErrorMsg())
dbcon.Disconnect()
diff --git a/code/game/world.dm b/code/game/world.dm
index dd3b60958a..148a8eae3d 100644
--- a/code/game/world.dm
+++ b/code/game/world.dm
@@ -553,7 +553,7 @@ var/world_topic_spam_protect_time = world.timeofday
log_misc("Failed to connect to database in load_mentors().")
return
- var/DBQuery/query = SSdbcore.NewQuery("SELECT ckey, mentor FROM erro_mentor") //CHOMPEdit TGSQL
+ var/datum/db_query/query = SSdbcore.NewQuery("SELECT ckey, mentor FROM erro_mentor") //CHOMPEdit TGSQL
query.Execute()
while(query.NextRow())
var/ckey = query.item[1]
@@ -632,7 +632,7 @@ var/failed_old_db_connections = 0
to_world_log("SQL connection disabled in config.")
else if(establish_db_connection())//CHOMPEdit Begin
to_world_log("Feedback database connection established.")
- var/DBQuery/query_truncate = SSdbcore.NewQuery("TRUNCATE erro_dialog")
+ var/datum/db_query/query_truncate = SSdbcore.NewQuery("TRUNCATE erro_dialog")
var/num_tries = 0
while(!query_truncate.Execute() && num_tries<5)
num_tries++
@@ -640,7 +640,7 @@ var/failed_old_db_connections = 0
if(num_tries==5)
log_admin("ERROR TRYING TO CLEAR erro_dialog")
qdel(query_truncate)
- var/DBQuery/query_truncate2 = SSdbcore.NewQuery("TRUNCATE erro_attacklog")
+ var/datum/db_query/query_truncate2 = SSdbcore.NewQuery("TRUNCATE erro_attacklog")
num_tries = 0
while(!query_truncate2.Execute() && num_tries<5)
num_tries++
@@ -671,7 +671,7 @@ var/failed_old_db_connections = 0
if ( . )
failed_db_connections = 0 //If this connection succeeded, reset the failed connections counter.
//CHOMPEdit Begin
- var/DBQuery/query_truncate = dbcon.NewQuery("TRUNCATE erro_dialog")
+ var/datum/db_query/query_truncate = dbcon.NewQuery("TRUNCATE erro_dialog")
var/num_tries = 0
while(!query_truncate.Execute() && num_tries<5)
num_tries++
diff --git a/code/modules/DMAPI/yawnDMAPI.dm b/code/modules/DMAPI/yawnDMAPI.dm
index 8f2c5b7605..d8048799b5 100644
--- a/code/modules/DMAPI/yawnDMAPI.dm
+++ b/code/modules/DMAPI/yawnDMAPI.dm
@@ -85,17 +85,17 @@ GLOBAL_LIST_EMPTY(pending_discord_registrations)
/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]'")
+ var/datum/db_query/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)
@@ -106,7 +106,7 @@ GLOBAL_LIST_EMPTY(pending_discord_registrations)
// 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()
@@ -114,11 +114,11 @@ GLOBAL_LIST_EMPTY(pending_discord_registrations)
// 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 = "A request has been sent from Discord to validate your Byond username, by '[sender.friendly_name]' in '[sender.channel.friendly_name]'\
If you did not send this request, do not click the link below, and do notify an administrator in-game or on Discord ASAP.\
@@ -128,6 +128,6 @@ GLOBAL_LIST_EMPTY(pending_discord_registrations)
// 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."
-*/
\ No newline at end of file
+*/
diff --git a/code/modules/admin/DB ban/functions.dm b/code/modules/admin/DB ban/functions.dm
index 01c7480170..4269b27b85 100644
--- a/code/modules/admin/DB ban/functions.dm
+++ b/code/modules/admin/DB ban/functions.dm
@@ -44,7 +44,7 @@
computerid = bancid
ip = banip
- var/DBQuery/query = SSdbcore.NewQuery("SELECT id FROM erro_player WHERE ckey = :t_ckey", list("t_ckey",ckey)) //CHOMPEdit TGSQL
+ var/datum/db_query/query = SSdbcore.NewQuery("SELECT id FROM erro_player WHERE ckey = :t_ckey", list("t_ckey",ckey)) //CHOMPEdit TGSQL
query.Execute()
var/validckey = 0
if(query.NextRow())
@@ -83,7 +83,7 @@
var/list/sqlargs = list("t_bantype" = bantype_str, "t_reason" = reason, "t_job" = job, "t_ckey" = ckey, "t_a_ckey" = a_ckey, "t_who" = who, "t_adminwho" = adminwho) //CHOMPEdit TGSQL
var/sql = "INSERT INTO erro_ban (`id`,`bantime`,`serverip`,`bantype`,`reason`,`job`,`duration`,`rounds`,`expiration_time`,`ckey`,`computerid`,`ip`,`a_ckey`,`a_computerid`,`a_ip`,`who`,`adminwho`,`edits`,`unbanned`,`unbanned_datetime`,`unbanned_ckey`,`unbanned_computerid`,`unbanned_ip`) VALUES (null, Now(), '[serverip]', :t_bantype, :t_reason, :t_job, [(duration)?"[duration]":"0"], [(rounds)?"[rounds]":"0"], Now() + INTERVAL [(duration>0) ? duration : 0] MINUTE, :t_ckey, '[computerid]', '[ip]', :t_a_ckey, '[a_computerid]', '[a_ip]', :t_who, :t_adminwho, '', null, null, null, null, null)" //CHOMPEdit TGSQL
- var/DBQuery/query_insert = SSdbcore.NewQuery(sql,sqlargs) //CHOMPEdit TGSQL
+ var/datum/db_query/query_insert = SSdbcore.NewQuery(sql,sqlargs) //CHOMPEdit TGSQL
query_insert.Execute()
to_chat(usr, "[span_blue("Ban saved to database.")]")
message_admins("[key_name_admin(usr)] has added a [bantype_str] for [ckey] [(job)?"([job])":""] [(duration > 0)?"([duration] minutes)":""] with the reason: \"[reason]\" to the ban database.",1)
@@ -132,7 +132,7 @@
var/ban_id
var/ban_number = 0 //failsafe
- var/DBQuery/query = SSdbcore.NewQuery(sql, list("t_ckey" = ckey)) //CHOMPEdit TGSQL
+ var/datum/db_query/query = SSdbcore.NewQuery(sql, list("t_ckey" = ckey)) //CHOMPEdit TGSQL
query.Execute()
while(query.NextRow())
ban_id = query.item[1]
@@ -162,7 +162,7 @@
to_chat(usr, "Cancelled")
return
- var/DBQuery/query = SSdbcore.NewQuery("SELECT ckey, duration, reason FROM erro_ban WHERE id = [banid]") //CHOMPEdit TGSQL
+ var/datum/db_query/query = SSdbcore.NewQuery("SELECT ckey, duration, reason FROM erro_ban WHERE id = [banid]") //CHOMPEdit TGSQL
query.Execute()
var/eckey = usr.ckey //Editing admin ckey
@@ -190,7 +190,7 @@
to_chat(usr, "Cancelled")
return
var/list/sqlargs = list("t_reason" = value, "t_edits" = "- [eckey] changed ban reason from \\\"[reason]\\\" to \\\"[value]\\\"
") //CHOMPEdit TGSQL
- var/DBQuery/update_query = SSdbcore.NewQuery("UPDATE erro_ban SET reason = '[value]', edits = CONCAT(edits,:t_edits) WHERE id = [banid]", sqlargs) //CHOMPEdit TGSQL
+ var/datum/db_query/update_query = SSdbcore.NewQuery("UPDATE erro_ban SET reason = '[value]', edits = CONCAT(edits,:t_edits) WHERE id = [banid]", sqlargs) //CHOMPEdit TGSQL
update_query.Execute()
message_admins("[key_name_admin(usr)] has edited a ban for [pckey]'s reason from [reason] to [value]",1)
qdel(update_query) //CHOMPEdit TGSQL
@@ -201,7 +201,7 @@
to_chat(usr, "Cancelled")
return
var/list/sqlargs = list("t_edits" = "- [eckey] changed ban duration from [duration] to [value]
") //CHOMPEdit TGSQL
- var/DBQuery/update_query = SSdbcore.NewQuery("UPDATE erro_ban SET duration = [value], edits = CONCAT(edits,:t_edits), expiration_time = DATE_ADD(bantime, INTERVAL [value] MINUTE) WHERE id = [banid]",sqlargs) //CHOMPEdit TGSQL
+ var/datum/db_query/update_query = SSdbcore.NewQuery("UPDATE erro_ban SET duration = [value], edits = CONCAT(edits,:t_edits), expiration_time = DATE_ADD(bantime, INTERVAL [value] MINUTE) WHERE id = [banid]",sqlargs) //CHOMPEdit TGSQL
message_admins("[key_name_admin(usr)] has edited a ban for [pckey]'s duration from [duration] to [value]",1)
update_query.Execute()
qdel(update_query) //CHOMPEdit TGSQL
@@ -225,7 +225,7 @@
var/ban_number = 0 //failsafe
var/pckey
- var/DBQuery/query = SSdbcore.NewQuery(sql) //CHOMPEdit TGSQL
+ var/datum/db_query/query = SSdbcore.NewQuery(sql) //CHOMPEdit TGSQL
query.Execute()
while(query.NextRow())
pckey = query.item[1]
@@ -249,7 +249,7 @@
var/sql_update = "UPDATE erro_ban SET unbanned = 1, unbanned_datetime = Now(), unbanned_ckey = :t_ckey, unbanned_computerid = '[unban_computerid]', unbanned_ip = '[unban_ip]' WHERE id = [id]" //CHOMPEdit TGSQL
message_admins("[key_name_admin(usr)] has lifted [pckey]'s ban.",1)
- var/DBQuery/query_update = SSdbcore.NewQuery(sql_update,sqlargs) //CHOMPEdit TGSQL
+ var/datum/db_query/query_update = SSdbcore.NewQuery(sql_update,sqlargs) //CHOMPEdit TGSQL
query_update.Execute()
qdel(query_update) //CHOMPEdit TGSQL
@@ -407,7 +407,7 @@
else
bantypesearch += "'PERMABAN' "
- var/DBQuery/select_query = SSdbcore.NewQuery("SELECT id, bantime, bantype, reason, job, duration, expiration_time, ckey, a_ckey, unbanned, unbanned_ckey, unbanned_datetime, edits, ip, computerid FROM erro_ban WHERE 1 [playersearch] [adminsearch] [ipsearch] [cidsearch] [bantypesearch] ORDER BY bantime DESC LIMIT 100", sqlargs) //CHOMPEdit TGSQL
+ var/datum/db_query/select_query = SSdbcore.NewQuery("SELECT id, bantime, bantype, reason, job, duration, expiration_time, ckey, a_ckey, unbanned, unbanned_ckey, unbanned_datetime, edits, ip, computerid FROM erro_ban WHERE 1 [playersearch] [adminsearch] [ipsearch] [cidsearch] [bantypesearch] ORDER BY bantime DESC LIMIT 100", sqlargs) //CHOMPEdit TGSQL
select_query.Execute()
var/now = time2text(world.realtime, "YYYY-MM-DD hh:mm:ss") // MUST BE the same format as SQL gives us the dates in, and MUST be least to most specific (i.e. year, month, day not day, month, year)
diff --git a/code/modules/admin/IsBanned.dm b/code/modules/admin/IsBanned.dm
index 9325152a23..002352d68e 100644
--- a/code/modules/admin/IsBanned.dm
+++ b/code/modules/admin/IsBanned.dm
@@ -56,7 +56,7 @@
log_misc("Key [ckeytext] cid not checked. Non-Numeric: [computer_id]")
failedcid = 1
- var/DBQuery/query = SSdbcore.NewQuery("SELECT ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype FROM erro_ban WHERE (ckey = :t_ckey [ipquery] [cidquery]) AND (bantype = 'PERMABAN' OR (bantype = 'TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)", list("t_ckey" = ckeytext)) //CHOMPEdit TGSQL
+ var/datum/db_query/query = SSdbcore.NewQuery("SELECT ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype FROM erro_ban WHERE (ckey = :t_ckey [ipquery] [cidquery]) AND (bantype = 'PERMABAN' OR (bantype = 'TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)", list("t_ckey" = ckeytext)) //CHOMPEdit TGSQL
query.Execute()
diff --git a/code/modules/admin/admin_ranks.dm b/code/modules/admin/admin_ranks.dm
index 3f40e5ebe5..235b546950 100644
--- a/code/modules/admin/admin_ranks.dm
+++ b/code/modules/admin/admin_ranks.dm
@@ -69,7 +69,7 @@ var/list/admin_ranks = list() //list of all ranks with associated rights
C.holder = null
GLOB.admins.Cut()
load_admin_ranks() //CHOMP Edit: moved this from "f(config.admin_legacy_system)" and put it here instead, literally just moved it 3 lines.
-
+
if(config.admin_legacy_system)
//Clear profile access
for(var/A in world.GetConfig("admin"))
@@ -119,7 +119,7 @@ var/list/admin_ranks = list() //list of all ranks with associated rights
load_admins()
return
- var/DBQuery/query = SSdbcore.NewQuery("SELECT ckey, rank, level, flags FROM erro_admin") //CHOMPEdit TGSQL
+ var/datum/db_query/query = SSdbcore.NewQuery("SELECT ckey, rank, level, flags FROM erro_admin") //CHOMPEdit TGSQL
query.Execute()
while(query.NextRow())
var/ckey = query.item[1]
diff --git a/code/modules/admin/admin_tools.dm b/code/modules/admin/admin_tools.dm
index 2d9ae2cdd4..4d4ecc4019 100644
--- a/code/modules/admin/admin_tools.dm
+++ b/code/modules/admin/admin_tools.dm
@@ -12,7 +12,7 @@
//CHOMPEdit Begin
/*for(var/d in M.dialogue_log)
dat += "[d]
"*/
- var/DBQuery/query = SSdbcore.NewQuery("SELECT id,time,ckey,mob,message from erro_attacklog WHERE ckey = :t_ckey", list("t_ckey" = M.ckey))
+ var/datum/db_query/query = SSdbcore.NewQuery("SELECT id,time,ckey,mob,message from erro_attacklog WHERE ckey = :t_ckey", list("t_ckey" = M.ckey))
if(!query.Execute())
dat += "Database query error"
else
@@ -49,11 +49,11 @@
dat += "Current Antag?: [(M.mind.special_role)?"Yes":"No"]
"
dat += "
Note: This is arranged from earliest to latest.
"
-
+
//CHOMPEdit Begin
/*for(var/d in M.dialogue_log)
dat += "[d]
"*/
- var/DBQuery/query = SSdbcore.NewQuery("SELECT mid,time,ckey,mob,type,message from erro_dialog WHERE ckey = :t_ckey", list("t_ckey" = M.ckey))
+ var/datum/db_query/query = SSdbcore.NewQuery("SELECT mid,time,ckey,mob,type,message from erro_dialog WHERE ckey = :t_ckey", list("t_ckey" = M.ckey))
if(!query.Execute())
dat += "Database query error"
else
@@ -76,4 +76,4 @@
onclose(usr, "admin_dialogue_log")
- feedback_add_details("admin_verb","PDL") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
\ No newline at end of file
+ feedback_add_details("admin_verb","PDL") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
diff --git a/code/modules/admin/admin_verbs_vr.dm b/code/modules/admin/admin_verbs_vr.dm
index 0cd74ca1b5..f6db65d671 100644
--- a/code/modules/admin/admin_verbs_vr.dm
+++ b/code/modules/admin/admin_verbs_vr.dm
@@ -103,7 +103,7 @@
dat += {"(Order book by SS13BN)