Skip to content

Commit

Permalink
Merge pull request #4274 from GremlingSS/TalkingCactus-515-compat
Browse files Browse the repository at this point in the history
Talking cactus 515 compat but I take over.
  • Loading branch information
Tk420634 authored Mar 10, 2024
2 parents bbfde56 + 7b77b7b commit 565a868
Show file tree
Hide file tree
Showing 963 changed files with 3,070 additions and 3,039 deletions.
10 changes: 6 additions & 4 deletions SpacemanDMM.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
environment = "fortune13.dme"

[langserver]
dreamchecker = true

[debugger]
engine = "auxtools"

#[code_standards]
[code_standards]
disallow_relative_type_definitions = true
disallow_relative_proc_definitions = true

[dmdoc]
use_typepath_names = true

[debugger]
engine = "auxtools"
2 changes: 1 addition & 1 deletion arfsuits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4831,7 +4831,7 @@
emped = TRUE
slowdown += induced_slowdown
L.update_equipment_speed_mods()
addtimer(CALLBACK(src, .proc/end_emp_effect, induced_slowdown), 50)
addtimer(CALLBACK(src, PROC_REF(end_emp_effect), induced_slowdown), 50)
return

/obj/item/clothing/suit/armor/power_armor/proc/end_emp_effect(slowdown_induced)
Expand Down
2 changes: 1 addition & 1 deletion code/__DEFINES/callbacks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// A shorthand for the callback datum, [documented here](datum/callback.html)
#define CALLBACK new /datum/callback
#define INVOKE_ASYNC world.ImmediateInvokeAsync
#define CALLBACK_NEW(typepath, args) CALLBACK(GLOBAL_PROC, /proc/___callbacknew, typepath, args)
#define CALLBACK_NEW(typepath, args) CALLBACK(usr, GLOBAL_PROC_REF(___callbacknew), typepath, args)
4 changes: 2 additions & 2 deletions code/__DEFINES/cooldowns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#define COMSIG_CD_STOP(cd_index) "cooldown_[cd_index]"
#define COMSIG_CD_RESET(cd_index) "cd_reset_[cd_index]"

#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))
#define TIMER_COOLDOWN_START(cd_source, cd_index, cd_time) LAZYSET(cd_source.cooldowns, cd_index, addtimer(CALLBACK(usr, GLOBAL_PROC_REF(end_cooldown), cd_source, cd_index), cd_time))

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

Expand All @@ -47,7 +47,7 @@
* A bit more expensive than the regular timers, but can be reset before they end and the time left can be checked.
*/

#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))
#define S_TIMER_COOLDOWN_START(cd_source, cd_index, cd_time) LAZYSET(cd_source.cooldowns, cd_index, addtimer(CALLBACK(usr, GLOBAL_PROC_REF(end_cooldown), cd_source, cd_index), cd_time, TIMER_STOPPABLE))

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

Expand Down
6 changes: 3 additions & 3 deletions code/__DEFINES/qdel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
#define QDELETED(X) (!X || QDELING(X))
#define QDESTROYING(X) (!X || X.gc_destroyed == GC_CURRENTLY_BEING_QDELETED)

#define QDEL_IN(item, time) addtimer(CALLBACK(GLOBAL_PROC, .proc/qdel, (time) > GC_FILTER_QUEUE ? WEAKREF(item) : item), time, TIMER_STOPPABLE)
#define QDEL_IN_CLIENT_TIME(item, time) addtimer(CALLBACK(GLOBAL_PROC, .proc/qdel, item), time, TIMER_STOPPABLE | TIMER_CLIENT_TIME)
#define QDEL_IN(item, time) addtimer(CALLBACK(usr, GLOBAL_PROC_REF(qdel), (time) > GC_FILTER_QUEUE ? WEAKREF(item) : item), time, TIMER_STOPPABLE)
#define QDEL_IN_CLIENT_TIME(item, time) addtimer(CALLBACK(usr, GLOBAL_PROC_REF(qdel), item), time, TIMER_STOPPABLE | TIMER_CLIENT_TIME)
#define QDEL_NULL(item) qdel(item); item = null
#define QDEL_LIST(L) if(L) { for(var/I in L) qdel(I); L.Cut(); }
#define QDEL_LIST_IN(L, time) addtimer(CALLBACK(GLOBAL_PROC, .proc/______qdel_list_wrapper, L), time, TIMER_STOPPABLE)
#define QDEL_LIST_IN(L, time) addtimer(CALLBACK(usr, GLOBAL_PROC_REF(______qdel_list_wrapper), L), time, TIMER_STOPPABLE)
#define QDEL_LIST_ASSOC(L) if(L) { for(var/I in L) { qdel(L[I]); qdel(I); } L.Cut(); }
#define QDEL_LIST_ASSOC_VAL(L) if(L) { for(var/I in L) qdel(L[I]); L.Cut(); }

