From daf55e611ca77da3c62acb170c8d6fb4d49a7675 Mon Sep 17 00:00:00 2001 From: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Date: Mon, 5 Jun 2023 21:25:09 -0700 Subject: [PATCH] Cleans up/renames as private some internal var definitions, removes some fucked uses of internal list vars (#75769) ## About The Pull Request [Improves the documentation of DCS lists, removes old list of callback docs that no longer apply](https://github.com/tgstation/tgstation/commit/c3821d9f5ffaeaa4772f927c819da0c1de0ca27c) [Adds a second signal register to decal rotating, adds a trait to objects under a tile. STOP DIRECTLY READING HIDDEN LISTS I SWEAR TO GOD](https://github.com/tgstation/tgstation/commit/6b3f97a76a6f7d24ab952739a1561633922994e1) [Removes direct reads of the timer list, they were redundant mostly](https://github.com/tgstation/tgstation/commit/14fcd9f8a6d1b2d42ec6df3493ebc76fe7c12032) [Please stop directly reading/modifying the traits list to ensure your dna rot follows the brain](https://github.com/tgstation/tgstation/commit/ec0e5237ec2b7c3b7806cb993670acc8ce388bdc) [Marks internal datum lists as well internal with _](https://github.com/tgstation/tgstation/pull/75769/commits/57c6577ff61629b8ea792ee37ec4f2490a8e2865) [57c6577](https://github.com/tgstation/tgstation/pull/75769/commits/57c6577ff61629b8ea792ee37ec4f2490a8e2865) Does the same to _clear_signal_refs() in hopes of keeping people from touching it ## Why It's Good For The Game They pissed me off. Users should not be touching these lists, especially in ways that make assumptions about their structure and are thus prone to breaking if that ever changes. Most of these are close to zero cost changes, using a wrapper to solve the problem, or just yeeting it Two aren't, Decals with a direction have gained a second signal register on init, and things that sit underfloor (cables/pipes) now get a trait when inserted there. This should have a minimal impact on memory/init time, bugging @Mothblocks about it just in case --- code/__DEFINES/dcs/helpers.dm | 2 +- .../signals/signals_atom/signals_atom_main.dm | 2 + code/__DEFINES/traits.dm | 38 +++++++++------- code/__HELPERS/duplicating.dm | 10 ++--- code/controllers/subsystem/dcs.dm | 2 +- code/controllers/subsystem/overlays.dm | 2 +- code/controllers/subsystem/timer.dm | 8 ++-- code/datums/components/_component.dm | 44 +++++++++---------- code/datums/components/food/decomposition.dm | 20 +++++---- code/datums/components/plumbing/_plumbing.dm | 6 +++ code/datums/datum.dm | 36 +++++++-------- code/datums/elements/decals/_decal.dm | 31 +++++++------ code/datums/elements/undertile.dm | 2 + code/game/turfs/change_turf.dm | 8 ++-- code/game/turfs/turf.dm | 2 +- code/modules/admin/verbs/admin.dm | 4 +- .../admin/view_variables/topic_basic.dm | 7 +-- .../machinery/components/components_base.dm | 4 ++ code/modules/cargo/supplypod.dm | 14 +++--- code/modules/mob/living/brain/brain_item.dm | 5 ++- code/modules/unit_tests/organs.dm | 4 +- .../unit_tests/trait_addition_and_removal.dm | 2 +- 22 files changed, 135 insertions(+), 118 deletions(-) diff --git a/code/__DEFINES/dcs/helpers.dm b/code/__DEFINES/dcs/helpers.dm index a8dc3865702..d1ca969241c 100644 --- a/code/__DEFINES/dcs/helpers.dm +++ b/code/__DEFINES/dcs/helpers.dm @@ -2,7 +2,7 @@ /// The datum hosting the signal is automaticaly added as the first argument /// Returns a bitfield gathered from all registered procs /// Arguments given here are packaged in a list and given to _SendSignal -#define SEND_SIGNAL(target, sigtype, arguments...) ( !target.comp_lookup?[sigtype] ? NONE : target._SendSignal(sigtype, list(target, ##arguments)) ) +#define SEND_SIGNAL(target, sigtype, arguments...) ( !target._comp_lookup?[sigtype] ? NONE : target._SendSignal(sigtype, list(target, ##arguments)) ) #define SEND_GLOBAL_SIGNAL(sigtype, arguments...) ( SEND_SIGNAL(SSdcs, sigtype, ##arguments) ) diff --git a/code/__DEFINES/dcs/signals/signals_atom/signals_atom_main.dm b/code/__DEFINES/dcs/signals/signals_atom/signals_atom_main.dm index 7c9f4f0a432..9e02b01e236 100644 --- a/code/__DEFINES/dcs/signals/signals_atom/signals_atom_main.dm +++ b/code/__DEFINES/dcs/signals/signals_atom/signals_atom_main.dm @@ -50,6 +50,8 @@ #define COMSIG_ATOM_UPDATED_ICON "atom_updated_icon" ///from base of [/atom/proc/smooth_icon]: () #define COMSIG_ATOM_SMOOTHED_ICON "atom_smoothed_icon" +///from [/datum/controller/subsystem/processing/dcs/proc/rotate_decals]: (list/datum/element/decal/rotating) +#define COMSIG_ATOM_DECALS_ROTATING "atom_decals_rotating" ///from base of atom/Entered(): (atom/movable/arrived, atom/old_loc, list/atom/old_locs) #define COMSIG_ATOM_ENTERED "atom_entered" ///from base of atom/movable/Moved(): (atom/movable/arrived, atom/old_loc, list/atom/old_locs) diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm index ba2c6696c77..09f8a3721c3 100644 --- a/code/__DEFINES/traits.dm +++ b/code/__DEFINES/traits.dm @@ -5,13 +5,13 @@ #define ADD_TRAIT(target, trait, source) \ do { \ var/list/_L; \ - if (!target.status_traits) { \ - target.status_traits = list(); \ - _L = target.status_traits; \ + if (!target._status_traits) { \ + target._status_traits = list(); \ + _L = target._status_traits; \ _L[trait] = list(source); \ SEND_SIGNAL(target, SIGNAL_ADDTRAIT(trait), trait); \ } else { \ - _L = target.status_traits; \ + _L = target._status_traits; \ if (_L[trait]) { \ _L[trait] |= list(source); \ } else { \ @@ -22,7 +22,7 @@ } while (0) #define REMOVE_TRAIT(target, trait, sources) \ do { \ - var/list/_L = target.status_traits; \ + var/list/_L = target._status_traits; \ var/list/_S; \ if (sources && !islist(sources)) { \ _S = list(sources); \ @@ -40,13 +40,13 @@ SEND_SIGNAL(target, SIGNAL_REMOVETRAIT(trait), trait); \ }; \ if (!length(_L)) { \ - target.status_traits = null \ + target._status_traits = null \ }; \ } \ } while (0) #define REMOVE_TRAIT_NOT_FROM(target, trait, sources) \ do { \ - var/list/_traits_list = target.status_traits; \ + var/list/_traits_list = target._status_traits; \ var/list/_sources_list; \ if (sources && !islist(sources)) { \ _sources_list = list(sources); \ @@ -64,13 +64,13 @@ SEND_SIGNAL(target, SIGNAL_REMOVETRAIT(trait), trait); \ }; \ if (!length(_traits_list)) { \ - target.status_traits = null \ + target._status_traits = null \ }; \ } \ } while (0) #define REMOVE_TRAITS_NOT_IN(target, sources) \ do { \ - var/list/_L = target.status_traits; \ + var/list/_L = target._status_traits; \ var/list/_S = sources; \ if (_L) { \ for (var/_T in _L) { \ @@ -81,14 +81,14 @@ }; \ };\ if (!length(_L)) { \ - target.status_traits = null\ + target._status_traits = null\ };\ }\ } while (0) #define REMOVE_TRAITS_IN(target, sources) \ do { \ - var/list/_L = target.status_traits; \ + var/list/_L = target._status_traits; \ var/list/_S = sources; \ if (sources && !islist(sources)) { \ _S = list(sources); \ @@ -104,15 +104,18 @@ }; \ };\ if (!length(_L)) { \ - target.status_traits = null\ + target._status_traits = null\ };\ }\ } while (0) -#define HAS_TRAIT(target, trait) (target.status_traits?[trait] ? TRUE : FALSE) -#define HAS_TRAIT_FROM(target, trait, source) (HAS_TRAIT(target, trait) && (source in target.status_traits[trait])) -#define HAS_TRAIT_FROM_ONLY(target, trait, source) (HAS_TRAIT(target, trait) && (source in target.status_traits[trait]) && (length(target.status_traits[trait]) == 1)) -#define HAS_TRAIT_NOT_FROM(target, trait, source) (HAS_TRAIT(target, trait) && (length(target.status_traits[trait] - source) > 0)) +#define HAS_TRAIT(target, trait) (target._status_traits?[trait] ? TRUE : FALSE) +#define HAS_TRAIT_FROM(target, trait, source) (HAS_TRAIT(target, trait) && (source in target._status_traits[trait])) +#define HAS_TRAIT_FROM_ONLY(target, trait, source) (HAS_TRAIT(target, trait) && (source in target._status_traits[trait]) && (length(target._status_traits[trait]) == 1)) +#define HAS_TRAIT_NOT_FROM(target, trait, source) (HAS_TRAIT(target, trait) && (length(target._status_traits[trait] - source) > 0)) +/// Returns a list of trait sources for this trait. Only useful for wacko cases and internal futzing +/// You should not be using this +#define GET_TRAIT_SOURCES(target, trait) target._status_traits?[trait] || list() /* Remember to update _globalvars/traits.dm if you're adding/removing/renaming traits. @@ -844,6 +847,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai #define TRAIT_CURRENTLY_CLEANING "currently_cleaning" /// Objects with this trait are deleted if they fall into chasms, rather than entering abstract storage #define TRAIT_CHASM_DESTROYED "chasm_destroyed" +/// Trait from being under the floor in some manner +#define TRAIT_UNDERFLOOR "underfloor" // unique trait sources, still defines #define EMP_TRAIT "emp_trait" @@ -948,6 +953,7 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai /// Trait given by hallucinations #define HALLUCINATION_TRAIT "hallucination_trait" + /** * Trait granted by [/mob/living/carbon/Initialize] and * granted/removed by [/obj/item/organ/internal/tongue] diff --git a/code/__HELPERS/duplicating.dm b/code/__HELPERS/duplicating.dm index f5d56cc879d..e26543ca24e 100644 --- a/code/__HELPERS/duplicating.dm +++ b/code/__HELPERS/duplicating.dm @@ -3,18 +3,18 @@ GLOBAL_LIST_INIT(duplicate_forbidden_vars, list( "AIStatus", "actions", "active_hud_list", - "active_timers", + "_active_timers", "appearance", "area", "atmos_adjacent_turfs", "bodyparts", "ckey", "client_mobs_in_contents", - "comp_lookup", + "_comp_lookup", "computer_id", "contents", "cooldowns", - "datum_components", + "_datum_components", "external_organs", "external_organs_slot", "group", @@ -38,10 +38,10 @@ GLOBAL_LIST_INIT(duplicate_forbidden_vars, list( "power_supply", "quirks", "reagents", - "signal_procs", + "_signal_procs", "stat", "status_effects", - "status_traits", + "_status_traits", "tag", "tgui_shared_states", "type", diff --git a/code/controllers/subsystem/dcs.dm b/code/controllers/subsystem/dcs.dm index 4fa8581f66a..035860e90cf 100644 --- a/code/controllers/subsystem/dcs.dm +++ b/code/controllers/subsystem/dcs.dm @@ -6,7 +6,7 @@ PROCESSING_SUBSYSTEM_DEF(dcs) var/list/elements_by_type = list() /datum/controller/subsystem/processing/dcs/Recover() - comp_lookup = SSdcs.comp_lookup + _comp_lookup = SSdcs._comp_lookup /datum/controller/subsystem/processing/dcs/proc/GetElement(list/arguments) var/datum/element/eletype = arguments[1] diff --git a/code/controllers/subsystem/overlays.dm b/code/controllers/subsystem/overlays.dm index fc494ef5e8a..5d52733e2f1 100644 --- a/code/controllers/subsystem/overlays.dm +++ b/code/controllers/subsystem/overlays.dm @@ -211,7 +211,7 @@ SUBSYSTEM_DEF(overlays) continue if(name == "vars") // Go away continue - if(name == "comp_lookup") // This is just gonna happen with marked datums, don't care + if(name == "_comp_lookup") // This is just gonna happen with marked datums, don't care continue if(name == "overlays") first.realize_overlays() diff --git a/code/controllers/subsystem/timer.dm b/code/controllers/subsystem/timer.dm index ef6841894d5..af6f346cd76 100644 --- a/code/controllers/subsystem/timer.dm +++ b/code/controllers/subsystem/timer.dm @@ -420,7 +420,7 @@ SUBSYSTEM_DEF(timer) CRASH("Invalid timer state: Timer created that would require a backtrack to run (addtimer would never let this happen): [SStimer.get_timer_debug_string(src)]") if (callBack.object != GLOBAL_PROC && !QDESTROYING(callBack.object)) - LAZYADD(callBack.object.active_timers, src) + LAZYADD(callBack.object._active_timers, src) bucketJoin() @@ -429,9 +429,9 @@ SUBSYSTEM_DEF(timer) if (flags & TIMER_UNIQUE && hash) timer_subsystem.hashes -= hash - if (callBack && callBack.object && callBack.object != GLOBAL_PROC && callBack.object.active_timers) - callBack.object.active_timers -= src - UNSETEMPTY(callBack.object.active_timers) + if (callBack && callBack.object && callBack.object != GLOBAL_PROC && callBack.object._active_timers) + callBack.object._active_timers -= src + UNSETEMPTY(callBack.object._active_timers) callBack = null diff --git a/code/datums/components/_component.dm b/code/datums/components/_component.dm index 8cbc4efd329..eb8898372f7 100644 --- a/code/datums/components/_component.dm +++ b/code/datums/components/_component.dm @@ -90,9 +90,9 @@ /datum/component/proc/_JoinParent() var/datum/P = parent //lazy init the parent's dc list - var/list/dc = P.datum_components + var/list/dc = P._datum_components if(!dc) - P.datum_components = dc = list() + P._datum_components = dc = list() //set up the typecache var/our_type = type @@ -127,7 +127,7 @@ */ /datum/component/proc/_RemoveFromParent() var/datum/parent = src.parent - var/list/parents_components = parent.datum_components + var/list/parents_components = parent._datum_components for(var/I in _GetInverseTypeList()) var/list/components_of_type = parents_components[I] @@ -143,7 +143,7 @@ parents_components -= I if(!parents_components.len) - parent.datum_components = null + parent._datum_components = null UnregisterFromParent() @@ -220,9 +220,9 @@ RegisterSignals(target, signal_type, proctype, override) return - var/list/procs = (signal_procs ||= list()) + var/list/procs = (_signal_procs ||= list()) var/list/target_procs = (procs[target] ||= list()) - var/list/lookup = (target.comp_lookup ||= list()) + var/list/lookup = (target._comp_lookup ||= list()) if(!override && target_procs[signal_type]) var/override_message = "[signal_type] overridden. Use override = TRUE to suppress this warning.\nTarget: [target] ([target.type]) Proc: [proctype]" @@ -258,13 +258,13 @@ * * sig_typeor_types Signal string key or list of signal keys to stop listening to specifically */ /datum/proc/UnregisterSignal(datum/target, sig_type_or_types) - var/list/lookup = target.comp_lookup - if(!signal_procs || !signal_procs[target] || !lookup) + var/list/lookup = target._comp_lookup + if(!_signal_procs || !_signal_procs[target] || !lookup) return if(!islist(sig_type_or_types)) sig_type_or_types = list(sig_type_or_types) for(var/sig in sig_type_or_types) - if(!signal_procs[target][sig]) + if(!_signal_procs[target][sig]) if(!istext(sig)) stack_trace("We're unregistering with something that isn't a valid signal \[[sig]\], you fucked up") continue @@ -272,25 +272,25 @@ if(2) lookup[sig] = (lookup[sig]-src)[1] if(1) - stack_trace("[target] ([target.type]) somehow has single length list inside comp_lookup") + stack_trace("[target] ([target.type]) somehow has single length list inside _comp_lookup") if(src in lookup[sig]) lookup -= sig if(!length(lookup)) - target.comp_lookup = null + target._comp_lookup = null break if(0) if(lookup[sig] != src) continue lookup -= sig if(!length(lookup)) - target.comp_lookup = null + target._comp_lookup = null break else lookup[sig] -= src - signal_procs[target] -= sig_type_or_types - if(!signal_procs[target].len) - signal_procs -= target + _signal_procs[target] -= sig_type_or_types + if(!_signal_procs[target].len) + _signal_procs -= target /** * Called on a component when a component of the same type was added to the same parent @@ -354,17 +354,17 @@ * Use the [SEND_SIGNAL] define instead */ /datum/proc/_SendSignal(sigtype, list/arguments) - var/target = comp_lookup[sigtype] + var/target = _comp_lookup[sigtype] if(!length(target)) var/datum/listening_datum = target - return NONE | call(listening_datum, listening_datum.signal_procs[src][sigtype])(arglist(arguments)) + return NONE | call(listening_datum, listening_datum._signal_procs[src][sigtype])(arglist(arguments)) . = NONE // This exists so that even if one of the signal receivers unregisters the signal, // all the objects that are receiving the signal get the signal this final time. // AKA: No you can't cancel the signal reception of another object by doing an unregister in the same signal. var/list/queued_calls = list() for(var/datum/listening_datum as anything in target) - queued_calls[listening_datum] = listening_datum.signal_procs[src][sigtype] + queued_calls[listening_datum] = listening_datum._signal_procs[src][sigtype] for(var/datum/listening_datum as anything in queued_calls) . |= call(listening_datum, queued_calls[listening_datum])(arglist(arguments)) @@ -381,7 +381,7 @@ RETURN_TYPE(c_type) if(initial(c_type.dupe_mode) == COMPONENT_DUPE_ALLOWED || initial(c_type.dupe_mode) == COMPONENT_DUPE_SELECTIVE) stack_trace("GetComponent was called to get a component of which multiple copies could be on an object. This can easily break and should be changed. Type: \[[c_type]\]") - var/list/dc = datum_components + var/list/dc = _datum_components if(!dc) return null . = dc[c_type] @@ -401,7 +401,7 @@ RETURN_TYPE(c_type) if(initial(c_type.dupe_mode) == COMPONENT_DUPE_ALLOWED || initial(c_type.dupe_mode) == COMPONENT_DUPE_SELECTIVE) stack_trace("GetComponent was called to get a component of which multiple copies could be on an object. This can easily break and should be changed. Type: \[[c_type]\]") - var/list/dc = datum_components + var/list/dc = _datum_components if(!dc) return null var/datum/component/C = dc[c_type] @@ -419,7 +419,7 @@ * * c_type The component type path */ /datum/proc/GetComponents(c_type) - var/list/components = datum_components?[c_type] + var/list/components = _datum_components?[c_type] if(!components) return list() return islist(components) ? components : list(components) @@ -590,7 +590,7 @@ * * /datum/target the target to move the components to */ /datum/proc/TransferComponents(datum/target) - var/list/dc = datum_components + var/list/dc = _datum_components if(!dc) return var/comps = dc[/datum/component] diff --git a/code/datums/components/food/decomposition.dm b/code/datums/components/food/decomposition.dm index dc6a8119e9b..c8fa61368dc 100644 --- a/code/datums/components/food/decomposition.dm +++ b/code/datums/components/food/decomposition.dm @@ -89,10 +89,18 @@ remove_timer() return ..() +/// Returns the time remaining in decomp, either from our potential timer or our own value, whichever is more useful +/datum/component/decomposition/proc/get_time() + if(!timerid) + return time_remaining + return timeleft(timerid) + /datum/component/decomposition/proc/remove_timer() - if(active_timers) // Makes sure there's an active timer to delete. - time_remaining = timeleft(timerid) - deltimer(timerid) + if(!timerid) + return + time_remaining = timeleft(timerid) + deltimer(timerid) + timerid = null /datum/component/decomposition/proc/dropped() SIGNAL_HANDLER @@ -118,11 +126,7 @@ /datum/component/decomposition/proc/examine(datum/source, mob/user, list/examine_list) SIGNAL_HANDLER - var/time_d = 0 - if(active_timers) // Is the timer currently applied to this? - time_d = timeleft(timerid) - else - time_d = time_remaining + var/time_d = get_time() switch(time_d / original_time) if(0.5 to 0.75) // 25% rotten examine_list += span_notice("[parent] looks kinda stale.") diff --git a/code/datums/components/plumbing/_plumbing.dm b/code/datums/components/plumbing/_plumbing.dm index 661591bc23c..5c53310237c 100644 --- a/code/datums/components/plumbing/_plumbing.dm +++ b/code/datums/components/plumbing/_plumbing.dm @@ -63,6 +63,7 @@ /datum/component/plumbing/UnregisterFromParent() UnregisterSignal(parent, list(COMSIG_MOVABLE_MOVED, COMSIG_PARENT_QDELETING, COMSIG_OBJ_DEFAULT_UNFASTEN_WRENCH, COMSIG_OBJ_HIDE, \ COMSIG_ATOM_UPDATE_OVERLAYS, COMSIG_ATOM_DIR_CHANGE, COMSIG_MOVABLE_CHANGE_DUCT_LAYER, COMSIG_COMPONENT_ADDED)) + REMOVE_TRAIT(parent, TRAIT_UNDERFLOOR, REF(src)) /datum/component/plumbing/Destroy() ducts = null @@ -316,6 +317,11 @@ var/should_hide = !underfloor_accessibility + if(should_hide) + ADD_TRAIT(parent_obj, TRAIT_UNDERFLOOR, REF(src)) + else + REMOVE_TRAIT(parent_obj, TRAIT_UNDERFLOOR, REF(src)) + if(parent_movable.anchored || !should_hide) tile_covered = should_hide parent_obj.update_appearance() diff --git a/code/datums/datum.dm b/code/datums/datum.dm index 97d5f83f0d8..763f7f017b4 100644 --- a/code/datums/datum.dm +++ b/code/datums/datum.dm @@ -18,24 +18,24 @@ var/gc_destroyed /// Active timers with this datum as the target - var/list/active_timers + var/list/_active_timers /// Status traits attached to this datum. associative list of the form: list(trait name (string) = list(source1, source2, source3,...)) - var/list/status_traits + var/list/_status_traits /** * Components attached to this datum * - * Lazy associated list in the structure of `type:component/list of components` + * Lazy associated list in the structure of `type -> component/list of components` */ - var/list/datum_components + var/list/_datum_components /** * Any datum registered to receive signals from this datum is in this list * - * Lazy associated list in the structure of `signal:registree/list of registrees` + * Lazy associated list in the structure of `signal -> registree/list of registrees` */ - var/list/comp_lookup - /// Lazy associated list in the structure of `signals:proctype` that are run when the datum receives that signal - var/list/list/datum/callback/signal_procs + var/list/_comp_lookup + /// Lazy associated list in the structure of `target -> list(signal -> proctype)` that are run when the datum receives that signal + var/list/list/_signal_procs /// Datum level flags var/datum_flags = NONE @@ -107,9 +107,9 @@ datum_flags &= ~DF_USE_TAG //In case something tries to REF us weak_reference = null //ensure prompt GCing of weakref. - if(active_timers) - var/list/timers = active_timers - active_timers = null + if(_active_timers) + var/list/timers = _active_timers + _active_timers = null for(var/datum/timedevent/timer as anything in timers) if (timer.spent && !(timer.flags & TIMER_DELETE_ME)) continue @@ -122,7 +122,7 @@ #endif //BEGIN: ECS SHIT - var/list/dc = datum_components + var/list/dc = _datum_components if(dc) var/all_components = dc[/datum/component] if(length(all_components)) @@ -133,15 +133,15 @@ qdel(C, FALSE, TRUE) dc.Cut() - clear_signal_refs() + _clear_signal_refs() //END: ECS SHIT return QDEL_HINT_QUEUE ///Only override this if you know what you're doing. You do not know what you're doing ///This is a threat -/datum/proc/clear_signal_refs() - var/list/lookup = comp_lookup +/datum/proc/_clear_signal_refs() + var/list/lookup = _comp_lookup if(lookup) for(var/sig in lookup) var/list/comps = lookup[sig] @@ -151,10 +151,10 @@ else var/datum/component/comp = comps comp.UnregisterSignal(src, sig) - comp_lookup = lookup = null + _comp_lookup = lookup = null - for(var/target in signal_procs) - UnregisterSignal(target, signal_procs[target]) + for(var/target in _signal_procs) + UnregisterSignal(target, _signal_procs[target]) #ifdef DATUMVAR_DEBUGGING_MODE /datum/proc/save_vars() diff --git a/code/datums/elements/decals/_decal.dm b/code/datums/elements/decals/_decal.dm index 9776c378d37..bf6fa1bc25c 100644 --- a/code/datums/elements/decals/_decal.dm +++ b/code/datums/elements/decals/_decal.dm @@ -20,23 +20,17 @@ if(old_dir == new_dir) return - var/list/resulting_decals_params = list() // param lists - var/list/old_decals = list() //instances - if(!source.comp_lookup || !source.comp_lookup[COMSIG_ATOM_UPDATE_OVERLAYS]) - //should probably also unregister itself + var/list/datum/element/decal/old_decals = list() //instances + SEND_SIGNAL(source, COMSIG_ATOM_DECALS_ROTATING, old_decals) + + if(!length(old_decals)) + UnregisterSignal(source, COMSIG_ATOM_DIR_CHANGE) return - if(length(source.comp_lookup[COMSIG_ATOM_UPDATE_OVERLAYS])) - for(var/datum/element/decal/decal in source.comp_lookup[COMSIG_ATOM_UPDATE_OVERLAYS]) - old_decals += decal - resulting_decals_params += list(decal.get_rotated_parameters(old_dir,new_dir)) - else - var/datum/element/decal/decal = source.comp_lookup[COMSIG_ATOM_UPDATE_OVERLAYS] - if(!istype(decal)) - return - old_decals += decal - resulting_decals_params += list(decal.get_rotated_parameters(old_dir,new_dir)) + var/list/resulting_decals_params = list() // param lists + for(var/datum/element/decal/rotating as anything in old_decals) + resulting_decals_params += list(rotating.get_rotated_parameters(old_dir,new_dir)) //Instead we could generate ids and only remove duplicates to save on churn on four-corners symmetry ? for(var/datum/element/decal/decal in old_decals) @@ -80,7 +74,7 @@ base_icon_state = _icon_state smoothing = _smoothing - RegisterSignal(target,COMSIG_ATOM_UPDATE_OVERLAYS, PROC_REF(apply_overlay), TRUE) + RegisterSignal(target, COMSIG_ATOM_UPDATE_OVERLAYS, PROC_REF(apply_overlay), TRUE) if(target.flags_1 & INITIALIZED_1) target.update_appearance(UPDATE_OVERLAYS) //could use some queuing here now maybe. else @@ -88,7 +82,8 @@ if(isitem(target)) INVOKE_ASYNC(target, TYPE_PROC_REF(/obj/item/, update_slot_icon), TRUE) if(_dir) - SSdcs.RegisterSignal(target,COMSIG_ATOM_DIR_CHANGE, TYPE_PROC_REF(/datum/controller/subsystem/processing/dcs, rotate_decals), TRUE) + RegisterSignal(target, COMSIG_ATOM_DECALS_ROTATING, PROC_REF(shuttle_rotate), TRUE) + SSdcs.RegisterSignal(target, COMSIG_ATOM_DIR_CHANGE, TYPE_PROC_REF(/datum/controller/subsystem/processing/dcs, rotate_decals), override=TRUE) if(!isnull(_smoothing)) RegisterSignal(target, COMSIG_ATOM_SMOOTHED_ICON, PROC_REF(smooth_react), TRUE) if(_cleanable) @@ -160,6 +155,10 @@ Detach(source) new_turf.AddElement(type, pic.icon, base_icon_state, directional, pic.plane, pic.layer, pic.alpha, pic.color, smoothing, cleanable, description) +/datum/element/decal/proc/shuttle_rotate(datum/source, list/datum/element/decal/rotating) + SIGNAL_HANDLER + rotating += src + /** * Reacts to the source atom smoothing. * diff --git a/code/datums/elements/undertile.dm b/code/datums/elements/undertile.dm index 75d19606efb..e1fdef4d413 100644 --- a/code/datums/elements/undertile.dm +++ b/code/datums/elements/undertile.dm @@ -42,6 +42,7 @@ if(underfloor_accessibility < UNDERFLOOR_INTERACTABLE) SET_PLANE_IMPLICIT(source, FLOOR_PLANE) // We do this so that turfs that allow you to see what's underneath them don't have to be on the game plane (which causes ambient occlusion weirdness) + ADD_TRAIT(source, TRAIT_UNDERFLOOR, REF(src)) if(tile_overlay) T.add_overlay(tile_overlay) @@ -58,6 +59,7 @@ else SET_PLANE_IMPLICIT(source, initial(source.plane)) + REMOVE_TRAIT(source, TRAIT_UNDERFLOOR, REF(src)) if(invisibility_trait) REMOVE_TRAIT(source, invisibility_trait, ELEMENT_TRAIT(type)) diff --git a/code/game/turfs/change_turf.dm b/code/game/turfs/change_turf.dm index 03cfcfc1baf..68395f911d6 100644 --- a/code/game/turfs/change_turf.dm +++ b/code/game/turfs/change_turf.dm @@ -98,17 +98,17 @@ GLOBAL_LIST_INIT(blacklisted_automated_baseturfs, typecacheof(list( changing_turf = TRUE qdel(src) //Just get the side effects and call Destroy //We do this here so anything that doesn't want to persist can clear itself - var/list/old_comp_lookup = comp_lookup?.Copy() - var/list/old_signal_procs = signal_procs?.Copy() + var/list/old_comp_lookup = _comp_lookup?.Copy() + var/list/old_signal_procs = _signal_procs?.Copy() var/turf/new_turf = new path(src) // WARNING WARNING // Turfs DO NOT lose their signals when they get replaced, REMEMBER THIS // It's possible because turfs are fucked, and if you have one in a list and it's replaced with another one, the list ref points to the new turf if(old_comp_lookup) - LAZYOR(new_turf.comp_lookup, old_comp_lookup) + LAZYOR(new_turf._comp_lookup, old_comp_lookup) if(old_signal_procs) - LAZYOR(new_turf.signal_procs, old_signal_procs) + LAZYOR(new_turf._signal_procs, old_signal_procs) for(var/datum/callback/callback as anything in post_change_callbacks) callback.InvokeAsync(new_turf) diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index b52182a88e8..27612e4d300 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -212,7 +212,7 @@ GLOBAL_LIST_EMPTY(station_turfs) /// Turfs DO NOT lose their signals when they get replaced, REMEMBER THIS /// It's possible because turfs are fucked, and if you have one in a list and it's replaced with another one, the list ref points to the new turf /// We do it because moving signals over was needlessly expensive, and bloated a very commonly used bit of code -/turf/clear_signal_refs() +/turf/_clear_signal_refs() return /turf/attack_hand(mob/user, list/modifiers) diff --git a/code/modules/admin/verbs/admin.dm b/code/modules/admin/verbs/admin.dm index 1ec9c8f99c7..56c118acd6b 100644 --- a/code/modules/admin/verbs/admin.dm +++ b/code/modules/admin/verbs/admin.dm @@ -134,7 +134,7 @@ if("Remove") if(!GLOB.trait_name_map) GLOB.trait_name_map = generate_trait_name_map() - for(var/trait in D.status_traits) + for(var/trait in D._status_traits) var/name = GLOB.trait_name_map[trait] || trait available_traits[name] = trait @@ -157,7 +157,7 @@ if("All") source = null if("Specific") - source = input("Source to be removed","Trait Remove/Add") as null|anything in sort_list(D.status_traits[chosen_trait]) + source = input("Source to be removed","Trait Remove/Add") as null|anything in sort_list(GET_TRAIT_SOURCES(D, chosen_trait)) if(!source) return REMOVE_TRAIT(D,chosen_trait,source) diff --git a/code/modules/admin/view_variables/topic_basic.dm b/code/modules/admin/view_variables/topic_basic.dm index 09759c72c6f..167d44f7087 100644 --- a/code/modules/admin/view_variables/topic_basic.dm +++ b/code/modules/admin/view_variables/topic_basic.dm @@ -87,12 +87,7 @@ return var/mass_remove = href_list[VV_HK_MASS_REMOVECOMPONENT] var/list/components = list() - var/all_components_on_target = LAZYACCESS(target.datum_components, /datum/component) - if(islist(all_components_on_target)) - for(var/datum/component/component in LAZYACCESS(target.datum_components, /datum/component)) - components += component.type - else if(all_components_on_target) - var/datum/component/component = all_components_on_target + for(var/datum/component/component in target.GetComponents(/datum/component)) components += component.type var/list/names = list() names += "---Components---" diff --git a/code/modules/atmospherics/machinery/components/components_base.dm b/code/modules/atmospherics/machinery/components/components_base.dm index 887d74dcdff..3ee1169c332 100644 --- a/code/modules/atmospherics/machinery/components/components_base.dm +++ b/code/modules/atmospherics/machinery/components/components_base.dm @@ -52,6 +52,10 @@ /obj/machinery/atmospherics/components/proc/hide_pipe(datum/source, underfloor_accessibility) SIGNAL_HANDLER showpipe = !!underfloor_accessibility + if(showpipe) + REMOVE_TRAIT(src, TRAIT_UNDERFLOOR, REF(src)) + else + ADD_TRAIT(src, TRAIT_UNDERFLOOR, REF(src)) update_appearance() /obj/machinery/atmospherics/components/update_icon() diff --git a/code/modules/cargo/supplypod.dm b/code/modules/cargo/supplypod.dm index e2df91c342a..7989cd086c7 100644 --- a/code/modules/cargo/supplypod.dm +++ b/code/modules/cargo/supplypod.dm @@ -389,14 +389,12 @@ return FALSE if(istype(obj_to_insert, /obj/effect/supplypod_rubble)) return FALSE - if((obj_to_insert.comp_lookup && obj_to_insert.comp_lookup[COMSIG_OBJ_HIDE]) && reverse_option_list["Underfloor"]) - return TRUE - else if ((obj_to_insert.comp_lookup && obj_to_insert.comp_lookup[COMSIG_OBJ_HIDE]) && !reverse_option_list["Underfloor"]) - return FALSE - if(isProbablyWallMounted(obj_to_insert) && reverse_option_list["Wallmounted"]) - return TRUE - else if (isProbablyWallMounted(obj_to_insert) && !reverse_option_list["Wallmounted"]) - return FALSE + + if(HAS_TRAIT(obj_to_insert, TRAIT_UNDERFLOOR)) + return !!reverse_option_list["Underfloor"] + if(isProbablyWallMounted(obj_to_insert)) + return !!reverse_option_list["Wallmounted"] + if(!obj_to_insert.anchored && reverse_option_list["Unanchored"]) return TRUE if(obj_to_insert.anchored && !ismecha(obj_to_insert) && reverse_option_list["Anchored"]) //Mecha are anchored but there is a separate option for them diff --git a/code/modules/mob/living/brain/brain_item.dm b/code/modules/mob/living/brain/brain_item.dm index 2f0397a46b5..2b485fbdc46 100644 --- a/code/modules/mob/living/brain/brain_item.dm +++ b/code/modules/mob/living/brain/brain_item.dm @@ -143,8 +143,9 @@ if(!brainmob.stored_dna) brainmob.stored_dna = new /datum/dna/stored(brainmob) C.dna.copy_dna(brainmob.stored_dna) - if(HAS_TRAIT(L, TRAIT_BADDNA)) - LAZYSET(brainmob.status_traits, TRAIT_BADDNA, L.status_traits[TRAIT_BADDNA]) + // Hack, fucked dna needs to follow the brain to prevent memes, so we need to copy over the trait sources and shit + for(var/source in GET_TRAIT_SOURCES(L, TRAIT_BADDNA)) + ADD_TRAIT(brainmob, TRAIT_BADDNA, source) if(L.mind && L.mind.current) L.mind.transfer_to(brainmob) to_chat(brainmob, span_notice("You feel slightly disoriented. That's normal when you're just a brain.")) diff --git a/code/modules/unit_tests/organs.dm b/code/modules/unit_tests/organs.dm index 759e955e319..81edc652301 100644 --- a/code/modules/unit_tests/organs.dm +++ b/code/modules/unit_tests/organs.dm @@ -55,9 +55,9 @@ TEST_ASSERT(lab_rat.get_organ_slot(test_organ.slot) == test_organ, TEST_ORGAN_INSERT_MESSAGE(test_organ, "should make the organ available via human's `get_organ_slot()` proc.")) if(LAZYLEN(test_organ.organ_traits)) - TEST_ASSERT(LAZYLEN(lab_rat.status_traits), TEST_ORGAN_INSERT_MESSAGE(test_organ, "should add Traits to lazylist `human.status_traits`.")) + TEST_ASSERT(LAZYLEN(lab_rat._status_traits), TEST_ORGAN_INSERT_MESSAGE(test_organ, "should add Traits to lazylist `human._status_traits`.")) for(var/test_trait in test_organ.organ_traits) - TEST_ASSERT(HAS_TRAIT(lab_rat, test_trait), TEST_ORGAN_INSERT_MESSAGE(test_organ, "should add Trait `[test_trait]` to lazylist `human.status_traits`")) + TEST_ASSERT(HAS_TRAIT(lab_rat, test_trait), TEST_ORGAN_INSERT_MESSAGE(test_organ, "should add Trait `[test_trait]` to lazylist `human._status_traits`")) if(LAZYLEN(test_organ.actions)) TEST_ASSERT(LAZYLEN(lab_rat.actions), TEST_ORGAN_INSERT_MESSAGE(test_organ, "should add Actions to lazylist `human.actions`.")) diff --git a/code/modules/unit_tests/trait_addition_and_removal.dm b/code/modules/unit_tests/trait_addition_and_removal.dm index dcab577d661..273cf102a00 100644 --- a/code/modules/unit_tests/trait_addition_and_removal.dm +++ b/code/modules/unit_tests/trait_addition_and_removal.dm @@ -81,7 +81,7 @@ TEST_ASSERT(HAS_TRAIT(trait_target, TRAIT_UNIT_TEST_C), "[TRAIT_UNIT_TEST_C] was unexpectedly removed when using REMOVE_TRAIT() using [UNIT_TEST_SOURCE_MAIN] (was added using add_traits())!") REMOVE_TRAIT(trait_target, TRAIT_UNIT_TEST_C, UNIT_TEST_SOURCE_MAIN) //just for cleanliness+completeness - TEST_ASSERT(!length(trait_target.status_traits), "Failed to clean up all status traits at the end of the unit test!") + TEST_ASSERT(!length(trait_target._status_traits), "Failed to clean up all status traits at the end of the unit test!") #undef TRAIT_UNIT_TEST_MAIN #undef TRAIT_UNIT_TEST_ALT