Merge pull request #14959 from Citadel-Station-13/table-floodfills

rewrites subtler_around_table to be slightly cleaner and (probably) work?
This commit is contained in:
Lin
2021-07-25 13:56:35 -07:00
committed by GitHub
2 changed files with 33 additions and 26 deletions
@@ -243,6 +243,32 @@
new framestack(T, framestackamount)
qdel(src)
/**
* Gets all connected tables
* Cardinals only
*/
/obj/structure/table/proc/connected_floodfill(max = 25)
. = list()
connected_floodfill_internal(., list())
/obj/structure/table/proc/connected_floodfill_internal(list/out = list(), list/processed = list())
if(processed[src])
return
processed[src] = TRUE
out += src
var/obj/structure/table/other
#define RUN_TABLE(dir) \
other = locate(/obj/structure/table) in get_step(src, dir); \
if(other) { \
other.connected_floodfill_internal(out, processed); \
}
RUN_TABLE(NORTH)
RUN_TABLE(SOUTH)
RUN_TABLE(EAST)
RUN_TABLE(WEST)
#undef RUN_TABLE
/obj/structure/table/greyscale
icon = 'icons/obj/smooth_structures/table_greyscale.dmi'
icon_state = "table"
+7 -26
View File
@@ -144,33 +144,14 @@
message = "<span class='emote'><b>[user]</b> <i>[user.say_emphasis(message)]</i></span>"
var/list/show_to = list()
var/list/processing = list()
var/safety = 25
var/list/processed = list()
for(var/obj/structure/table/T in range(user, 1))
processing |= T
for(var/i = 1; i <= processing.len; ++i)
var/obj/structure/table/T = processing[i]
if(safety-- <= 0)
to_chat(user, "Table scan aborted early, some people might have not received the message (max 25)")
break
if(get_dist(T, user) > 7)
continue // nah
processing |= T
for(var/mob/living/M in range(T, 1)) // no ghosts/cameramobs
show_to |= M
var/obj/structure/table/other
other = locate() in get_step(T, NORTH)
if(other)
processing |= other
other = locate() in get_step(T, SOUTH)
if(other)
processing |= other
other = locate() in get_step(T, WEST)
if(other)
processing |= other
other = locate() in get_step(T, EAST)
if(other)
processing |= other
if(processed[T])
continue
for(var/obj/structure/table/T2 in T.connected_floodfill(25))
processed[T2] = TRUE
for(var/mob/living/L in range(T2, 1))
show_to |= L
for(var/i in show_to)
var/mob/M = i