Expand Down
84 changes: 42 additions & 42 deletions code/__DEFINES/rust_g.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,31 @@
#endif

/// Gets the version of rust_g
/proc/rustg_get_version() return call(RUST_G, "get_version")()
/proc/rustg_get_version() return LIBCALL(RUST_G, "get_version")()


/**
* Sets up the Aho-Corasick automaton with its default options.
*
* 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
* 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 LIBCALL
* Arguments:
* * key - The key for the automaton, to be used with subsequent rustg_acreplace/rustg_acreplace_with_replacements calls
* * key - The key for the automaton, to be used with subsequent rustg_acreplace/rustg_acreplace_with_replacements LIBCALLs
* * patterns - A non-associative list of strings to search for
* * replacements - Default replacements for this automaton, used with rustg_acreplace
*/
#define rustg_setup_acreplace(key, patterns, replacements) call(RUST_G, "setup_acreplace")(key, json_encode(patterns), json_encode(replacements))
#define rustg_setup_acreplace(key, patterns, replacements) LIBCALL(RUST_G, "setup_acreplace")(key, json_encode(patterns), json_encode(replacements))

/**
* Sets up the Aho-Corasick automaton using supplied options.
*
* 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
* 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 LIBCALL
* Arguments:
* * key - The key for the automaton, to be used with subsequent rustg_acreplace/rustg_acreplace_with_replacements calls
* * 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.
* * key - The key for the automaton, to be used with subsequent rustg_acreplace/rustg_acreplace_with_replacements LIBCALLs
* * 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 identiLIBCALLy named methods at https://docs.rs/aho-corasick/latest/aho_corasick/struct.AhoCorasickBuilder.html to see what the options do.
* * patterns - A non-associative list of strings to search for
* * replacements - Default replacements for this automaton, used with rustg_acreplace
*/
#define rustg_setup_acreplace_with_options(key, options, patterns, replacements) call(RUST_G, "setup_acreplace")(key, json_encode(options), json_encode(patterns), json_encode(replacements))
#define rustg_setup_acreplace_with_options(key, options, patterns, replacements) LIBCALL(RUST_G, "setup_acreplace")(key, json_encode(options), json_encode(patterns), json_encode(replacements))

/**
* Run the specified replacement engine with the provided haystack text to replace, returning replaced text.
Expand All @@ -72,17 +72,17 @@
* * key - The key for the automaton
* * text - Text to run replacements on
*/
#define rustg_acreplace(key, text) call(RUST_G, "acreplace")(key, text)
#define rustg_acreplace(key, text) LIBCALL(RUST_G, "acreplace")(key, text)

/**
* Run the specified replacement engine with the provided haystack text to replace, returning replaced text.
*
* Arguments:
* * key - The key for the automaton
* * text - Text to run replacements on
* * replacements - Replacements for this call. Must be the same length as the set-up patterns
* * replacements - Replacements for this LIBCALL. Must be the same length as the set-up patterns
*/
#define rustg_acreplace_with_replacements(key, text, replacements) call(RUST_G, "acreplace_with_replacements")(key, text, json_encode(replacements))
#define rustg_acreplace_with_replacements(key, text, replacements) LIBCALL(RUST_G, "acreplace_with_replacements")(key, text, json_encode(replacements))

