SSmapping updates (#18066)

* A few SSmapping improvement

* sync1

* try 1

* remove print

* fixed1

* fixed2

* broken1

* fixed3

* use old reader

* clean up

* also remove this debug

* Don't load reebe and arena in low mem mode

* Latest version loader with mapgen fixed

* I missed this part somehow
This commit is contained in:
Ling
2023-02-26 14:11:27 +01:00
committed by GitHub
parent a7ca1b4d54
commit c77594d110
10 changed files with 146 additions and 68 deletions

View File

@@ -1229,6 +1229,9 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)
/mob/dview/Initialize() //Properly prevents this mob from gaining huds or joining any global lists
SHOULD_CALL_PARENT(FALSE)
if(flags_1 & INITIALIZED_1)
stack_trace("Warning: [src]([type]) initialized multiple times!")
flags_1 |= INITIALIZED_1
return INITIALIZE_HINT_NORMAL
/mob/dview/Destroy(force = FALSE)

View File

@@ -69,6 +69,7 @@ SUBSYSTEM_DEF(mapping)
process_teleport_locs() //Sets up the wizard teleport locations
preloadTemplates()
run_map_generation()
#ifndef LOWMEMORYMODE
// Create space ruin levels
while (space_levels_so_far < config.space_ruin_levels)
@@ -116,24 +117,21 @@ SUBSYSTEM_DEF(mapping)
seedRuins(space_ruins, CONFIG_GET(number/space_budget), list(/area/space), space_ruins_templates)
seedStation()
loading_ruins = FALSE
#endif
//Load Reebe
var/list/errorList = list()
var/list/reebes = SSmapping.LoadGroup(errorList, "Reebe", "map_files/generic", "City_of_Cogs.dmm", default_traits = ZTRAITS_REEBE, silent = TRUE)
SSmapping.LoadGroup(errorList, "Reebe", "map_files/generic", "City_of_Cogs.dmm", default_traits = ZTRAITS_REEBE, silent = TRUE)
if(errorList.len) // reebe failed to load
message_admins("Reebe failed to load!")
log_game("Reebe failed to load!")
for(var/datum/parsed_map/PM in reebes)
PM.initTemplateBounds()
//Load an Arena
errorList = list()
var/list/arenas = SSmapping.LoadGroup(errorList, "Arena", "templates", "arena.dmm", silent = TRUE)
SSmapping.LoadGroup(errorList, "Arena", "templates", "arena.dmm", silent = TRUE)
if(errorList.len) // arena failed to load
message_admins("A shuttle arena failed to load!")
log_game("A shuttle arena failed to load!")
for(var/datum/parsed_map/PM in arenas)
PM.initTemplateBounds()
#endif
// Add the transit level
transit = add_new_zlevel("Transit/Reserved", list(ZTRAIT_RESERVED = TRUE))
require_area_resort()

View File

@@ -9,6 +9,7 @@ SUBSYSTEM_DEF(shuttle)
loading_points = 4.9 SECONDS // Yogs -- loading times
var/list/mobile = list()
/// A list of all the stationary docking ports.
var/list/stationary = list()
var/list/beacons = list()
var/list/transit = list()
@@ -71,7 +72,7 @@ SUBSYSTEM_DEF(shuttle)
continue
supply_packs[P.type] = P
initial_load()
setup_shuttles(stationary)
if(!arrivals)
WARNING("No /obj/docking_port/mobile/arrivals placed on the map!")
@@ -83,10 +84,9 @@ SUBSYSTEM_DEF(shuttle)
WARNING("No /obj/docking_port/mobile/supply placed on the map!")
return SS_INIT_SUCCESS
/datum/controller/subsystem/shuttle/proc/initial_load()
for(var/s in stationary)
var/obj/docking_port/stationary/S = s
S.load_roundstart()
/datum/controller/subsystem/shuttle/proc/setup_shuttles(list/ports)
for(var/obj/docking_port/stationary/port as anything in ports)
port.load_roundstart()
CHECK_TICK
/datum/controller/subsystem/shuttle/fire()
@@ -935,4 +935,3 @@ SUBSYSTEM_DEF(shuttle)
message_admins("[key_name_admin(usr)] loaded [mdp] with the shuttle manipulator.")
log_admin("[key_name(usr)] loaded [mdp] with the shuttle manipulator.</span>")
SSblackbox.record_feedback("text", "shuttle_manipulator", 1, "[mdp.name]")

