Skip to content

Commit 3b10d2d

Browse files
Update TGS DMAPI
1 parent 3991d5e commit 3b10d2d

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

code/__DEFINES/tgs.dm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// tgstation-server DMAPI
22

3-
#define TGS_DMAPI_VERSION "6.0.3"
3+
#define TGS_DMAPI_VERSION "6.0.6"
44

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

@@ -102,6 +102,8 @@
102102
// #define TGS_EVENT_WORLD_REBOOT 20
103103
/// Watchdog event when TgsInitializationComplete() is called. No parameters.
104104
#define TGS_EVENT_WORLD_PRIME 21
105+
// DMAPI also doesnt implement this
106+
// #define TGS_EVENT_DREAM_DAEMON_LAUNCH 22
105107

106108
// OTHER ENUMS
107109

code/modules/tgs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This folder should be placed on it's own inside a codebase that wishes to use th
77
- The other versioned folders contain code for the different DMAPI versions.
88
- [v3210](./v3210) contains the final TGS3 API.
99
- [v4](./v4) is the legacy DMAPI 4 (Used in TGS 4.0.X versions).
10-
- [v5](./v5) is the current DMAPI version used by TGS4 >=4.1.
10+
- [v5](./v5) is the current DMAPI version used by TGS >=4.1.
1111
- [LICENSE](./LICENSE) is the MIT license for the DMAPI.
1212

1313
APIs communicate with TGS in two ways. All versions implement TGS -> DM communication using /world/Topic. DM -> TGS communication, called the bridge method, is different for each version.

code/modules/tgs/v3210/api.dm

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
#define SERVICE_RETURN_SUCCESS "SUCCESS"
3030

31+
#define TGS_FILE2LIST(filename) (splittext(trim_left(trim_right(file2text(filename))), "\n"))
32+
3133
/datum/tgs_api/v3210
3234
var/reboot_mode = REBOOT_MODE_NORMAL
3335
var/comms_key
@@ -53,9 +55,6 @@
5355
return copytext(text, 1, i + 1)
5456
return ""
5557

56-
/datum/tgs_api/v3210/proc/file2list(filename)
57-
return splittext(trim_left(trim_right(file2text(filename))), "\n")
58-
5958
/datum/tgs_api/v3210/OnWorldNew(minimum_required_security_level)
6059
. = FALSE
6160

@@ -64,13 +63,21 @@
6463
if(!instance_name)
6564
instance_name = "TG Station Server" //maybe just upgraded
6665

67-
var/list/logs = file2list(".git/logs/HEAD")
66+
var/list/logs = TGS_FILE2LIST(".git/logs/HEAD")
6867
if(logs.len)
69-
logs = splittext(logs[logs.len - 1], " ")
70-
commit = logs[2]
71-
logs = file2list(".git/logs/refs/remotes/origin/master")
68+
logs = splittext(logs[logs.len], " ")
69+
if (logs.len >= 2)
70+
commit = logs[2]
71+
else
72+
TGS_ERROR_LOG("Error parsing commit logs")
73+
74+
logs = TGS_FILE2LIST(".git/logs/refs/remotes/origin/master")
7275
if(logs.len)
73-
originmastercommit = splittext(logs[logs.len - 1], " ")[2]
76+
logs = splittext(logs[logs.len], " ")
77+
if (logs.len >= 2)
78+
originmastercommit = logs[2]
79+
else
80+
TGS_ERROR_LOG("Error parsing origin commmit logs")
7481

7582
if(world.system_type != MS_WINDOWS)
7683
TGS_ERROR_LOG("This API version is only supported on Windows. Not running on Windows. Aborting initialization!")
@@ -92,7 +99,11 @@
9299
if(skip_compat_check && !fexists(SERVICE_INTERFACE_DLL))
93100
TGS_ERROR_LOG("Service parameter present but no interface DLL detected. This is symptomatic of running a service less than version 3.1! Please upgrade.")
94101
return
102+
#if DM_VERSION >= 515
103+
call_ext(SERVICE_INTERFACE_DLL, SERVICE_INTERFACE_FUNCTION)(instance_name, command) //trust no retval
104+
#else
95105
call(SERVICE_INTERFACE_DLL, SERVICE_INTERFACE_FUNCTION)(instance_name, command) //trust no retval
106+
#endif
96107
return TRUE
97108

98109
/datum/tgs_api/v3210/OnTopic(T)
@@ -226,3 +237,5 @@
226237
#undef SERVICE_REQUEST_API_VERSION
227238

228239
#undef SERVICE_RETURN_SUCCESS
240+
241+
#undef TGS_FILE2LIST

code/modules/tgs/v5/api.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@
269269
if(!result)
270270
return
271271

272-
//okay so the standard TGS4 proceedure is: right before rebooting change the port to whatever was sent to us in the above json's data parameter
272+
//okay so the standard TGS proceedure is: right before rebooting change the port to whatever was sent to us in the above json's data parameter
273273

274274
var/port = result[DMAPI5_BRIDGE_RESPONSE_NEW_PORT]
275275
if(!isnum(port))

0 commit comments

Comments
 (0)