/**
* This proc generates a cellular automata noise grid which can be used in procedural generation methods.
Expand All @@ -98,63 +98,63 @@
* * 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)
LIBCALL(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_dmi_strip_metadata(fname) LIBCALL(RUST_G, "dmi_strip_metadata")(fname)
#define rustg_dmi_create_png(path, width, height, data) LIBCALL(RUST_G, "dmi_create_png")(path, width, height, data)
#define rustg_dmi_resize_png(path, width, height, resizetype) LIBCALL(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)
#define rustg_file_get_line_count(fname) text2num(call(RUST_G, "file_get_line_count")(fname))
#define rustg_file_seek_line(fname, line) call(RUST_G, "file_seek_line")(fname, "[line]")
#define rustg_file_read(fname) LIBCALL(RUST_G, "file_read")(fname)
#define rustg_file_exists(fname) LIBCALL(RUST_G, "file_exists")(fname)
#define rustg_file_write(text, fname) LIBCALL(RUST_G, "file_write")(text, fname)
#define rustg_file_append(text, fname) LIBCALL(RUST_G, "file_append")(text, fname)
#define rustg_file_get_line_count(fname) text2num(LIBCALL(RUST_G, "file_get_line_count")(fname))
#define rustg_file_seek_line(fname, line) LIBCALL(RUST_G, "file_seek_line")(fname, "[line]")

#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_git_revparse(rev) LIBCALL(RUST_G, "rg_git_revparse")(rev)
#define rustg_git_commit_date(rev) LIBCALL(RUST_G, "rg_git_commit_date")(rev)

#define RUSTG_HTTP_METHOD_GET "get"
#define RUSTG_HTTP_METHOD_PUT "put"
#define RUSTG_HTTP_METHOD_DELETE "delete"
#define RUSTG_HTTP_METHOD_PATCH "patch"
#define RUSTG_HTTP_METHOD_HEAD "head"
#define RUSTG_HTTP_METHOD_POST "post"
#define rustg_http_request_blocking(method, url, body, headers, options) call(RUST_G, "http_request_blocking")(method, url, body, headers, options)
#define rustg_http_request_async(method, url, body, headers, options) call(RUST_G, "http_request_async")(method, url, body, headers, options)
#define rustg_http_check_request(req_id) call(RUST_G, "http_check_request")(req_id)
#define rustg_http_request_blocking(method, url, body, headers, options) LIBCALL(RUST_G, "http_request_blocking")(method, url, body, headers, options)
#define rustg_http_request_async(method, url, body, headers, options) LIBCALL(RUST_G, "http_request_async")(method, url, body, headers, options)
#define rustg_http_check_request(req_id) LIBCALL(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_json_is_valid(text) (LIBCALL(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_log_write(fname, text, format) LIBCALL(RUST_G, "log_write")(fname, text, format)
/proc/rustg_log_close_all() return LIBCALL(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_noise_get_at_coordinates(seed, x, y) LIBCALL(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]")
#define rustg_sql_connect_pool(options) LIBCALL(RUST_G, "sql_connect_pool")(options)
#define rustg_sql_query_async(handle, query, params) LIBCALL(RUST_G, "sql_query_async")(handle, query, params)
#define rustg_sql_query_blocking(handle, query, params) LIBCALL(RUST_G, "sql_query_blocking")(handle, query, params)
#define rustg_sql_connected(handle) LIBCALL(RUST_G, "sql_connected")(handle)
#define rustg_sql_disconnect_pool(handle) LIBCALL(RUST_G, "sql_disconnect_pool")(handle)
#define rustg_sql_check_query(job_id) LIBCALL(RUST_G, "sql_check_query")("[job_id]")

#define rustg_time_microseconds(id) text2num(call(RUST_G, "time_microseconds")(id))
#define rustg_time_milliseconds(id) text2num(call(RUST_G, "time_milliseconds")(id))
#define rustg_time_reset(id) call(RUST_G, "time_reset")(id)
#define rustg_time_microseconds(id) text2num(LIBCALL(RUST_G, "time_microseconds")(id))
#define rustg_time_milliseconds(id) text2num(LIBCALL(RUST_G, "time_milliseconds")(id))
#define rustg_time_reset(id) LIBCALL(RUST_G, "time_reset")(id)

#define rustg_read_toml_file(path) json_decode(call(RUST_G, "toml_file_to_json")(path) || "null")
#define rustg_read_toml_file(path) json_decode(LIBCALL(RUST_G, "toml_file_to_json")(path) || "null")

#define rustg_url_encode(text) call(RUST_G, "url_encode")("[text]")
#define rustg_url_decode(text) call(RUST_G, "url_decode")(text)
#define rustg_url_encode(text) LIBCALL(RUST_G, "url_encode")("[text]")
#define rustg_url_decode(text) LIBCALL(RUST_G, "url_decode")(text)

#ifdef RUSTG_OVERRIDE_BUILTINS
#define url_encode(text) rustg_url_encode(text)
Expand Down
2 changes: 1 addition & 1 deletion code/__DEFINES/skills/helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
if(body.mind){\
body.mind.add_skill_modifier(prototype.identifier)\
} else {\
prototype.RegisterSignal(body, COMSIG_MOB_ON_NEW_MIND, /datum/skill_modifier.proc/on_mob_new_mind, TRUE)\
prototype.RegisterSignal(body, COMSIG_MOB_ON_NEW_MIND, TYPE_PROC_REF(/datum/skill_modifier,on_mob_new_mind), TRUE)\
}

/// Same as above but to remove the skill modifier.
Expand Down
52 changes: 47 additions & 5 deletions code/__DEFINES/spaceman_dmm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,72 @@

// The SPACEMAN_DMM define is set by the linter and other tooling when it runs.
#ifdef SPACEMAN_DMM
/**
* Sets a return type expression for a proc. The return type can take the forms:
* `/typepath` - a raw typepath. The return type of the proc is the type named.
* `param` - a typepath given as a parameter, for procs which return an instance of the passed-in type.
* `param.type` - the static type of a passed-in parameter, for procs which
* return their input or otherwise another value of the same type.
* `param[_].type` - the static type of a passed-in parameter, with one level
* of `/list` stripped, for procs which select one item from a list. The `[_]`
* may be repeated to strip more levels of `/list`.
*/
#define RETURN_TYPE(X) set SpacemanDMM_return_type = X
/**
* If set, will enable a diagnostic on children of the proc it is set on which do
* not contain any `..()` parent calls. This can help with finding situations
* where a signal or other important handling in the parent proc is being skipped.
* Child procs may set this setting to `0` instead to override the check.
*/
#define SHOULD_CALL_PARENT(X) set SpacemanDMM_should_call_parent = X
#define UNLINT(X) SpacemanDMM_unlint(X)
/**
* If set, raise a warning for any child procs that override this one,
* regardless of if it calls parent or not.
* This functions in a similar way to the `final` keyword in some languages.
* This cannot be disabled by child overrides.
*/
#define SHOULD_NOT_OVERRIDE(X) set SpacemanDMM_should_not_override = X
/**
* If set, raise a warning if the proc or one of the sub-procs it calls
* uses a blocking call, such as `sleep()` or `input()` without using `set waitfor = 0`
* This cannot be disabled by child overrides.
*/
#define SHOULD_NOT_SLEEP(X) set SpacemanDMM_should_not_sleep = X
/**
* If set, ensure a proc is 'pure', such that it does not make any changes
* outside itself or output. This also checks to make sure anything using
* this proc doesn't invoke it without making use of the return value.
* This cannot be disabled by child overrides.
*/
#define SHOULD_BE_PURE(X) set SpacemanDMM_should_be_pure = X
///Private procs can only be called by things of exactly the same type.
#define PRIVATE_PROC(X) set SpacemanDMM_private_proc = X
///Protected procs can only be call by things of the same type *or subtypes*.
#define PROTECTED_PROC(X) set SpacemanDMM_protected_proc = X
///If set, will not lint.
#define UNLINT(X) SpacemanDMM_unlint(X)

