Files
Bubberstation/code/datums/elements/forced_gravity.dm
AnturK 4d6a8bc537 515 Compatibility (#71161)
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>
2022-11-15 03:50:11 +00:00

39 lines
1.2 KiB
Plaintext

/datum/element/forced_gravity
element_flags = ELEMENT_BESPOKE
id_arg_index = 2
///the level of gravity we force unto our target
var/gravity
///whether we will override the turf if it forces no gravity
var/ignore_turf_gravity
/datum/element/forced_gravity/Attach(datum/target, gravity = 1, ignore_turf_gravity = FALSE)
. = ..()
if(!isatom(target))
return ELEMENT_INCOMPATIBLE
src.gravity = gravity
src.ignore_turf_gravity = ignore_turf_gravity
RegisterSignal(target, COMSIG_ATOM_HAS_GRAVITY, PROC_REF(gravity_check))
if(isturf(target))
RegisterSignal(target, COMSIG_TURF_HAS_GRAVITY, PROC_REF(turf_gravity_check))
/datum/element/forced_gravity/Detach(datum/source)
. = ..()
var/static/list/signals_b_gone = list(COMSIG_ATOM_HAS_GRAVITY, COMSIG_TURF_HAS_GRAVITY)
UnregisterSignal(source, signals_b_gone)
/datum/element/forced_gravity/proc/gravity_check(datum/source, turf/location, list/gravs)
SIGNAL_HANDLER
if(!ignore_turf_gravity && location.force_no_gravity)
return FALSE
gravs += gravity
return TRUE
/datum/element/forced_gravity/proc/turf_gravity_check(datum/source, atom/checker, list/gravs)
SIGNAL_HANDLER
return gravity_check(null, source, gravs)