Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More hard delete fixes #4223

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions code/modules/unit_tests/unit_test.dm
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,15 @@ GLOBAL_VAR_INIT(focused_tests, focused_tests())
/obj/item/organ/external/wings,
/obj/effect/spawner/random_engines,
/obj/effect/spawner/random_bar,
///this instant starts a timer, and if its being instantly deleted it can cause issues
/obj/machinery/atm,
/datum/hotspot,
/obj/machinery/ocean_elevator,
/atom/movable/outdoor_effect,
/turf/closed/mineral/random/regrowth,
/obj/effect/abstract/signboard_holder, // monkestation addition: shouldn't exist outside of signboards
// monkestation start
/obj/machinery/atm, // this instantly starts a timer, and if its being instantly deleted it can cause issues
/obj/effect/abstract/signboard_holder, // shouldn't exist outside of signboards
/obj/structure/hive_exit, // should not exist on its own without being crated by a hive
// monkestation end
)
//Say it with me now, type template
ignore += typesof(/obj/effect/mapping_helpers)
Expand Down
89 changes: 43 additions & 46 deletions monkestation/code/modules/botany/species/apid/hive/hive_object.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,45 @@ GLOBAL_LIST_INIT(hive_exits, list())
honey_frames += HF

for(var/obj/structure/hive_exit/exit as anything in GLOB.hive_exits)
if(exit.linked_hive)
if(!QDELETED(exit.linked_hive))
continue
exit.linked_hive = src
linked_exit = exit
linked_exit.name = "[created_name]'s hive exit"
break

if(!linked_exit)
if(QDELETED(linked_exit))
var/datum/map_template/hive/hive = new()
var/datum/turf_reservation/roomReservation = SSmapping.request_turf_block_reservation(hive.width, hive.height, 1)
var/turf/bottom_left = roomReservation.bottom_left_turfs[1]
var/datum/map_template/load_from = hive

load_from.load(bottom_left)
for(var/obj/structure/hive_exit/exit as anything in GLOB.hive_exits)
if(exit.linked_hive)
if(!QDELETED(exit.linked_hive))
continue
exit.linked_hive = src
linked_exit = exit
break

/obj/structure/beebox/hive/Destroy()
. = ..()
var/turf/turf = get_turf(src)
for(var/atom/movable/listed as anything in linked_exit?.atoms_inside)
if(isnull(turf))
continue
listed.forceMove(get_turf(src))
var/area/area = get_area(linked_exit)
if(area)
for(var/atom/movable/movable as anything in area)
if(isturf(movable))
continue
if(isnull(turf))
continue
movable.forceMove(turf)

linked_exit?.linked_hive = null
linked_exit.name = "generic hive exit"
if(linked_exit?.linked_hive == src)
var/drop_loc = drop_location() || get_turf(src)
if(!isnull(drop_loc))
for(var/atom/movable/listed as anything in linked_exit.atoms_inside)
if(QDELETED(listed))
continue
listed.forceMove(drop_loc)
linked_exit.atoms_inside.Cut()
var/area/area = get_area(linked_exit)
for(var/turf/hive_turf as anything in area?.get_turfs_from_all_zlevels())
for(var/atom/movable/movable as anything in hive_turf)
if(QDELETED(movable))
continue
movable.forceMove(drop_loc)
linked_exit.linked_hive = null
linked_exit.name = "generic hive exit"
linked_exit = null

/obj/structure/beebox/hive/attack_hand(mob/living/user, list/modifiers)
Expand Down Expand Up @@ -88,37 +88,36 @@ GLOBAL_LIST_INIT(hive_exits, list())
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
anchored = TRUE
move_resist = INFINITY

var/obj/structure/beebox/hive/linked_hive

var/list/atoms_inside = list()

/obj/structure/hive_exit/Initialize(mapload)
. = ..()
GLOB.hive_exits += src
RegisterSignal(get_area(src), COMSIG_AREA_EXITED, PROC_REF(exit_area))
RegisterSignal(get_area(src), COMSIG_AREA_ENTERED, PROC_REF(enter_area))
var/area/our_area = get_area(src)
RegisterSignal(our_area, COMSIG_AREA_EXITED, PROC_REF(exit_area))
RegisterSignal(our_area, COMSIG_AREA_ENTERED, PROC_REF(enter_area))

/obj/structure/hive_exit/Destroy()
. = ..()
if(!linked_hive || !get_turf(linked_hive))
return
var/turf/turf = get_turf(linked_hive)
for(var/atom/movable/listed in atoms_inside)
if(isnull(turf))
continue
listed.forceMove(turf)
var/area/area = get_area(src)
for(var/atom/movable/movable as anything in area)
if(isturf(movable))
continue
if(isnull(turf))
continue
movable.forceMove(turf)

