long_jump() now uses an arrive_time var instead of sleeping the whole time.

Makes ETAs more accurate, allows the possibility of interrupting
long_jumps in the future.
This commit is contained in:
mwerezak
2014-06-30 13:57:41 -04:00
parent abc54987b4
commit 9991b46ea6
6 changed files with 42 additions and 26 deletions

View File

@@ -155,9 +155,9 @@ var/global/datum/emergency_shuttle_controller/emergency_shuttle
//returns the time left until the shuttle arrives at it's destination, in seconds //returns the time left until the shuttle arrives at it's destination, in seconds
/datum/emergency_shuttle_controller/proc/estimate_arrival_time() /datum/emergency_shuttle_controller/proc/estimate_arrival_time()
var/eta var/eta
if (!isnull(shuttle.last_move_time)) if (shuttle.has_arrive_time())
//if we have a last_move_time than we are in transition and can get an accurate ETA //we are in transition and can get an accurate ETA
eta = shuttle.last_move_time + shuttle.move_time*10 eta = shuttle.arrive_time
else else
//otherwise we need to estimate the arrival time using the scheduled launch time //otherwise we need to estimate the arrival time using the scheduled launch time
eta = launch_time + shuttle.move_time*10 + shuttle.warmup_time*10 eta = launch_time + shuttle.move_time*10 + shuttle.warmup_time*10

View File

@@ -400,13 +400,18 @@
if (!emergency_shuttle.online()) if (!emergency_shuttle.online())
dat += "<a href='?src=\ref[src];call_shuttle=1'>Call Shuttle</a><br>" dat += "<a href='?src=\ref[src];call_shuttle=1'>Call Shuttle</a><br>"
else else
var/timeleft = emergency_shuttle.estimate_launch_time() if (emergency_shuttle.wait_for_launch)
switch(emergency_shuttle.location()) var/timeleft = emergency_shuttle.estimate_launch_time()
if(1) dat += "ETL: <a href='?src=\ref[src];edit_shuttle_time=1'>[(timeleft / 60) % 60]:[add_zero(num2text(timeleft % 60), 2)]</a><BR>"
dat += "ETA: <a href='?src=\ref[src];edit_shuttle_time=1'>[(timeleft / 60) % 60]:[add_zero(num2text(timeleft % 60), 2)]</a><BR>"
dat += "<a href='?src=\ref[src];call_shuttle=2'>Send Back</a><br>" else if (emergency_shuttle.shuttle.has_arrive_time())
if(0) var/timeleft = emergency_shuttle.estimate_arrival_time()
dat += "ETA: <a href='?src=\ref[src];edit_shuttle_time=1'>[(timeleft / 60) % 60]:[add_zero(num2text(timeleft % 60), 2)]</a><BR>" dat += "ETA: <a href='?src=\ref[src];edit_shuttle_time=1'>[(timeleft / 60) % 60]:[add_zero(num2text(timeleft % 60), 2)]</a><BR>"
dat += "<a href='?src=\ref[src];call_shuttle=2'>Send Back</a><br>"
if (emergency_shuttle.shuttle.moving_status == SHUTTLE_WARMUP)
dat += "Launching now..."
dat += "<a href='?src=\ref[src];delay_round_end=1'>[ticker.delay_end ? "End Round Normally" : "Delay Round End"]</a><br>" dat += "<a href='?src=\ref[src];delay_round_end=1'>[ticker.delay_end ? "End Round Normally" : "Delay Round End"]</a><br>"
if(ticker.mode.syndicates.len) if(ticker.mode.syndicates.len)
dat += "<br><table cellspacing=5><tr><td><B>Syndicates</B></td><td></td></tr>" dat += "<br><table cellspacing=5><tr><td><B>Syndicates</B></td><td></td></tr>"

View File