View File

@@ -71,6 +71,9 @@
place.baseturfs.Insert(3, /turf/baseturf_skipover/shuttle)
for(var/obj/docking_port/mobile/port in place)
// initTemplateBounds explicitly ignores the shuttle's docking port, to ensure that it calculates the bounds of the shuttle correctly
// so we need to manually initialize it here
SSatoms.InitializeAtoms(list(port))
if(register)
port.register()
if(isnull(port_x_offset))

View File

@@ -25,37 +25,85 @@
cached_map = parsed
return bounds
/datum/parsed_map/proc/initTemplateBounds()
/datum/map_template/proc/initTemplateBounds(list/bounds)
if (!bounds) //something went wrong
stack_trace("[name] template failed to initialize correctly!")
return
var/list/obj/machinery/atmospherics/atmos_machines = list()
var/list/obj/structure/cable/cables = list()
var/list/atom/atoms = list()
var/list/atom/movable/movables = list()
var/list/obj/docking_port/stationary/ports = list()
var/list/area/areas = list()
var/list/turfs = block( locate(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ]),
locate(bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ]))
var/list/border = block(locate(max(bounds[MAP_MINX]-1, 1), max(bounds[MAP_MINY]-1, 1), bounds[MAP_MINZ]),
locate(min(bounds[MAP_MAXX]+1, world.maxx), min(bounds[MAP_MAXY]+1, world.maxy), bounds[MAP_MAXZ])) - turfs
for(var/L in turfs)
var/turf/B = L
atoms += B
areas |= B.loc
for(var/A in B)
atoms += A
if(istype(A, /obj/structure/cable))
cables += A
continue
if(istype(A, /obj/machinery/atmospherics))
atmos_machines += A
for(var/L in border)
var/turf/T = L
T.air_update_turf(TRUE) //calculate adjacent turfs along the border to prevent runtimes
var/list/turfs = block(
locate(
bounds[MAP_MINX],
bounds[MAP_MINY],
bounds[MAP_MINZ]
),
locate(
bounds[MAP_MAXX],
bounds[MAP_MAXY],
bounds[MAP_MAXZ]
)
)
for(var/turf/current_turf as anything in turfs)
var/area/current_turfs_area = current_turf.loc
areas |= current_turfs_area
if(!SSatoms.initialized)
continue
for(var/movable_in_turf in current_turf)
if(istype(movable_in_turf, /obj/docking_port/mobile))
continue // mobile docking ports need to be initialized after their template has finished loading, to ensure that their bounds are setup
movables += movable_in_turf
if(istype(movable_in_turf, /obj/structure/cable))
cables += movable_in_turf
continue
if(istype(movable_in_turf, /obj/machinery/atmospherics))
atmos_machines += movable_in_turf
if(istype(movable_in_turf, /obj/docking_port/stationary))
ports += movable_in_turf
// Not sure if there is some importance here to make sure the area is in z
// first or not. Its defined In Initialize yet its run first in templates
// BEFORE so... hummm
SSmapping.reg_in_areas_in_z(areas)
SSatoms.InitializeAtoms(areas + turfs + atoms)
//SSnetworks.assign_areas_root_ids(areas, src)
if(!SSatoms.initialized)
return
SSatoms.InitializeAtoms(areas + turfs + movables)
for(var/turf/unlit as anything in turfs)
var/area/loc_area = unlit.loc
if(!IS_DYNAMIC_LIGHTING(loc_area))
continue
unlit.lighting_build_overlay()
// NOTE, now that Initialize and LateInitialize run correctly, do we really
// need these two below?
SSmachines.setup_template_powernets(cables)
SSair.setup_template_machinery(atmos_machines)
SSshuttle.setup_shuttles(ports)
//calculate all turfs inside the border
var/list/template_and_bordering_turfs = block(
locate(
max(bounds[MAP_MINX]-1, 1),
max(bounds[MAP_MINY]-1, 1),
bounds[MAP_MINZ]
),
locate(
min(bounds[MAP_MAXX]+1, world.maxx),
min(bounds[MAP_MAXY]+1, world.maxy),
bounds[MAP_MAXZ]
)
)
for(var/turf/affected_turf as anything in template_and_bordering_turfs)
affected_turf.air_update_turf(TRUE, TRUE)
affected_turf.levelupdate()
/datum/map_template/proc/load_new_z(secret = FALSE)
var/x = round((world.maxx - width)/2)
@@ -69,7 +117,7 @@
require_area_resort()
//initialize things that are normally initialized after map load
parsed.initTemplateBounds()
initTemplateBounds(bounds)
smooth_zlevel(world.maxz)
log_game("Z-level [name] loaded at at [x],[y],[world.maxz]")
@@ -98,7 +146,7 @@
require_area_resort()
//initialize things that are normally initialized after map load
parsed.initTemplateBounds()
initTemplateBounds(bounds)
log_game("[name] loaded at at [T.x],[T.y],[T.z]")
return bounds

