mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-28 23:58:07 +01:00
Lag check on initialization (and on a missed del-all proc)
This commit is contained in:
@@ -70,7 +70,7 @@ var/global/datum/controller/master/Master = new()
|
||||
if(zlevel && zlevel > 0 && zlevel <= world.maxz)
|
||||
for(var/datum/subsystem/SS in subsystems)
|
||||
SS.Initialize(world.timeofday, zlevel)
|
||||
sleep(-1)
|
||||
CHECK_TICK
|
||||
return
|
||||
world << "<span class='boldannounce'>Initializing subsystems...</span>"
|
||||
|
||||
@@ -95,7 +95,7 @@ var/global/datum/controller/master/Master = new()
|
||||
// Initialize subsystems.
|
||||
for(var/datum/subsystem/SS in subsystems)
|
||||
SS.Initialize(world.timeofday, zlevel)
|
||||
sleep(-1)
|
||||
CHECK_TICK
|
||||
|
||||
world << "<span class='boldannounce'>Initializations complete!</span>"
|
||||
|
||||
@@ -106,16 +106,18 @@ var/global/datum/controller/master/Master = new()
|
||||
world.sleep_offline = 1
|
||||
world.fps = config.fps
|
||||
|
||||
sleep(-1)
|
||||
sleep(1)
|
||||
|
||||
// Loop.
|
||||
Master.process()
|
||||
|
||||
// Notify the MC that the round has started.
|
||||
/datum/controller/master/proc/RoundStart()
|
||||
var/timer = world.time
|
||||
for(var/datum/subsystem/SS in subsystems)
|
||||
timer += world.tick_lag
|
||||
SS.can_fire = 1
|
||||
SS.next_fire = world.time + rand(0, SS.wait) // Stagger subsystems.
|
||||
SS.next_fire = timer + rand(0, SS.wait) // Stagger subsystems.
|
||||
|
||||
// Used to smooth out costs to try and avoid oscillation.
|
||||
#define MC_AVERAGE_FAST(average, current) (0.7 * (average) + 0.3 * (current))
|
||||
@@ -129,8 +131,10 @@ var/global/datum/controller/master/Master = new()
|
||||
// Schedule the first run of the Subsystems.
|
||||
var/timer = world.time
|
||||
for(var/datum/subsystem/SS in subsystems)
|
||||
timer += world.tick_lag
|
||||
SS.next_fire = timer
|
||||
if (SS.can_fire)
|
||||
timer += world.tick_lag
|
||||
SS.next_fire = timer
|
||||
|
||||
var/list/subsystemstorun = subsystems.Copy()
|
||||
var/start_time
|
||||
while(1) // More efficient than recursion.
|
||||
|
||||
@@ -203,6 +203,7 @@ var/datum/subsystem/air/SSair
|
||||
T.excited = 1
|
||||
active_turfs |= T
|
||||
break
|
||||
CHECK_TICK
|
||||
|
||||
if(active_turfs.len)
|
||||
warning("There are [active_turfs.len] active turfs at roundstart, this is a mapping error caused by a difference of the air between the adjacent turfs. You can see its coordinates using \"Mapping -> Show roundstart AT list\" verb (debug verbs required)")
|
||||
@@ -214,6 +215,7 @@ var/datum/subsystem/air/SSair
|
||||
if (z_level && AM.z != z_level)
|
||||
continue
|
||||
AM.atmosinit()
|
||||
CHECK_TICK
|
||||
|
||||
//this can't be done with setup_atmos_machinery() because
|
||||
// all atmos machinery has to initalize before the first
|
||||
@@ -223,12 +225,15 @@ var/datum/subsystem/air/SSair
|
||||
if (z_level && AM.z != z_level)
|
||||
continue
|
||||
AM.build_network()
|
||||
CHECK_TICK
|
||||
|
||||
/datum/subsystem/air/proc/setup_template_machinery(list/atmos_machines)
|
||||
for(var/A in atmos_machines)
|
||||
var/obj/machinery/atmospherics/AM = A
|
||||
AM.atmosinit()
|
||||
CHECK_TICK
|
||||
|
||||
for(var/A in atmos_machines)
|
||||
var/obj/machinery/atmospherics/AM = A
|
||||
AM.build_network()
|
||||
CHECK_TICK
|
||||
|
||||
@@ -61,11 +61,13 @@ var/datum/subsystem/lighting/SSlighting
|
||||
if (A.lighting_use_dynamic == DYNAMIC_LIGHTING_IFSTARLIGHT)
|
||||
if (config.starlight)
|
||||
A.SetDynamicLighting()
|
||||
CHECK_TICK
|
||||
|
||||
|
||||
for(var/thing in changed_lights)
|
||||
var/datum/light_source/LS = thing
|
||||
LS.check()
|
||||
CHECK_TICK
|
||||
changed_lights.Cut()
|
||||
|
||||
var/z_start = 1
|
||||
@@ -80,6 +82,7 @@ var/datum/subsystem/lighting/SSlighting
|
||||
for(var/thing in turfs_to_init)
|
||||
var/turf/T = thing
|
||||
T.init_lighting()
|
||||
CHECK_TICK
|
||||
|
||||
if(z_level)
|
||||
//we need to loop through to clear only shifted turfs from the list. or we will cause errors
|
||||
@@ -88,6 +91,7 @@ var/datum/subsystem/lighting/SSlighting
|
||||
if(T.z in z_start to z_finish)
|
||||
continue
|
||||
changed_turfs.Remove(thing)
|
||||
CHECK_TICK
|
||||
else
|
||||
changed_turfs.Cut()
|
||||
|
||||
|
||||
@@ -42,65 +42,69 @@ var/datum/subsystem/minimap/SSminimap
|
||||
var/icon/minimap = new /icon('icons/minimap.dmi')
|
||||
// Scale it up to our target size.
|
||||
minimap.Scale(MINIMAP_SIZE, MINIMAP_SIZE)
|
||||
var/list/obj_icons = list()
|
||||
var/counter = 128
|
||||
|
||||
var/counter = 64
|
||||
// Loop over turfs and generate icons.
|
||||
for(var/T in block(locate(x1, y1, z), locate(x2, y2, z)))
|
||||
|
||||
var/turf/tile = T
|
||||
var/icon/tile_icon
|
||||
var/obj/obj
|
||||
generate_tile(T, minimap)
|
||||
|
||||
// Don't use icons for space, just add objects in space if they exist.
|
||||
if(istype(tile, /turf/space))
|
||||
obj = locate(/obj/structure/lattice/catwalk) in tile
|
||||
if(obj)
|
||||
tile_icon = new /icon('icons/obj/smooth_structures/catwalk.dmi', "catwalk", SOUTH)
|
||||
obj = locate(/obj/structure/lattice) in tile
|
||||
if(obj)
|
||||
tile_icon = new /icon('icons/obj/smooth_structures/lattice.dmi', "lattice", SOUTH)
|
||||
obj = locate(/obj/structure/grille) in tile
|
||||
if(obj)
|
||||
tile_icon = new /icon('icons/obj/structures.dmi', "grille", SOUTH)
|
||||
obj = locate(/obj/structure/transit_tube) in tile
|
||||
if(obj)
|
||||
tile_icon = new /icon('icons/obj/atmospherics/pipes/transit_tube.dmi', obj.icon_state, obj.dir)
|
||||
else
|
||||
tile_icon = new /icon(tile.icon, tile.icon_state, tile.dir)
|
||||
obj_icons.Cut()
|
||||
|
||||
obj = locate(/obj/structure) in tile
|
||||
if(obj)
|
||||
obj_icons += getFlatIcon(obj)
|
||||
obj = locate(/obj/machinery) in tile
|
||||
if(obj)
|
||||
obj_icons += new /icon(obj.icon, obj.icon_state, obj.dir, 1, 0)
|
||||
obj = locate(/obj/structure/window) in tile
|
||||
if(obj)
|
||||
obj_icons += new /icon('icons/obj/smooth_structures/window.dmi', "window", SOUTH)
|
||||
|
||||
for(var/I in obj_icons)
|
||||
var/icon/obj_icon = I
|
||||
tile_icon.Blend(obj_icon, ICON_OVERLAY)
|
||||
|
||||
if(tile_icon)
|
||||
// Scale the icon.
|
||||
tile_icon.Scale(TILE_SIZE, TILE_SIZE)
|
||||
// Add the tile to the minimap.
|
||||
minimap.Blend(tile_icon, ICON_OVERLAY, ((tile.x - 1) * TILE_SIZE), ((tile.y - 1) * TILE_SIZE))
|
||||
del(tile_icon)
|
||||
|
||||
//byond bug, this fixes OOM crashes by flattening and reseting the minimap icon holder every 255 tiles
|
||||
//byond bug, this fixes OOM crashes by flattening and reseting the minimap icon holder every 64 tiles
|
||||
counter--
|
||||
if (counter <= 0)
|
||||
counter = 128
|
||||
if(counter <= 0)
|
||||
counter = 64
|
||||
var/icon/flatten = new /icon()
|
||||
flatten.Insert(minimap, "", SOUTH, 1, 0)
|
||||
del(minimap)
|
||||
minimap = flatten
|
||||
sleep(-1)
|
||||
sleep(world.tick_lag) //we have to sleep in order to get byond to clear out the proc's garbage bin
|
||||
|
||||
CHECK_TICK
|
||||
|
||||
|
||||
// Create a new icon and insert the generated minimap, so that BYOND doesn't generate different directions.
|
||||
var/icon/final = new /icon()
|
||||
final.Insert(minimap, "", SOUTH, 1, 0)
|
||||
fcopy(final, map_path(z))
|
||||
|
||||
/datum/subsystem/minimap/proc/generate_tile(turf/tile, icon/minimap)
|
||||
var/icon/tile_icon
|
||||
var/obj/obj
|
||||
var/list/obj_icons = list()
|
||||
// Don't use icons for space, just add objects in space if they exist.
|
||||
if(istype(tile, /turf/space))
|
||||
obj = locate(/obj/structure/lattice/catwalk) in tile
|
||||
if(obj)
|
||||
tile_icon = new /icon('icons/obj/smooth_structures/catwalk.dmi', "catwalk", SOUTH)
|
||||
obj = locate(/obj/structure/lattice) in tile
|
||||
if(obj)
|
||||
tile_icon = new /icon('icons/obj/smooth_structures/lattice.dmi', "lattice", SOUTH)
|
||||
obj = locate(/obj/structure/grille) in tile
|
||||
if(obj)
|
||||
tile_icon = new /icon('icons/obj/structures.dmi', "grille", SOUTH)
|
||||
obj = locate(/obj/structure/transit_tube) in tile
|
||||
if(obj)
|
||||
tile_icon = new /icon('icons/obj/atmospherics/pipes/transit_tube.dmi', obj.icon_state, obj.dir)
|
||||
else
|
||||
tile_icon = new /icon(tile.icon, tile.icon_state, tile.dir)
|
||||
obj_icons.Cut()
|
||||
|
||||
obj = locate(/obj/structure) in tile
|
||||
if(obj)
|
||||
obj_icons += getFlatIcon(obj)
|
||||
obj = locate(/obj/machinery) in tile
|
||||
if(obj)
|
||||
obj_icons += new /icon(obj.icon, obj.icon_state, obj.dir, 1, 0)
|
||||
obj = locate(/obj/structure/window) in tile
|
||||
if(obj)
|
||||
obj_icons += new /icon('icons/obj/smooth_structures/window.dmi', "window", SOUTH)
|
||||
|
||||
for(var/I in obj_icons)
|
||||
var/icon/obj_icon = I
|
||||
tile_icon.Blend(obj_icon, ICON_OVERLAY)
|
||||
|
||||
if(tile_icon)
|
||||
// Scale the icon.
|
||||
tile_icon.Scale(TILE_SIZE, TILE_SIZE)
|
||||
// Add the tile to the minimap.
|
||||
minimap.Blend(tile_icon, ICON_OVERLAY, ((tile.x - 1) * TILE_SIZE), ((tile.y - 1) * TILE_SIZE))
|
||||
del(tile_icon)
|
||||
@@ -23,6 +23,7 @@ var/datum/subsystem/objects/SSobj
|
||||
if (zlevel && A.z != zlevel)
|
||||
continue
|
||||
A.initialize()
|
||||
CHECK_TICK
|
||||
. = ..()
|
||||
|
||||
|
||||
|
||||
@@ -212,3 +212,4 @@ var/datum/subsystem/shuttle/SSshuttle
|
||||
S.dwidth = M.dwidth
|
||||
S.dheight = M.dheight
|
||||
moveShuttle(M.id, "[M.roundstart_move]", 0)
|
||||
CHECK_TICK
|
||||
|
||||
@@ -676,6 +676,7 @@ body
|
||||
if(Obj.type == O_type)
|
||||
i++
|
||||
qdel(Obj)
|
||||
CHECK_TICK
|
||||
if(!i)
|
||||
usr << "No objects of this type exist"
|
||||
return
|
||||
@@ -687,6 +688,7 @@ body
|
||||
if(istype(Obj,O_type))
|
||||
i++
|
||||
qdel(Obj)
|
||||
CHECK_TICK
|
||||
if(!i)
|
||||
usr << "No objects of this type exist"
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user