@@ -239,12 +239,23 @@
else if(href_list["edit_shuttle_time"]) else if(href_list["edit_shuttle_time"])
if(!check_rights(R_SERVER)) return if(!check_rights(R_SERVER)) return
var/new_time_left = input("Enter new shuttle launch duration (seconds):","Edit Shuttle Timeleft", emergency_shuttle.estimate_launch_time() ) as num if (emergency_shuttle.wait_for_launch)
var/new_time_left = input("Enter new shuttle launch countdown (seconds):","Edit Shuttle Launch Time", emergency_shuttle.estimate_launch_time() ) as num
emergency_shuttle.launch_time = world.time + new_time_left*10 emergency_shuttle.launch_time = world.time + new_time_left*10
log_admin("[key_name(usr)] edited the Emergency Shuttle's timeleft to [new_time_left]") log_admin("[key_name(usr)] edited the Emergency Shuttle's launch time to [new_time_left]")
message_admins("\blue [key_name_admin(usr)] edited the Emergency Shuttle's timeleft to [new_time_left*10]", 1) message_admins("\blue [key_name_admin(usr)] edited the Emergency Shuttle's launch time to [new_time_left*10]", 1)
else if (emergency_shuttle.shuttle.has_arrive_time())
var/new_time_left = input("Enter new shuttle arrival time (seconds):","Edit Shuttle Arrival Time", emergency_shuttle.estimate_arrival_time() ) as num
emergency_shuttle.shuttle.arrive_time = world.time + new_time_left*10
log_admin("[key_name(usr)] edited the Emergency Shuttle's arrival time to [new_time_left]")
message_admins("\blue [key_name_admin(usr)] edited the Emergency Shuttle's arrival time to [new_time_left*10]", 1)
else
alert("The shuttle is neither counting down to launch nor is it in transit. Please try again when it is.")
href_list["secretsadmin"] = "check_antagonist" href_list["secretsadmin"] = "check_antagonist"
else if(href_list["delay_round_end"]) else if(href_list["delay_round_end"])

View File

@@ -9,6 +9,8 @@
var/docking_controller_tag //tag of the controller used to coordinate docking 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/datum/computer/file/embedded_program/docking/docking_controller //the controller itself. (micro-controller, not game controller)
var/arrive_time = 0 //the time at which the shuttle arrives when long jumping
/datum/shuttle/proc/short_jump(var/area/origin,var/area/destination) /datum/shuttle/proc/short_jump(var/area/origin,var/area/destination)
if(moving_status != SHUTTLE_IDLE) return if(moving_status != SHUTTLE_IDLE) return
@@ -34,13 +36,15 @@
move(departing, interim, direction) move(departing, interim, direction)
sleep(travel_time*10) moving_status = SHUTTLE_INTRANSIT
arrive_time = world.time + travel_time*10
while (world.time < arrive_time)
sleep(5)
move(interim, destination, direction) move(interim, destination, direction)
moving_status = SHUTTLE_IDLE moving_status = SHUTTLE_IDLE
/datum/shuttle/proc/dock() /datum/shuttle/proc/dock()
if (!docking_controller) if (!docking_controller)
return return
@@ -78,8 +82,6 @@
if (docking_controller && !docking_controller.undocked()) if (docking_controller && !docking_controller.undocked())
docking_controller.force_undock() docking_controller.force_undock()
moving_status = SHUTTLE_INTRANSIT
var/list/dstturfs = list() var/list/dstturfs = list()
var/throwy = world.maxy var/throwy = world.maxy
@@ -117,4 +119,8 @@
if(!M.buckled) if(!M.buckled)
M.Weaken(3) M.Weaken(3)
return return
//returns 1 if the shuttle has a valid arrive time
/datum/shuttle/proc/has_arrive_time()
return (moving_status == SHUTTLE_INTRANSIT)

View File

@@ -1,6 +1,6 @@
/datum/shuttle/ferry/emergency /datum/shuttle/ferry/emergency
var/last_move_time = null //the time at which the shuttle last moved. Used for ETAs //pass
/datum/shuttle/ferry/emergency/arrived() /datum/shuttle/ferry/emergency/arrived()
emergency_shuttle.shuttle_arrived() emergency_shuttle.shuttle_arrived()
@@ -18,11 +18,6 @@
..() ..()
/datum/shuttle/ferry/emergency/move(var/area/origin,var/area/destination) /datum/shuttle/ferry/emergency/move(var/area/origin,var/area/destination)
if (destination == area_transition)
last_move_time = world.time
else
last_move_time = null
if (origin == area_station) //leaving the station if (origin == area_station) //leaving the station
emergency_shuttle.departed = 1 emergency_shuttle.departed = 1

View File

@@ -5,7 +5,6 @@
/datum/shuttle/ferry/supply /datum/shuttle/ferry/supply
var/away_location = 1 //the location to hide at while pretending to be in-transit var/away_location = 1 //the location to hide at while pretending to be in-transit
var/arrive_time = 0
var/late_chance = 80 var/late_chance = 80
var/max_late_time = 300 var/max_late_time = 300