diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index cea6353699ad..068d85a71ba5 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -1501,6 +1501,19 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new) #define UNTIL(X) while(!(X)) stoplag() +/// Macro for cases where an UNTIL() may go on forever (such as for an http request) +#define UNTIL_OR_TIMEOUT(X, __time) \ + do {\ + __time = max(__time, 0);\ + var/__start_time = world.time;\ + while(!(X)) {;\ + stoplag();\ + if(__start_time + __time <= world.time) {;\ + CRASH("UNTIL_OR_TIMEOUT hit timeout limit of [__time]");\ + };\ + };\ + } while(FALSE) + //Repopulates sortedAreas list /proc/repopulate_sorted_areas() GLOB.sorted_areas = list()