mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Conflicts: code/__defines/btime.dm code/__defines/process_scheduler.dm code/_helpers/time.dm code/controllers/ProcessScheduler/core/_stubs.dm code/controllers/ProcessScheduler/core/processScheduler.dm polaris.dme
99 lines
3.0 KiB
Plaintext
99 lines
3.0 KiB
Plaintext
#define SECOND *10
|
|
#define SECONDS *10
|
|
|
|
#define MINUTE *600
|
|
#define MINUTES *600
|
|
|
|
#define HOUR *36000
|
|
#define HOURS *36000
|
|
|
|
#define DAY *864000
|
|
#define DAYS *864000
|
|
|
|
#define TimeOfGame (get_game_time())
|
|
#define TimeOfTick (world.tick_usage*0.01*world.tick_lag)
|
|
|
|
/proc/get_game_time()
|
|
var/global/time_offset = 0
|
|
var/global/last_time = 0
|
|
var/global/last_usage = 0
|
|
|
|
var/wtime = world.time
|
|
var/wusage = world.tick_usage * 0.01
|
|
|
|
if(last_time < wtime && last_usage > 1)
|
|
time_offset += last_usage - 1
|
|
|
|
last_time = wtime
|
|
last_usage = wusage
|
|
|
|
return wtime + (time_offset + wusage) * world.tick_lag
|
|
|
|
var/roundstart_hour = 0
|
|
var/station_date = ""
|
|
var/next_station_date_change = 1 DAY
|
|
|
|
#define station_adjusted_time(time) time2text(time + station_time_in_ticks, "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)
|
|
|
|
/proc/stationtime2text()
|
|
if(!roundstart_hour) roundstart_hour = pick(2,7,12,17)
|
|
return time2text(station_time_in_ticks, "hh:mm")
|
|
|
|
/proc/stationdate2text()
|
|
var/update_time = FALSE
|
|
if(station_time_in_ticks > 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/timeofday = world.timeofday + extra_days
|
|
station_date = num2text((text2num(time2text(timeofday, "YYYY"))+544)) + "-" + time2text(timeofday, "MM-DD")
|
|
return station_date
|
|
|
|
/proc/time_stamp()
|
|
return time2text(world.timeofday, "hh:mm:ss")
|
|
|
|
/* Returns 1 if it is the selected month and day */
|
|
proc/isDay(var/month, var/day)
|
|
if(isnum(month) && isnum(day))
|
|
var/MM = text2num(time2text(world.timeofday, "MM")) // get the current month
|
|
var/DD = text2num(time2text(world.timeofday, "DD")) // get the current day
|
|
if(month == MM && day == DD)
|
|
return 1
|
|
|
|
// Uncomment this out when debugging!
|
|
//else
|
|
//return 1
|
|
|
|
var/next_duration_update = 0
|
|
var/last_round_duration = 0
|
|
var/round_start_time = 0
|
|
|
|
/hook/roundstart/proc/start_timer()
|
|
round_start_time = world.time
|
|
return 1
|
|
|
|
/proc/roundduration2text()
|
|
if(!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/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)
|
|
|
|
mins = mins < 10 ? add_zero(mins, 1) : mins
|
|
hours = hours < 10 ? add_zero(hours, 1) : hours
|
|
|
|
last_round_duration = "[hours]:[mins]"
|
|
next_duration_update = world.time + 1 MINUTES
|
|
return last_round_duration
|
|
|
|
//Can be useful for things dependent on process timing
|
|
/proc/process_schedule_interval(var/process_name)
|
|
var/datum/controller/process/process = processScheduler.getProcess(process_name)
|
|
return process.schedule_interval |