mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-19 19:13:30 +01:00
Fixes init on various things, as well as allowing the
map loader to safely load templates mid-run
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
var/dirt_count = 0
|
||||
var/zpos
|
||||
var/list/init_list = list()
|
||||
var/list/pipes = list()
|
||||
var/list/cables = list()
|
||||
|
||||
/datum/zlevel/New(z)
|
||||
zpos = z
|
||||
@@ -14,21 +12,35 @@
|
||||
throw EXCEPTION("Init told to resume when z-level still dirty. Z level: '[zpos]'")
|
||||
log_debug("Releasing freeze on z-level '[zpos]'!")
|
||||
log_debug("Beginning initialization!")
|
||||
var/list/our_atoms = init_list // OURS NOW!!! (Keeping this list to ourselves will prevent hijack)
|
||||
init_list = list()
|
||||
var/list/late_maps = list()
|
||||
var/list/pipes = list()
|
||||
var/list/cables = list()
|
||||
var/watch = start_watch()
|
||||
for(var/schmoo in init_list)
|
||||
for(var/schmoo in our_atoms)
|
||||
var/atom/movable/AM = schmoo
|
||||
if(AM) // to catch stuff like the nuke disk that no longer exists
|
||||
|
||||
// This can mess with our state - we leave these for last
|
||||
if(istype(AM, /obj/effect/landmark/map_loader))
|
||||
late_maps.Add(AM)
|
||||
continue
|
||||
AM.initialize()
|
||||
if(istype(AM, /obj/machinery/atmospherics))
|
||||
pipes.Add(AM)
|
||||
else if(istype(AM, /obj/structure/cable))
|
||||
cables.Add(AM)
|
||||
log_debug("Primary initialization finished in [stop_watch(watch)]s.")
|
||||
init_list.Cut()
|
||||
do_pipes()
|
||||
do_cables()
|
||||
our_atoms.Cut()
|
||||
if(pipes.len)
|
||||
do_pipes(pipes)
|
||||
if(cables.len)
|
||||
do_cables(cables)
|
||||
if(late_maps.len)
|
||||
do_late_maps(late_maps)
|
||||
|
||||
/datum/zlevel/proc/do_pipes()
|
||||
/datum/zlevel/proc/do_pipes(list/pipes)
|
||||
var/watch = start_watch()
|
||||
log_debug("Building pipenets on z-level '[zpos]'!")
|
||||
for(var/schmoo in pipes)
|
||||
@@ -38,7 +50,7 @@
|
||||
pipes.Cut()
|
||||
log_debug("Took [stop_watch(watch)]s")
|
||||
|
||||
/datum/zlevel/proc/do_cables()
|
||||
/datum/zlevel/proc/do_cables(list/cables)
|
||||
var/watch = start_watch()
|
||||
log_debug("Building powernets on z-level '[zpos]'!")
|
||||
for(var/schmoo in cables)
|
||||
@@ -47,3 +59,15 @@
|
||||
makepowernet_for(C)
|
||||
cables.Cut()
|
||||
log_debug("Took [stop_watch(watch)]s")
|
||||
|
||||
/datum/zlevel/proc/do_late_maps(list/late_maps)
|
||||
var/watch = start_watch()
|
||||
log_debug("Loading map templates on z-level '[zpos]'!")
|
||||
zlevels.add_dirt(zpos) // Let's not repeatedly resume init for each template
|
||||
for(var/schmoo in late_maps)
|
||||
var/obj/effect/landmark/map_loader/ML = schmoo
|
||||
if(ML)
|
||||
ML.initialize()
|
||||
late_maps.Cut()
|
||||
zlevels.remove_dirt(zpos)
|
||||
log_debug("Took [stop_watch(watch)]s")
|
||||
|
||||
Reference in New Issue
Block a user