Adds shuttle controller

Moves all ferry shuttle processing into one place: the new shuttle
controller.

Also cleans up the emergency shuttle controller a bit more and fixes
multi-shuttle cooldown.

Conflicts:
	code/controllers/master_controller.dm
	code/controllers/verbs.dm
	code/game/supplyshuttle.dm
	code/modules/shuttles/shuttle.dm
This commit is contained in:
mwerezak
2014-06-24 07:06:48 -04:00
committed by ZomgPonies
parent 727d7400ee
commit e6944b989c
12 changed files with 542 additions and 538 deletions
+3 -3
View File
@@ -2048,15 +2048,15 @@
if("moveshuttle")
if(!shuttles) return // Something is very wrong, the global shuttle list has not been created.
if(!shuttle_controller) return // Something is very wrong, the shuttle controller has not been created.
feedback_inc("admin_secrets_fun_used",1)
feedback_add_details("admin_secrets_fun_used","ShA")
var/shuttle_tag = input("Which shuttle do you want to call?") as null|anything in shuttles
var/shuttle_tag = input("Which shuttle do you want to call?") as null|anything in shuttle_controller.shuttles
if(shuttle_tag)
var/datum/shuttle/S = shuttles[shuttle_tag]
var/datum/shuttle/S = shuttle_controller.shuttles[shuttle_tag]
if(istype(S) && S.moving_status == 0)
S.move()
message_admins("\blue [key_name_admin(usr)] moved the [shuttle_tag] shuttle", 1)
+3 -197
View File
@@ -3,14 +3,12 @@
//shuttle moving state defines are in setup.dm
var/global/list/shuttles
/datum/shuttle
var/warmup_time = 0
var/moving_status = SHUTTLE_IDLE //prevents people from doing things they shouldn't when the shuttle is in transit
var/moving_status = SHUTTLE_IDLE
var/docking_controller_tag //tag of the controller used to coordinate docking
var/datum/computer/file/embedded_program/docking/docking_controller //the controller itself
var/datum/computer/file/embedded_program/docking/docking_controller //the controller itself. (micro-controller, not game controller)
/datum/shuttle/proc/short_jump(var/area/origin,var/area/destination)
if(moving_status != SHUTTLE_IDLE) return
@@ -35,7 +33,7 @@ var/global/list/shuttles
move(locate(departing),locate(interim))
sleep(travel_time)
sleep(travel_time*10)
move(locate(interim),locate(destination))
@@ -117,195 +115,3 @@ var/global/list/shuttles
M.Weaken(3)
return
/proc/setup_shuttles()
shuttles = list()
var/datum/shuttle/ferry/shuttle
// Escape shuttle and pods
shuttle = new/datum/shuttle/ferry/emergency()
shuttle.location = 1
shuttle.warmup_time = 10
shuttle.area_offsite = locate(/area/shuttle/escape/centcom)
shuttle.area_station = locate(/area/shuttle/escape/station)
shuttle.area_transition = locate(/area/shuttle/escape/transit)
shuttle.travel_time = SHUTTLE_TRANSIT_DURATION
//shuttle.docking_controller_tag = "supply_shuttle"
//shuttle.dock_target_station = "cargo_bay"
shuttles["Escape"] = shuttle
emergency_shuttle.shuttle = shuttle
emergency_shuttle.setup_pods()
// Supply shuttle
shuttle = new/datum/shuttle/ferry/supply()
shuttle.location = 1
shuttle.warmup_time = 10
shuttle.area_offsite = locate(/area/supply/dock)
shuttle.area_station = locate(/area/supply/station)
shuttle.docking_controller_tag = "supply_shuttle"
shuttle.dock_target_station = "cargo_bay"
shuttles["Supply"] = shuttle
supply_controller.shuttle = shuttle
// Admin shuttles.
shuttle = new()
shuttle.location = 1
shuttle.warmup_time = 10
shuttle.area_offsite = locate(/area/shuttle/transport1/centcom)
shuttle.area_station = locate(/area/shuttle/transport1/station)
shuttle.docking_controller_tag = "centcom_shuttle"
shuttle.dock_target_station = "centcom_shuttle_dock_airlock"
shuttle.dock_target_offsite = "centcom_shuttle_bay"
shuttles["Centcom"] = shuttle
shuttle = new()
shuttle.location = 1
shuttle.warmup_time = 10 //want some warmup time so people can cancel.
shuttle.area_offsite = locate(/area/shuttle/administration/centcom)
shuttle.area_station = locate(/area/shuttle/administration/station)
shuttle.docking_controller_tag = "admin_shuttle"
shuttle.dock_target_station = "admin_shuttle_dock_airlock"
shuttle.dock_target_offsite = "admin_shuttle_bay"
shuttles["Administration"] = shuttle
shuttle = new()
shuttle.area_offsite = locate(/area/shuttle/alien/base)
shuttle.area_station = locate(/area/shuttle/alien/mine)
shuttles["Alien"] = shuttle
// Public shuttles
shuttle = new()
shuttle.location = 1
shuttle.warmup_time = 10
shuttle.area_offsite = locate(/area/shuttle/constructionsite/site)
shuttle.area_station = locate(/area/shuttle/constructionsite/station)
shuttle.docking_controller_tag = "engineering_shuttle"
shuttle.dock_target_station = "engineering_dock_airlock"
shuttle.dock_target_offsite = "engineering_station_airlock"
shuttles["Engineering"] = shuttle
shuttle = new()
shuttle.warmup_time = 10
shuttle.area_offsite = locate(/area/shuttle/mining/outpost)
shuttle.area_station = locate(/area/shuttle/mining/station)
shuttle.docking_controller_tag = "mining_shuttle"
shuttle.dock_target_station = "mining_dock_airlock"
shuttle.dock_target_offsite = "mining_outpost_airlock"
shuttles["Mining"] = shuttle
shuttle = new()
shuttle.warmup_time = 10
shuttle.area_offsite = locate(/area/shuttle/research/outpost)
shuttle.area_station = locate(/area/shuttle/research/station)
shuttle.docking_controller_tag = "research_shuttle"
shuttle.dock_target_station = "research_dock_airlock"
shuttle.dock_target_offsite = "research_outpost_dock"
shuttles["Research"] = shuttle
// ERT Shuttle
var/datum/shuttle/ferry/multidock/specops/ERT = new()
ERT.location = 1
ERT.warmup_time = 10
ERT.area_offsite = locate(/area/shuttle/specops/station) //centcom is the home station, the Exodus is offsite
ERT.area_station = locate(/area/shuttle/specops/centcom)
ERT.docking_controller_tag = "specops_shuttle_port"
ERT.docking_controller_tag_station = "specops_shuttle_port"
ERT.docking_controller_tag_offsite = "specops_shuttle_fore"
ERT.dock_target_station = "specops_dock_airlock"
ERT.dock_target_offsite = "specops_centcom_dock"
shuttles["Special Operations"] = ERT
//Vox Shuttle.
var/datum/shuttle/multi_shuttle/VS = new/datum/shuttle/multi_shuttle()
VS.origin = /area/shuttle/vox/station
VS.destinations = list(
"NGS Cyberiad" = /area/vox_station/northwest_solars
)
VS.announcer = "NSV Icarus"
VS.arrival_message = "Attention, Cyberiad, we just tracked a small target bypassing our defensive perimeter. Can't fire on it without hitting the station - you've got incoming visitors, like it or not."
VS.departure_message = "Your guests are pulling away, Cyberiad - moving too fast for us to draw a bead on them. Looks like they're heading out of the system at a rapid clip."
VS.interim = /area/vox_station/transit
VS.warmup_time = 10
shuttles["Vox Skipjack"] = VS
//Nuke Ops shuttle.
var/datum/shuttle/multi_shuttle/MS = new/datum/shuttle/multi_shuttle()
MS.origin = /area/syndicate_station/start
MS.destinations = list(
"Northwest of the station" = /area/syndicate_station/northwest,
"North of the station" = /area/syndicate_station/north,
"Northeast of the station" = /area/syndicate_station/northeast,
"Southwest of the station" = /area/syndicate_station/southwest,
"South of the station" = /area/syndicate_station/south,
"Southeast of the station" = /area/syndicate_station/southeast,
"Telecomms Satellite" = /area/syndicate_station/commssat,
"Mining Asteroid" = /area/syndicate_station/mining
)
MS.announcer = "NSV Icarus"
MS.arrival_message = "Attention, Exodus, you have a large signature approaching the station - looks unarmed to surface scans. We're too far out to intercept - brace for visitors."
MS.departure_message = "Your visitors are on their way out of the system, Exodus, burning delta-v like it's nothing. Good riddance."
MS.interim = /area/syndicate_station/transit
MS.warmup_time = 10
shuttles["Syndicate"] = MS
/proc/setup_shuttle_docks()
var/datum/shuttle/shuttle
var/datum/shuttle/ferry/multidock/multidock
var/list/dock_controller_map = list() //so we only have to iterate once through each list
//multidock shuttles
var/list/dock_controller_map_station = list()
var/list/dock_controller_map_offsite = list()
for (var/shuttle_tag in shuttles)
shuttle = shuttles[shuttle_tag]
if (shuttle.docking_controller_tag)
dock_controller_map[shuttle.docking_controller_tag] = shuttle
if (istype(shuttle, /datum/shuttle/ferry/multidock))
multidock = shuttle
dock_controller_map_station[multidock.docking_controller_tag_station] = multidock
dock_controller_map_offsite[multidock.docking_controller_tag_offsite] = multidock
//search for the controllers, if we have one.
if (dock_controller_map.len)
for (var/obj/machinery/embedded_controller/radio/C in machines) //only radio controllers are supported at the moment
if (istype(C.program, /datum/computer/file/embedded_program/docking))
if (C.id_tag in dock_controller_map)
shuttle = dock_controller_map[C.id_tag]
shuttle.docking_controller = C.program
dock_controller_map -= C.id_tag
if (C.id_tag in dock_controller_map_station)
multidock = dock_controller_map_station[C.id_tag]
if (istype(multidock))
multidock.docking_controller_station = C.program
dock_controller_map_station -= C.id_tag
if (C.id_tag in dock_controller_map_offsite)
multidock = dock_controller_map_offsite[C.id_tag]
if (istype(multidock))
multidock.docking_controller_offsite = C.program
dock_controller_map_offsite -= C.id_tag
//sanity check
if (dock_controller_map.len || dock_controller_map_station.len || dock_controller_map_offsite.len)
var/dat = ""
for (var/dock_tag in dock_controller_map + dock_controller_map_station + dock_controller_map_offsite)
dat += "\"[dock_tag]\", "
world << "/red /b warning: shuttles with docking tags [dat] could not find their controllers!"
//makes all shuttles docked to something at round start go into the docked state
for (var/shuttle_tag in shuttles)
shuttle = shuttles[shuttle_tag]
shuttle.dock()
+11 -36
View File
@@ -9,8 +9,7 @@
var/direction = 0 //0 = going to station, 1 = going to offsite.
var/process_state = IDLE_STATE
//this mutex ensures that only one console is processing the shuttle's controls at a time
var/obj/machinery/computer/shuttle_control/in_use = null //this doesn't have to be a console...
var/in_use = null //tells the controller whether this shuttle needs processing
var/area_transition
var/travel_time = 0
@@ -68,7 +67,7 @@
return area_station
return area_offsite
/datum/shuttle/ferry/proc/process_shuttle()
/datum/shuttle/ferry/proc/process()
switch(process_state)
if (WAIT_LAUNCH)
if (skip_docking_checks() || docking_controller.can_launch())
@@ -98,7 +97,7 @@
return dock_target
/datum/shuttle/ferry/proc/launch(var/obj/machinery/computer/shuttle_control/user)
/datum/shuttle/ferry/proc/launch(var/user)
if (!can_launch()) return
in_use = user //obtain an exclusive lock on the shuttle
@@ -106,12 +105,15 @@
process_state = WAIT_LAUNCH
undock()
/datum/shuttle/ferry/proc/force_launch(var/obj/machinery/computer/shuttle_control/user)
/datum/shuttle/ferry/proc/force_launch(var/user)
if (!can_force()) return
in_use = user //obtain an exclusive lock on the shuttle
short_jump()
if (travel_time && area_transition)
long_jump(null, null, area_transition, travel_time)
else
short_jump()
process_state = WAIT_ARRIVE
@@ -166,27 +168,6 @@
var/launch_override = 0
//TODO move this stuff into the shuttle datum itself, instead of manipulating the shuttle's members
/obj/machinery/computer/shuttle_control/process()
if (!shuttles || !(shuttle_tag in shuttles))
return
var/datum/shuttle/ferry/shuttle = shuttles[shuttle_tag]
if (!istype(shuttle))
return
if (shuttle.in_use == src)
shuttle.process_shuttle()
/obj/machinery/computer/shuttle_control/Del()
var/datum/shuttle/ferry/shuttle = shuttles[shuttle_tag]
if (!istype(shuttle))
return
if (shuttle.in_use == src)
shuttle.in_use = null //shuttle may not dock properly if this gets deleted while in transit, but its not a big deal
/obj/machinery/computer/shuttle_control/attack_hand(user as mob)
if(..(user))
return
@@ -196,7 +177,7 @@
/obj/machinery/computer/shuttle_control/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null)
var/data[0]
var/datum/shuttle/ferry/shuttle = shuttles[shuttle_tag]
var/datum/shuttle/ferry/shuttle = shuttle_controller.shuttles[shuttle_tag]
if (!istype(shuttle))
return
@@ -241,7 +222,6 @@
ui.open()
ui.set_auto_update(1)
//TODO: Canceling launches, dock overrides using the console, forcing dock/undock
/obj/machinery/computer/shuttle_control/Topic(href, href_list)
if(..())
return
@@ -249,7 +229,7 @@
usr.set_machine(src)
src.add_fingerprint(usr)
var/datum/shuttle/ferry/shuttle = shuttles[shuttle_tag]
var/datum/shuttle/ferry/shuttle = shuttle_controller.shuttles[shuttle_tag]
if (!istype(shuttle))
return
@@ -260,11 +240,11 @@
else if(href_list["cancel"])
shuttle.cancel_launch()
/obj/machinery/computer/shuttle_control/attackby(obj/item/weapon/W as obj, mob/user as mob)
if (istype(W, /obj/item/weapon/card/emag))
src.req_access = list()
src.req_one_access = list()
hacked = 1
usr << "You short out the console's ID checking system. It's now available to everyone!"
else
@@ -273,8 +253,3 @@
/obj/machinery/computer/shuttle_control/bullet_act(var/obj/item/projectile/Proj)
visible_message("[Proj] ricochets off [src]!")
#undef IDLE_STATE
#undef WAIT_LAUNCH
#undef WAIT_ARRIVE
#undef WAIT_FINISH
+12 -9
View File
@@ -4,8 +4,8 @@
var/cloaked = 1
var/at_origin = 1
var/move_time = 240
var/cooldown = 200
var/last_move = 0
var/cooldown = 20
var/last_move = 0 //the time at which we last moved
var/announcer
var/arrival_message
@@ -21,6 +21,10 @@
..()
if(origin) last_departed = origin
/datum/shuttle/multi_shuttle/move()
..()
last_move = world.time
/datum/shuttle/multi_shuttle/proc/announce_departure()
if(cloaked || isnull(departure_message))
@@ -44,7 +48,7 @@
return
src.add_fingerprint(user)
var/datum/shuttle/multi_shuttle/MS = shuttles[shuttle_tag]
var/datum/shuttle/multi_shuttle/MS = shuttle_controller.shuttles[shuttle_tag]
if(!istype(MS)) return
var/dat
@@ -57,7 +61,7 @@
var/area/areacheck = get_area(src)
dat += "Location: [areacheck.name]<br>"
if((MS.last_move + MS.cooldown) > world.time)
if((MS.last_move + MS.cooldown*10) > world.time)
dat += "<font color='red'>Engines charging.</font><br>"
else
dat += "<font color='green'>Engines ready.</font><br>"
@@ -76,17 +80,13 @@
usr.set_machine(src)
src.add_fingerprint(usr)
var/datum/shuttle/multi_shuttle/MS = shuttles[shuttle_tag]
var/datum/shuttle/multi_shuttle/MS = shuttle_controller.shuttles[shuttle_tag]
if(!istype(MS)) return
if (MS.moving_status != SHUTTLE_IDLE)
usr << "\blue [shuttle_tag] vessel is moving."
return
if((MS.last_move + MS.cooldown) > world.time)
usr << "\red The ship is inoperable while the engines are charging."
return
if(href_list["start"])
if(MS.at_origin)
@@ -109,6 +109,9 @@
usr << "\red Ship stealth systems have been [(MS.cloaked ? "activated. The station will not" : "deactivated. The station will")] be warned of our arrival."
if(href_list["move_multi"])
if((MS.last_move + MS.cooldown) > world.time)
usr << "\red The ship's drive is inoperable while the engines are charging."
return
var/choice = input("Select a destination.") as null|anything in MS.destinations
if(!choice) return