From a41d6b4369aa021fd2174ed2e0bf61359287a5a5 Mon Sep 17 00:00:00 2001 From: Katherine Kiefer Date: Sun, 10 Mar 2024 12:41:16 +1100 Subject: [PATCH] fix the runtimes --- code/__DEFINES/spaceman_dmm.dm | 52 +++++++++++++++++++++++++++--- code/__HELPERS/_auxtools_api.dm | 43 ++++++++++++++++++++++++ code/__HELPERS/_extools_api.dm | 5 --- code/game/world.dm | 14 ++++++++ code/modules/vehicles/speedbike.dm | 3 +- tgstation.dme | 2 +- 6 files changed, 107 insertions(+), 12 deletions(-) create mode 100644 code/__HELPERS/_auxtools_api.dm delete mode 100644 code/__HELPERS/_extools_api.dm diff --git a/code/__DEFINES/spaceman_dmm.dm b/code/__DEFINES/spaceman_dmm.dm index f15d6a175f..cabb02fd49 100644 --- a/code/__DEFINES/spaceman_dmm.dm +++ b/code/__DEFINES/spaceman_dmm.dm @@ -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") diff --git a/code/__HELPERS/_auxtools_api.dm b/code/__HELPERS/_auxtools_api.dm new file mode 100644 index 0000000000..0117ded4c5 --- /dev/null +++ b/code/__HELPERS/_auxtools_api.dm @@ -0,0 +1,43 @@ +#define AUXTOOLS_FULL_INIT 2 +#define AUXTOOLS_PARTIAL_INIT 1 + +GLOBAL_LIST_EMPTY(auxtools_initialized) +GLOBAL_PROTECT(auxtools_initialized) + +#define AUXTOOLS_CHECK(LIB)\ + if (!CONFIG_GET(flag/auxtools_enabled)) {\ + CRASH("Auxtools is not enabled in config!");\ + }\ + if (GLOB.auxtools_initialized[LIB] != AUXTOOLS_FULL_INIT) {\ + if (fexists(LIB)) {\ + var/string = call_ext(LIB,"auxtools_init")();\ + if(findtext(string, "SUCCESS")) {\ + GLOB.auxtools_initialized[LIB] = AUXTOOLS_FULL_INIT;\ + } else {\ + CRASH(string);\ + }\ + } else {\ + CRASH("No file named [LIB] found!")\ + }\ + }\ + +#define AUXTOOLS_SHUTDOWN(LIB)\ + if (GLOB.auxtools_initialized[LIB] == AUXTOOLS_FULL_INIT && fexists(LIB)){\ + call_ext(LIB,"auxtools_shutdown")();\ + GLOB.auxtools_initialized[LIB] = AUXTOOLS_PARTIAL_INIT;\ + }\ + +#define AUXTOOLS_FULL_SHUTDOWN(LIB)\ + if (GLOB.auxtools_initialized[LIB] && fexists(LIB)){\ + call_ext(LIB,"auxtools_full_shutdown")();\ + GLOB.auxtools_initialized[LIB] = FALSE;\ + } + +/proc/auxtools_stack_trace(msg) + CRASH(msg) + +/proc/auxtools_expr_stub() + CRASH("auxtools not loaded") + +/proc/enable_debugging(mode, port) + CRASH("auxtools not loaded") diff --git a/code/__HELPERS/_extools_api.dm b/code/__HELPERS/_extools_api.dm deleted file mode 100644 index a8044c2203..0000000000 --- a/code/__HELPERS/_extools_api.dm +++ /dev/null @@ -1,5 +0,0 @@ -//#define EXTOOLS_LOGGING // rust_g is used as a fallback if this is undefined - -/proc/extools_log_write() - -/proc/extools_finalize_logging() diff --git a/code/game/world.dm b/code/game/world.dm index 918382696f..df6e461262 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -9,6 +9,11 @@ GLOBAL_LIST(topic_status_cache) //So subsystems globals exist, but are not initialised /world/New() + var/dll = GetConfig("env", "AUXTOOLS_DEBUG_DLL") + if (dll) + call_ext(dll, "auxtools_init")() + enable_debugging() + world.Profile(PROFILE_START) log_world("World loaded at [TIME_STAMP("hh:mm:ss", FALSE)]!") @@ -262,14 +267,23 @@ GLOBAL_LIST(topic_status_cache) if(do_hard_reboot) log_world("World hard rebooted at [TIME_STAMP("hh:mm:ss", FALSE)]") shutdown_logging() // See comment below. + var/debug_server = world.GetConfig("env", "AUXTOOLS_DEBUG_DLL") + if (debug_server) + call_ext(debug_server, "auxtools_shutdown")() TgsEndProcess() log_world("World rebooted at [TIME_STAMP("hh:mm:ss", FALSE)]") shutdown_logging() // Past this point, no logging procs can be used, at risk of data loss. + var/debug_server = world.GetConfig("env", "AUXTOOLS_DEBUG_DLL") + if (debug_server) + call_ext(debug_server, "auxtools_shutdown")() ..() /world/Del() shutdown_logging() // makes sure the thread is closed before end, else we terminate + var/debug_server = world.GetConfig("env", "AUXTOOLS_DEBUG_DLL") + if (debug_server) + call_ext(debug_server, "auxtools_shutdown")() ..() /world/proc/update_status() diff --git a/code/modules/vehicles/speedbike.dm b/code/modules/vehicles/speedbike.dm index d0b9c1fe96..2988be55ce 100644 --- a/code/modules/vehicles/speedbike.dm +++ b/code/modules/vehicles/speedbike.dm @@ -44,7 +44,7 @@ icon = 'icons/obj/car.dmi' icon_state = "speedwagon" layer = LYING_MOB_LAYER - var/static/mutable_appearance/overlay = mutable_appearance(icon, "speedwagon_cover", ABOVE_MOB_LAYER) + var/static/mutable_appearance/overlay max_buckled_mobs = 4 var/crash_all = FALSE //CHAOS pixel_y = -48 @@ -52,6 +52,7 @@ /obj/vehicle/ridden/space/speedwagon/Initialize(mapload) . = ..() + overlay = mutable_appearance(icon, "speedwagon_cover", ABOVE_MOB_LAYER) add_overlay(overlay) var/datum/component/riding/D = LoadComponent(/datum/component/riding) D.vehicle_move_delay = 0 diff --git a/tgstation.dme b/tgstation.dme index 043969c663..b2aa6b767e 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -187,8 +187,8 @@ #include "code\__DEFINES\skills\helpers.dm" #include "code\__DEFINES\storage\_storage.dm" #include "code\__DEFINES\storage\volumetrics.dm" +#include "code\__HELPERS\_auxtools_api.dm" #include "code\__HELPERS\_cit_helpers.dm" -#include "code\__HELPERS\_extools_api.dm" #include "code\__HELPERS\_lists.dm" #include "code\__HELPERS\_logging.dm" #include "code\__HELPERS\_string_lists.dm"