GLOB.hive_exits -= src
linked_hive?.linked_exit = null
var/area/our_area = get_area(src)
UnregisterSignal(our_area, list(COMSIG_AREA_EXITED, COMSIG_AREA_ENTERED))
if(linked_hive?.linked_exit == src)
var/turf/drop_loc = linked_hive.drop_location() || get_turf(linked_hive)
if(!isnull(drop_loc))
for(var/atom/movable/listed as anything in atoms_inside)
if(QDELETED(listed))
continue
listed.forceMove(drop_loc)
for(var/turf/hive_turf as anything in our_area?.get_turfs_from_all_zlevels())
for(var/atom/movable/movable as anything in hive_turf.contents)
if(QDELETED(movable))
continue
movable.forceMove(drop_loc)
linked_hive.linked_exit = null
atoms_inside.Cut()
linked_hive = null
return ..()

/obj/structure/hive_exit/attack_hand(mob/living/user, list/modifiers)
. = ..()
Expand All @@ -136,14 +135,12 @@ GLOBAL_LIST_INIT(hive_exits, list())
do_teleport(user, get_turf(linked_hive), no_effects = TRUE, forced = TRUE)

/obj/structure/hive_exit/proc/exit_area(datum/source, atom/removed)
if(isturf(removed))
return
atoms_inside -= removed
if(!isturf(removed))
atoms_inside -= removed

/obj/structure/hive_exit/proc/enter_area(datum/source, atom/added)
if(isturf(added))
return
atoms_inside += added
if(!isturf(added))
atoms_inside += added


/datum/map_template/hive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
if(!pipe_overlay_appearance)
pipe_overlay_appearance = mutable_appearance(icon = 'monkestation/code/modules/map_gen_expansions/icons/plasma_extractor.dmi', icon_state = "pipe", layer = ABOVE_ALL_MOB_LAYER, plane = ABOVE_GAME_PLANE, alpha = 100, offset_spokesman = parent)

/datum/component/pipe_laying/Destroy(force)
. = ..()
clear_click_catch(destroying = TRUE)
part_hub = null
current_target_weakref = null

/datum/component/pipe_laying/RegisterWithParent()
. = ..()
RegisterSignal(parent, COMSIG_ATOM_ATTACKBY, PROC_REF(on_attackby))
Expand Down Expand Up @@ -98,17 +104,20 @@
* Removes all overlays and clears the list of turfs, essentially resetting the component back to default,
* ready to use again later (if possible).
*/
/datum/component/pipe_laying/proc/clear_click_catch()
if(!lockon_component)
/datum/component/pipe_laying/proc/clear_click_catch(destroying = FALSE)
if(!lockon_component && !destroying)
return
for(var/turf/turfs_with_overlay as anything in turfs_hovering)
turfs_with_overlay.cut_overlay(pipe_overlay_appearance)
turfs_hovering.Cut()
UnregisterSignal(pipe_placing, COMSIG_MOVABLE_MOVED)
pipe_placing = null
pipe_placer.clear_fullscreen("pipe_extractor")
pipe_placer = null
playsound(parent, 'sound/effects/empulse.ogg', 75, TRUE)
if(pipe_placing)
UnregisterSignal(pipe_placing, COMSIG_MOVABLE_MOVED)
pipe_placing = null
if(pipe_placer)
pipe_placer.clear_fullscreen("pipe_extractor")
pipe_placer = null
if(!destroying)
playsound(parent, 'sound/effects/empulse.ogg', 75, TRUE)
QDEL_NULL(lockon_component)

///Called when the user clicks on something, which we just redirect to build pipes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ TODO LIST:
///The main pipe that owns us as part of our 3x3 machine.
var/obj/structure/plasma_extraction_hub/part/pipe/main/pipe_owner

/obj/structure/plasma_extraction_hub/part/Destroy()
pipe_owner = null
return ..()

/**
* Plasma extraction machine pipe
* There's 3 of these on each plasma extraction machine, one of which is the owner of the rest.
Expand All @@ -48,9 +52,9 @@ TODO LIST:
AddComponent(/datum/component/pipe_laying, src)

/obj/structure/plasma_extraction_hub/part/pipe/Destroy()
. = ..()
last_pipe = null
QDEL_LIST(connected_pipes)
return ..()

/**
* Called when a pipe with a reference to us is destroyed,
Expand Down
Loading