isopenturf() macro, update_above improvements (#2931)

changes:

Added a isopenturf() macro, equivalent to istype(thing, /turf/simulated/open).
Converted most/all instances of istype(/turf/simulated/open) to isopenturf().
Made update_above()' aware of queue status & inlined a proc-call.
This commit is contained in:
Lohikar
2017-07-03 04:04:18 -05:00
committed by skull132
parent d0fcc77f31
commit 9c010f92d1
18 changed files with 29 additions and 33 deletions

View File

@@ -12,7 +12,7 @@
/obj/item/weapon/ladder_mobile/proc/place_ladder(atom/A, mob/user)
if (istype(A, /turf/simulated/open)) //Place into open space
if (isopenturf(A)) //Place into open space
var/turf/below_loc = GetBelow(A)
if (!below_loc || (istype(/turf/space, below_loc)))
to_chat(user, "<span class='notice'>Why would you do that?! There is only infinite space there...</span>")
@@ -33,7 +33,7 @@
else if (istype(A, /turf/simulated/floor)) //Place onto Floor
var/turf/upper_loc = GetAbove(A)
if (!upper_loc || !istype(upper_loc,/turf/simulated/open))
if (!upper_loc || !isopenturf(upper_loc))
user << "<span class='notice'>There is something above. You can't deploy!</span>"
return
user.visible_message("<span class='warning'>[user] begins deploying \the [src] on \the [A].</span>",

View File

@@ -7,7 +7,7 @@
/turf/Entered(atom/movable/thing, atom/oldLoc)
. = ..()
if (above && !thing.no_z_overlay && !thing.bound_overlay && !istype(oldLoc, /turf/simulated/open))
if (above && !thing.no_z_overlay && !thing.bound_overlay && !isopenturf(oldLoc))
above.update_icon()
/turf/Destroy()
@@ -43,8 +43,11 @@
return
// check_existence returns TRUE if the overlay is valid.
if (bound_overlay.check_existence() && !bound_overlay.queued)
if (isopenturf(bound_overlay.loc) && !bound_overlay.queued)
SSopenturf.queued_overlays += bound_overlay
bound_overlay.queued = TRUE
else
qdel(bound_overlay)
/atom/movable/proc/get_above_oo()
. = list()
@@ -136,22 +139,13 @@
/atom/movable/openspace/overlay/forceMove(atom/dest)
. = ..()
if (istype(dest, /turf/simulated/open))
if (isopenturf(dest))
if (destruction_timer)
deltimer(destruction_timer)
destruction_timer = null
else if (!destruction_timer)
destruction_timer = addtimer(CALLBACK(GLOBAL_PROC, /proc/qdel, src), 10 SECONDS, TIMER_STOPPABLE)
// Checks if we've moved off of an openturf.
// Returns TRUE if we're continuing to exist, FALSE if we're deleting ourselves.
/atom/movable/openspace/overlay/proc/check_existence()
if (!istype(loc, /turf/simulated/open))
qdel(src)
return FALSE
else
return TRUE
// Called when the turf we're on is deleted/changed.
/atom/movable/openspace/overlay/proc/owning_turf_changed()
if (!destruction_timer)