Where No Spaceman Has Gone Before: a space sector system (#11801)

This commit is contained in:
Alberyk
2021-05-31 00:32:07 +02:00
committed by GitHub
parent c40366dcf2
commit da4f065701
25 changed files with 114 additions and 21 deletions
@@ -19,6 +19,8 @@ var/datum/controller/subsystem/atlas/SSatlas
var/list/list/connected_z_cache = list()
var/z_levels = 0 // Each bit represents a connection between adjacent levels. So the first bit means levels 1 and 2 are connected.
var/datum/space_sector/current_sector
var/list/possible_sectors = list ()
/datum/controller/subsystem/atlas/stat_entry()
..("W:{X:[world.maxx] Y:[world.maxy] Z:[world.maxz]} ZL:[z_levels]")
@@ -76,6 +78,27 @@ var/datum/controller/subsystem/atlas/SSatlas
QDEL_NULL(maploader)
InitializeSectors()
var/chosen_sector
var/using_sector_config = FALSE
if(config.current_space_sector)
chosen_sector = config.current_space_sector
using_sector_config = TRUE
else
chosen_sector = current_map.default_sector
var/datum/space_sector/selected_sector = SSatlas.possible_sectors[chosen_sector]
if(!selected_sector)
if(using_sector_config)
log_debug("atlas: [chosen_sector] used in the config file is not a valid space sector")
current_sector = new /datum/space_sector/tau_ceti //if all fails, we go with tau ceti
log_debug("atlas: Unable to select [chosen_sector] as a valid space sector. Tau Ceti will be used instead.")
else
current_sector = selected_sector
..()
/datum/controller/subsystem/atlas/proc/load_map_directory(directory, overwrite_default_z = FALSE)
@@ -164,6 +187,15 @@ var/datum/controller/subsystem/atlas/SSatlas
var/datum/spawnpoint/S = new type
spawn_locations[S.display_name] = S
/datum/controller/subsystem/atlas/proc/InitializeSectors()
for (var/type in subtypesof(/datum/space_sector))
var/datum/space_sector/space_sector = new type()
possible_sectors[space_sector.name] = space_sector
if (!possible_sectors.len)
crash_with("No space sectors located in SSatlas.")
// Called when there's a fatal, unrecoverable error in mapload. This reboots the server.
/world/proc/map_panic(reason)
to_chat(world, "<span class='danger'>Fatal error during map setup, unable to continue! Server will reboot in 60 seconds.</span>")
@@ -185,10 +217,6 @@ var/datum/controller/subsystem/atlas/SSatlas
world.name = sname
world.log << "Set world.name to [sname]."
/proc/system_name()
ASSERT(current_map)
return current_map.system_name
/proc/commstation_name()
ASSERT(current_map)
return current_map.dock_name
@@ -73,9 +73,9 @@
log_ss("map_finalization", "Error while creating away mission datum: [ec]")
continue
if(length(am.valid_maps))
if(!(current_map.name in am.valid_maps))
log_ss("map_finalization", "[current_map.name] is not a valid map for [am.name]")
if(length(am.valid_sectors))
if(!(SSatlas.current_sector.name in am.valid_sectors))
log_ss("map_finalization", "[SSatlas.current_sector.name] is not a valid map for [am.name]")
continue
if(!am.validate_maps(folder))