mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-01-01 04:52:16 +00:00
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.
147 lines
5.3 KiB
Plaintext
147 lines
5.3 KiB
Plaintext
SUBSYSTEM_DEF(mapping)
|
|
name = "Mapping"
|
|
init_order = INIT_ORDER_AWAY_MAPS
|
|
flags = SS_NO_FIRE
|
|
|
|
var/list/map_templates = list()
|
|
var/list/space_ruins_templates = list()
|
|
var/list/exoplanet_ruins_templates = list()
|
|
var/list/away_sites_templates = list()
|
|
var/list/submaps = list()
|
|
|
|
var/list/used_turfs = list() //list of turf = datum/turf_reservation -- Currently unused
|
|
|
|
/// List of z level (as number) -> list of all z levels vertically connected to ours
|
|
/// Useful for fast grouping lookups and such
|
|
var/list/z_level_to_stack = list()
|
|
|
|
///list of all z level datums in the order of their z (z level 1 is at index 1, etc.)
|
|
var/list/datum/space_level/z_list = list()
|
|
|
|
///list of all z level indices that form multiz connections and whether theyre linked up or down.
|
|
///list of lists, inner lists are of the form: list("up or down link direction" = TRUE)
|
|
var/list/multiz_levels = list()
|
|
|
|
/// list of traits and their associated z leves
|
|
var/list/z_trait_levels = list()
|
|
|
|
/// True when in the process of adding a new Z-level, global locking
|
|
var/adding_new_zlevel = FALSE
|
|
|
|
/datum/controller/subsystem/mapping/Initialize(timeofday)
|
|
//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()
|
|
|
|
return SS_INIT_SUCCESS
|
|
|
|
/datum/controller/subsystem/mapping/Recover()
|
|
flags |= SS_NO_INIT
|
|
map_templates = SSmapping.map_templates
|
|
space_ruins_templates = SSmapping.space_ruins_templates
|
|
exoplanet_ruins_templates = SSmapping.exoplanet_ruins_templates
|
|
away_sites_templates = SSmapping.away_sites_templates
|
|
|
|
/datum/controller/subsystem/mapping/proc/preloadTemplates(path = "maps/templates/") //see master controller setup
|
|
var/list/filelist = flist(path)
|
|
for(var/map in filelist)
|
|
var/datum/map_template/T = new(path = "[path][map]", rename = "[map]")
|
|
map_templates[T.id] = T
|
|
preloadBlacklistableTemplates()
|
|
|
|
/datum/controller/subsystem/mapping/proc/preloadBlacklistableTemplates()
|
|
// Still supporting bans by filename
|
|
var/list/banned_exoplanet_dmms = generateMapList("config/exoplanet_ruin_blacklist.txt")
|
|
var/list/banned_space_dmms = generateMapList("config/space_ruin_blacklist.txt")
|
|
var/list/banned_away_site_dmms = generateMapList("config/away_site_blacklist.txt")
|
|
|
|
if (!banned_exoplanet_dmms || !banned_space_dmms || !banned_away_site_dmms)
|
|
log_admin("One or more map blacklist files are not present in the config directory!")
|
|
|
|
var/list/banned_maps = list() + banned_exoplanet_dmms + banned_space_dmms + banned_away_site_dmms
|
|
|
|
for(var/item in sortList(subtypesof(/datum/map_template), GLOBAL_PROC_REF(cmp_ruincost_priority)))
|
|
var/datum/map_template/map_template_type = item
|
|
// screen out the abstract subtypes
|
|
if(!initial(map_template_type.id))
|
|
continue
|
|
var/datum/map_template/MT = new map_template_type()
|
|
|
|
if (banned_maps)
|
|
if(banned_maps.Find(MT.mappath))
|
|
continue
|
|
|
|
map_templates[MT.id] = MT
|
|
|
|
// This is nasty..
|
|
if(istype(MT, /datum/map_template/ruin/exoplanet))
|
|
exoplanet_ruins_templates[MT.id] = MT
|
|
else if(istype(MT, /datum/map_template/ruin/space))
|
|
space_ruins_templates[MT.id] = MT
|
|
else if(istype(MT, /datum/map_template/ruin/away_site))
|
|
away_sites_templates[MT.id] = MT
|
|
|
|
/datum/controller/subsystem/mapping/proc/generate_linkages_for_z_level(z_level)
|
|
if(!isnum(z_level) || z_level <= 0)
|
|
return FALSE
|
|
|
|
if(multiz_levels.len < z_level)
|
|
multiz_levels.len = z_level
|
|
|
|
var/z_above = level_trait(z_level, ZTRAIT_UP)
|
|
var/z_below = level_trait(z_level, ZTRAIT_DOWN)
|
|
if(!(z_above == TRUE || z_above == FALSE || z_above == null) || !(z_below == TRUE || z_below == FALSE || z_below == null))
|
|
stack_trace("Warning, numeric mapping offsets are deprecated. Instead, mark z level connections by setting UP/DOWN to true if the connection is allowed")
|
|
multiz_levels[z_level] = new /list(LARGEST_Z_LEVEL_INDEX)
|
|
multiz_levels[z_level][Z_LEVEL_UP] = !!z_above
|
|
multiz_levels[z_level][Z_LEVEL_DOWN] = !!z_below
|
|
|
|
/// Takes a z level datum, and tells the mapping subsystem to manage it
|
|
/// Also handles things like plane offset generation, and other things that happen on a z level to z level basis
|
|
/datum/controller/subsystem/mapping/proc/manage_z_level(datum/space_level/new_z, filled_with_space, contain_turfs = TRUE)
|
|
// First, add the z
|
|
z_list += new_z
|
|
|
|
// Then we build our lookup lists
|
|
var/z_value = new_z.z_value
|
|
|
|
z_level_to_stack.len += 1
|
|
// Bare minimum we have ourselves
|
|
z_level_to_stack[z_value] = list(z_value)
|
|
|
|
//Placeholder for now
|
|
/datum/controller/subsystem/mapping/proc/get_reservation_from_turf(turf/T)
|
|
RETURN_TYPE(/datum/turf_reservation)
|
|
return used_turfs[T]
|
|
|
|
|
|
/proc/generateMapList(filename)
|
|
var/list/potentialMaps = list()
|
|
var/list/Lines = world.file2list(filename)
|
|
if(!Lines.len)
|
|
return
|
|
for (var/t in Lines)
|
|
if (!t)
|
|
continue
|
|
t = trim(t)
|
|
if (length(t) == 0)
|
|
continue
|
|
else if (copytext(t, 1, 2) == "#")
|
|
continue
|
|
var/pos = findtext(t, " ")
|
|
var/name = null
|
|
if (pos)
|
|
name = lowertext(copytext(t, 1, pos))
|
|
else
|
|
name = lowertext(t)
|
|
if (!name)
|
|
continue
|
|
potentialMaps.Add(t)
|
|
return potentialMaps
|