Files
Bubberstation/code/datums/elements/forced_gravity.dm
Bloop 1a0a8e6e9a Attempts to fix an issue with gravity generators triggering CI failures (#76764)
## About The Pull Request

#76730 continuation, but I think I have found the actual source of the
bug. EDIT: Just kidding, that turned out to not be it either.

The issue:

During init, when the gravity generator is being set up and creating its
proximity field, a turf can get the `COMSIG_ATOM_HAS_GRAVITY` signal
registered to it multiple times. It seems like it shouldn't be possible
for this to happen due to the `HAS_TRAIT(TRAIT_FORCED_GRAVITY)` check,
but it can.

I've only seen this happen during CI and have not been able to reproduce
it during runtime, but it comes up often enough to be a nuisance when
testing PRs.

As seen below, causing CI failures. The problem turf is directly below
the `gravity_generator/main` object.


![firefox_D4BgPpRbW6](https://github.com/tgstation/tgstation/assets/13398309/d41355de-d05b-4f9d-8305-524408c93022)

I spent too much time trying to figure out the cause of this duped
signal when it really does not matter if this signal gets overridden
here, since it's always going to be from the same proximity field.
Suppressing the warning will stop the CI failures without any ill
effects in this case.

So let's just do that.

## Why It's Good For The Game

Less CI failures for something trivial.

## Changelog

🆑
fix: fixes gravity generators causing CI failures from overriding a
signal
/🆑
2023-07-19 10:10:49 +02:00

45 lines
1.4 KiB
Plaintext

/datum/element/forced_gravity
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 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, can_override = FALSE)
. = ..()
if(!isatom(target))
return ELEMENT_INCOMPATIBLE
var/our_ref = REF(src)
if(HAS_TRAIT_FROM(target, TRAIT_FORCED_GRAVITY, our_ref))
return
src.gravity = gravity
src.ignore_turf_gravity = ignore_turf_gravity
RegisterSignal(target, COMSIG_ATOM_HAS_GRAVITY, PROC_REF(gravity_check), override = can_override)
if(isturf(target))
RegisterSignal(target, COMSIG_TURF_HAS_GRAVITY, PROC_REF(turf_gravity_check), override = can_override)
ADD_TRAIT(target, TRAIT_FORCED_GRAVITY, our_ref)
/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)
REMOVE_TRAIT(source, TRAIT_FORCED_GRAVITY, REF(src))
/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
gravity_check(null, source, gravs)