mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Improves the fix for shuttles being stuck if...
... the docking controller is destroyed.
This commit is contained in:
@@ -9,7 +9,7 @@ var/global/datum/shuttle_controller/shuttle_controller
|
||||
/datum/shuttle_controller/proc/process()
|
||||
//process ferry shuttles
|
||||
for (var/datum/shuttle/ferry/shuttle in process_shuttles)
|
||||
if (shuttle.in_use)
|
||||
if (shuttle.process_state)
|
||||
shuttle.process()
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
//Shuttle controller is instantiated in master_controller.dm.
|
||||
|
||||
//shuttle moving state defines are in setup.dm
|
||||
#define DOCK_ATTEMPT_TIMEOUT 450 //how long in ticks we wait before assuming the docking controller is broken or blown up.
|
||||
|
||||
/datum/shuttle
|
||||
var/warmup_time = 0
|
||||
@@ -10,8 +9,6 @@
|
||||
|
||||
var/docking_controller_tag //tag of the controller used to coordinate docking
|
||||
var/datum/computer/file/embedded_program/docking/docking_controller //the controller itself. (micro-controller, not game controller)
|
||||
|
||||
var/last_dock_attempt_time = 0
|
||||
|
||||
/datum/shuttle/proc/short_jump(var/area/origin,var/area/destination)
|
||||
if(moving_status != SHUTTLE_IDLE) return
|
||||
@@ -52,14 +49,11 @@
|
||||
if (!dock_target)
|
||||
return
|
||||
|
||||
last_dock_attempt_time = world.time
|
||||
docking_controller.initiate_docking(dock_target)
|
||||
|
||||
/datum/shuttle/proc/undock()
|
||||
if (!docking_controller)
|
||||
return
|
||||
|
||||
last_dock_attempt_time = world.time
|
||||
docking_controller.initiate_undocking()
|
||||
|
||||
/datum/shuttle/proc/current_dock_target()
|
||||
@@ -68,8 +62,6 @@
|
||||
/datum/shuttle/proc/skip_docking_checks()
|
||||
if (!docking_controller || !current_dock_target())
|
||||
return 1 //shuttles without docking controllers or at locations without docking ports act like old-style shuttles
|
||||
if (world.time > last_dock_attempt_time + DOCK_ATTEMPT_TIMEOUT)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
//just moves the shuttle from A to B, if it can be moved
|
||||
@@ -83,6 +75,9 @@
|
||||
if(origin == destination)
|
||||
//world << "cancelling move, shuttle will overlap."
|
||||
return
|
||||
|
||||
if (docking_controller && !docking_controller.undocked())
|
||||
docking_controller.force_undock()
|
||||
|
||||
moving_status = SHUTTLE_INTRANSIT
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#define WAIT_ARRIVE 2
|
||||
#define WAIT_FINISH 3
|
||||
|
||||
#define DOCK_ATTEMPT_TIMEOUT 450 //how long in ticks we wait before assuming the docking controller is broken or blown up.
|
||||
|
||||
/datum/shuttle/ferry
|
||||
var/location = 0 //0 = at area_station, 1 = at area_offsite
|
||||
@@ -20,6 +21,8 @@
|
||||
//TODO: change location to a string and use a mapping for area and dock targets.
|
||||
var/dock_target_station
|
||||
var/dock_target_offsite
|
||||
|
||||
var/last_dock_attempt_time = 0
|
||||
|
||||
/datum/shuttle/ferry/short_jump(var/area/origin,var/area/destination)
|
||||
if(isnull(location))
|
||||
@@ -47,16 +50,16 @@
|
||||
..(departing, destination, interim, travel_time, direction)
|
||||
|
||||
/datum/shuttle/ferry/move(var/area/origin,var/area/destination)
|
||||
|
||||
if (docking_controller && !docking_controller.undocked())
|
||||
docking_controller.force_undock()
|
||||
|
||||
..(origin, destination)
|
||||
|
||||
if (destination == area_station) location = 0
|
||||
if (destination == area_offsite) location = 1
|
||||
//if this is a long_jump retain the location we were last at until we get to the new one
|
||||
|
||||
/datum/shuttle/ferry/dock()
|
||||
..()
|
||||
last_dock_attempt_time = world.time
|
||||
|
||||
/datum/shuttle/ferry/proc/get_location_area(location_id = null)
|
||||
if (isnull(location_id))
|
||||
location_id = location
|
||||
@@ -80,11 +83,11 @@
|
||||
if (WAIT_ARRIVE)
|
||||
if (moving_status == SHUTTLE_IDLE)
|
||||
dock()
|
||||
in_use = null //release lock
|
||||
process_state = WAIT_FINISH
|
||||
if (WAIT_FINISH)
|
||||
if (skip_docking_checks() || docking_controller.docked())
|
||||
if (skip_docking_checks() || docking_controller.docked() || world.time > last_dock_attempt_time + DOCK_ATTEMPT_TIMEOUT)
|
||||
process_state = IDLE_STATE
|
||||
in_use = null //release lock
|
||||
arrived()
|
||||
|
||||
/datum/shuttle/ferry/current_dock_target()
|
||||
|
||||
Reference in New Issue
Block a user