Skip to content

Commit 73b528b

Browse files
rdraganTheChosenEvilOneLemonInTheDark
authored
515 Update (#346)
* fix compile errors * update rust_g.dm and a bunch of proc refs * update proc refs * update more proc refs * update more proc refs * update more proc refs * update global proc refs * remove CALLBACK_NEW * update INVOKE_ASYNC * tgui update * global proc ref fixes * lazy tgui update + DM fixes * fix some more interfaces * Moves ui references from the tgui subsystem to datums themselves (#76215) Unused vars have 0 memory cost, and the ref and list lookup here is REALLY expensive, for both init and foam spreading. Saves 0.2s off a station flood on meta, and 0.17s off init. More time in other qdel heavy areas Pulled off #76104 for the sake of cleanliness * finally fix tgui * forgot ping.dm * more UI fixes * more context var removals * why do NumberInput be like this? * Broke this three weeks ago. * fix tgui alerts * update byond dependency * update node version * update DreamAnnotate * fix constants test * linter appeasement * pwease * fluid * updated build/lib/yarn.js * actual linter appeasement * restore CameraConsole CSS classes * remove tgui-say; not used, never will be. * update yarn.lock * UI fixes * another patch * playtimes --------- Co-authored-by: TheChosenEvilOne <[email protected]> Co-authored-by: LemonInTheDark <[email protected]>
1 parent 6d9e755 commit 73b528b

File tree

817 files changed

+30600
-19180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

817 files changed

+30600
-19180
lines changed

.github/workflows/ci_suite.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
tools/bootstrap/python -m mapmerge2.dmm_test
4444
~/dreamchecker > ${GITHUB_WORKSPACE}/output-annotations.txt 2>&1
4545
- name: Annotate Lints
46-
uses: yogstation13/DreamAnnotate@v1
46+
uses: yogstation13/DreamAnnotate@v2
4747
if: always()
4848
with:
4949
outputFile: output-annotations.txt
@@ -79,10 +79,10 @@ jobs:
7979
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
8080
steps:
8181
- uses: actions/checkout@v3
82-
- name: Use Node.js 14.16.1
82+
- name: Use Node.js 20.13.1
8383
uses: actions/setup-node@v3
8484
with:
85-
node-version: 14.16.1
85+
node-version: 20.13.1
8686
- name: Restore BYOND cache
8787
uses: actions/cache@v3
8888
with:
@@ -122,10 +122,10 @@ jobs:
122122
runs-on: windows-latest
123123
steps:
124124
- uses: actions/checkout@v3
125-
- name: Use Node.js 14.16.1
125+
- name: Use Node.js 20.13.1
126126
uses: actions/setup-node@v3
127127
with:
128-
node-version: 14.16.1
128+
node-version: 20.13.1
129129
- name: Restore Yarn cache
130130
uses: actions/cache@v3
131131
with:

code/__DEFINES/MC.dm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#define START_PROCESSING(Processor, Datum) if (!(Datum.datum_flags & DF_ISPROCESSING)) {Datum.datum_flags |= DF_ISPROCESSING;Processor.processing += Datum}
2323
#define STOP_PROCESSING(Processor, Datum) Datum.datum_flags &= ~DF_ISPROCESSING;Processor.processing -= Datum
2424

25+
#define MC_RUNNING(INIT_STAGE...) (Master && Master.processing > 0 && Master.current_runlevel && Master.init_stage_completed == (max(min(INITSTAGE_MAX, ##INIT_STAGE), 1)))
26+
2527
//! SubSystem flags (Please design any new flags so that the default is off, to make adding flags to subsystems easier)
2628

2729
/// subsystem does not initialize.

code/__DEFINES/callbacks.dm

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
#define GLOBAL_PROC "some_magic_bullshit"
22
/// A shorthand for the callback datum, [documented here](datum/callback.html)
33
#define CALLBACK new /datum/callback
4-
#define INVOKE_ASYNC world.ImmediateInvokeAsync
5-
#define CALLBACK_NEW(typepath, args) CALLBACK(GLOBAL_PROC, /proc/___callbacknew, typepath, args)
4+
5+
///Per the DM reference, spawn(-1) will execute the spawned code immediately until a block is met.
6+
#define MAKE_SPAWN_ACT_LIKE_WAITFOR -1
7+
///Create a codeblock that will not block the callstack if a block is met.
8+
#define ASYNC spawn(MAKE_SPAWN_ACT_LIKE_WAITFOR)
9+
10+
#define INVOKE_ASYNC(proc_owner, proc_path, proc_arguments...) \
11+
if ((proc_owner) == GLOBAL_PROC) { \
12+
ASYNC { \
13+
call(proc_path)(##proc_arguments); \
14+
}; \
15+
} \
16+
else { \
17+
ASYNC { \
18+
/* Written with `0 ||` to avoid the compiler seeing call("string"), and thinking it's a deprecated DLL */ \
19+
call(0 || proc_owner, proc_path)(##proc_arguments); \
20+
}; \
21+
}
22+
23+
/// like CALLBACK but specifically for verb callbacks
24+
#define VERB_CALLBACK new /datum/callback/verb_callback

code/__DEFINES/chat.dm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
* SPDX-License-Identifier: MIT
44
*/
55

6+
/// How many chat payloads to keep in history
7+
#define CHAT_RELIABILITY_HISTORY_SIZE 5
8+
/// How many resends to allow before giving up
9+
#define CHAT_RELIABILITY_MAX_RESENDS 3
10+
611
#define MESSAGE_TYPE_SYSTEM "system"
712
#define MESSAGE_TYPE_LOCALCHAT "localchat"
813
#define MESSAGE_TYPE_RADIO "radio"

code/__DEFINES/cooldowns.dm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#define COMSIG_CD_STOP(cd_index) "cooldown_[cd_index]"
5555
#define COMSIG_CD_RESET(cd_index) "cd_reset_[cd_index]"
5656

57-
#define TIMER_COOLDOWN_START(cd_source, cd_index, cd_time) LAZYSET(cd_source.cooldowns, cd_index, addtimer(CALLBACK(GLOBAL_PROC, /proc/end_cooldown, cd_source, cd_index), cd_time))
57+
#define TIMER_COOLDOWN_START(cd_source, cd_index, cd_time) LAZYSET(cd_source.cooldowns, cd_index, addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(end_cooldown), cd_source, cd_index), cd_time))
5858

5959
#define TIMER_COOLDOWN_CHECK(cd_source, cd_index) LAZYACCESS(cd_source.cooldowns, cd_index)
6060

@@ -67,7 +67,7 @@
6767
* A bit more expensive than the regular timers, but can be reset before they end and the time left can be checked.
6868
*/
6969

70-
#define S_TIMER_COOLDOWN_START(cd_source, cd_index, cd_time) LAZYSET(cd_source.cooldowns, cd_index, addtimer(CALLBACK(GLOBAL_PROC, /proc/end_cooldown, cd_source, cd_index), cd_time, TIMER_STOPPABLE))
70+
#define S_TIMER_COOLDOWN_START(cd_source, cd_index, cd_time) LAZYSET(cd_source.cooldowns, cd_index, addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(end_cooldown), cd_source, cd_index), cd_time, TIMER_STOPPABLE))
7171

7272
#define S_TIMER_COOLDOWN_RESET(cd_source, cd_index) reset_cooldown(cd_source, cd_index)
7373

code/__DEFINES/rust_g.dm

Lines changed: 116 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,58 @@
3838
#define RUST_G (__rust_g || __detect_rust_g())
3939
#endif
4040

41+
// Handle 515 call() -> call_ext() changes
42+
#if DM_VERSION >= 515
43+
#define RUSTG_CALL call_ext
44+
#else
45+
#define RUSTG_CALL call
46+
#endif
47+
4148
/// Gets the version of rust_g
42-
/proc/rustg_get_version() return call(RUST_G, "get_version")()
49+
/proc/rustg_get_version() return RUSTG_CALL(RUST_G, "get_version")()
50+
51+
52+
/**
53+
* Sets up the Aho-Corasick automaton with its default options.
54+
*
55+
* 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
56+
* Arguments:
57+
* * key - The key for the automaton, to be used with subsequent rustg_acreplace/rustg_acreplace_with_replacements calls
58+
* * patterns - A non-associative list of strings to search for
59+
* * replacements - Default replacements for this automaton, used with rustg_acreplace
60+
*/
61+
#define rustg_setup_acreplace(key, patterns, replacements) RUSTG_CALL(RUST_G, "setup_acreplace")(key, json_encode(patterns), json_encode(replacements))
62+
63+
/**
64+
* Sets up the Aho-Corasick automaton using supplied options.
65+
*
66+
* 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
67+
* Arguments:
68+
* * key - The key for the automaton, to be used with subsequent rustg_acreplace/rustg_acreplace_with_replacements calls
69+
* * 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.
70+
* * patterns - A non-associative list of strings to search for
71+
* * replacements - Default replacements for this automaton, used with rustg_acreplace
72+
*/
73+
#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))
74+
75+
/**
76+
* Run the specified replacement engine with the provided haystack text to replace, returning replaced text.
77+
*
78+
* Arguments:
79+
* * key - The key for the automaton
80+
* * text - Text to run replacements on
81+
*/
82+
#define rustg_acreplace(key, text) RUSTG_CALL(RUST_G, "acreplace")(key, text)
83+
84+
/**
85+
* Run the specified replacement engine with the provided haystack text to replace, returning replaced text.
86+
*
87+
* Arguments:
88+
* * key - The key for the automaton
89+
* * text - Text to run replacements on
90+
* * replacements - Replacements for this call. Must be the same length as the set-up patterns
91+
*/
92+
#define rustg_acreplace_with_replacements(key, text, replacements) RUSTG_CALL(RUST_G, "acreplace_with_replacements")(key, text, json_encode(replacements))
4393

4494
/**
4595
* This proc generates a cellular automata noise grid which can be used in procedural generation methods.
@@ -55,55 +105,95 @@
55105
* * height: The height of the grid.
56106
*/
57107
#define rustg_cnoise_generate(percentage, smoothing_iterations, birth_limit, death_limit, width, height) \
58-
call(RUST_G, "cnoise_generate")(percentage, smoothing_iterations, birth_limit, death_limit, width, height)
108+
RUSTG_CALL(RUST_G, "cnoise_generate")(percentage, smoothing_iterations, birth_limit, death_limit, width, height)
59109

60-
#define rustg_dmi_strip_metadata(fname) call(RUST_G, "dmi_strip_metadata")(fname)
61-
#define rustg_dmi_create_png(path, width, height, data) call(RUST_G, "dmi_create_png")(path, width, height, data)
62-
#define rustg_dmi_resize_png(path, width, height, resizetype) call(RUST_G, "dmi_resize_png")(path, width, height, resizetype)
110+
#define rustg_dmi_strip_metadata(fname) RUSTG_CALL(RUST_G, "dmi_strip_metadata")(fname)
111+
#define rustg_dmi_create_png(path, width, height, data) RUSTG_CALL(RUST_G, "dmi_create_png")(path, width, height, data)
112+
#define rustg_dmi_resize_png(path, width, height, resizetype) RUSTG_CALL(RUST_G, "dmi_resize_png")(path, width, height, resizetype)
113+
/**
114+
* 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.
115+
*
116+
* output: json_encode'd list. json_decode to get a flat list with icon states in the order they're in inside the .dmi
117+
*/
118+
#define rustg_dmi_icon_states(fname) RUSTG_CALL(RUST_G, "dmi_icon_states")(fname)
63119

64-
#define rustg_file_read(fname) call(RUST_G, "file_read")(fname)
65-
#define rustg_file_exists(fname) call(RUST_G, "file_exists")(fname)
66-
#define rustg_file_write(text, fname) call(RUST_G, "file_write")(text, fname)
67-
#define rustg_file_append(text, fname) call(RUST_G, "file_append")(text, fname)
120+
#define rustg_file_read(fname) RUSTG_CALL(RUST_G, "file_read")(fname)
121+
#define rustg_file_exists(fname) (RUSTG_CALL(RUST_G, "file_exists")(fname) == "true")
122+
#define rustg_file_write(text, fname) RUSTG_CALL(RUST_G, "file_write")(text, fname)
123+
#define rustg_file_append(text, fname) RUSTG_CALL(RUST_G, "file_append")(text, fname)
124+
#define rustg_file_get_line_count(fname) text2num(RUSTG_CALL(RUST_G, "file_get_line_count")(fname))
125+
#define rustg_file_seek_line(fname, line) RUSTG_CALL(RUST_G, "file_seek_line")(fname, "[line]")
68126

69127
#ifdef RUSTG_OVERRIDE_BUILTINS
70128
#define file2text(fname) rustg_file_read("[fname]")
71129
#define text2file(text, fname) rustg_file_append(text, "[fname]")
72130
#endif
73131

74-
#define rustg_git_revparse(rev) call(RUST_G, "rg_git_revparse")(rev)
75-
#define rustg_git_commit_date(rev) call(RUST_G, "rg_git_commit_date")(rev)
132+
/// Returns the git hash of the given revision, ex. "HEAD".
133+
#define rustg_git_revparse(rev) RUSTG_CALL(RUST_G, "rg_git_revparse")(rev)
134+
135+
/**
136+
* Returns the date of the given revision in the format YYYY-MM-DD.
137+
* Returns null if the revision is invalid.
138+
*/
139+
#define rustg_git_commit_date(rev) RUSTG_CALL(RUST_G, "rg_git_commit_date")(rev)
76140

77141
#define RUSTG_HTTP_METHOD_GET "get"
78142
#define RUSTG_HTTP_METHOD_PUT "put"
79143
#define RUSTG_HTTP_METHOD_DELETE "delete"
80144
#define RUSTG_HTTP_METHOD_PATCH "patch"
81145
#define RUSTG_HTTP_METHOD_HEAD "head"
82146
#define RUSTG_HTTP_METHOD_POST "post"
83-
#define rustg_http_request_blocking(method, url, body, headers, options) call(RUST_G, "http_request_blocking")(method, url, body, headers, options)
84-
#define rustg_http_request_async(method, url, body, headers, options) call(RUST_G, "http_request_async")(method, url, body, headers, options)
85-
#define rustg_http_check_request(req_id) call(RUST_G, "http_check_request")(req_id)
147+
#define rustg_http_request_blocking(method, url, body, headers, options) RUSTG_CALL(RUST_G, "http_request_blocking")(method, url, body, headers, options)
148+
#define rustg_http_request_async(method, url, body, headers, options) RUSTG_CALL(RUST_G, "http_request_async")(method, url, body, headers, options)
149+
#define rustg_http_check_request(req_id) RUSTG_CALL(RUST_G, "http_check_request")(req_id)
86150

87151
#define RUSTG_JOB_NO_RESULTS_YET "NO RESULTS YET"
88152
#define RUSTG_JOB_NO_SUCH_JOB "NO SUCH JOB"
89153
#define RUSTG_JOB_ERROR "JOB PANICKED"
90154

91-
#define rustg_json_is_valid(text) (call(RUST_G, "json_is_valid")(text) == "true")
155+
#define rustg_json_is_valid(text) (RUSTG_CALL(RUST_G, "json_is_valid")(text) == "true")
156+
157+
#define rustg_log_write(fname, text, format) RUSTG_CALL(RUST_G, "log_write")(fname, text, format)
158+
/proc/rustg_log_close_all() return RUSTG_CALL(RUST_G, "log_close_all")()
159+
160+
#define rustg_noise_get_at_coordinates(seed, x, y) RUSTG_CALL(RUST_G, "noise_get_at_coordinates")(seed, x, y)
161+
162+
#define rustg_sql_connect_pool(options) RUSTG_CALL(RUST_G, "sql_connect_pool")(options)
163+
#define rustg_sql_query_async(handle, query, params) RUSTG_CALL(RUST_G, "sql_query_async")(handle, query, params)
164+
#define rustg_sql_query_blocking(handle, query, params) RUSTG_CALL(RUST_G, "sql_query_blocking")(handle, query, params)
165+
#define rustg_sql_connected(handle) RUSTG_CALL(RUST_G, "sql_connected")(handle)
166+
#define rustg_sql_disconnect_pool(handle) RUSTG_CALL(RUST_G, "sql_disconnect_pool")(handle)
167+
#define rustg_sql_check_query(job_id) RUSTG_CALL(RUST_G, "sql_check_query")("[job_id]")
168+
169+
#define rustg_time_microseconds(id) text2num(RUSTG_CALL(RUST_G, "time_microseconds")(id))
170+
#define rustg_time_milliseconds(id) text2num(RUSTG_CALL(RUST_G, "time_milliseconds")(id))
171+
#define rustg_time_reset(id) RUSTG_CALL(RUST_G, "time_reset")(id)
92172

93-
#define rustg_log_write(fname, text, format) call(RUST_G, "log_write")(fname, text, format)
94-
/proc/rustg_log_close_all() return call(RUST_G, "log_close_all")()
173+
/// Returns the timestamp as a string
174+
/proc/rustg_unix_timestamp()
175+
return RUSTG_CALL(RUST_G, "unix_timestamp")()
95176

96-
#define rustg_noise_get_at_coordinates(seed, x, y) call(RUST_G, "noise_get_at_coordinates")(seed, x, y)
177+
#define rustg_raw_read_toml_file(path) json_decode(RUSTG_CALL(RUST_G, "toml_file_to_json")(path) || "null")
97178

98-
#define rustg_sql_connect_pool(options) call(RUST_G, "sql_connect_pool")(options)
99-
#define rustg_sql_query_async(handle, query, params) call(RUST_G, "sql_query_async")(handle, query, params)
100-
#define rustg_sql_query_blocking(handle, query, params) call(RUST_G, "sql_query_blocking")(handle, query, params)
101-
#define rustg_sql_connected(handle) call(RUST_G, "sql_connected")(handle)
102-
#define rustg_sql_disconnect_pool(handle) call(RUST_G, "sql_disconnect_pool")(handle)
103-
#define rustg_sql_check_query(job_id) call(RUST_G, "sql_check_query")("[job_id]")
179+
/proc/rustg_read_toml_file(path)
180+
var/list/output = rustg_raw_read_toml_file(path)
181+
if (output["success"])
182+
return json_decode(output["content"])
183+
else
184+
CRASH(output["content"])
185+
186+
#define rustg_raw_toml_encode(value) json_decode(RUSTG_CALL(RUST_G, "toml_encode")(json_encode(value)))
187+
188+
/proc/rustg_toml_encode(value)
189+
var/list/output = rustg_raw_toml_encode(value)
190+
if (output["success"])
191+
return output["content"]
192+
else
193+
CRASH(output["content"])
104194

105-
#define rustg_url_encode(text) call(RUST_G, "url_encode")(text)
106-
#define rustg_url_decode(text) call(RUST_G, "url_decode")(text)
195+
#define rustg_url_encode(text) RUSTG_CALL(RUST_G, "url_encode")("[text]")
196+
#define rustg_url_decode(text) RUSTG_CALL(RUST_G, "url_decode")(text)
107197

108198
#ifdef RUSTG_OVERRIDE_BUILTINS
109199
#define url_encode(text) rustg_url_encode(text)

code/__DEFINES/spaceman_dmm.dm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
/world/proc/enable_debugger()
4141
var/dll = world.GetConfig("env", "AUXTOOLS_DEBUG_DLL")
4242
if (dll)
43-
call(dll, "auxtools_init")()
43+
call_ext(dll, "auxtools_init")()
4444
enable_debugging()
4545

4646
/world/Del()
4747
var/debug_server = world.GetConfig("env", "AUXTOOLS_DEBUG_DLL")
4848
if (debug_server)
49-
call(debug_server, "auxtools_shutdown")()
49+
call_ext(debug_server, "auxtools_shutdown")()
5050
. = ..()

code/__DEFINES/subsystems.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
// Subsystem fire priority, from lowest to highest priority
160160
// If the subsystem isn't listed here it's either DEFAULT or PROCESS (if it's a processing subsystem child)
161161

162+
#define FIRE_PRIORITY_PING 10
162163
#define FIRE_PRIORITY_IDLE_NPC 10
163164
#define FIRE_PRIORITY_SERVER_MAINT 10
164165
#define FIRE_PRIORITY_RESEARCH 10

code/__DEFINES/tgui.dm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
/// Maximum ping timeout allowed to detect zombie windows
1616
#define TGUI_PING_TIMEOUT 4 SECONDS
17+
/// Used for rate-limiting to prevent DoS by excessively refreshing a TGUI window
18+
#define TGUI_REFRESH_FULL_UPDATE_COOLDOWN (1 SECONDS)
1719

1820
/// Window does not exist
1921
#define TGUI_WINDOW_CLOSED 0

code/__HELPERS/game.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@
335335
/proc/flick_overlay(image/I, list/show_to, duration)
336336
for(var/client/C in show_to)
337337
C.images += I
338-
addtimer(CALLBACK(GLOBAL_PROC, /proc/remove_images_from_clients, I, show_to), duration, TIMER_CLIENT_TIME)
338+
addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(remove_images_from_clients), I, show_to), duration, TIMER_CLIENT_TIME)
339339

340340
/proc/flick_overlay_view(image/I, atom/target, duration) //wrapper for the above, flicks to everyone who can see the target atom
341341
var/list/viewing = list()

0 commit comments

Comments
 (0)