Skip to content

Commit

Permalink
Automatic TGS DMAPI Update (#4779)
Browse files Browse the repository at this point in the history
This pull request updates the TGS DMAPI to the latest version. Please
note any breaking or unimplemented changes before merging.

Co-authored-by: tgstation-server <[email protected]>
  • Loading branch information
cm13-github and tgstation-server committed Oct 26, 2023
1 parent c590d11 commit c1563b8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion code/__DEFINES/tgs.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// tgstation-server DMAPI

#define TGS_DMAPI_VERSION "6.6.0"
#define TGS_DMAPI_VERSION "6.6.1"

// All functions and datums outside this document are subject to change with any version and should not be relied on.

Expand Down
4 changes: 4 additions & 0 deletions code/modules/tgs/core/datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ TGS_DEFINE_AND_SET_GLOBAL(tgs, null)
src.event_handler = event_handler
src.version = version

/datum/tgs_api/proc/TerminateWorld()
del(world)
sleep(1) // https://www.byond.com/forum/post/2894866

/datum/tgs_api/latest
parent_type = /datum/tgs_api/v5

Expand Down
10 changes: 5 additions & 5 deletions code/modules/tgs/v4/api.dm
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
if(cached_json["apiValidateOnly"])
TGS_INFO_LOG("Validating API and exiting...")
Export(TGS4_COMM_VALIDATE, list(TGS4_PARAMETER_DATA = "[minimum_required_security_level]"))
del(world)
TerminateWorld()

security_level = cached_json["securityLevel"]
chat_channels_json_path = cached_json["chatChannelsJson"]
Expand Down Expand Up @@ -188,24 +188,24 @@
requesting_new_port = TRUE
if(!world.OpenPort(0)) //open any port
TGS_ERROR_LOG("Unable to open random port to retrieve new port![TGS4_PORT_CRITFAIL_MESSAGE]")
del(world)
TerminateWorld()

//request a new port
export_lock = FALSE
var/list/new_port_json = Export(TGS4_COMM_NEW_PORT, list(TGS4_PARAMETER_DATA = "[world.port]"), TRUE) //stringify this on purpose

if(!new_port_json)
TGS_ERROR_LOG("No new port response from server![TGS4_PORT_CRITFAIL_MESSAGE]")
del(world)
TerminateWorld()

var/new_port = new_port_json[TGS4_PARAMETER_DATA]
if(!isnum(new_port) || new_port <= 0)
TGS_ERROR_LOG("Malformed new port json ([json_encode(new_port_json)])![TGS4_PORT_CRITFAIL_MESSAGE]")
del(world)
TerminateWorld()

if(new_port != world.port && !world.OpenPort(new_port))
TGS_ERROR_LOG("Unable to open port [new_port]![TGS4_PORT_CRITFAIL_MESSAGE]")
del(world)
TerminateWorld()
requesting_new_port = FALSE

while(export_lock)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/tgs/v5/api.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

if(runtime_information[DMAPI5_RUNTIME_INFORMATION_API_VALIDATE_ONLY])
TGS_INFO_LOG("DMAPI validation, exiting...")
del(world)
TerminateWorld()

version = new /datum/tgs_version(runtime_information[DMAPI5_RUNTIME_INFORMATION_SERVER_VERSION])
security_level = runtime_information[DMAPI5_RUNTIME_INFORMATION_SECURITY_LEVEL]
Expand Down

0 comments on commit c1563b8

Please sign in to comment.