diff --git a/baystation12.dme b/baystation12.dme index 0abf32bf787..43733732a07 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -1293,6 +1293,7 @@ #include "code\modules\shuttles\shuttle.dm" #include "code\modules\shuttles\shuttle_console.dm" #include "code\modules\shuttles\shuttle_specops.dm" +#include "code\modules\shuttles\shuttle_supply.dm" #include "code\modules\shuttles\shuttles_multi.dm" #include "code\modules\supermatter\supermatter.dm" #include "code\modules\surgery\appendix.dm" diff --git a/code/controllers/verbs.dm b/code/controllers/verbs.dm index 3faa6e4c809..491a1b2c43a 100644 --- a/code/controllers/verbs.dm +++ b/code/controllers/verbs.dm @@ -1,7 +1,7 @@ //TODO: rewrite and standardise all controller datums to the datum/controller type //TODO: allow all controllers to be deleted for clean restarts (see WIP master controller stuff) - MC done - lighting done -/client/proc/restart_controller(controller in list("Master","Failsafe","Lighting","Supply Shuttle")) +/client/proc/restart_controller(controller in list("Master","Failsafe","Lighting","Supply")) set category = "Debug" set name = "Restart Controller" set desc = "Restart one of the various periodic loop controllers for the game (be careful!)" @@ -21,14 +21,14 @@ new /datum/controller/lighting() lighting_controller.process() feedback_add_details("admin_verb","RLighting") - if("Supply Shuttle") - supply_shuttle.process() + if("Supply") + supply_controller.process() feedback_add_details("admin_verb","RSupply") message_admins("Admin [key_name_admin(usr)] has restarted the [controller] controller.") return -/client/proc/debug_controller(controller in list("Master","Failsafe","Ticker","Lighting","Air","Jobs","Sun","Radio","Supply Shuttle","Emergency Shuttle","Configuration","pAI", "Cameras", "Transfer Controller")) +/client/proc/debug_controller(controller in list("Master","Failsafe","Ticker","Lighting","Air","Jobs","Sun","Radio","Supply","Emergency Shuttle","Configuration","pAI", "Cameras", "Transfer Controller")) set category = "Debug" set name = "Debug Controller" set desc = "Debug the various periodic loop controllers for the game (be careful!)" @@ -59,8 +59,8 @@ if("Radio") debug_variables(radio_controller) feedback_add_details("admin_verb","DRadio") - if("Supply Shuttle") - debug_variables(supply_shuttle) + if("Supply") + debug_variables(supply_controller) feedback_add_details("admin_verb","DSupply") if("Emergency Shuttle") debug_variables(emergency_shuttle) diff --git a/code/game/gamemodes/gameticker.dm b/code/game/gamemodes/gameticker.dm index 0ae6a7b28b2..18f6d114106 100644 --- a/code/game/gamemodes/gameticker.dm +++ b/code/game/gamemodes/gameticker.dm @@ -129,7 +129,7 @@ var/global/datum/controller/gameticker/ticker //here to initialize the random events nicely at round start setup_economy() - + setup_shuttle_docks() spawn(0)//Forking here so we dont have to wait for this to finish @@ -154,7 +154,7 @@ var/global/datum/controller/gameticker/ticker if(admins_number == 0) send2adminirc("Round has started with no admins online.") - supply_shuttle.process() //Start the supply shuttle regenerating points -- TLE + supply_controller.process() //Start the supply shuttle regenerating points -- TLE master_controller.process() //Start master_controller.process() lighting_controller.process() //Start processing DynamicAreaLighting updates @@ -320,7 +320,7 @@ var/global/datum/controller/gameticker/ticker else game_finished = (mode.check_finished() || (emergency_shuttle.location == 2 && emergency_shuttle.alert == 1)) mode_finished = game_finished - + if(!mode.explosion_in_progress && game_finished && (mode_finished || post_game)) current_state = GAME_STATE_FINISHED @@ -351,17 +351,17 @@ var/global/datum/controller/gameticker/ticker world << "\blue An admin has delayed the round end" else world << "\blue An admin has delayed the round end" - + else if (mode_finished) post_game = 1 - + mode.cleanup() - + //call a transfer shuttle vote spawn(50) world << "\red The round has ended!" vote.autotransfer() - + return 1 proc/getfactionbyname(var/name) diff --git a/code/game/machinery/status_display.dm b/code/game/machinery/status_display.dm index c62f1a236aa..404c2d54ca4 100644 --- a/code/game/machinery/status_display.dm +++ b/code/game/machinery/status_display.dm @@ -110,13 +110,22 @@ update_display(line1, line2) if(4) // supply shuttle timer var/line1 = "SUPPLY" - var/line2 - if(supply_shuttle.moving) + var/line2 = "" + + var/datum/shuttle/ferry/supply/shuttle = supply_controller.get_shuttle() + if (!shuttle) + line2 = "Error" + else if(shuttle.has_eta()) line2 = get_supply_shuttle_timer() if(lentext(line2) > CHARS_PER_LINE) line2 = "Error" + else if (shuttle.moving_status == SHUTTLE_WARMUP) + if (shuttle.at_station()) + line2 = "Launch" + else + line2 = "ETA" else - if(supply_shuttle.at_station) + if(shuttle.at_station()) line2 = "Docked" else line1 = "" @@ -162,8 +171,12 @@ return "" proc/get_supply_shuttle_timer() - if(supply_shuttle.moving) - var/timeleft = round((supply_shuttle.eta_timeofday - world.timeofday) / 10,1) + var/datum/shuttle/ferry/supply/shuttle = supply_controller.get_shuttle() + if (!shuttle) + return "Error" + + if(shuttle.has_eta()) + var/timeleft = round((shuttle.arrive_time - world.time) / 10,1) if(timeleft < 0) return "Late" return "[add_zero(num2text((timeleft / 60) % 60),2)]:[add_zero(num2text(timeleft % 60), 2)]" diff --git a/code/game/objects/items/devices/PDA/cart.dm b/code/game/objects/items/devices/PDA/cart.dm index 499bbef25f6..0f041ef5c9f 100644 --- a/code/game/objects/items/devices/PDA/cart.dm +++ b/code/game/objects/items/devices/PDA/cart.dm @@ -411,12 +411,14 @@ if(mode==47) var/supplyData[0] - supplyData["shuttle_moving"] = supply_shuttle.moving - supplyData["shuttle_eta"] = supply_shuttle.eta - supplyData["shuttle_loc"] = supply_shuttle.at_station ? "Station" : "Dock" + var/datum/shuttle/ferry/supply/shuttle = supply_controller.get_shuttle() + if (shuttle) + supplyData["shuttle_moving"] = shuttle.has_eta() + supplyData["shuttle_eta"] = shuttle.eta_minutes() + supplyData["shuttle_loc"] = shuttle.at_station() ? "Station" : "Dock" var/supplyOrderCount = 0 var/supplyOrderData[0] - for(var/S in supply_shuttle.shoppinglist) + for(var/S in supply_controller.shoppinglist) var/datum/supply_order/SO = S supplyOrderData[++supplyOrderData.len] = list("Number" = SO.ordernum, "Name" = html_encode(SO.object.name), "ApprovedBy" = SO.orderedby, "Comment" = html_encode(SO.comment)) @@ -428,7 +430,7 @@ var/requestCount = 0 var/requestData[0] - for(var/S in supply_shuttle.requestlist) + for(var/S in supply_controller.requestlist) var/datum/supply_order/SO = S requestCount++ requestData[++requestData.len] = list("Number" = SO.ordernum, "Name" = html_encode(SO.object.name), "OrderedBy" = SO.orderedby, "Comment" = html_encode(SO.comment)) diff --git a/code/game/supplyshuttle.dm b/code/game/supplyshuttle.dm index 63f69b5becf..aa4ecd007d5 100644 --- a/code/game/supplyshuttle.dm +++ b/code/game/supplyshuttle.dm @@ -4,7 +4,7 @@ #define SUPPLY_STATION_AREATYPE "/area/supply/station" //Type of the supply shuttle area for station #define SUPPLY_DOCK_AREATYPE "/area/supply/dock" //Type of the supply shuttle area for dock -var/datum/controller/supply_shuttle/supply_shuttle = new() +var/datum/controller/supply/supply_controller = new() var/list/mechtoys = list( /obj/item/toy/prize/ripley, @@ -125,7 +125,7 @@ var/list/mechtoys = list( var/orderedby = null var/comment = null -/datum/controller/supply_shuttle +/datum/controller/supply var/processing = 1 var/processing_interval = 300 var/iteration = 0 @@ -142,15 +142,23 @@ var/list/mechtoys = list( var/list/requestlist = list() var/list/supply_packs = list() //shuttle movement - var/at_station = 0 var/movetime = 1200 - var/moving = 0 - var/eta_timeofday - var/eta + var/shuttle_tag = "Supply" New() ordernum = rand(1,9000) + proc/get_shuttle() + if (!shuttles || !(shuttle_tag in shuttles)) + return null + + var/datum/shuttle/ferry/supply/shuttle = shuttles[shuttle_tag] + + if (!istype(shuttle)) + return null + + return shuttle + //Supply shuttle ticker - handles supply point regenertion and shuttle travelling between centcomm and the station proc/process() for(var/typepath in (typesof(/datum/supply_packs) - /datum/supply_packs)) @@ -164,30 +172,17 @@ var/list/mechtoys = list( iteration++ points += points_per_process - if(moving == 1) - var/ticksleft = (eta_timeofday - world.timeofday) - if(ticksleft > 0) - eta = round(ticksleft/600,1) - else - eta = 0 - var/datum/shuttle/S = shuttles["Supply"] - if (istype(S)) S.move() - moving = 0 - at_station = !at_station - sleep(processing_interval) - - //Check whether the shuttle is allowed to move - proc/can_move() - if(moving) return 0 - - var/area/shuttle = locate(/area/supply/station) - if(!shuttle) return 0 - - if(forbidden_atoms_check(shuttle)) - return 0 - - return 1 + + spawn(0) + set background = 1 + while(1) + if(processing) + var/datum/shuttle/ferry/supply/shuttle = get_shuttle() + if (shuttle && shuttle.in_use) + shuttle.process_shuttle() + + sleep(10) //To stop things being sent to centcomm which should not be sent to centcomm. Recursively checks for these types. proc/forbidden_atoms_check(atom/A) @@ -207,11 +202,10 @@ var/list/mechtoys = list( //Sellin proc/sell() - var/shuttle_at - if(at_station) shuttle_at = SUPPLY_STATION_AREATYPE - else shuttle_at = SUPPLY_DOCK_AREATYPE + var/datum/shuttle/ferry/supply/shuttle_datum = get_shuttle() + if (!shuttle_datum) return - var/area/shuttle = locate(shuttle_at) + var/area/shuttle = shuttle_datum.get_location_area() if(!shuttle) return var/phoron_count = 0 @@ -259,11 +253,10 @@ var/list/mechtoys = list( proc/buy() if(!shoppinglist.len) return - var/shuttle_at - if(at_station) shuttle_at = SUPPLY_STATION_AREATYPE - else shuttle_at = SUPPLY_DOCK_AREATYPE + var/datum/shuttle/ferry/supply/shuttle_datum = get_shuttle() + if (!shuttle_datum) return - var/area/shuttle = locate(shuttle_at) + var/area/shuttle = shuttle_datum.get_location_area() if(!shuttle) return var/list/clear_turfs = list() @@ -290,7 +283,7 @@ var/list/mechtoys = list( slip.info = "

[command_name()] Shipping Manifest



" slip.info +="Order #[SO.ordernum]
" slip.info +="Destination: [station_name]
" - slip.info +="[supply_shuttle.shoppinglist.len] PACKAGES IN THIS SHIPMENT
" + slip.info +="[shoppinglist.len] PACKAGES IN THIS SHIPMENT
" slip.info +="CONTENTS: