Skip to content

Commit

Permalink
Partial revert of #17405, implement LAG_INIT (#18978)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sovexe committed May 28, 2024
1 parent 99bdacc commit 619ca24
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
7 changes: 7 additions & 0 deletions _std/defines/lag.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion code/_lighting/RobustLight2.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion code/datums/controllers/process/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions code/modules/worldgen/GenerateMining.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -294,15 +294,15 @@ 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)
if((T?.loc?.type == /area/space) || istype(T?.loc , /area/allowGenerate) || isgenplanet(T))
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))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/worldgen/worldgen_parent.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 619ca24

Please sign in to comment.