BSQL is fucking dead
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
#define BSQL_EXTERNAL_CONFIGURATION
|
||||
#define BSQL_DEL_PROC(path) ##path/Destroy()
|
||||
#define BSQL_DEL_CALL(obj) qdel(##obj)
|
||||
#define BSQL_IS_DELETED(obj) (QDELETED(obj))
|
||||
#define BSQL_PROTECT_DATUM(path) GENERAL_PROTECT_DATUM(##path)
|
||||
#define BSQL_ERROR(message) SSdbcore.ReportError(message)
|
||||
@@ -1,135 +0,0 @@
|
||||
//BSQL - DMAPI
|
||||
#define BSQL_VERSION "v1.3.0.0"
|
||||
|
||||
//types of connections
|
||||
#define BSQL_CONNECTION_TYPE_MARIADB "MySql"
|
||||
#define BSQL_CONNECTION_TYPE_SQLSERVER "SqlServer"
|
||||
|
||||
#define BSQL_DEFAULT_TIMEOUT 5
|
||||
#define BSQL_DEFAULT_THREAD_LIMIT 50
|
||||
|
||||
//Call this before rebooting or shutting down your world to clean up gracefully. This invalidates all active connection and operation datums
|
||||
/world/proc/BSQL_Shutdown()
|
||||
return
|
||||
|
||||
/*
|
||||
Called whenever a library call is made with verbose information, override and do with as you please
|
||||
message: English debug message
|
||||
*/
|
||||
/world/proc/BSQL_Debug(msg)
|
||||
return
|
||||
|
||||
/*
|
||||
Create a new database connection, does not perform the actual connect
|
||||
connection_type: The BSQL connection_type to use
|
||||
asyncTimeout: The timeout to use for normal operations, 0 for infinite, defaults to BSQL_DEFAULT_TIMEOUT
|
||||
blockingTimeout: The timeout to use for blocking operations, must be less than or equal to asyncTimeout, 0 for infinite, defaults to asyncTimeout
|
||||
threadLimit: The limit of additional threads BSQL will run simultaneously, defaults to BSQL_DEFAULT_THREAD_LIMIT
|
||||
*/
|
||||
/datum/BSQL_Connection/New(connection_type, asyncTimeout, blockingTimeout, threadLimit)
|
||||
return ..()
|
||||
|
||||
/*
|
||||
Starts an operation to connect to a database. Should only have 1 successful call
|
||||
ipaddress: The ip/hostname of the target server
|
||||
port: The port of the target server
|
||||
username: The username to login to the target server
|
||||
password: The password for the target server
|
||||
database: Optional database to connect to. Must be used when trying to do database operations, `USE x` is not sufficient
|
||||
Returns: A /datum/BSQL_Operation representing the connection or null if an error occurred
|
||||
*/
|
||||
/datum/BSQL_Connection/proc/BeginConnect(ipaddress, port, username, password, database)
|
||||
return
|
||||
|
||||
/*
|
||||
Properly quotes a string for use by the database. The connection must be open for this proc to succeed
|
||||
str: The string to quote
|
||||
Returns: The string quoted on success, null on error
|
||||
*/
|
||||
/datum/BSQL_Connection/proc/Quote(str)
|
||||
return
|
||||
|
||||
/*
|
||||
Starts an operation for a query
|
||||
query: The text of the query. Only one query allowed per invocation, no semicolons
|
||||
Returns: A /datum/BSQL_Operation/Query representing the running query and subsequent result set or null if an error occurred
|
||||
|
||||
Note for MariaDB: The underlying connection is pooled. In order to use connection state based properties (i.e. LAST_INSERT_ID()) you can guarantee multiple queries will use the same connection by running BSQL_DEL_CALL(query) on the finished /datum/BSQL_Operation/Query and then creating the next one with another call to BeginQuery() with no sleeps in between
|
||||
*/
|
||||
/datum/BSQL_Connection/proc/BeginQuery(query)
|
||||
return
|
||||
|
||||
/*
|
||||
Checks if the operation is complete. This, in some cases must be called multiple times with false return before a result is present regardless of timespan. For best performance check it once per tick
|
||||
|
||||
Returns: TRUE if the operation is complete, FALSE if it's not, null on error
|
||||
*/
|
||||
/datum/BSQL_Operation/proc/IsComplete()
|
||||
return
|
||||
|
||||
/*
|
||||
Blocks the entire game until the given operation completes. IsComplete should not be checked after calling this to avoid potential side effects.
|
||||
|
||||
Returns: TRUE on success, FALSE if the operation wait time exceeded the connection's blockingTimeout setting
|
||||
*/
|
||||
/datum/BSQL_Operation/proc/WaitForCompletion()
|
||||
return
|
||||
|
||||
/*
|
||||
Get the error message associated with an operation. Should not be used while IsComplete() returns FALSE
|
||||
|
||||
Returns: The error message, if any. null otherwise
|
||||
*/
|
||||
/datum/BSQL_Operation/proc/GetError()
|
||||
return
|
||||
|
||||
/*
|
||||
Get the error code associated with an operation. Should not be used while IsComplete() returns FALSE
|
||||
|
||||
Returns: The error code, if any. null otherwise
|
||||
*/
|
||||
/datum/BSQL_Operation/proc/GetErrorCode()
|
||||
return
|
||||
|
||||
/*
|
||||
Gets an associated list of column name -> value representation of the most recent row in the query. Only valid if IsComplete() returns TRUE. If this returns null and no errors are present there are no more results in the query. Important to note that once IsComplete() returns TRUE it must not be called again without checking this or the row values may be lost
|
||||
|
||||
Returns: An associated list of column name -> value for the row. Values will always be either strings or null
|
||||
*/
|
||||
/datum/BSQL_Operation/Query/proc/CurrentRow()
|
||||
return
|
||||
|
||||
|
||||
/*
|
||||
Code configuration options below
|
||||
|
||||
Define this to avoid modifying this file but the following defines must be declared somewhere else before BSQL/includes.dm is included
|
||||
*/
|
||||
#ifndef BSQL_EXTERNAL_CONFIGURATION
|
||||
|
||||
//Modify this if you disagree with byond's GC schemes. Ensure this is called for all connections and operations when they are deleted or they will leak native resources until /world/proc/BSQL_Shutdown() is called
|
||||
#define BSQL_DEL_PROC(path) ##path/Del()
|
||||
|
||||
//The equivalent of calling del() in your codebase
|
||||
#define BSQL_DEL_CALL(obj) del(##obj)
|
||||
|
||||
//Returns TRUE if an object is delete
|
||||
#define BSQL_IS_DELETED(obj) (obj == null)
|
||||
|
||||
//Modify this to add protections to the connection and query datums
|
||||
#define BSQL_PROTECT_DATUM(path)
|
||||
|
||||
//Modify this to change up error handling for the library
|
||||
#define BSQL_ERROR(message) CRASH("BSQL: [##message]")
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
Copyright 2018 Jordan Brown
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
@@ -1,19 +1,76 @@
|
||||
// rust_g.dm - DM API for rust_g extension library
|
||||
#define RUST_G "rust_g"
|
||||
//
|
||||
// To configure, create a `rust_g.config.dm` and set what you care about from
|
||||
// the following options:
|
||||
//
|
||||
// #define RUST_G "path/to/rust_g"
|
||||
// Override the .dll/.so detection logic with a fixed path or with detection
|
||||
// logic of your own.
|
||||
//
|
||||
// #define RUSTG_OVERRIDE_BUILTINS
|
||||
// Enable replacement rust-g functions for certain builtins. Off by default.
|
||||
|
||||
#define RUSTG_JOB_NO_RESULTS_YET "NO RESULTS YET"
|
||||
#define RUSTG_JOB_NO_SUCH_JOB "NO SUCH JOB"
|
||||
#define RUSTG_JOB_ERROR "JOB PANICKED"
|
||||
#ifndef RUST_G
|
||||
// Default automatic RUST_G detection.
|
||||
// On Windows, looks in the standard places for `rust_g.dll`.
|
||||
// On Linux, looks in `.`, `$LD_LIBRARY_PATH`, and `~/.byond/bin` for either of
|
||||
// `librust_g.so` (preferred) or `rust_g` (old).
|
||||
|
||||
/* This comment bypasses grep checks */ /var/__rust_g
|
||||
|
||||
/proc/__detect_rust_g()
|
||||
if (world.system_type == UNIX)
|
||||
if (fexists("./librust_g.so"))
|
||||
// No need for LD_LIBRARY_PATH badness.
|
||||
return __rust_g = "./librust_g.so"
|
||||
else if (fexists("./rust_g"))
|
||||
// Old dumb filename.
|
||||
return __rust_g = "./rust_g"
|
||||
else if (fexists("[world.GetConfig("env", "HOME")]/.byond/bin/rust_g"))
|
||||
// Old dumb filename in `~/.byond/bin`.
|
||||
return __rust_g = "rust_g"
|
||||
else
|
||||
// It's not in the current directory, so try others
|
||||
return __rust_g = "librust_g.so"
|
||||
else
|
||||
return __rust_g = "rust_g"
|
||||
|
||||
#define RUST_G (__rust_g || __detect_rust_g())
|
||||
#endif
|
||||
|
||||
/**
|
||||
* 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) \
|
||||
call(RUST_G, "cnoise_generate")(percentage, smoothing_iterations, birth_limit, death_limit, width, height)
|
||||
|
||||
#define rustg_dmi_strip_metadata(fname) call(RUST_G, "dmi_strip_metadata")(fname)
|
||||
#define rustg_dmi_create_png(path, width, height, data) call(RUST_G, "dmi_create_png")(path, width, height, data)
|
||||
#define rustg_dmi_resize_png(path, width, height, resizetype) call(RUST_G, "dmi_resize_png")(path, width, height, resizetype)
|
||||
|
||||
#define rustg_file_read(fname) call(RUST_G, "file_read")(fname)
|
||||
#define rustg_file_exists(fname) call(RUST_G, "file_exists")(fname)
|
||||
#define rustg_file_write(text, fname) call(RUST_G, "file_write")(text, fname)
|
||||
#define rustg_file_append(text, fname) call(RUST_G, "file_append")(text, fname)
|
||||
|
||||
#ifdef RUSTG_OVERRIDE_BUILTINS
|
||||
#define file2text(fname) rustg_file_read("[fname]")
|
||||
#define text2file(text, fname) rustg_file_append(text, "[fname]")
|
||||
#endif
|
||||
|
||||
#define rustg_git_revparse(rev) call(RUST_G, "rg_git_revparse")(rev)
|
||||
#define rustg_git_commit_date(rev) call(RUST_G, "rg_git_commit_date")(rev)
|
||||
|
||||
#define rustg_log_write(fname, text, format) call(RUST_G, "log_write")(fname, text, format)
|
||||
/proc/rustg_log_close_all() return call(RUST_G, "log_close_all")()
|
||||
|
||||
#define RUSTG_HTTP_METHOD_GET "get"
|
||||
#define RUSTG_HTTP_METHOD_PUT "put"
|
||||
#define RUSTG_HTTP_METHOD_DELETE "delete"
|
||||
@@ -23,3 +80,22 @@
|
||||
#define rustg_http_request_blocking(method, url, body, headers) call(RUST_G, "http_request_blocking")(method, url, body, headers)
|
||||
#define rustg_http_request_async(method, url, body, headers) call(RUST_G, "http_request_async")(method, url, body, headers)
|
||||
#define rustg_http_check_request(req_id) 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) (call(RUST_G, "json_is_valid")(text) == "true")
|
||||
|
||||
#define rustg_log_write(fname, text, format) call(RUST_G, "log_write")(fname, text, format)
|
||||
/proc/rustg_log_close_all() return call(RUST_G, "log_close_all")()
|
||||
|
||||
#define rustg_noise_get_at_coordinates(seed, x, y) call(RUST_G, "noise_get_at_coordinates")(seed, x, y)
|
||||
|
||||
#define rustg_sql_connect_pool(options) call(RUST_G, "sql_connect_pool")(options)
|
||||
#define rustg_sql_query_async(handle, query, params) call(RUST_G, "sql_query_async")(handle, query, params)
|
||||
#define rustg_sql_query_blocking(handle, query, params) call(RUST_G, "sql_query_blocking")(handle, query, params)
|
||||
#define rustg_sql_connected(handle) call(RUST_G, "sql_connected")(handle)
|
||||
#define rustg_sql_disconnect_pool(handle) call(RUST_G, "sql_disconnect_pool")(handle)
|
||||
#define rustg_sql_check_query(job_id) call(RUST_G, "sql_check_query")("[job_id]")
|
||||
|
||||
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
// tgstation-server DMAPI
|
||||
|
||||
#define TGS_DMAPI_VERSION "5.2.10"
|
||||
#define TGS_DMAPI_VERSION "5.2.9"
|
||||
|
||||
// All functions and datums outside this document are subject to change with any version and should not be relied on.
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
#define TGS_EVENT_REPO_CHECKOUT 1
|
||||
/// 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 merges a pull request. 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
|
||||
#define TGS_EVENT_REPO_PRE_SYNCHRONIZE 4
|
||||
@@ -190,21 +190,21 @@
|
||||
|
||||
/// Represents a merge of a GitHub pull request.
|
||||
/datum/tgs_revision_information/test_merge
|
||||
/// The test merge number.
|
||||
/// The pull request number.
|
||||
var/number
|
||||
/// The test merge source's title when it was merged.
|
||||
/// The pull request title when it was merged.
|
||||
var/title
|
||||
/// The test merge source's body when it was merged.
|
||||
/// The pull request body when it was merged.
|
||||
var/body
|
||||
/// The Username of the test merge source's author.
|
||||
/// The GitHub username of the pull request's author.
|
||||
var/author
|
||||
/// An http URL to the test merge source.
|
||||
/// An http URL to the pull request.
|
||||
var/url
|
||||
/// The SHA of the test merge when that was merged.
|
||||
/// The SHA of the pull request when that was merged.
|
||||
var/pull_request_commit
|
||||
/// ISO 8601 timestamp of when the test merge was created on TGS.
|
||||
/// ISO 8601 timestamp of when the pull request was merged.
|
||||
var/time_merged
|
||||
/// Optional comment left by the TGS user who initiated the merge.
|
||||
/// (Nullable) Comment left by the TGS user who initiated the merge..
|
||||
var/comment
|
||||
|
||||
/// Represents a connected chat channel.
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
switch(event_code)
|
||||
if(TGS_EVENT_REBOOT_MODE_CHANGE)
|
||||
var/list/reboot_mode_lookup = list ("[TGS_REBOOT_MODE_NORMAL]" = "be normal", "[TGS_REBOOT_MODE_SHUTDOWN]" = "shutdown the server", "[TGS_REBOOT_MODE_RESTART]" = "hard restart the server")
|
||||
var old_reboot_mode = args[2]
|
||||
var new_reboot_mode = args[3]
|
||||
var/old_reboot_mode = args[2]
|
||||
var/new_reboot_mode = args[3]
|
||||
message_admins("TGS: Reboot will no longer [reboot_mode_lookup["[old_reboot_mode]"]], it will instead [reboot_mode_lookup["[new_reboot_mode]"]]")
|
||||
if(TGS_EVENT_PORT_SWAP)
|
||||
message_admins("TGS: Changing port from [world.port] to [args[2]]")
|
||||
@@ -28,12 +28,14 @@
|
||||
var/datum/tgs_version/old_version = world.TgsVersion()
|
||||
var/datum/tgs_version/new_version = args[2]
|
||||
if(!old_version.Equals(new_version))
|
||||
to_chat(world, "<span class='boldannounce'>TGS updated to v[old_version.deprefixed_parameter]</span>")
|
||||
to_chat(world, "<span class='boldannounce'>TGS updated to v[new_version.deprefixed_parameter]</span>")
|
||||
else
|
||||
message_admins("TGS: Back online")
|
||||
if(reattach_timer)
|
||||
deltimer(reattach_timer)
|
||||
reattach_timer = null
|
||||
if(TGS_EVENT_WATCHDOG_SHUTDOWN)
|
||||
to_chat_immediate(world, "<span class='boldannounce'>Server is shutting down!</span>")
|
||||
|
||||
/datum/tgs_event_handler/impl/proc/LateOnReattach()
|
||||
message_admins("Warning: TGS hasn't notified us of it coming back for a full minute! Is there a problem?")
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
Copyright 2018 Jordan Brown
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,68 +0,0 @@
|
||||
/datum/BSQL_Connection
|
||||
var/id
|
||||
var/connection_type
|
||||
|
||||
BSQL_PROTECT_DATUM(/datum/BSQL_Connection)
|
||||
|
||||
/datum/BSQL_Connection/New(connection_type, asyncTimeout, blockingTimeout, threadLimit)
|
||||
if(asyncTimeout == null)
|
||||
asyncTimeout = BSQL_DEFAULT_TIMEOUT
|
||||
if(blockingTimeout == null)
|
||||
blockingTimeout = asyncTimeout
|
||||
if(threadLimit == null)
|
||||
threadLimit = BSQL_DEFAULT_THREAD_LIMIT
|
||||
|
||||
src.connection_type = connection_type
|
||||
|
||||
world._BSQL_InitCheck(src)
|
||||
|
||||
var/error = world._BSQL_Internal_Call("CreateConnection", connection_type, "[asyncTimeout]", "[blockingTimeout]", "[threadLimit]")
|
||||
if(error)
|
||||
BSQL_ERROR(error)
|
||||
return
|
||||
|
||||
id = world._BSQL_Internal_Call("GetConnection")
|
||||
if(!id)
|
||||
BSQL_ERROR("BSQL library failed to provide connect operation for connection id [id]([connection_type])!")
|
||||
|
||||
BSQL_DEL_PROC(/datum/BSQL_Connection)
|
||||
var/error
|
||||
if(id)
|
||||
error = world._BSQL_Internal_Call("ReleaseConnection", id)
|
||||
. = ..()
|
||||
if(error)
|
||||
BSQL_ERROR(error)
|
||||
|
||||
/datum/BSQL_Connection/BeginConnect(ipaddress, port, username, password, database)
|
||||
var/error = world._BSQL_Internal_Call("OpenConnection", id, ipaddress, "[port]", username, password, database)
|
||||
if(error)
|
||||
BSQL_ERROR(error)
|
||||
return
|
||||
|
||||
var/op_id = world._BSQL_Internal_Call("GetOperation")
|
||||
if(!op_id)
|
||||
BSQL_ERROR("Library failed to provide connect operation for connection id [id]([connection_type])!")
|
||||
return
|
||||
|
||||
return new /datum/BSQL_Operation(src, op_id)
|
||||
|
||||
|
||||
/datum/BSQL_Connection/BeginQuery(query)
|
||||
var/error = world._BSQL_Internal_Call("NewQuery", id, query)
|
||||
if(error)
|
||||
BSQL_ERROR(error)
|
||||
return
|
||||
|
||||
var/op_id = world._BSQL_Internal_Call("GetOperation")
|
||||
if(!op_id)
|
||||
BSQL_ERROR("Library failed to provide query operation for connection id [id]([connection_type])!")
|
||||
return
|
||||
|
||||
return new /datum/BSQL_Operation/Query(src, op_id)
|
||||
|
||||
/datum/BSQL_Connection/Quote(str)
|
||||
if(!str)
|
||||
return null;
|
||||
. = world._BSQL_Internal_Call("QuoteString", id, "[str]")
|
||||
if(!.)
|
||||
BSQL_ERROR("Library failed to provide quote for [str]!")
|
||||
@@ -1,43 +0,0 @@
|
||||
/world/proc/_BSQL_Internal_Call(func, ...)
|
||||
var/list/call_args = args.Copy(2)
|
||||
BSQL_Debug("_BSQL_Internal_Call(): [args[1]]([call_args.Join(", ")])")
|
||||
. = call(_BSQL_Library_Path(), func)(arglist(call_args))
|
||||
BSQL_Debug("Result: [. == null ? "NULL" : "\"[.]\""]")
|
||||
|
||||
/world/proc/_BSQL_Library_Path()
|
||||
return system_type == MS_WINDOWS ? "BSQL.dll" : "libBSQL.so"
|
||||
|
||||
/world/proc/_BSQL_InitCheck(datum/BSQL_Connection/caller)
|
||||
var/static/library_initialized = FALSE
|
||||
if(_BSQL_Initialized())
|
||||
return
|
||||
var/libPath = _BSQL_Library_Path()
|
||||
if(!fexists(libPath))
|
||||
BSQL_DEL_CALL(caller)
|
||||
BSQL_ERROR("Could not find [libPath]!")
|
||||
return
|
||||
|
||||
var/version = _BSQL_Internal_Call("Version")
|
||||
if(version != BSQL_VERSION)
|
||||
BSQL_DEL_CALL(caller)
|
||||
BSQL_ERROR("BSQL DMAPI version mismatch! Expected [BSQL_VERSION], got [version == null ? "NULL" : version]!")
|
||||
return
|
||||
|
||||
var/result = _BSQL_Internal_Call("Initialize")
|
||||
if(result)
|
||||
BSQL_DEL_CALL(caller)
|
||||
BSQL_ERROR(result)
|
||||
return
|
||||
_BSQL_Initialized(TRUE)
|
||||
|
||||
/world/proc/_BSQL_Initialized(new_val)
|
||||
var/static/bsql_library_initialized = FALSE
|
||||
if(new_val != null)
|
||||
bsql_library_initialized = new_val
|
||||
return bsql_library_initialized
|
||||
|
||||
/world/BSQL_Shutdown()
|
||||
if(!_BSQL_Initialized())
|
||||
return
|
||||
_BSQL_Internal_Call("Shutdown")
|
||||
_BSQL_Initialized(FALSE)
|
||||
@@ -1,47 +0,0 @@
|
||||
/datum/BSQL_Operation
|
||||
var/datum/BSQL_Connection/connection
|
||||
var/id
|
||||
|
||||
BSQL_PROTECT_DATUM(/datum/BSQL_Operation)
|
||||
|
||||
/datum/BSQL_Operation/New(datum/BSQL_Connection/connection, id)
|
||||
src.connection = connection
|
||||
src.id = id
|
||||
|
||||
BSQL_DEL_PROC(/datum/BSQL_Operation)
|
||||
var/error
|
||||
if(!BSQL_IS_DELETED(connection))
|
||||
error = world._BSQL_Internal_Call("ReleaseOperation", connection.id, id)
|
||||
. = ..()
|
||||
if(error)
|
||||
BSQL_ERROR(error)
|
||||
|
||||
/datum/BSQL_Operation/IsComplete()
|
||||
if(BSQL_IS_DELETED(connection))
|
||||
return TRUE
|
||||
var/result = world._BSQL_Internal_Call("OpComplete", connection.id, id)
|
||||
if(!result)
|
||||
BSQL_ERROR("Error fetching operation [id] for connection [connection.id]!")
|
||||
return
|
||||
return result == "DONE"
|
||||
|
||||
/datum/BSQL_Operation/GetError()
|
||||
if(BSQL_IS_DELETED(connection))
|
||||
return "Connection deleted!"
|
||||
return world._BSQL_Internal_Call("GetError", connection.id, id)
|
||||
|
||||
/datum/BSQL_Operation/GetErrorCode()
|
||||
if(BSQL_IS_DELETED(connection))
|
||||
return -2
|
||||
return text2num(world._BSQL_Internal_Call("GetErrorCode", connection.id, id))
|
||||
|
||||
/datum/BSQL_Operation/WaitForCompletion()
|
||||
if(BSQL_IS_DELETED(connection))
|
||||
return
|
||||
var/error = world._BSQL_Internal_Call("BlockOnOperation", connection.id, id)
|
||||
if(error)
|
||||
if(error == "Operation timed out!") //match this with the implementation
|
||||
return FALSE
|
||||
BSQL_ERROR("Error waiting for operation [id] for connection [connection.id]! [error]")
|
||||
return
|
||||
return TRUE
|
||||
@@ -1,35 +0,0 @@
|
||||
/datum/BSQL_Operation/Query
|
||||
var/last_result_json
|
||||
var/list/last_result
|
||||
|
||||
BSQL_PROTECT_DATUM(/datum/BSQL_Operation/Query)
|
||||
|
||||
/datum/BSQL_Operation/Query/CurrentRow()
|
||||
return last_result
|
||||
|
||||
/datum/BSQL_Operation/Query/IsComplete()
|
||||
//whole different ballgame here
|
||||
if(BSQL_IS_DELETED(connection))
|
||||
return TRUE
|
||||
var/result = world._BSQL_Internal_Call("ReadyRow", connection.id, id)
|
||||
switch(result)
|
||||
if("DONE")
|
||||
//load the data
|
||||
LoadQueryResult()
|
||||
return TRUE
|
||||
if("NOTDONE")
|
||||
return FALSE
|
||||
else
|
||||
BSQL_ERROR(result)
|
||||
|
||||
/datum/BSQL_Operation/Query/WaitForCompletion()
|
||||
. = ..()
|
||||
if(.)
|
||||
LoadQueryResult()
|
||||
|
||||
/datum/BSQL_Operation/Query/proc/LoadQueryResult()
|
||||
last_result_json = world._BSQL_Internal_Call("GetRow", connection.id, id)
|
||||
if(last_result_json)
|
||||
last_result = json_decode(last_result_json)
|
||||
else
|
||||
last_result = null
|
||||
@@ -1,4 +0,0 @@
|
||||
#include "core\connection.dm"
|
||||
#include "core\library.dm"
|
||||
#include "core\operation.dm"
|
||||
#include "core\query.dm"
|
||||
@@ -98,19 +98,18 @@
|
||||
return json_encode(response)
|
||||
|
||||
/datum/tgs_api/v5/OnTopic(T)
|
||||
if(!initialized)
|
||||
return FALSE //continue world/Topic
|
||||
|
||||
var/list/params = params2list(T)
|
||||
var/json = params[DMAPI5_TOPIC_DATA]
|
||||
if(!json)
|
||||
return FALSE // continue to /world/Topic
|
||||
return FALSE
|
||||
|
||||
var/list/topic_parameters = json_decode(json)
|
||||
if(!topic_parameters)
|
||||
return TopicResponse("Invalid topic parameters json!");
|
||||
|
||||
if(!initialized)
|
||||
TGS_WARNING_LOG("Missed topic due to not being initialized: [T]")
|
||||
return TRUE // too early to handle, but it's still our responsibility
|
||||
|
||||
var/their_sCK = topic_parameters[DMAPI5_PARAMETER_ACCESS_IDENTIFIER]
|
||||
if(their_sCK != access_identifier)
|
||||
return TopicResponse("Failed to decode [DMAPI5_PARAMETER_ACCESS_IDENTIFIER] from: [json]!");
|
||||
|
||||
BIN
Binary file not shown.
@@ -28,8 +28,6 @@
|
||||
#include "code\__DEFINES\atmospherics.dm"
|
||||
#include "code\__DEFINES\atom_hud.dm"
|
||||
#include "code\__DEFINES\botany.dm"
|
||||
#include "code\__DEFINES\bsql.config.dm"
|
||||
#include "code\__DEFINES\bsql.dm"
|
||||
#include "code\__DEFINES\callbacks.dm"
|
||||
#include "code\__DEFINES\cargo.dm"
|
||||
#include "code\__DEFINES\cinematics.dm"
|
||||
@@ -1816,7 +1814,6 @@
|
||||
#include "code\modules\awaymissions\mission_code\stationCollision.dm"
|
||||
#include "code\modules\awaymissions\mission_code\undergroundoutpost45.dm"
|
||||
#include "code\modules\awaymissions\mission_code\wildwest.dm"
|
||||
#include "code\modules\bsql\includes.dm"
|
||||
#include "code\modules\buildmode\bm_mode.dm"
|
||||
#include "code\modules\buildmode\buildmode.dm"
|
||||
#include "code\modules\buildmode\buttons.dm"
|
||||
|
||||
Reference in New Issue
Block a user