mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-23 12:07:27 +01:00
Initialization deferral is now handled by the caller, but
is now also seamless
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
var/datum/map_template/template = null
|
||||
var/centered = 1
|
||||
var/loaded = 0
|
||||
var/delay_init = 0
|
||||
|
||||
/obj/effect/landmark/map_loader/New(turf/loc, tname)
|
||||
..()
|
||||
@@ -28,13 +27,13 @@
|
||||
/obj/effect/landmark/map_loader/proc/load(datum/map_template/t)
|
||||
if(!t)
|
||||
return
|
||||
if(loaded)
|
||||
if(loaded) // I wanna be super sure this loads only once
|
||||
return
|
||||
loaded = 1
|
||||
var/turf/pos = get_turf(src)
|
||||
// Hop to nullspace so we don't get re-initialized by the map we're loading
|
||||
loc = null
|
||||
t.load(pos, centered = centered, delay_init = delay_init)
|
||||
t.load(pos, centered = centered)
|
||||
t.loaded++
|
||||
qdel(src)
|
||||
|
||||
|
||||
@@ -31,12 +31,13 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
* If `measureOnly` is set, then no atoms will be created, and all this will do
|
||||
* is return the bounds after parsing the file
|
||||
*
|
||||
* If delay_init is set, then all initializations while the map is loading will
|
||||
* be deferred until later
|
||||
* You'll need it for large initializations like loading the cyberiad, where
|
||||
* glass and similar can cause atmos to initialize before it's ready
|
||||
* If you need to freeze init while you're working, you can use the spacial allocator's
|
||||
* "add_dirt" and "remove_dirt" which will put initializations on hold until you say
|
||||
* the word. This is important for loading large maps such as the cyberiad, where
|
||||
* atmos will attempt to start before it's ready, causing runtimes galore if init is
|
||||
* allowed to romp unchecked.
|
||||
*/
|
||||
/dmm_suite/load_map(dmm_file as file, x_offset as num, y_offset as num, z_offset as num, cropMap as num, measureOnly as num, delay_init as num)
|
||||
/dmm_suite/load_map(dmm_file as file, x_offset as num, y_offset as num, z_offset as num, cropMap as num, measureOnly as num)
|
||||
var/tfile = dmm_file//the map file we're creating
|
||||
var/fname = "Lambda"
|
||||
if(isfile(tfile))
|
||||
@@ -57,8 +58,6 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
|
||||
|
||||
var/dmm_suite/loaded_map/LM = new
|
||||
if(measureOnly)
|
||||
delay_init = 0
|
||||
// This try-catch is used as a budget "Finally" clause, as the dirt count
|
||||
// needs to be reset
|
||||
var/watch = start_watch()
|
||||
@@ -91,9 +90,6 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
var/xcrd
|
||||
var/ycrd = text2num(dmmRegex.group[4]) + y_offset - 1
|
||||
var/zcrd = text2num(dmmRegex.group[5]) + z_offset - 1
|
||||
if(!measureOnly && delay_init)
|
||||
zlevels.add_dirt(zcrd)
|
||||
LM.touched_z_levels |= zcrd
|
||||
|
||||
if(zcrd > world.maxz)
|
||||
if(cropMap)
|
||||
@@ -161,15 +157,9 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
CHECK_TICK
|
||||
catch(var/exception/e)
|
||||
_preloader.reset()
|
||||
if(delay_init)
|
||||
for(var/i in LM.touched_z_levels)
|
||||
zlevels.remove_dirt(i)
|
||||
throw e
|
||||
|
||||
if(delay_init)
|
||||
_preloader.reset()
|
||||
for(var/i in LM.touched_z_levels)
|
||||
zlevels.remove_dirt(i)
|
||||
_preloader.reset()
|
||||
log_debug("Loaded map in [stop_watch(watch)]s.")
|
||||
qdel(LM)
|
||||
if(bounds[MAP_MINX] == 1.#INF) // Shouldn't need to check every item
|
||||
@@ -465,7 +455,6 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
// a new area type for each new ruin
|
||||
/dmm_suite/loaded_map
|
||||
parent_type = /datum
|
||||
var/list/touched_z_levels = list()
|
||||
var/list/area_list = list()
|
||||
var/index = 1 // To store the state of the regex
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
var/global/list/potentialRandomZlevels = generateMapList(filename = "config/away_mission_config.txt")
|
||||
|
||||
// Call this before you remove the last dirt on a z level - that way, all objects
|
||||
// will have proper atmos and other important enviro things
|
||||
/proc/late_setup_level(turfs, smoothTurfs)
|
||||
var/total_timer = start_watch()
|
||||
var/subtimer = start_watch()
|
||||
@@ -12,14 +14,10 @@ var/global/list/potentialRandomZlevels = generateMapList(filename = "config/away
|
||||
log_debug("\tTook [stop_watch(subtimer)]s")
|
||||
|
||||
subtimer = start_watch()
|
||||
log_debug("Initializing objects and lighting")
|
||||
log_debug("Initializing lighting")
|
||||
for(var/turf/T in turfs)
|
||||
if(T.dynamic_lighting)
|
||||
T.lighting_build_overlays()
|
||||
for(var/obj/structure/cable/PC in T)
|
||||
makepowernet_for(PC)
|
||||
for(var/atom/movable/AM in T)
|
||||
AM.initialize()
|
||||
log_debug("\tTook [stop_watch(subtimer)]s")
|
||||
|
||||
subtimer = start_watch()
|
||||
@@ -35,14 +33,6 @@ var/global/list/potentialRandomZlevels = generateMapList(filename = "config/away
|
||||
var/turf/simulated/mineral/MT = T
|
||||
MT.add_edges()
|
||||
log_debug("\tTook [stop_watch(subtimer)]s")
|
||||
|
||||
log_debug("Initializing pipenets")
|
||||
// We do this once we're finished initializing since otherwise the pipes
|
||||
// won't have finished connecting
|
||||
for(var/turf/T in turfs)
|
||||
for(var/obj/machinery/atmospherics/machine in T)
|
||||
machine.build_network()
|
||||
log_debug("\tTook [stop_watch(subtimer)]s")
|
||||
log_debug("Late setup finished - took [stop_watch(total_timer)]s")
|
||||
|
||||
/proc/createRandomZlevel()
|
||||
@@ -56,8 +46,11 @@ var/global/list/potentialRandomZlevels = generateMapList(filename = "config/away
|
||||
var/map = pick(potentialRandomZlevels)
|
||||
var/file = file(map)
|
||||
if(isfile(file))
|
||||
maploader.load_map(file)
|
||||
late_setup_level(block(locate(1, 1, world.maxz), locate(world.maxx, world.maxy, world.maxz)))
|
||||
var/zlev = zlevels.add_new_zlevel()
|
||||
zlevels.add_dirt(zlev)
|
||||
maploader.load_map(file, z_offset = zlev)
|
||||
late_setup_level(block(locate(1, 1, zlev), locate(world.maxx, world.maxy, zlev)))
|
||||
zlevels.remove_dirt(zlev)
|
||||
log_to_dd(" Away mission loaded: [map]")
|
||||
|
||||
//map_transition_config.Add(AWAY_MISSION_LIST)
|
||||
@@ -85,8 +78,11 @@ var/global/list/potentialRandomZlevels = generateMapList(filename = "config/away
|
||||
var/file = file(map)
|
||||
if(isfile(file))
|
||||
log_startup_progress("Loading away mission: [map]")
|
||||
maploader.load_map(file)
|
||||
late_setup_level(block(locate(1, 1, world.maxz), locate(world.maxx, world.maxy, world.maxz)))
|
||||
var/zlev = zlevels.add_new_zlevel()
|
||||
zlevels.add_dirt(zlev)
|
||||
maploader.load_map(file, z_offset = zlev)
|
||||
late_setup_level(block(locate(1, 1, zlev), locate(world.maxx, world.maxy, zlev)))
|
||||
zlevels.remove_dirt(zlev)
|
||||
log_to_dd(" Away mission loaded: [map]")
|
||||
|
||||
//map_transition_config.Add(AWAY_MISSION_LIST)
|
||||
|
||||
Reference in New Issue
Block a user