mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-31 03:52:31 +00:00
Makes the code compatible with 515.1594+
Few simple changes and one very painful one.
Let's start with the easy:
* puts call behind `LIBCALL` define, so call_ext is properly used in 515
* Adds `NAMEOF_STATIC(_,X)` macro for nameof in static definitions since
src is now invalid there.
* Fixes tgui and devserver. From 515 onward the tmp3333{procid} cache
directory is not appened to base path in browser controls so we don't
check for it in base js and put the dev server dummy window file in
actual directory not the byond root.
* Renames the few things that had /final/ in typepath to ultimate since
final is a new keyword
And the very painful change:
`.proc/whatever` format is no longer valid, so we're replacing it with
new nameof() function. All this wrapped in three new macros.
`PROC_REF(X)`,`TYPE_PROC_REF(TYPE,X)`,`GLOBAL_PROC_REF(X)`. Global is
not actually necessary but if we get nameof that does not allow globals
it would be nice validation.
This is pretty unwieldy but there's no real alternative.
If you notice anything weird in the commits let me know because majority
was done with regex replace.
@tgstation/commit-access Since the .proc/stuff is pretty big change.
Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
68 lines
2.2 KiB
Plaintext
68 lines
2.2 KiB
Plaintext
/**
|
|
* A holder for simple behaviour that can be attached to many different types
|
|
*
|
|
* Only one element of each type is instanced during game init.
|
|
* Otherwise acts basically like a lightweight component.
|
|
*/
|
|
/datum/element
|
|
/// Option flags for element behaviour
|
|
var/element_flags = NONE
|
|
/**
|
|
* The index of the first attach argument to consider for duplicate elements
|
|
*
|
|
* Is only used when flags contains [ELEMENT_BESPOKE]
|
|
*
|
|
* This is infinity so you must explicitly set this
|
|
*/
|
|
var/id_arg_index = INFINITY
|
|
|
|
/// Activates the functionality defined by the element on the given target datum
|
|
/datum/element/proc/Attach(datum/target)
|
|
SHOULD_CALL_PARENT(TRUE)
|
|
if(type == /datum/element)
|
|
return ELEMENT_INCOMPATIBLE
|
|
SEND_SIGNAL(target, COMSIG_ELEMENT_ATTACH, src)
|
|
if(element_flags & ELEMENT_DETACH_ON_HOST_DESTROY)
|
|
RegisterSignal(target, COMSIG_PARENT_QDELETING, PROC_REF(OnTargetDelete), override = TRUE)
|
|
|
|
/datum/element/proc/OnTargetDelete(datum/source, force)
|
|
SIGNAL_HANDLER
|
|
Detach(source)
|
|
|
|
/// Deactivates the functionality defines by the element on the given datum
|
|
/datum/element/proc/Detach(datum/source, ...)
|
|
SIGNAL_HANDLER
|
|
SHOULD_CALL_PARENT(TRUE)
|
|
|
|
SEND_SIGNAL(source, COMSIG_ELEMENT_DETACH, src)
|
|
UnregisterSignal(source, COMSIG_PARENT_QDELETING)
|
|
|
|
/datum/element/Destroy(force)
|
|
if(!force)
|
|
return QDEL_HINT_LETMELIVE
|
|
SSdcs.elements_by_type -= type
|
|
return ..()
|
|
|
|
//DATUM PROCS
|
|
|
|
/// Finds the singleton for the element type given and attaches it to src
|
|
/datum/proc/_AddElement(list/arguments)
|
|
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)
|
|
arguments[1] = src
|
|
if(ele.Attach(arglist(arguments)) == ELEMENT_INCOMPATIBLE)
|
|
CRASH("Incompatible [arguments[1]] assigned to a [type]! args: [json_encode(args)]")
|
|
|
|
/**
|
|
* Finds the singleton for the element type given and detaches it from src
|
|
* You only need additional arguments beyond the type if you're using [ELEMENT_BESPOKE]
|
|
*/
|
|
/datum/proc/_RemoveElement(list/arguments)
|
|
var/datum/element/ele = SSdcs.GetElement(arguments)
|
|
if(ele.element_flags & ELEMENT_COMPLEX_DETACH)
|
|
arguments[1] = src
|
|
ele.Detach(arglist(arguments))
|
|
else
|
|
ele.Detach(src)
|