mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-30 16:47:13 +01:00
[MIRROR] Space/Changeturf fixes and optimizations [MDB IGNORE] (#19201)
Space/Changeturf fixes and optimizations Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: GoldenAlpharex <jerego1234@hotmail.com> Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com>
This commit is contained in:
co-authored by
LemonInTheDark
GoldenAlpharex
GoldenAlpharex
parent
f558095a40
commit
db33d75a5e
@@ -148,13 +148,13 @@ SUBSYSTEM_DEF(mapping)
|
||||
#endif
|
||||
// Run map generation after ruin generation to prevent issues
|
||||
run_map_generation()
|
||||
// Add the transit level
|
||||
transit = add_new_zlevel("Transit/Reserved", list(ZTRAIT_RESERVED = TRUE))
|
||||
// Add the first transit level
|
||||
var/datum/space_level/base_transit = add_reservation_zlevel()
|
||||
require_area_resort()
|
||||
// Set up Z-level transitions.
|
||||
setup_map_transitions()
|
||||
generate_station_area_list()
|
||||
initialize_reserved_level(transit.z_value)
|
||||
initialize_reserved_level(base_transit.z_value)
|
||||
calculate_default_z_level_gravities()
|
||||
|
||||
return SS_INIT_SUCCESS
|
||||
@@ -171,7 +171,8 @@ SUBSYSTEM_DEF(mapping)
|
||||
var/packetlen = length(packet)
|
||||
while(packetlen)
|
||||
if(MC_TICK_CHECK)
|
||||
lists_to_reserve.Cut(1, index)
|
||||
if(index)
|
||||
lists_to_reserve.Cut(1, index)
|
||||
return
|
||||
var/turf/T = packet[packetlen]
|
||||
T.empty(RESERVED_TURF_TYPE, RESERVED_TURF_TYPE, null, TRUE)
|
||||
@@ -328,7 +329,6 @@ Used by the AI doomsday and the self-destruct nuke.
|
||||
turf_reservations = SSmapping.turf_reservations
|
||||
used_turfs = SSmapping.used_turfs
|
||||
holodeck_templates = SSmapping.holodeck_templates
|
||||
transit = SSmapping.transit
|
||||
areas_in_z = SSmapping.areas_in_z
|
||||
|
||||
config = SSmapping.config
|
||||
@@ -663,6 +663,12 @@ GLOBAL_LIST_EMPTY(the_station_areas)
|
||||
message_admins("Loading [away_name] failed!")
|
||||
return
|
||||
|
||||
/// Adds a new reservation z level. A bit of space that can be handed out on request
|
||||
/// Of note, reservations default to transit turfs, to make their most common use, shuttles, faster
|
||||
/datum/controller/subsystem/mapping/proc/add_reservation_zlevel(for_shuttles)
|
||||
num_of_res_levels++
|
||||
return add_new_zlevel("Transit/Reserved #[num_of_res_levels]", list(ZTRAIT_RESERVED = TRUE))
|
||||
|
||||
/datum/controller/subsystem/mapping/proc/RequestBlockReservation(width, height, z, type = /datum/turf_reservation, turf_type_override)
|
||||
UNTIL((!z || reservation_ready["[z]"]) && !clearing_reserved_turfs)
|
||||
var/datum/turf_reservation/reserve = new type
|
||||
@@ -673,8 +679,7 @@ GLOBAL_LIST_EMPTY(the_station_areas)
|
||||
if(reserve.Reserve(width, height, i))
|
||||
return reserve
|
||||
//If we didn't return at this point, theres a good chance we ran out of room on the exisiting reserved z levels, so lets try a new one
|
||||
num_of_res_levels += 1
|
||||
var/datum/space_level/newReserved = add_new_zlevel("Transit/Reserved [num_of_res_levels]", list(ZTRAIT_RESERVED = TRUE))
|
||||
var/datum/space_level/newReserved = add_reservation_zlevel()
|
||||
initialize_reserved_level(newReserved.z_value)
|
||||
if(reserve.Reserve(width, height, newReserved.z_value))
|
||||
return reserve
|
||||
@@ -687,7 +692,9 @@ GLOBAL_LIST_EMPTY(the_station_areas)
|
||||
return reserve
|
||||
QDEL_NULL(reserve)
|
||||
|
||||
//This is not for wiping reserved levels, use wipe_reservations() for that.
|
||||
///Sets up a z level as reserved
|
||||
///This is not for wiping reserved levels, use wipe_reservations() for that.
|
||||
///If this is called after SSatom init, it will call Initialize on all turfs on the passed z, as its name promises
|
||||
/datum/controller/subsystem/mapping/proc/initialize_reserved_level(z)
|
||||
UNTIL(!clearing_reserved_turfs) //regardless, lets add a check just in case.
|
||||
clearing_reserved_turfs = TRUE //This operation will likely clear any existing reservations, so lets make sure nothing tries to make one while we're doing it.
|
||||
@@ -697,11 +704,15 @@ GLOBAL_LIST_EMPTY(the_station_areas)
|
||||
var/turf/A = get_turf(locate(SHUTTLE_TRANSIT_BORDER,SHUTTLE_TRANSIT_BORDER,z))
|
||||
var/turf/B = get_turf(locate(world.maxx - SHUTTLE_TRANSIT_BORDER,world.maxy - SHUTTLE_TRANSIT_BORDER,z))
|
||||
var/block = block(A, B)
|
||||
for(var/t in block)
|
||||
// No need to empty() these, because it's world init and they're
|
||||
// already /turf/open/space/basic.
|
||||
var/turf/T = t
|
||||
for(var/turf/T as anything in block)
|
||||
// No need to empty() these, because they just got created and are already /turf/open/space/basic.
|
||||
T.flags_1 |= UNUSED_RESERVATION_TURF
|
||||
CHECK_TICK
|
||||
|
||||
// Gotta create these suckers if we've not done so already
|
||||
if(SSatoms.initialized)
|
||||
SSatoms.InitializeAtoms(Z_TURFS(z))
|
||||
|
||||
unused_turfs["[z]"] = block
|
||||
reservation_ready["[z]"] = TRUE
|
||||
clearing_reserved_turfs = FALSE
|
||||
|
||||
Reference in New Issue
Block a user