View File

@@ -29,9 +29,13 @@ GLOBAL_LIST_INIT(_preloader_path, null)
#endif
what.vars[attribute] = value
/// Template noop (no operation) is used to skip a turf or area when the template is loaded this allows for template transparency
/// ex. if a ship has gaps in it's design, you would use template_noop to fill these in so that when the ship moves z-level, any
/// tiles these gaps land on will not be deleted and replaced with the ships (empty) tiles
/area/template_noop
name = "Area Passthrough"
/// See above explanation
/turf/template_noop
name = "Turf Passthrough"
icon_state = "noop"

View File

@@ -280,12 +280,15 @@
SSmapping.build_area_turfs(z_index)
if(!no_changeturf)
for(var/turf/T as anything in block(locate(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ]), locate(bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ])))
var/list/turfs = block(
locate(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ]),
locate(bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ]))
for(var/turf/T as anything in turfs)
//we do this after we load everything in. if we don't, we'll have weird atmos bugs regarding atmos adjacent turfs
T.AfterChange(CHANGETURF_IGNORE_AIR)
//if(expanded_x || expanded_y)
// SEND_GLOBAL_SIGNAL(COMSIG_GLOB_EXPANDED_WORLD_BOUNDS, expanded_x, expanded_y)
if(expanded_x || expanded_y)
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_EXPANDED_WORLD_BOUNDS, expanded_x, expanded_y)
#ifdef TESTING
if(turfsSkipped)
@@ -328,8 +331,10 @@
var/y_skip_above = min(world.maxy - y_relative_to_absolute, y_upper, relative_y)
// How many lines to skip because they'd be above the y cuttoff line
var/y_starting_skip = relative_y - y_skip_above
highest_y += y_starting_skip
if (y_skip_above == y_upper)
highest_y = y_upper
else
highest_y += y_starting_skip
// Y is the LOWEST it will ever be here, so we can easily set a threshold for how low to go
var/line_count = length(first_column.gridLines)
@@ -466,7 +471,10 @@
var/y_skip_above = min(world.maxy - y_relative_to_absolute, y_upper, relative_y)
// How many lines to skip because they'd be above the y cuttoff line
var/y_starting_skip = relative_y - y_skip_above
ycrd += y_starting_skip
if (y_skip_above == y_upper)
ycrd = y_upper
else
ycrd += y_starting_skip
// Y is the LOWEST it will ever be here, so we can easily set a threshold for how low to go
var/line_count = length(gset.gridLines)
@@ -781,11 +789,11 @@ GLOBAL_LIST_EMPTY(map_model_default)
//The next part of the code assumes there's ALWAYS an /area AND a /turf on a given tile
//first instance the /area and remove it from the members list
index = members.len
var/area/old_area
if(members[index] != /area/template_noop)
var/area/area_instance
if(members_attributes[index] != default_list)
world.preloader_setup(members_attributes[index], members[index])//preloader for assigning set variables on atom creation
area_instance = loaded_areas[members[index]]
var/area/area_instance = loaded_areas[members[index]]
if(!area_instance)
var/area_type = members[index]
// If this parsed map doesn't have that area already, we check the global cache
@@ -798,7 +806,7 @@ GLOBAL_LIST_EMPTY(map_model_default)
loaded_areas[area_type] = area_instance
if(!new_z)
var/area/old_area = crds.loc
old_area = crds.loc
old_area.turfs_to_uncontain += crds
area_instance.contained_turfs.Add(crds)
area_instance.contents.Add(crds)
@@ -826,6 +834,9 @@ GLOBAL_LIST_EMPTY(map_model_default)
if(GLOB.use_preloader && instance)//second preloader pass, for those atoms that don't ..() in New()
world.preloader_load(instance)
// If this isn't template work, we didn't change our turf and we changed area, then we've gotta handle area lighting transfer
else if(!no_changeturf && old_area)
crds.change_area(old_area, crds.loc)
MAPLOADING_CHECK_TICK
//finally instance all remainings objects/mobs