///If set, overriding their value isn't permitted by types that inherit it.
#define VAR_FINAL var/SpacemanDMM_final
///Private vars can only be called by things of exactly the same type.
#define VAR_PRIVATE var/SpacemanDMM_private
///Protected vars can only be called by things of the same type *or subtypes*.
#define VAR_PROTECTED var/SpacemanDMM_protected
#else
#define RETURN_TYPE(X)
#define SHOULD_CALL_PARENT(X)
#define UNLINT(X) X
#define SHOULD_NOT_OVERRIDE(X)
#define SHOULD_NOT_SLEEP(X)
#define SHOULD_BE_PURE(X)
#define PRIVATE_PROC(X)
#define PROTECTED_PROC(X)
#define UNLINT(X) X

#define VAR_FINAL var
#define VAR_PRIVATE var
#define VAR_PROTECTED var
#endif

/proc/enable_debugging()
CRASH("Auxtools not found")
7 changes: 5 additions & 2 deletions code/__HELPERS/_extools_api.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ GLOBAL_LIST_EMPTY(auxtools_initialized)
#define AUXTOOLS_CHECK(LIB)\
if (!GLOB.auxtools_initialized[LIB]) {\
if (fexists(LIB)) {\
var/string = call(LIB,"auxtools_init")();\
var/string = LIBCALL(LIB,"auxtools_init")();\
if(findtext(string, "SUCCESS")) {\
GLOB.auxtools_initialized[LIB] = TRUE;\
} else {\
Expand All @@ -29,6 +29,9 @@ GLOBAL_LIST_EMPTY(auxtools_initialized)

#define AUXTOOLS_SHUTDOWN(LIB)\
if (GLOB.auxtools_initialized[LIB] && fexists(LIB)){\
call(LIB,"auxtools_shutdown")();\
LIBCALL(LIB,"auxtools_shutdown")();\
GLOB.auxtools_initialized[LIB] = FALSE;\
}\

/proc/enable_debugging()
CRASH("Auxtools not found")
Loading

0 comments on commit 565a868

Please sign in to comment.