Files
Aurora.3/code/controllers/subsystems/mapping.dm
Matt Atlas baeb7c6afd Updates subsystem definitions to new standards. (#17470)
* My heart is dragging me down into...

...oblivion!

* drifting closer to the edge but she won't have me

* ever round me we are dead before we meet her

* for the last time

* wake up in sweat

* n

* fff

* uff

---------

Co-authored-by: Matt Atlas <liermattia@gmail.com>
2023-10-01 14:24:40 +00:00

97 lines
3.1 KiB
Plaintext

SUBSYSTEM_DEF(mapping)
name = "Mapping"
init_order = SS_INIT_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/submap_archetypes = list()
/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
current_map.build_away_sites()
current_map.build_exoplanets()
. = ..(timeofday)
/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(paths = list("[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)
var/is_banned = FALSE
for (var/mappath in MT.mappaths)
if(banned_maps.Find(mappath))
is_banned = TRUE
break
if (is_banned)
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
/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