diff --git a/code/__HELPERS/_dreamluau.dm b/code/__HELPERS/_dreamluau.dm index d8bb784c217..9436b95c551 100644 --- a/code/__HELPERS/_dreamluau.dm +++ b/code/__HELPERS/_dreamluau.dm @@ -1,3 +1,4 @@ +#ifndef DISABLE_DREAMLUAU /* This comment bypasses grep checks */ /var/__dreamluau /* This comment also bypasses grep checks */ /var/__dreamluau_exists @@ -299,3 +300,4 @@ */ #define DREAMLUAU_CLEAR_REF_USERDATA(object) DREAMLUAU_CALL(clear_ref_userdata)((object)) +#endif diff --git a/code/_compile_options.dm b/code/_compile_options.dm index 2bd9309406a..ee53eb99b8d 100644 --- a/code/_compile_options.dm +++ b/code/_compile_options.dm @@ -106,6 +106,16 @@ /// If this is uncommented, will profile mapload atom initializations // #define PROFILE_MAPLOAD_INIT_ATOM +/// If uncommented, Dreamluau will be fully disabled. +// #define DISABLE_DREAMLUAU + +// OpenDream currently doesn't support byondapi, so automatically disable it on OD, +// unless CIBUILDING is defined - we still want to lint dreamluau-related code. +// Get rid of this whenever it does have support. +#if defined(OPENDREAM) && !defined(SPACEMAN_DMM) && !defined(CIBUILDING) +#define DISABLE_DREAMLUAU +#endif + /// If this is uncommented, force our verb processing into just the 2% of a tick /// We normally reserve for it /// NEVER run this on live, it's for simulating highpop only diff --git a/code/controllers/subsystem/garbage.dm b/code/controllers/subsystem/garbage.dm index ad1b9e4132f..b9c8a08ca75 100644 --- a/code/controllers/subsystem/garbage.dm +++ b/code/controllers/subsystem/garbage.dm @@ -346,7 +346,9 @@ SUBSYSTEM_DEF(garbage) /// Datums passed to this will be given a chance to clean up references to allow the GC to collect them. /proc/qdel(datum/to_delete, force = FALSE) if(!istype(to_delete)) +#ifndef DISABLE_DREAMLUAU DREAMLUAU_CLEAR_REF_USERDATA(to_delete) +#endif del(to_delete) return diff --git a/code/controllers/subsystem/lua.dm b/code/controllers/subsystem/lua.dm index 99df8cf3354..2d199ccd3dc 100644 --- a/code/controllers/subsystem/lua.dm +++ b/code/controllers/subsystem/lua.dm @@ -1,3 +1,4 @@ +#ifndef DISABLE_DREAMLUAU SUBSYSTEM_DEF(lua) name = "Lua Scripting" runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT @@ -156,3 +157,4 @@ SUBSYSTEM_DEF(lua) continue state.log_result(json_data) return +#endif diff --git a/code/datums/datum.dm b/code/datums/datum.dm index 8337dac1131..c3c800bd85c 100644 --- a/code/datums/datum.dm +++ b/code/datums/datum.dm @@ -142,9 +142,11 @@ _clear_signal_refs() //END: ECS SHIT +#ifndef DISABLE_DREAMLUAU if(!(datum_flags & DF_STATIC_OBJECT)) DREAMLUAU_CLEAR_REF_USERDATA(vars) // vars ceases existing when src does, so we need to clear any lua refs to it that exist. DREAMLUAU_CLEAR_REF_USERDATA(src) +#endif return QDEL_HINT_QUEUE diff --git a/code/game/atom/_atom.dm b/code/game/atom/_atom.dm index a7d057aa9fa..a0083869167 100644 --- a/code/game/atom/_atom.dm +++ b/code/game/atom/_atom.dm @@ -186,12 +186,14 @@ if(smoothing_flags & SMOOTH_QUEUED) SSicon_smooth.remove_from_queues(src) +#ifndef DISABLE_DREAMLUAU // These lists cease existing when src does, so we need to clear any lua refs to them that exist. if(!(datum_flags & DF_STATIC_OBJECT)) DREAMLUAU_CLEAR_REF_USERDATA(contents) DREAMLUAU_CLEAR_REF_USERDATA(filters) DREAMLUAU_CLEAR_REF_USERDATA(overlays) DREAMLUAU_CLEAR_REF_USERDATA(underlays) +#endif return ..() diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index e6fe68ea4c4..5c61186b585 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -237,9 +237,11 @@ LAZYNULL(client_mobs_in_contents) +#ifndef DISABLE_DREAMLUAU // These lists cease existing when src does, so we need to clear any lua refs to them that exist. DREAMLUAU_CLEAR_REF_USERDATA(vis_contents) DREAMLUAU_CLEAR_REF_USERDATA(vis_locs) +#endif . = ..() diff --git a/code/game/world.dm b/code/game/world.dm index ea6c9cb976f..79ba0f231e9 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -503,7 +503,9 @@ GLOBAL_PROTECT(tracy_init_reason) /world/proc/on_tickrate_change() SStimer?.reset_buckets() +#ifndef DISABLE_DREAMLUAU DREAMLUAU_SET_EXECUTION_LIMIT_MILLIS(tick_lag * 100) +#endif /world/proc/init_byond_tracy() if(!fexists(TRACY_DLL_PATH)) diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 71374bf2464..9dbac57315d 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -1699,6 +1699,7 @@ return return usr.client?.mark_datum(datum_to_mark) +#ifndef DISABLE_DREAMLUAU else if(href_list["lua_state"]) if(!check_rights(R_DEBUG)) return @@ -1715,6 +1716,7 @@ editor.force_view_chunk = log_entry["chunk"] editor.force_modal = "viewChunk" editor.ui_interact(usr) +#endif else if(href_list["show_paper"]) if(!check_rights(R_ADMIN)) diff --git a/code/modules/admin/verbs/lua/_wrappers.dm b/code/modules/admin/verbs/lua/_wrappers.dm index d516f064f84..5fd78244b56 100644 --- a/code/modules/admin/verbs/lua/_wrappers.dm +++ b/code/modules/admin/verbs/lua/_wrappers.dm @@ -1,3 +1,4 @@ +#ifndef DISABLE_DREAMLUAU /proc/wrap_lua_get_var(datum/thing, var_name) SHOULD_NOT_SLEEP(TRUE) if(thing == world) @@ -46,3 +47,4 @@ var/result = list("status" = "print", "message" = print_message) INVOKE_ASYNC(target_state, TYPE_PROC_REF(/datum/lua_state, log_result), result, TRUE) log_lua("[target_state]: [print_message]") +#endif diff --git a/code/modules/admin/verbs/lua/helpers.dm b/code/modules/admin/verbs/lua/helpers.dm index c3072f15e74..fe844c5c55f 100644 --- a/code/modules/admin/verbs/lua/helpers.dm +++ b/code/modules/admin/verbs/lua/helpers.dm @@ -1,3 +1,4 @@ +#ifndef DISABLE_DREAMLUAU #define PROMISE_PENDING 0 #define PROMISE_RESOLVED 1 #define PROMISE_REJECTED 2 @@ -34,3 +35,4 @@ #undef PROMISE_PENDING #undef PROMISE_RESOLVED #undef PROMISE_REJECTED +#endif diff --git a/code/modules/admin/verbs/lua/lua_editor.dm b/code/modules/admin/verbs/lua/lua_editor.dm index 93e8e50c1a6..280bd52a57d 100644 --- a/code/modules/admin/verbs/lua/lua_editor.dm +++ b/code/modules/admin/verbs/lua/lua_editor.dm @@ -1,3 +1,4 @@ +#ifndef DISABLE_DREAMLUAU /datum/lua_editor var/datum/lua_state/current_state @@ -279,7 +280,12 @@ /datum/lua_editor/ui_close(mob/user) . = ..() qdel(src) +#endif ADMIN_VERB(lua_editor, R_DEBUG, "Open Lua Editor", "Its codin' time.", ADMIN_CATEGORY_DEBUG) +#ifndef DISABLE_DREAMLUAU var/datum/lua_editor/editor = new editor.ui_interact(user.mob) +#else + to_chat(user, span_warning("Lua support has been disabled at compile-time."), type = MESSAGE_TYPE_ADMINLOG, confidential = TRUE) // doing this instead of just disabling the verb entirely so it's clear WHY it doesn't work. +#endif diff --git a/code/modules/admin/verbs/lua/lua_state.dm b/code/modules/admin/verbs/lua/lua_state.dm index 30bc21c83b2..53b869e23a1 100644 --- a/code/modules/admin/verbs/lua/lua_state.dm +++ b/code/modules/admin/verbs/lua/lua_state.dm @@ -1,3 +1,4 @@ +#ifndef DISABLE_DREAMLUAU #define MAX_LOG_REPEAT_LOOKBACK 5 GLOBAL_DATUM(lua_usr, /mob) @@ -232,3 +233,4 @@ GLOBAL_PROTECT(lua_state_stack) SStgui.update_uis(editor) #undef MAX_LOG_REPEAT_LOOKBACK +#endif diff --git a/code/modules/error_handler/error_handler.dm b/code/modules/error_handler/error_handler.dm index 6585f92f9b6..7cdc43317e7 100644 --- a/code/modules/error_handler/error_handler.dm +++ b/code/modules/error_handler/error_handler.dm @@ -103,12 +103,14 @@ GLOBAL_VAR_INIT(total_runtimes_skipped, 0) // The proceeding mess will almost definitely break if error messages are ever changed var/list/splitlines = splittext(E.desc, "\n") var/list/desclines = list() +#ifndef DISABLE_DREAMLUAU var/list/state_stack = GLOB.lua_state_stack var/is_lua_call = length(state_stack) var/list/lua_stacks = list() if(is_lua_call) for(var/level in 1 to state_stack.len) lua_stacks += list(splittext(DREAMLUAU_GET_TRACEBACK(level), "\n")) +#endif if(LAZYLEN(splitlines) > ERROR_USEFUL_LEN) // If there aren't at least three lines, there's no info for(var/line in splitlines) if(LAZYLEN(line) < 3 || findtext(line, "source file:") || findtext(line, "usr.loc:")) @@ -124,8 +126,10 @@ GLOBAL_VAR_INIT(total_runtimes_skipped, 0) desclines += line if(usrinfo) //If this info isn't null, it hasn't been added yet desclines.Add(usrinfo) +#ifndef DISABLE_DREAMLUAU if(is_lua_call) SSlua.log_involved_runtime(E, desclines, lua_stacks) +#endif if(silencing) desclines += " (This error will now be silenced for [DisplayTimeText(configured_error_silence_time)])" if(GLOB.error_cache)