From 3e96c59bb79d99e3fa30f4ce9565d332cf82877d Mon Sep 17 00:00:00 2001 From: CitadelStationBot Date: Thu, 3 Aug 2017 13:15:13 -0500 Subject: [PATCH 1/5] Fixes SendSignal() --- code/datums/components/component.dm.rej | 63 +++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 code/datums/components/component.dm.rej diff --git a/code/datums/components/component.dm.rej b/code/datums/components/component.dm.rej new file mode 100644 index 0000000000..17aaf74125 --- /dev/null +++ b/code/datums/components/component.dm.rej @@ -0,0 +1,63 @@ +diff a/code/datums/components/component.dm b/code/datums/components/component.dm (rejected hunks) +@@ -26,7 +26,7 @@ + + //set up the typecache + var/our_type = type +- for(var/I in _GetInverseTypeListExceptRoot(our_type)) ++ for(var/I in _GetInverseTypeList(our_type)) + var/test = dc[I] + if(test) //already another component of this type here + var/list/components_of_type +@@ -66,7 +66,7 @@ + if(P) + var/list/dc = P.datum_components + var/our_type = type +- for(var/I in _GetInverseTypeListExceptRoot(our_type)) ++ for(var/I in _GetInverseTypeList(our_type)) + var/list/components_of_type = dc[I] + if(islist(components_of_type)) // + var/list/subtracted = components_of_type - src +@@ -110,25 +110,33 @@ + /datum/component/proc/OnTransfer(datum/new_parent) + return + +-/datum/component/proc/_GetInverseTypeListExceptRoot(our_type_cached) +- var/datum/component/current_type = our_type_cached +- . = list() ++/datum/component/proc/_GetInverseTypeList(current_type) ++ . = list(current_type) + while (current_type != /datum/component) +- . += current_type + current_type = type2parent(current_type) ++ . += current_type + + /datum/var/list/datum_components //special typecache of /datum/component + + /datum/proc/SendSignal(sigtype, ...) + var/list/comps = datum_components + . = FALSE +- for(var/I in comps) +- var/datum/component/C = I +- if(!C.enabled) +- continue +- if(C.ReceiveSignal(arglist(args))) ++ if(!comps) ++ return ++ var/target = comps[/datum/component] ++ if(!islist(target)) ++ var/datum/component/C = target ++ if(C.enabled && C.ReceiveSignal(arglist(args))) + ComponentActivated(C) +- . = TRUE ++ return TRUE ++ else ++ for(var/I in target) ++ var/datum/component/C = I ++ if(!C.enabled) ++ continue ++ if(C.ReceiveSignal(arglist(args))) ++ ComponentActivated(C) ++ . = TRUE + + /datum/proc/ComponentActivated(datum/component/C) + return From ab26b486b7648284bba6bf74ad04df1a6ac073ba Mon Sep 17 00:00:00 2001 From: LetterJay Date: Mon, 21 Aug 2017 02:38:51 -0500 Subject: [PATCH 2/5] Update component.dm --- code/datums/components/component.dm | 37 +++++++++++++++++------------ 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/code/datums/components/component.dm b/code/datums/components/component.dm index 4d5fae2115..6310021006 100644 --- a/code/datums/components/component.dm +++ b/code/datums/components/component.dm @@ -26,7 +26,7 @@ //set up the typecache var/our_type = type - for(var/I in _GetInverseTypeListExceptRoot(our_type)) + for(var/I in _GetInverseTypeList(our_type)) var/test = dc[I] if(test) //already another component of this type here var/list/components_of_type @@ -66,7 +66,7 @@ if(P) var/list/dc = P.datum_components var/our_type = type - for(var/I in _GetInverseTypeListExceptRoot(our_type)) + for(var/I in _GetInverseTypeList(our_type)) var/list/components_of_type = dc[I] if(islist(components_of_type)) // var/list/subtracted = components_of_type - src @@ -109,24 +109,31 @@ /datum/component/proc/OnTransfer(datum/new_parent) return - -/datum/component/proc/_GetInverseTypeListExceptRoot(our_type_cached) - var/datum/component/current_type = our_type_cached - . = list() - while (current_type != /datum/component) +/datum/component/proc/_GetInverseTypeList(current_type) + . = list(current_type) + while (current_type != /datum/component) + current_type = type2parent(current_type) . += current_type - current_type = type2parent(current_type) /datum/proc/SendSignal(sigtype, ...) var/list/comps = datum_components . = FALSE - for(var/I in comps) - var/datum/component/C = I - if(!C.enabled) - continue - if(C.ReceiveSignal(arglist(args))) - ComponentActivated(C) - . = TRUE + if(!comps) + return + var/target = comps[/datum/component] + if(!islist(target)) + var/datum/component/C = target + if(C.enabled && C.ReceiveSignal(arglist(args))) + ComponentActivated(C) + return TRUE + else + for(var/I in target) + var/datum/component/C = I + if(!C.enabled) + continue + if(C.ReceiveSignal(arglist(args))) + ComponentActivated(C) + . = TRUE /datum/proc/ComponentActivated(datum/component/C) return From 39a69c2a2895a618c0ec7671e45f781cfb41ce38 Mon Sep 17 00:00:00 2001 From: LetterJay Date: Mon, 21 Aug 2017 16:50:29 -0500 Subject: [PATCH 3/5] Update component.dm --- code/datums/components/component.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/datums/components/component.dm b/code/datums/components/component.dm index 6310021006..c9c5f38a60 100644 --- a/code/datums/components/component.dm +++ b/code/datums/components/component.dm @@ -124,7 +124,7 @@ if(!islist(target)) var/datum/component/C = target if(C.enabled && C.ReceiveSignal(arglist(args))) - ComponentActivated(C) + ComponentActivated(C) return TRUE else for(var/I in target) From 17c0c4ba7945258a1e949f3779318ebb400e60a4 Mon Sep 17 00:00:00 2001 From: LetterJay Date: Mon, 21 Aug 2017 18:39:30 -0500 Subject: [PATCH 4/5] FUCK --- code/datums/components/component.dm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/code/datums/components/component.dm b/code/datums/components/component.dm index c9c5f38a60..67d58d36e6 100644 --- a/code/datums/components/component.dm +++ b/code/datums/components/component.dm @@ -106,14 +106,17 @@ /datum/component/proc/InheritComponent(datum/component/C, i_am_original) return - /datum/component/proc/OnTransfer(datum/new_parent) return + +/datum/component/proc/AfterComponentActivated() + return + /datum/component/proc/_GetInverseTypeList(current_type) . = list(current_type) - while (current_type != /datum/component) - current_type = type2parent(current_type) - . += current_type + while (current_type != /datum/component) + current_type = type2parent(current_type) +. += current_type /datum/proc/SendSignal(sigtype, ...) var/list/comps = datum_components From 259edee5a27e04a721771d04d2c56cd780aefe4b Mon Sep 17 00:00:00 2001 From: LetterJay Date: Mon, 21 Aug 2017 18:49:14 -0500 Subject: [PATCH 5/5] Update component.dm --- code/datums/components/component.dm | 45 +++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/code/datums/components/component.dm b/code/datums/components/component.dm index 67d58d36e6..92ac9a4767 100644 --- a/code/datums/components/component.dm +++ b/code/datums/components/component.dm @@ -1,22 +1,35 @@ /datum/component var/enabled = TRUE var/dupe_mode = COMPONENT_DUPE_HIGHLANDER + var/dupe_type var/list/signal_procs var/datum/parent /datum/component/New(datum/P, ...) + parent = P + var/list/arguments = args.Copy() + arguments.Cut(1, 2) + Initialize(arglist(arguments)) + var/dm = dupe_mode if(dm != COMPONENT_DUPE_ALLOWED) - var/datum/component/old = P.GetExactComponent(type) - if(old) - switch(dm) - if(COMPONENT_DUPE_HIGHLANDER) - InheritComponent(old, FALSE) - qdel(old) - if(COMPONENT_DUPE_UNIQUE) - old.InheritComponent(src, TRUE) - qdel(src) - return + var/dt = dupe_type + var/datum/component/old + if(!dt) + old = P.GetExactComponent(type) + else + old = P.GetComponent(dt) + switch(dm) + if(COMPONENT_DUPE_UNIQUE) + old.InheritComponent(src, TRUE) + parent = null //prevent COMPONENT_REMOVING signal + qdel(src) + return + if(COMPONENT_DUPE_HIGHLANDER) + InheritComponent(old, FALSE) + qdel(old) + + //let the others know P.SendSignal(COMSIG_COMPONENT_ADDED, src) //lazy init the parent's dc list @@ -50,7 +63,8 @@ else //only component of this type, no list dc[I] = src - parent = P +/datum/component/proc/Initialize(...) + return /datum/component/Destroy() enabled = FALSE @@ -106,6 +120,7 @@ /datum/component/proc/InheritComponent(datum/component/C, i_am_original) return + /datum/component/proc/OnTransfer(datum/new_parent) return @@ -116,7 +131,7 @@ . = list(current_type) while (current_type != /datum/component) current_type = type2parent(current_type) -. += current_type + . += current_type /datum/proc/SendSignal(sigtype, ...) var/list/comps = datum_components @@ -128,6 +143,7 @@ var/datum/component/C = target if(C.enabled && C.ReceiveSignal(arglist(args))) ComponentActivated(C) + C.AfterComponentActivated() return TRUE else for(var/I in target) @@ -175,6 +191,11 @@ var/datum/component/C = new nt(arglist(args)) return QDELING(C) ? GetComponent(new_type) : C +/datum/proc/LoadComponent(component_type, ...) + . = GetComponent(component_type) + if(!.) + return AddComponent(arglist(args)) + /datum/proc/TakeComponent(datum/component/C) if(!C) return