mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-26 06:29:23 +01:00
AddComponent() now throws a crash message when the comp type arg is not a component. (#76221)
## About The Pull Request HEY! Did you know that the AddComponent() proc can complete without throwing errors when the component type argument is actually not a type or instance of a component? Me neither (until now), but I've recently discovered that while working on #76219 (Make sure to merge that one first). Also adds early return checks to the AddElement and RemoveElement procs. ## Why It's Good For The Game Silent bugs are awful. ## Changelog N/A
This commit is contained in:
@@ -53,6 +53,8 @@
|
||||
if(QDELING(src))
|
||||
CRASH("We just tried to add an element to a qdeleted datum, something is fucked")
|
||||
var/datum/element/ele = SSdcs.GetElement(arguments)
|
||||
if(!ele) // We couldn't fetch the element, likely because it was not an element.
|
||||
return // the crash message has already been sent
|
||||
arguments[1] = src
|
||||
if(ele.Attach(arglist(arguments)) == ELEMENT_INCOMPATIBLE)
|
||||
CRASH("Incompatible element [ele.type] was assigned to a [type]! args: [json_encode(args)]")
|
||||
@@ -63,6 +65,8 @@
|
||||
*/
|
||||
/datum/proc/_RemoveElement(list/arguments)
|
||||
var/datum/element/ele = SSdcs.GetElement(arguments)
|
||||
if(!ele) // We couldn't fetch the element, likely because it was not an element.
|
||||
return // the crash message has already been sent
|
||||
if(ele.element_flags & ELEMENT_COMPLEX_DETACH)
|
||||
arguments[1] = src
|
||||
ele.Detach(arglist(arguments))
|
||||
|
||||
Reference in New Issue
Block a user