diff --git a/_std/defines/lag.dm b/_std/defines/lag.dm index 78e2c189d6239..c2d1b4ae4f09f 100644 --- a/_std/defines/lag.dm +++ b/_std/defines/lag.dm @@ -16,6 +16,12 @@ #define LAGCHECK(x) // this is wrong and bad, but it'd be way too much effort to remove lagchecks from everything :/ #endif +#ifdef LIVE_SERVER +#define LAGCHECK_IF_LIVE(x) LAGCHECK(x) +#else +#define LAGCHECK_IF_LIVE(x) sleep(-1) +#endif + //for light queue - when should we queue? and when should we pause processing our dowork loop? #define LIGHTING_MAX_TICKUSAGE 140 @@ -26,6 +32,7 @@ #define LAG_MED 90 #define LAG_HIGH 90 #define LAG_REALTIME 90 +#define LAG_INIT 95 /// Waits until a given condition is true, tg-style async #define UNTIL(X) while(!(X)) sleep(1) diff --git a/code/_lighting/RobustLight2.dm b/code/_lighting/RobustLight2.dm index 1369e76cad598..dc04dbe3527eb 100644 --- a/code/_lighting/RobustLight2.dm +++ b/code/_lighting/RobustLight2.dm @@ -8,7 +8,7 @@ proc/RL_Start() if (light.enabled) light.apply() for (var/turf/T in world) - sleep(-1) + LAGCHECK_IF_LIVE(LAG_INIT) RL_UPDATE_LIGHT(T) proc/RL_Suspend() diff --git a/code/datums/controllers/process/items.dm b/code/datums/controllers/process/items.dm index 594a33791079d..b008b9a09e191 100644 --- a/code/datums/controllers/process/items.dm +++ b/code/datums/controllers/process/items.dm @@ -29,7 +29,7 @@ lasttime = world.timeofday game_start_countdown.update_status("Initializing items\n([itemcount], [round(itemcount / totalcount * 100)]%)") - LAGCHECK(LAG_HIGH) + LAGCHECK_IF_LIVE(LAG_INIT) logTheThing(LOG_DEBUG, src, "Main /obj initialize loop completed") diff --git a/code/modules/camera/coverage/datum/controller/camera_coverage.dm b/code/modules/camera/coverage/datum/controller/camera_coverage.dm index b6456e58ef78f..4dc8b03400aa5 100644 --- a/code/modules/camera/coverage/datum/controller/camera_coverage.dm +++ b/code/modules/camera/coverage/datum/controller/camera_coverage.dm @@ -51,7 +51,7 @@ var/global/datum/controller/camera_coverage/camera_coverage_controller lastpct = thispct game_start_countdown?.update_status("Updating cameras...\n[thispct]%") - sleep(-1) + LAGCHECK_IF_LIVE(LAG_INIT) game_start_countdown?.update_status("Updating cameras...\nCoverage...") src.update_all_emitters() diff --git a/code/modules/worldgen/GenerateMining.dm b/code/modules/worldgen/GenerateMining.dm index 0d0e2aebd30a1..4c6b0b1573139 100644 --- a/code/modules/worldgen/GenerateMining.dm +++ b/code/modules/worldgen/GenerateMining.dm @@ -171,7 +171,7 @@ TYPEINFO(/turf/variableTurf/clear) for(var/x in 1 to width) for(var/y in 1 to height) mapnew[x][y] = CAGetSolid(map, x, y, i) - sleep(-1) + LAGCHECK_IF_LIVE(LAG_INIT) map = mapnew for(var/x in 1 to width) @@ -185,7 +185,7 @@ TYPEINFO(/turf/variableTurf/clear) generated.Add(N) if(T.loc.type == /area/space || istype(T.loc, /area/allowGenerate)) new/area/allowGenerate/trench(T) - sleep(-1) + LAGCHECK_IF_LIVE(LAG_INIT) var/list/used = list() for(var/s in 0 to 19) @@ -263,7 +263,7 @@ TYPEINFO(/turf/variableTurf/clear) while(!istype(X, /turf/space) || ISDISTEDGE(X, AST_MAPSEEDBORDER) || (X.loc.type != /area/space && !istype(X.loc , /area/allowGenerate) && !isgenplanet(X))) X = pick(miningZ) - sleep(-1) + LAGCHECK(LAG_REALTIME) var/list/solidTiles = list() var/list/edgeTiles = list(X) @@ -294,7 +294,7 @@ TYPEINFO(/turf/variableTurf/clear) if(decideSolid(west, X, sizeMod)) solidTiles.Add(west) edgeTiles.Add(west) - sleep(-1) + LAGCHECK_IF_LIVE(LAG_INIT) var/list/placed = list() for(var/turf/T in solidTiles) @@ -302,7 +302,7 @@ TYPEINFO(/turf/variableTurf/clear) var/turf/simulated/wall/auto/asteroid/AST = T.ReplaceWith(/turf/simulated/wall/auto/asteroid, FALSE, TRUE, FALSE, TRUE) placed.Add(AST) AST.quality = quality - sleep(-1) + LAGCHECK_IF_LIVE(LAG_INIT) if(prob(15)) Turfspawn_Asteroid_SeedOre(placed, rand(2,6), rand(0,40)) diff --git a/code/modules/worldgen/worldgen_parent.dm b/code/modules/worldgen/worldgen_parent.dm index 9c5fa7b25ec19..e63ef1783db8d 100644 --- a/code/modules/worldgen/worldgen_parent.dm +++ b/code/modules/worldgen/worldgen_parent.dm @@ -6,4 +6,4 @@ /proc/initialize_worldgen() for(var/turf/U as anything in worldgenCandidates) U.generate_worldgen() - sleep(-1) + LAGCHECK_IF_LIVE(LAG_INIT)