diff --git a/code/controllers/subsystem/shuttles.dm b/code/controllers/subsystem/shuttles.dm
index 0a8fd071163..5247a0c5237 100644
--- a/code/controllers/subsystem/shuttles.dm
+++ b/code/controllers/subsystem/shuttles.dm
@@ -13,6 +13,7 @@ var/datum/subsystem/shuttle/SSshuttle
var/list/transit = list()
var/list/turf/transit_turfs = list()
+ var/list/transit_requesters = list()
//emergency shuttle stuff
var/obj/docking_port/mobile/emergency/emergency
@@ -77,6 +78,11 @@ var/datum/subsystem/shuttle/SSshuttle
world.log << "[transit_turfs.len] transit turfs registered"
/datum/subsystem/shuttle/fire()
+ if(transit_requesters.len)
+ var/requester = popleft(transit_requesters)
+ var/success = generate_transit_dock(requester)
+ if(!success) // BACK OF THE QUEUE
+ transit_requesters += requester
for(var/thing in mobile)
if(!thing)
mobile.Remove(thing)
@@ -234,13 +240,20 @@ var/datum/subsystem/shuttle/SSshuttle
return 2
return 0 //dock successful
-/datum/subsystem/shuttle/proc/requestTransitZone(obj/docking_port/mobile/M)
- // First, determine the size of the needed zone
- var/transit_width = M.width + M.dwidth + 14
- var/transit_height = M.height + M.dheight + 14
- // Then find a place to put the zone
+/datum/subsystem/shuttle/proc/request_transit_dock(obj/docking_port/mobile/M)
+ if(!istype(M))
+ throw EXCEPTION("[M] is not a mobile docking port")
- world << "Transit requested for [M]"
+ if(M.assigned_transit)
+ return
+ else
+ transit_requesters += M
+
+/datum/subsystem/shuttle/proc/generate_transit_dock(obj/docking_port/mobile/M)
+ // First, determine the size of the needed zone
+ var/transit_width = M.width + 14
+ var/transit_height = M.height + 14
+ // Then find a place to put the zone
var/list/proposed_zone
@@ -249,19 +262,16 @@ var/datum/subsystem/shuttle/SSshuttle
CHECK_TICK
var/turf/topleft = i
if(!(topleft.flags & UNUSED_TRANSIT_TURF))
- world << "Topleft [COORD(topleft)] is used"
+ continue
var/turf/bottomright = locate(topleft.x + transit_width,
topleft.y + transit_height, topleft.z)
if(!bottomright)
continue
if(!(bottomright.flags & UNUSED_TRANSIT_TURF))
- world << "Bottomright [COORD(bottomright)] is used."
continue
proposed_zone = block(topleft, bottomright)
- world << "Proposed zone of [proposed_zone.len] turfs made"
if(!proposed_zone)
- world << "Proposed zone was null."
continue
for(var/j in proposed_zone)
var/turf/T = j
@@ -270,38 +280,37 @@ var/datum/subsystem/shuttle/SSshuttle
break
if((!proposed_zone) || (!proposed_zone.len))
- world << "We couldn't find a suitable transit zone"
- return
+ return FALSE
- world << "Now creating transit port"
var/turf/topleft = proposed_zone[1]
// Then create a transit docking port in the middle
- var/mid_x = round(transit_width / 2) + topleft.x
- var/mid_y = round(transit_height / 2) + topleft.y
+ var/mid_x = 7 + M.dwidth + topleft.x
+ var/mid_y = 7 + M.dheight + topleft.y
var/turf/midpoint = locate(mid_x, mid_y, topleft.z)
var/obj/docking_port/stationary/transit/new_transit_dock = new(midpoint)
new_transit_dock.assigned_turfs = proposed_zone
new_transit_dock.name = "Transit for [M.id]/[M.name]"
- new_transit_dock.setDir(M.dir)
- world << "Now setting turf type"
+ var/dockdir = 270 + M.travelDir
+ new_transit_dock.setDir(angle2dir(dockdir))
+
+ var/spacedir = angle2dir(M.travelDir)
for(var/i in new_transit_dock.assigned_turfs)
var/turf/open/space/transit/T = i
- T.flags |= UNUSED_TRANSIT_TURF
+ T.flags &= ~(UNUSED_TRANSIT_TURF)
T.ChangeTurf(/turf/open/space/transit)
- T.setDir(M.travelDir)
+ T.setDir(spacedir)
T.update_icon()
- world << "Done!"
- return new_transit_dock
- // Then return it
+ M.assigned_transit = new_transit_dock
+ return TRUE
/datum/subsystem/shuttle/proc/initial_move()
for(var/obj/docking_port/mobile/M in mobile)
if(!M.roundstart_move)
continue
- moveShuttle(M.id, "[M.roundstart_move]", 0)
+ M.dockRoundstart()
CHECK_TICK
/datum/subsystem/shuttle/Recover()
diff --git a/code/modules/shuttle/computer.dm b/code/modules/shuttle/computer.dm
index 74e2343be67..5b3aa867654 100644
--- a/code/modules/shuttle/computer.dm
+++ b/code/modules/shuttle/computer.dm
@@ -28,7 +28,7 @@
for(var/obj/docking_port/stationary/S in SSshuttle.stationary)
if(!options.Find(S.id))
continue
- if(M.canDock(S))
+ if(!M.check_dock(S))
continue
destination_found = 1
dat += "Send to [S.name]
"
diff --git a/code/modules/shuttle/emergency.dm b/code/modules/shuttle/emergency.dm
index 0f3ec3d6c86..02dbd9eb669 100644
--- a/code/modules/shuttle/emergency.dm
+++ b/code/modules/shuttle/emergency.dm
@@ -168,6 +168,9 @@
for(var/obj/item/weapon/card/id/ID in src)
qdel(ID)
+ if(authorized && authorized.len)
+ authorized.Cut()
+ authorized = null
. = ..()
@@ -290,21 +293,26 @@
if(SHUTTLE_DOCKED)
- if(time_left <= ENGINES_START_TIME)
- mode = SHUTTLE_IGNITING
- for(var/A in SSshuttle.mobile)
- var/obj/docking_port/mobile/M = A
- if(M.launch_status == UNLAUNCHED) //Pods will not launch from the mine/planet, and other ships won't launch unless we tell them to.
- M.mode = SHUTTLE_IGNITING
+ if(time_left <= ENGINES_START_TIME * 10)
+ if(SSshuttle.emergencyNoEscape)
+ priority_announce("Hostile environment detected. Departure has been postponed indefinitely pending conflict resolution.", null, 'sound/misc/notice1.ogg', "Priority")
+ sound_played = 0 //Since we didn't launch, we will need to rev up the engines again next pass.
+ mode = SHUTTLE_STRANDED
+ else
+ mode = SHUTTLE_IGNITING
+ for(var/A in SSshuttle.mobile)
+ var/obj/docking_port/mobile/M = A
+ if(M.launch_status == UNLAUNCHED) //Pods will not launch from the mine/planet, and other ships won't launch unless we tell them to.
+ M.check_transit_zone()
if(SHUTTLE_IGNITING)
var/success = TRUE
- success &= (requestTransitZone() == TRANSIT_READY)
+ success &= (check_transit_zone() == TRANSIT_READY)
for(var/A in SSshuttle.mobile)
var/obj/docking_port/mobile/M = A
if(M.launch_status == UNLAUNCHED)
- success &= (M.requestTransitZone() == TRANSIT_READY)
+ success &= (M.check_transit_zone() == TRANSIT_READY)
if(!success)
setTimer(ENGINES_START_TIME * 10)
@@ -313,11 +321,6 @@
for(var/area/shuttle/escape/E in world)
E << 'sound/effects/hyperspace_begin.ogg'
- if(time_left <= 0 && SSshuttle.emergencyNoEscape)
- priority_announce("Hostile environment detected. Departure has been postponed indefinitely pending conflict resolution.", null, 'sound/misc/notice1.ogg', "Priority")
- sound_played = 0 //Since we didn't launch, we will need to rev up the engines again next pass.
- mode = SHUTTLE_STRANDED
-
if(time_left <= 0 && !SSshuttle.emergencyNoEscape)
//move each escape pod (or applicable spaceship) to its corresponding transit dock
for(var/A in SSshuttle.mobile)
diff --git a/code/modules/shuttle/manipulator.dm b/code/modules/shuttle/manipulator.dm
index dff8a4f409b..0a9837e7b37 100644
--- a/code/modules/shuttle/manipulator.dm
+++ b/code/modules/shuttle/manipulator.dm
@@ -219,7 +219,7 @@
// truthy value means that it cannot dock for some reason
// but we can ignore the someone else docked error because we'll
// be moving into their place shortly
- if(result && (result != SHUTTLE_SOMEONE_ELSE_DOCKED))
+ if((result != SHUTTLE_CAN_DOCK) && (result != SHUTTLE_SOMEONE_ELSE_DOCKED))
var/m = "Unsuccessful dock of [preview_shuttle] ([result])."
WARNING(m)
return
diff --git a/code/modules/shuttle/on_move.dm b/code/modules/shuttle/on_move.dm
index 449648702fb..b2c6487ebd5 100644
--- a/code/modules/shuttle/on_move.dm
+++ b/code/modules/shuttle/on_move.dm
@@ -16,7 +16,10 @@
. = ..()
if(!.)
return
- addtimer(src, "close", 0)
+ addtimer(src, "close", 0, TRUE)
+ // Close any attached airlocks as well
+ for(var/obj/machinery/door/D in orange(1, src))
+ addtimer(src, "close", 0, TRUE)
/mob/onShuttleMove()
if(!move_on_shuttle)
diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm
index dcd79c4fd96..75a3eafa384 100644
--- a/code/modules/shuttle/shuttle.dm
+++ b/code/modules/shuttle/shuttle.dm
@@ -19,7 +19,7 @@
var/dwidth = 0 //position relative to covered area, perpendicular to dir
var/dheight = 0 //position relative to covered area, parallel to dir
- //these objects are indestructable
+ //these objects are indestructible
/obj/docking_port/Destroy(force)
// unless you assert that you know what you're doing. Horrible things
// may result.
@@ -212,6 +212,7 @@
destination = null
previous = null
assigned_transit = null
+ areaInstance = null
. = ..()
/obj/docking_port/mobile/initialize()
@@ -394,15 +395,8 @@
/obj/docking_port/mobile/proc/dock(obj/docking_port/stationary/S1, force=FALSE)
// Crashing this ship with NO SURVIVORS
if(!force)
- var/status = canDock(S1)
- if(status == SHUTTLE_ALREADY_DOCKED)
- return status
- else if(status != SHUTTLE_CAN_DOCK)
- var/msg = "dock(): shuttle [src] cannot dock at [S1], \
- error: [status]"
- message_admins(msg)
- return status
-
+ if(!check_dock(S1))
+ return -1
if(!canMove())
return -1
@@ -484,7 +478,9 @@
return SSshuttle.getDock(roundstart_move)
/obj/docking_port/mobile/proc/dockRoundstart()
- return dock(findRoundstartDock())
+ var/port = findRoundstartDock()
+ if(port)
+ return dock(port)
/obj/effect/landmark/shuttle_import
name = "Shuttle Import"
@@ -550,20 +546,24 @@
if(SHUTTLE_CALL)
if(dock(destination))
setTimer(20)
+ return
if(SHUTTLE_RECALL)
if(dock(previous))
setTimer(20)
+ return
if(SHUTTLE_IGNITING)
if(check_transit_zone() != TRANSIT_READY)
setTimer(20)
+ return
else
mode = SHUTTLE_CALL
setTimer(callTime)
enterTransit()
- else
- mode = SHUTTLE_IDLE
- timer = 0
- destination = null
+ return
+
+ mode = SHUTTLE_IDLE
+ timer = 0
+ destination = null
/obj/docking_port/mobile/proc/check_ripples()
if(!ripples.len)
@@ -575,7 +575,7 @@
if(assigned_transit)
return TRANSIT_READY
else
- SSshuttle.request_transit_dock()
+ SSshuttle.request_transit_dock(src)
/obj/docking_port/mobile/proc/setTimer(wait)
timer = world.time + wait