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
This commit is contained in:
LemonInTheDark
2023-06-05 22:25:09 -06:00
committed by GitHub
parent 83cd4cac3b
commit daf55e611c
22 changed files with 135 additions and 118 deletions
+22 -22
View File
@@ -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]