move shuttle loading to cordons (#31237)

* move shuttle loading to cordons

* clean up our reservations after we move

* pull logs up to stack traces
This commit is contained in:
warriorstar-orion
2025-12-18 14:55:56 +00:00
committed by GitHub
parent 1e86d30353
commit c905f98f1d
6 changed files with 61 additions and 67 deletions
+1 -5
View File
@@ -12000,10 +12000,6 @@
/obj/effect/turf_decal/tiles/dark/checker,
/turf/simulated/floor/plasteel/white,
/area/ghost_bar)
"PA" = (
/obj/effect/landmark/shuttle_import,
/turf/space,
/area/space/centcomm)
"PB" = (
/obj/structure/table/wood,
/obj/item/storage/fancy/havana_cigar,
@@ -26587,7 +26583,7 @@ aN
aN
aN
aN
PA
aN
aN
aN
aN
+2
View File
@@ -45,3 +45,5 @@
/// from /datum/component/supermatter_crystal/proc/consume()
/// called on the thing consumed, passes the thing which consumed it
#define COMSIG_SUPERMATTER_CONSUMED "sm_consumed_this"
#define COMSIG_MOBILE_PORT_DOCKED "mobile_port_docked"
+16 -53
View File
@@ -52,8 +52,6 @@ SUBSYSTEM_DEF(shuttle)
// These vars are necessary to prevent multiple loads on the same turfs at the same times causing massive server issues
/// Whether or not a custom shuttle is currently loading at centcomm.
var/custom_escape_shuttle_loading = FALSE
/// Whether or not a shuttle is currently being loaded at the template landmark, if it exists.
var/loading_shuttle_at_preview_template = FALSE
/// Have we locked in the emergency shuttle, to prevent people from breaking things / wasting player money?
var/emergency_locked_in = FALSE
@@ -65,14 +63,10 @@ SUBSYSTEM_DEF(shuttle)
var/transit_utilized = 0
/datum/controller/subsystem/shuttle/Initialize()
if(!emergency)
WARNING("No /obj/docking_port/mobile/emergency placed on the map!")
if(!backup_shuttle)
WARNING("No /obj/docking_port/mobile/emergency/backup placed on the map!")
if(!supply)
WARNING("No /obj/docking_port/mobile/supply placed on the map!")
if(!gamma_armory)
WARNING("No /obj/docking_port/mobile/gamma_armory placed on the map!")
initial_load()
initial_move()
@@ -377,59 +371,28 @@ SUBSYSTEM_DEF(shuttle)
var/turf/spawn_location = pick(supply_shuttle_turfs)
new /obj/structure/closet/crate/mail(spawn_location)
// load an alternative shuttle in at the appropriate landmark.
/datum/controller/subsystem/shuttle/proc/load_template(datum/map_template/shuttle/S)
// load shuttle template, centred at shuttle import landmark,
if(loading_shuttle_at_preview_template)
CRASH("A shuttle was already loading at the preview template when another was loaded")
/// Loads a shuttle from the template into a cordon. Returns its docking port if successful.
/datum/controller/subsystem/shuttle/proc/load_template(datum/map_template/shuttle/template)
template.preload()
S.preload()
var/datum/turf_reservation/shuttle/reserve = SSmapping.request_turf_block_reservation(
template.width,
template.height,
reservation_type = /datum/turf_reservation/shuttle
)
if(!reserve)
stack_trace("failed to reserve turfs for shuttle loading template [template.mappath]")
return
loading_shuttle_at_preview_template = TRUE
var/turf/landmark_turf = get_turf(locate("landmark*Shuttle Import"))
S.load(landmark_turf, centered = TRUE)
var/affected = S.get_affected_turfs(landmark_turf, centered = TRUE)
var/mobile_docking_ports = 0
var/obj/docking_port/mobile/port
// Search the turfs for docking ports
// - We need to find the mobile docking port because that is the heart of
// the shuttle.
// - We need to check that no additional ports have slipped in from the
// template, because that causes unintended behaviour.
for(var/T in affected)
for(var/obj/docking_port/P in T)
if(istype(P, /obj/docking_port/mobile))
port = P
mobile_docking_ports++
if(mobile_docking_ports > 1)
qdel(P, force = TRUE)
log_world("Map warning: Shuttle Template [S.mappath] has multiple mobile docking ports.")
else if(!port.timid)
// The shuttle template we loaded isn't "timid" which means
// it's already registered with the shuttles subsystem.
// This is a bad thing.
WARNING("Template [S] is non-timid! Unloading.")
port.jumpToNullSpace()
loading_shuttle_at_preview_template = FALSE
return
if(istype(P, /obj/docking_port/stationary))
log_world("Map warning: Shuttle Template [S.mappath] has a stationary docking port.")
if(!template.load(reserve.bottom_left_turf))
stack_trace("failed to load shuttle template [template.mappath] into reservation")
return
var/obj/docking_port/mobile/port = reserve.locate_docking_port()
if(port)
loading_shuttle_at_preview_template = FALSE
return port
for(var/T in affected)
var/turf/T0 = T
T0.contents = null
var/msg = "load_template(): Shuttle Template [S.mappath] has no mobile docking port. Aborting import."
message_admins(msg)
WARNING(msg)
loading_shuttle_at_preview_template = FALSE
stack_trace("load_template(): shuttle [template.mappath] has no mobile docking port and may be malformed or have failed to load")
/// Create a new shuttle and replace the emergency shuttle with it.
/// if loaded shuttle is passed in, a new one will not be loaded.
-4
View File
@@ -11,10 +11,6 @@
abstract_move(T1)
return 1
/obj/effect/landmark/shuttle_import/onShuttleMove()
// Used for marking where to preview/load shuttles
return 0
/obj/docking_port/onShuttleMove()
// Stationary ports shouldn't move, mobile ones move themselves
return 0
+1 -5
View File
@@ -582,6 +582,7 @@
W.update_eligible_areas()
W.update_audio()
mobile_port.unlockPortDoors(S1)
SEND_SIGNAL(mobile_port, COMSIG_MOBILE_PORT_DOCKED, S1)
/obj/docking_port/mobile/proc/is_turf_blacklisted_for_transit(turf/T)
var/static/list/blacklisted_turf_types = typecacheof(list(/turf/space, /turf/simulated/floor/chasm, /turf/simulated/floor/lava, /turf/simulated/floor/plating/asteroid))
@@ -616,11 +617,6 @@
else
. = null
/obj/effect/landmark/shuttle_import
name = "Shuttle Import"
//shuttle-door closing is handled in the dock() proc whilst looping through turfs
//this one closes the door where we are docked at, if there is one there.
/obj/docking_port/mobile/proc/closePortDoors(obj/docking_port/stationary/S0)
@@ -160,3 +160,44 @@
/datum/turf_reservation/transit
turf_type = /turf/space/transit
required_traits = list(TCOMM_RELAY_ALWAYS)
/datum/turf_reservation/shuttle
/datum/turf_reservation/shuttle/proc/locate_docking_port()
// Search the turfs for docking ports
// - We need to find the mobile docking port because that is the heart of
// the shuttle.
// - We need to check that no additional ports have slipped in from the
// template, because that causes unintended behaviour.
var/mobile_docking_ports = 0
var/obj/docking_port/mobile/port
for(var/T as anything in reserved_turfs)
for(var/obj/docking_port/P in T)
if(istype(P, /obj/docking_port/mobile))
port = P
mobile_docking_ports++
if(mobile_docking_ports > 1)
qdel(P, force = TRUE)
stack_trace("shuttle template has multiple mobile docking ports")
else if(!port.timid)
// The shuttle template we loaded isn't "timid" which means
// it's already registered with the shuttles subsystem.
// This is a bad thing.
stack_trace("shuttle template is non-timid! Unloading.")
port.jumpToNullSpace()
return
if(istype(P, /obj/docking_port/stationary))
stack_trace("shuttle template has a stationary docking port")
if(!port)
stack_trace("could not find shuttle template mobile docking port")
return
RegisterSignal(port, COMSIG_MOBILE_PORT_DOCKED, PROC_REF(cleanup))
return port
/datum/turf_reservation/shuttle/proc/cleanup(datum/source, obj/docking_port/stationary/dest)
SIGNAL_HANDLER // COMSIG_MOBILE_PORT_DOCKED
UnregisterSignal(source, COMSIG_MOBILE_PORT_DOCKED)
qdel(src)