Runtime map now loads in ~11 seconds instead of ~40, sped up various other things (#19957)

Runtime map now has a bunch of new areas / items with often-tested
stuffs, and some hard-to-put-at-runtime stuffs.
Runtime map jobs now are positioned to make it faster to reach the
aforementioned often-tested stuffs.
Runtime map doesn't generate an overmap anymore by default, which speeds
up the process.
Runtime map now loads in ~11 seconds instead of ~40 seconds as it was
before.
Updated the maploader to be faster in parsing maps.
Bapi is not engaged anymore if we're only measuring the map size, which
speeds up the process.
In fastboot we do not generate the codexes anymore, which speeds up the
process.
In fastboot and if exoplanets and away sites are not enabled, we do not
parse the map templates anymore, which speeds up the process.
Updated the icon smoothing to be faster.
Optimized cargo area code.
Other optimizations.
This commit is contained in:
Fluffy
2024-10-06 21:31:01 +00:00
committed by GitHub
parent 9636363e60
commit b8902e2e16
124 changed files with 1238 additions and 134598 deletions
+3 -3
View File
@@ -56,7 +56,7 @@ SUBSYSTEM_DEF(icon_smooth)
continue
if((smoothing_atom.flags_1 & INITIALIZED_1) && !(smoothing_atom.icon_update_queued))
smooth_icon(smoothing_atom)
smoothing_atom.smooth_icon()
else
deferred += smoothing_atom
@@ -78,7 +78,7 @@ SUBSYSTEM_DEF(icon_smooth)
/datum/controller/subsystem/icon_smooth/Initialize()
for (var/zlevel = 1 to world.maxz)
smooth_zlevel(zlevel, FALSE)
smooth_zlevel(zlevel)
if (GLOB.config.fastboot)
LOG_DEBUG("icon_smoothing: Skipping prebake, fastboot enabled.")
@@ -94,7 +94,7 @@ SUBSYSTEM_DEF(icon_smooth)
if(QDELETED(smoothing_atom) || !(smoothing_atom.smoothing_flags & SMOOTH_QUEUED) || !smoothing_atom.z)
continue
smooth_icon(smoothing_atom)
smoothing_atom.smooth_icon()
CHECK_TICK
@@ -263,6 +263,7 @@ SUBSYSTEM_DEF(atlas)
. = "sccv_horizon"
/datum/controller/subsystem/atlas/proc/load_map_meta()
SHOULD_NOT_SLEEP(TRUE)
// This needs to be done after current_map is set, but before mapload.
admin_departments = list(
@@ -278,10 +279,8 @@ SUBSYSTEM_DEF(atlas)
for (var/thing in mapload_callbacks)
var/datum/callback/cb = thing
cb.InvokeAsync()
CHECK_TICK
mapload_callbacks.Cut()
mapload_callbacks = null
/datum/controller/subsystem/atlas/proc/OnMapload(datum/callback/callback)
if (!istype(callback))
@@ -290,11 +289,15 @@ SUBSYSTEM_DEF(atlas)
mapload_callbacks += callback
/datum/controller/subsystem/atlas/proc/setup_spawnpoints()
SHOULD_NOT_SLEEP(TRUE)
for (var/type in current_map.spawn_types)
var/datum/spawnpoint/S = new type
spawn_locations[S.display_name] = S
/datum/controller/subsystem/atlas/proc/InitializeSectors()
SHOULD_NOT_SLEEP(TRUE)
for (var/type in subtypesof(/datum/space_sector))
var/datum/space_sector/space_sector = new type()
@@ -12,9 +12,15 @@ SUBSYSTEM_DEF(codex)
var/list/chemistry_codex_ignored_result_path = list(/singleton/reagent/drink, /singleton/reagent/alcohol)
/datum/controller/subsystem/codex/Initialize()
generate_cooking_codex()
generate_chemistry_codex()
log_subsystem_codex("SScodex: [cooking_codex_data.len] cooking recipes; [chemistry_codex_data.len] chemistry recipes.")
//We don't build the codex in fastboot, it's slow and kind of pointless for tests
if(GLOB.config.fastboot)
log_subsystem_codex("SScodex: Fastboot detected, skipping codex generation.")
else
generate_cooking_codex()
generate_chemistry_codex()
log_subsystem_codex("SScodex: [length(cooking_codex_data)] cooking recipes; [length(chemistry_codex_data)] chemistry recipes.")
return SS_INIT_SUCCESS
/datum/controller/subsystem/codex/proc/generate_cooking_codex()
@@ -24,6 +24,41 @@ SUBSYSTEM_DEF(holomap)
/// List of all `/obj/effect/landmark/minimap_poi`.
var/list/obj/effect/landmark/minimap_poi/pois = list()
/*#############################################
Typecaches used for map icon generation
#############################################*/
var/static/list/mineral_wall_tcache = typecacheof(list(
/turf/simulated/mineral,
/turf/unsimulated/mineral,
))
var/static/list/mineral_floor_tcache = typecacheof(list(
/turf/unsimulated/floor/asteroid,
/turf/simulated/mineral,
/turf/simulated/floor/exoplanet,
))
var/static/list/hull_tcache = typecacheof(list(
/turf/simulated/wall,
/turf/simulated/floor,
/turf/unsimulated/wall,
/turf/unsimulated/floor,
))
var/static/list/rock_tcache = typecacheof(list(
/turf/simulated/mineral,
/turf/unsimulated/floor/asteroid,
/turf/simulated/open
))
var/static/list/obstacle_tcache = typecacheof(list(
/turf/simulated/wall,
/turf/unsimulated/mineral,
/turf/unsimulated/wall
))
var/static/list/path_tcache = typecacheof(list(
/turf/simulated/floor,
/turf/unsimulated/floor
)) - typecacheof(/turf/unsimulated/floor/asteroid)
/datum/controller/subsystem/holomap/Initialize()
generate_all_minimaps()
LOG_DEBUG("SSholomap: [minimaps.len] maps.")
@@ -40,6 +75,7 @@ SUBSYSTEM_DEF(holomap)
generate_minimap(z)
generate_minimap_area_colored(z)
generate_minimap_scan(z)
CHECK_TICK
/datum/controller/subsystem/holomap/proc/generate_minimap(zlevel = 1)
// Sanity checks - Better to generate a helpful error message now than have DrawBox() runtime
@@ -49,40 +85,19 @@ SUBSYSTEM_DEF(holomap)
if(world.maxy > canvas.Height())
CRASH("Minimap for z=[zlevel] : world.maxy ([world.maxy]) must be <= [canvas.Height()]")
var/list/rock_tcache = typecacheof(list(
/turf/simulated/mineral,
/turf/unsimulated/floor/asteroid,
/turf/simulated/open
))
var/list/obstacle_tcache = typecacheof(list(
/turf/simulated/wall,
/turf/unsimulated/mineral,
/turf/unsimulated/wall
))
var/list/path_tcache = typecacheof(list(
/turf/simulated/floor,
/turf/unsimulated/floor
)) - typecacheof(/turf/unsimulated/floor/asteroid)
var/turf/T
var/area/A
var/Ttype
for (var/thing in Z_TURFS(zlevel))
T = thing
A = T.loc
Ttype = T.type
for(var/turf/T as anything in Z_TURFS(zlevel))
var/area/A = T.loc
var/Ttype = T.type
if (A.area_flags & AREA_FLAG_HIDE_FROM_HOLOMAP)
continue
if (rock_tcache[Ttype])
continue
if (obstacle_tcache[Ttype] || (T.contents.len && locate(/obj/structure/grille, T)))
if (obstacle_tcache[Ttype] || (length(T.contents) && locate(/obj/structure/grille, T)))
canvas.DrawBox(HOLOMAP_OBSTACLE + "DD", T.x, T.y)
else if(path_tcache[Ttype] || (T.contents.len && locate(/obj/structure/lattice/catwalk, T)))
else if(path_tcache[Ttype] || (length(T.contents) && locate(/obj/structure/lattice/catwalk, T)))
canvas.DrawBox(HOLOMAP_PATH + "DD", T.x, T.y)
CHECK_TICK
minimaps[zlevel] = canvas
minimaps_base64[zlevel] = icon2base64(canvas)
@@ -94,11 +109,9 @@ SUBSYSTEM_DEF(holomap)
if(world.maxy > canvas.Height())
crash_with("Minimap for z=[zlevel] : world.maxy ([world.maxy]) must be <= [canvas.Height()]")
var/turf/T
var/area/A
for (var/thing in Z_TURFS(zlevel))
T = thing
A = T.loc
for (var/turf/T as anything in Z_TURFS(zlevel))
var/area/A = T.loc
if (A.area_flags & AREA_FLAG_HIDE_FROM_HOLOMAP)
continue
if (A.holomap_color)
@@ -121,27 +134,8 @@ SUBSYSTEM_DEF(holomap)
if(world.maxy > canvas.Height())
CRASH("Minimap for z=[zlevel] : world.maxy ([world.maxy]) must be <= [canvas.Height()]")
var/list/mineral_wall_tcache = typecacheof(list(
/turf/simulated/mineral,
/turf/unsimulated/mineral,
))
var/list/mineral_floor_tcache = typecacheof(list(
/turf/unsimulated/floor/asteroid,
/turf/simulated/mineral,
/turf/simulated/floor/exoplanet,
))
var/list/hull_tcache = typecacheof(list(
/turf/simulated/wall,
/turf/simulated/floor,
/turf/unsimulated/wall,
/turf/unsimulated/floor,
))
var/turf/T
var/Ttype
for (var/thing in Z_TURFS(zlevel))
T = thing
Ttype = T.type
for(var/turf/T as anything in Z_TURFS(zlevel))
var/Ttype = T.type
if (mineral_wall_tcache[Ttype])
canvas.DrawBox(HOLOMAP_MINERAL_WALL, T.x, T.y)
@@ -150,6 +144,4 @@ SUBSYSTEM_DEF(holomap)
else if(hull_tcache[Ttype])
canvas.DrawBox(HOLOMAP_OBSTACLE, T.x, T.y)
CHECK_TICK
minimaps_scan_base64[zlevel] = icon2base64(canvas)
+8 -7
View File
@@ -8,7 +8,6 @@ SUBSYSTEM_DEF(mapping)
var/list/exoplanet_ruins_templates = list()
var/list/away_sites_templates = list()
var/list/submaps = list()
var/list/submap_archetypes = list()
var/list/used_turfs = list() //list of turf = datum/turf_reservation -- Currently unused
@@ -30,13 +29,15 @@ SUBSYSTEM_DEF(mapping)
var/adding_new_zlevel = FALSE
/datum/controller/subsystem/mapping/Initialize(timeofday)
// Load templates and build away sites.
preloadTemplates()
for(var/atype in subtypesof(/singleton/submap_archetype))
submap_archetypes[atype] = new atype
//If we're in fastboot and not spawning exoplanets or awaysites
//this is different from TG and Bay, which always preload, but it saves a lot of time for us
//so we'll do it this way and hope for the best
if(!GLOB.config.fastboot || GLOB.config.exoplanets["enable_loading"] || GLOB.config.awaysites["enable_loading"])
// Load templates and build away sites.
preloadTemplates()
SSatlas.current_map.build_away_sites()
SSatlas.current_map.build_exoplanets()
SSatlas.current_map.build_away_sites()
SSatlas.current_map.build_exoplanets()
return SS_INIT_SUCCESS