Fix/rename some timing stuff

This commit is contained in:
Arokha Sieyes
2020-05-08 01:51:24 -04:00
parent 209f09f1ba
commit 07e2efb9b8
10 changed files with 25 additions and 30 deletions
+12 -16
View File
@@ -35,25 +35,25 @@
return wtime + (time_offset + wusage) * world.tick_lag
var/roundstart_hour
GLOBAL_VAR_INIT(roundstart_hour, pick(2,7,12,17))
var/station_date = ""
var/next_station_date_change = 1 DAY
#define duration2stationtime(time) time2text(station_time_in_ticks + time, "hh:mm")
#define worldtime2stationtime(time) time2text(roundstart_hour HOURS + time, "hh:mm")
#define round_duration_in_ticks (round_start_time ? world.time - round_start_time : 0)
#define station_time_in_ticks (roundstart_hour HOURS + round_duration_in_ticks)
#define duration2stationtime(time) time2text(station_time_in_ds + time, "hh:mm")
#define worldtime2stationtime(time) time2text(GLOB.roundstart_hour HOURS + time, "hh:mm")
#define round_duration_in_ds (GLOB.round_start_time ? world.time - GLOB.round_start_time : 0)
#define station_time_in_ds (GLOB.roundstart_hour HOURS + round_duration_in_ds)
/proc/stationtime2text()
return time2text(station_time_in_ticks, "hh:mm")
return time2text(station_time_in_ds, "hh:mm") //For some reason, this is not accurate. It's expecting some other kind of times, maybe? Like ones from world.realtime?
/proc/stationdate2text()
var/update_time = FALSE
if(station_time_in_ticks > next_station_date_change)
if(station_time_in_ds > next_station_date_change)
next_station_date_change += 1 DAY
update_time = TRUE
if(!station_date || update_time)
var/extra_days = round(station_time_in_ticks / (1 DAY)) DAYS
var/extra_days = round(station_time_in_ds / (1 DAY)) DAYS
var/timeofday = world.timeofday + extra_days
station_date = num2text((text2num(time2text(timeofday, "YYYY"))+544)) + "-" + time2text(timeofday, "MM-DD")
return station_date
@@ -83,19 +83,19 @@ proc/isDay(var/month, var/day)
var/next_duration_update = 0
var/last_round_duration = 0
var/round_start_time = 0
GLOBAL_VAR_INIT(round_start_time, 0)
/hook/roundstart/proc/start_timer()
round_start_time = world.time
GLOB.round_start_time = world.time
return 1
/proc/roundduration2text()
if(!round_start_time)
if(!GLOB.round_start_time)
return "00:00"
if(last_round_duration && world.time < next_duration_update)
return last_round_duration
var/mills = round_duration_in_ticks // 1/10 of a second, not real milliseconds but whatever
var/mills = round_duration_in_ds // 1/10 of a second, not real milliseconds but whatever
//var/secs = ((mills % 36000) % 600) / 10 //Not really needed, but I'll leave it here for refrence.. or something
var/mins = round((mills % 36000) / 600)
var/hours = round(mills / 36000)
@@ -112,10 +112,6 @@ var/round_start_time = 0
var/datum/controller/process/process = processScheduler.getProcess(process_name)
return process.schedule_interval
/hook/startup/proc/set_roundstart_hour()
roundstart_hour = pick(2,7,12,17)
return 1
/var/midnight_rollovers = 0
/var/rollovercheck_last_timeofday = 0
/proc/update_midnight_rollover()
+1 -1
View File
@@ -12,6 +12,6 @@ datum/controller/transfer_controller/Destroy()
datum/controller/transfer_controller/process()
currenttick = currenttick + 1
if (round_duration_in_ticks >= timerbuffer - 1 MINUTE)
if (round_duration_in_ds >= timerbuffer - 1 MINUTE)
SSvote.autotransfer()
timerbuffer = timerbuffer + config.vote_autotransfer_interval
+1 -1
View File
@@ -109,7 +109,7 @@ SUBSYSTEM_DEF(game_master)
return FALSE
// Last minute antagging is bad for humans to do, so the GM will respect the start and end of the round.
var/mills = round_duration_in_ticks
var/mills = round_duration_in_ds
var/mins = round((mills % 36000) / 600)
var/hours = round(mills / 36000)
+1 -1
View File
@@ -20,7 +20,7 @@ SUBSYSTEM_DEF(nightshift)
return ..()
/datum/controller/subsystem/nightshift/fire(resumed = FALSE)
if(round_duration_in_ticks < nightshift_first_check)
if(round_duration_in_ds < nightshift_first_check)
return
check_nightshift()
+1 -1
View File
@@ -34,7 +34,7 @@
if(emergency_shuttle.shuttle && (emergency_shuttle.shuttle.moving_status == SHUTTLE_WARMUP || emergency_shuttle.shuttle.moving_status == SHUTTLE_INTRANSIT))
return // Don't do anything if the shuttle's coming.
var/mills = round_duration_in_ticks
var/mills = round_duration_in_ds
var/mins = round((mills % 36000) / 600)
var/hours = round(mills / 36000)
+1 -1
View File
@@ -185,7 +185,7 @@
// Description: This writes to the logs list, so that people can see what people are doing on the Exonet ingame. Note that this is not an admin logging function.
// Communicators are already logged seperately.
/obj/machinery/exonet_node/proc/write_log(var/origin_address, var/target_address, var/data_type, var/content)
//var/timestamp = time2text(station_time_in_ticks, "hh:mm:ss")
//var/timestamp = time2text(station_time_in_ds, "hh:mm:ss")
var/timestamp = "[stationdate2text()] [stationtime2text()]"
var/msg = "[timestamp] | FROM [origin_address] TO [target_address] | TYPE: [data_type] | CONTENT: [content]"
logs.Add(msg)
+1 -1
View File
@@ -79,7 +79,7 @@
newMsg.body = msg
newMsg.time_stamp = "[stationtime2text()]"
newMsg.is_admin_message = adminMessage
newMsg.post_time = round_duration_in_ticks // Should be almost universally unique
newMsg.post_time = round_duration_in_ds // Should be almost universally unique
if(message_type)
newMsg.message_type = message_type
if(photo)
+1 -1
View File
@@ -22,7 +22,7 @@ var/global/list/severity_to_string = list(EVENT_LEVEL_MUNDANE = "Mundane", EVENT
var/last_world_time = 0
/datum/event_container/process()
if(!round_start_time)
if(!GLOB.round_start_time)
return //don't do events if the round hasn't even started yet
if(!next_event_time)
@@ -86,10 +86,10 @@
power_draw_per_use = 4
/obj/item/integrated_circuit/time/clock/do_work()
set_pin_data(IC_OUTPUT, 1, time2text(station_time_in_ticks, "hh:mm:ss") )
set_pin_data(IC_OUTPUT, 2, text2num(time2text(station_time_in_ticks, "hh") ) )
set_pin_data(IC_OUTPUT, 3, text2num(time2text(station_time_in_ticks, "mm") ) )
set_pin_data(IC_OUTPUT, 4, text2num(time2text(station_time_in_ticks, "ss") ) )
set_pin_data(IC_OUTPUT, 1, time2text(station_time_in_ds, "hh:mm:ss") )
set_pin_data(IC_OUTPUT, 2, text2num(time2text(station_time_in_ds, "hh") ) )
set_pin_data(IC_OUTPUT, 3, text2num(time2text(station_time_in_ds, "mm") ) )
set_pin_data(IC_OUTPUT, 4, text2num(time2text(station_time_in_ds, "ss") ) )
push_data()
activate_pin(2)
+2 -3
View File
@@ -136,8 +136,7 @@ var/list/all_maps = list()
// We have to invent a time
else
var/seconds_stationtime = round(station_time_in_ticks*0.1) //Not actually ticks......
var/datum/time/T = new(seconds_stationtime)
var/datum/time/T = new (station_time_in_ds)
return T
// Returns a boolean for if it's night or not on a particular zlevel
@@ -145,7 +144,7 @@ var/list/all_maps = list()
if(!z)
z = 1
var/datum/time/now = get_zlevel_time(z)
var/percent = now.seconds_stored / now.seconds_in_day
var/percent = now.seconds_stored / now.seconds_in_day //practically all of these are in DS
// First quarter, last quarter
if(percent < 0.25 || percent > 0.75)