Skip to content

Commit

Permalink
Replace direct poi_list manipulation with element (tgstation#55416)
Browse files Browse the repository at this point in the history
Replaces GLOB.poi_list |= src and GLOB.poi_list -= src with an element that handles it directly.

More consistent code, especially when a lot of code couldn't decide how to add/remove (some |=, some -=, some .Remove, etc).
  • Loading branch information
Mothblocks authored Dec 10, 2020
1 parent d24c06a commit 0a77d27
Show file tree
Hide file tree
Showing 23 changed files with 38 additions and 76 deletions.
13 changes: 13 additions & 0 deletions code/datums/elements/point_of_interest.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// Designates the atom as a "point of interest", meaning it can be directly orbited
/datum/element/point_of_interest
element_flags = ELEMENT_DETACH

/datum/element/point_of_interest/Attach(datum/target)
if (!isatom(target))
return ELEMENT_INCOMPATIBLE
GLOB.poi_list += target
return ..()

/datum/element/point_of_interest/Detach(datum/target)
GLOB.poi_list -= target
return ..()
5 changes: 3 additions & 2 deletions code/game/objects/effects/anomalies.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

/obj/effect/anomaly/Initialize(mapload, new_lifespan, drops_core = TRUE)
. = ..()
GLOB.poi_list |= src

AddElement(/datum/element/point_of_interest)

START_PROCESSING(SSobj, src)
impact_area = get_area(src)

Expand Down Expand Up @@ -59,7 +61,6 @@
qdel(src)

/obj/effect/anomaly/Destroy()
GLOB.poi_list.Remove(src)
STOP_PROCESSING(SSobj, src)
qdel(countdown)
if(aSignal)
Expand Down
8 changes: 2 additions & 6 deletions code/game/objects/effects/spiders.dm
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,8 @@
pixel_x = base_pixel_x + rand(3,-3)
pixel_y = base_pixel_y + rand(3,-3)
START_PROCESSING(SSobj, src)
. = ..()
GLOB.poi_list |= src

/obj/structure/spider/eggcluster/Destroy()
. = ..()
GLOB.poi_list.Remove(src)
AddElement(/datum/element/point_of_interest)
return ..()

/obj/structure/spider/eggcluster/process(delta_time)
amount_grown += rand(0,1) * delta_time
Expand Down
6 changes: 1 addition & 5 deletions code/game/objects/items/eightball.dm
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,7 @@
. = ..()
for (var/answer in haunted_answers)
votes[answer] = 0
GLOB.poi_list |= src

/obj/item/toy/eightball/haunted/Destroy()
GLOB.poi_list -= src
. = ..()
AddElement(/datum/element/point_of_interest)

/obj/item/toy/eightball/haunted/MakeHaunted()
return FALSE
Expand Down
3 changes: 1 addition & 2 deletions code/game/objects/items/his_grace.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
/obj/item/his_grace/Initialize()
. = ..()
START_PROCESSING(SSprocessing, src)
GLOB.poi_list += src
AddElement(/datum/element/point_of_interest)
RegisterSignal(src, COMSIG_MOVABLE_POST_THROW, .proc/move_gracefully)

/obj/item/his_grace/Destroy()
STOP_PROCESSING(SSprocessing, src)
GLOB.poi_list -= src
for(var/mob/living/L in src)
L.forceMove(get_turf(src))
return ..()
Expand Down
3 changes: 1 addition & 2 deletions code/modules/antagonists/blob/structures/core.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/obj/structure/blob/core/Initialize(mapload, client/new_overmind = null, placed = 0)
GLOB.blob_cores += src
START_PROCESSING(SSobj, src)
GLOB.poi_list |= src
AddElement(/datum/element/point_of_interest)
update_icon() //so it atleast appears
if(!placed && !overmind)
return INITIALIZE_HINT_QDEL
Expand All @@ -39,7 +39,6 @@
overmind.blob_core = null
overmind = null
STOP_PROCESSING(SSobj, src)
GLOB.poi_list -= src
return ..()

/obj/structure/blob/core/ex_act(severity, target)
Expand Down
6 changes: 1 addition & 5 deletions code/modules/antagonists/cult/runes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,7 @@ structure_check() searches for nearby cultist structures required for the invoca

/obj/effect/rune/narsie/Initialize(mapload, set_keyword)
. = ..()
GLOB.poi_list |= src

/obj/effect/rune/narsie/Destroy()
GLOB.poi_list -= src
. = ..()
AddElement(/datum/element/point_of_interest)

/obj/effect/rune/narsie/conceal() //can't hide this, and you wouldn't want to
return
Expand Down
11 changes: 2 additions & 9 deletions code/modules/antagonists/nukeop/equipment/nuclearbomb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@
core = new /obj/item/nuke_core(src)
STOP_PROCESSING(SSobj, core)
update_icon()
GLOB.poi_list |= src
AddElement(/datum/element/point_of_interest)
previous_level = get_security_level()

/obj/machinery/nuclearbomb/Destroy()
safety = FALSE
if(!exploding)
// If we're not exploding, set the alert level back to normal
set_safety()
GLOB.poi_list -= src
GLOB.nuke_list -= src
QDEL_NULL(countdown)
QDEL_NULL(core)
Expand Down Expand Up @@ -636,7 +635,7 @@ This is here to make the tiles around the station mininuke change when it's arme
/obj/item/disk/nuclear/Initialize()
. = ..()
if(!fake)
GLOB.poi_list |= src
AddElement(/datum/element/point_of_interest)
last_disk_move = world.time
START_PROCESSING(SSobj, src)

Expand Down Expand Up @@ -699,12 +698,6 @@ This is here to make the tiles around the station mininuke change when it's arme
return TRUE
return ..()

/obj/item/disk/nuclear/Destroy(force=FALSE)
// respawning is handled in /obj/Destroy()
if(force)
GLOB.poi_list -= src
. = ..()

/obj/item/disk/nuclear/suicide_act(mob/user)
user.visible_message("<span class='suicide'>[user] is going delta! It looks like [user.p_theyre()] trying to commit suicide!</span>")
playsound(src, 'sound/machines/alarm.ogg', 50, -1, TRUE)
Expand Down
6 changes: 1 addition & 5 deletions code/modules/awaymissions/capture_the_flag.dm
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,7 @@

/obj/machinery/capture_the_flag/Initialize()
. = ..()
GLOB.poi_list |= src

/obj/machinery/capture_the_flag/Destroy()
GLOB.poi_list.Remove(src)
..()
AddElement(/datum/element/point_of_interest)

/obj/machinery/capture_the_flag/process(delta_time)
for(var/i in spawned_mobs)
Expand Down
3 changes: 1 addition & 2 deletions code/modules/awaymissions/corpse.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,10 @@
if(instant || (roundstart && (mapload || (SSticker && SSticker.current_state > GAME_STATE_SETTING_UP))))
INVOKE_ASYNC(src, .proc/create)
else if(ghost_usable)
GLOB.poi_list |= src
AddElement(/datum/element/point_of_interest)
LAZYADD(GLOB.mob_spawners[name], src)

/obj/effect/mob_spawn/Destroy()
GLOB.poi_list -= src
var/list/spawners = GLOB.mob_spawners[name]
LAZYREMOVE(spawners, src)
if(!LAZYLEN(spawners))
Expand Down
6 changes: 1 addition & 5 deletions code/modules/events/immovable_rod.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ In my current plan for it, 'solid' will be defined as anything with density == 1
z_original = z
destination = end
special_target = aimed_at
GLOB.poi_list += src
AddElement(/datum/element/point_of_interest)

var/special_target_valid = FALSE
if(special_target)
Expand Down Expand Up @@ -104,10 +104,6 @@ In my current plan for it, 'solid' will be defined as anything with density == 1
if(istype(ghost))
ghost.ManualFollow(src)

/obj/effect/immovablerod/Destroy()
GLOB.poi_list -= src
. = ..()

/obj/effect/immovablerod/Moved()
if((z != z_original))
qdel(src)
Expand Down
3 changes: 1 addition & 2 deletions code/modules/events/wizard/greentext.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

/obj/item/greentext/Initialize(mapload)
. = ..()
GLOB.poi_list |= src
AddElement(/datum/element/point_of_interest)
roundend_callback = CALLBACK(src,.proc/check_winner)
SSticker.OnRoundend(roundend_callback)

Expand Down Expand Up @@ -84,7 +84,6 @@
return QDEL_HINT_LETMELIVE

SSticker.round_end_events -= roundend_callback
GLOB.poi_list.Remove(src)
for(var/i in GLOB.player_list)
var/mob/M = i
var/message = "<span class='warning'>A dark temptation has passed from this world"
Expand Down
3 changes: 1 addition & 2 deletions code/modules/mining/lavaland/necropolis_chests.dm
Original file line number Diff line number Diff line change
Expand Up @@ -832,15 +832,14 @@
. = ..()
spirits = list()
START_PROCESSING(SSobj, src)
GLOB.poi_list |= src
AddElement(/datum/element/point_of_interest)
AddComponent(/datum/component/butchering, 150, 90)

/obj/item/melee/ghost_sword/Destroy()
for(var/mob/dead/observer/G in spirits)
G.invisibility = GLOB.observer_default_invisibility
spirits.Cut()
STOP_PROCESSING(SSobj, src)
GLOB.poi_list -= src
. = ..()

/obj/item/melee/ghost_sword/attack_self(mob/user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@
var/area/A = get_area(src)
if(A)
notify_ghosts("A drone shell has been created in \the [A.name].", source = src, action=NOTIFY_ATTACK, flashwindow = FALSE, ignore_key = POLL_IGNORE_DRONE, notify_suiciders = FALSE)
GLOB.poi_list |= src

/obj/effect/mob_spawn/drone/Destroy()
GLOB.poi_list -= src
. = ..()
AddElement(/datum/element/point_of_interest)

//ATTACK GHOST IGNORING PARENT RETURN VALUE
/obj/effect/mob_spawn/drone/attack_ghost(mob/user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,13 +616,9 @@
activation_sound = 'sound/effects/ghost2.ogg'
var/ready_to_deploy = FALSE

/obj/machinery/anomalous_crystal/helpers/Destroy()
GLOB.poi_list -= src
. = ..()

/obj/machinery/anomalous_crystal/helpers/ActivationReaction(mob/user, method)
if(..() && !ready_to_deploy)
GLOB.poi_list |= src
AddElement(/datum/element/point_of_interest)
ready_to_deploy = TRUE
notify_ghosts("An anomalous crystal has been activated in [get_area(src)]! This crystal can always be used by ghosts hereafter.", enter_link = "<a href=?src=[REF(src)];ghostjoin=1>(Click to enter)</a>", ghost_sound = 'sound/effects/ghost2.ogg', source = src, action = NOTIFY_ATTACK, header = "Anomalous crystal activated")

Expand Down
3 changes: 1 addition & 2 deletions code/modules/power/singularity/singularity.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
energy = starting_energy

START_PROCESSING(SSobj, src)
GLOB.poi_list |= src
AddElement(/datum/element/point_of_interest)
GLOB.singularities |= src

var/datum/component/singularity/new_component = AddComponent(
Expand All @@ -58,7 +58,6 @@

/obj/singularity/Destroy()
STOP_PROCESSING(SSobj, src)
GLOB.poi_list.Remove(src)
GLOB.singularities.Remove(src)
return ..()

Expand Down
3 changes: 1 addition & 2 deletions code/modules/power/supermatter/supermatter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
SSair.start_processing_machine(src)
countdown = new(src)
countdown.start()
GLOB.poi_list |= src
AddElement(/datum/element/point_of_interest)
radio = new(src)
radio.keyslot = new radio_key
radio.listening = 0
Expand All @@ -340,7 +340,6 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
investigate_log("has been destroyed.", INVESTIGATE_SUPERMATTER)
SSair.stop_processing_machine(src)
QDEL_NULL(radio)
GLOB.poi_list -= src
QDEL_NULL(countdown)
if(is_main_engine && GLOB.main_supermatter_engine == src)
GLOB.main_supermatter_engine = null
Expand Down
1 change: 0 additions & 1 deletion code/modules/power/tesla/energy_ball.dm
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@
/obj/energy_ball/orbit(obj/energy_ball/target)
if (istype(target))
target.orbiting_balls += src
GLOB.poi_list -= src
. = ..()

/obj/energy_ball/stop_orbit()
Expand Down
6 changes: 1 addition & 5 deletions code/modules/projectiles/guns/energy/pulse.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,14 @@

/obj/item/gun/energy/pulse/prize/Initialize()
. = ..()
GLOB.poi_list += src
AddElement(/datum/element/point_of_interest)
var/turf/T = get_turf(src)

message_admins("A pulse rifle prize has been created at [ADMIN_VERBOSEJMP(T)]")
log_game("A pulse rifle prize has been created at [AREACOORD(T)]")

notify_ghosts("Someone won a pulse rifle as a prize!", source = src, action = NOTIFY_ORBIT, header = "Pulse rifle prize")

/obj/item/gun/energy/pulse/prize/Destroy()
GLOB.poi_list -= src
. = ..()

/obj/item/gun/energy/pulse/loyalpin
pin = /obj/item/firing_pin/implant/mindshield

Expand Down
3 changes: 1 addition & 2 deletions code/modules/spells/spell_types/lichdom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,14 @@
name = "phylactery of [mind.name]"

active_phylacteries++
GLOB.poi_list |= src
AddElement(/datum/element/point_of_interest)
START_PROCESSING(SSobj, src)
if(initial(SSticker.mode.round_ends_with_antag_death))
SSticker.mode.round_ends_with_antag_death = FALSE

/obj/item/phylactery/Destroy(force=FALSE)
STOP_PROCESSING(SSobj, src)
active_phylacteries--
GLOB.poi_list -= src
if(!active_phylacteries)
SSticker.mode.round_ends_with_antag_death = initial(SSticker.mode.round_ends_with_antag_death)
. = ..()
Expand Down
6 changes: 1 addition & 5 deletions code/modules/swarmers/swarmer_objs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@

/obj/structure/swarmer_beacon/Initialize()
. = ..()
GLOB.poi_list |= src

/obj/structure/swarmer_beacon/Destroy()
. = ..()
GLOB.poi_list.Remove(src)
AddElement(/datum/element/point_of_interest)

/obj/structure/swarmer_beacon/attack_ghost(mob/user)
. = ..()
Expand Down
3 changes: 1 addition & 2 deletions code/modules/vehicles/mecha/_mecha.dm
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
add_scanmod()
add_capacitor()
START_PROCESSING(SSobj, src)
GLOB.poi_list |= src
AddElement(/datum/element/point_of_interest)
log_message("[src.name] created.", LOG_MECHA)
GLOB.mechas_list += src //global mech list
prepare_huds()
Expand Down Expand Up @@ -217,7 +217,6 @@
QDEL_NULL(capacitor)
QDEL_NULL(internal_tank)
STOP_PROCESSING(SSobj, src)
GLOB.poi_list.Remove(src)
LAZYCLEARLIST(equipment)
if(loc)
loc.assume_air(cabin_air)
Expand Down
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@
#include "code\datums\elements\forced_gravity.dm"
#include "code\datums\elements\light_blocking.dm"
#include "code\datums\elements\obj_regen.dm"
#include "code\datums\elements\point_of_interest.dm"
#include "code\datums\elements\rad_insulation.dm"
#include "code\datums\elements\selfknockback.dm"
#include "code\datums\elements\snail_crawl.dm"
Expand Down

0 comments on commit 0a77d27

Please sign in to comment.