View File

@@ -19,8 +19,10 @@
/datum/mapGeneratorModule/reload_station_map/generate()
if(!istype(mother, /datum/mapGenerator/repair/reload_station_map))
return
var/datum/mapGenerator/repair/reload_station_map/mother1 = mother
GLOB.reloading_map = TRUE
// This is kind of finicky on multi-Z maps but the reader would need to be
// changed to allow Z cropping and that's a mess
var/z_offset = SSmapping.station_start
@@ -32,26 +34,40 @@
var/list/obj/machinery/atmospherics/atmos_machines = list()
var/list/obj/structure/cable/cables = list()
var/list/atom/atoms = list()
var/list/atom/movable/movables = list()
var/list/area/areas = list()
var/list/turfs = block(
locate(
bounds[MAP_MINX],
bounds[MAP_MINY],
SSmapping.station_start
),
locate(
bounds[MAP_MAXX],
bounds[MAP_MAXY],
z_offset - 1
)
)
for(var/turf/current_turf as anything in turfs)
var/area/current_turfs_area = current_turf.loc
areas |= current_turfs_area
for(var/movable_in_turf in current_turf)
movables += movable_in_turf
if(istype(movable_in_turf, /obj/structure/cable))
cables += movable_in_turf
continue
if(istype(movable_in_turf, /obj/machinery/atmospherics))
atmos_machines += movable_in_turf
SSatoms.InitializeAtoms(areas + turfs + movables)
SSmachines.setup_template_powernets(cables)
SSair.setup_template_machinery(atmos_machines)
require_area_resort()
for(var/L in block(locate(bounds[MAP_MINX], bounds[MAP_MINY], SSmapping.station_start),
locate(bounds[MAP_MAXX], bounds[MAP_MAXY], z_offset - 1)))
set waitfor = FALSE
var/turf/B = L
atoms += B
for(var/A in B)
atoms += A
if(istype(A,/obj/structure/cable))
cables += A
continue
if(istype(A,/obj/machinery/atmospherics))
atmos_machines += A
SSatoms.InitializeAtoms(atoms)
SSmachines.setup_template_powernets(cables)
SSair.setup_template_machinery(atmos_machines)
GLOB.reloading_map = FALSE
/datum/mapGenerator/repair

View File

@@ -115,10 +115,8 @@
var/area/old_area = oldT.loc
var/move_mode = old_area.beforeShuttleMove(shuttle_areas) //areas
var/list/old_contents = oldT.contents
for(var/k in 1 to old_contents.len)
for(var/atom/movable/moving_atom as anything in oldT.contents)
CHECK_TICK
var/atom/movable/moving_atom = old_contents[k]
if(moving_atom.loc != oldT) //fix for multi-tile objects
continue
move_mode = moving_atom.beforeShuttleMove(newT, rotation, move_mode, src) //atoms

View File

@@ -67,13 +67,11 @@ GLOBAL_LIST_EMPTY(pocket_mirrors)
RegisterSignal(guardian, COMSIG_MOVABLE_MOVED, .proc/auto_demanifest)
if (!LAZYLEN(pocket_dim))
var/list/errorList = list()
var/pocket_dim_level = SSmapping.LoadGroup(errorList, "Pocket Dimension [GLOB.pocket_dim]", "templates", "pocket_dimension.dmm", default_traits = list("Pocket Dimension" = TRUE, "Pocket Dimension [GLOB.pocket_dim]" = TRUE, ZTRAIT_BOMBCAP_MULTIPLIER = 0), silent = TRUE)
SSmapping.LoadGroup(errorList, "Pocket Dimension [GLOB.pocket_dim]", "templates", "pocket_dimension.dmm", default_traits = list("Pocket Dimension" = TRUE, "Pocket Dimension [GLOB.pocket_dim]" = TRUE, ZTRAIT_BOMBCAP_MULTIPLIER = 0), silent = TRUE)
if (errorList.len)
message_admins("A pocket dimension failed to load!")
log_game("A pocket dimension failed to load!")
return FALSE
for (var/datum/parsed_map/PM in pocket_dim_level)
PM.initTemplateBounds()
pocket_dim = "Pocket Dimension [GLOB.pocket_dim++]"
GLOB.pocket_mirrors[pocket_dim] = list()
var/pz = get_pocket_z()