Files
vgstation13/code/libs/BSQL/core/connection.dm
DamianX 85ff9b697a Fixed a bunch of warnings and errors (#26993)
* renamed implant malfunction defines

* refactored domutation

* possibly fix something about whitelists

* fix admin_memo warning

* fixed wrong attackby parameters in click.dm

* remove superfluous return in BSQL

* maybe fix something in mob/add_language

* maybe fix more language stuff

* Added return-type annotation to job_controller

* removed unreachable code from observer.dm

* possibly fix electrocute_act

* fixed bees wow this code never ran, 100% tested

* fixed parrot life

* fixed wolf attack logs

* fix bear life

* removed unreachable slime/show_inv

* fixed human/electrocute_act

* actually just get rid of this shit

* properly add return types

* removed more returns from BSQL

* added get_organ return type

* fixed infrared holder_movement

* fixed type_instances declaration

* fixed unreacheable overlay/New

* possibly fix release_restraints

* remove hopefully final return from BSQL
2020-07-01 09:46:00 -03:00

64 lines
1.9 KiB
Plaintext

/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)
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)
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 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)
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 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]!")