mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
Merge branch 'master' of https://github.com/PolarisSS13/Polaris into NanoGrade
Conflicts: code/_helpers/time.dm code/modules/economy/ATM.dm
This commit is contained in:
@@ -4,17 +4,56 @@
|
||||
#define MINUTE *600
|
||||
#define MINUTES *600
|
||||
|
||||
var/roundstart_hour = 0
|
||||
//Returns the world time in english
|
||||
proc/worldtime2text(time = world.time, timeshift = 1)
|
||||
if(!roundstart_hour) roundstart_hour = pick(2,7,12,17)
|
||||
return timeshift ? time2text(time+(36000*roundstart_hour), "hh:mm") : time2text(time, "hh:mm")
|
||||
#define HOUR *36000
|
||||
#define HOURS *36000
|
||||
|
||||
proc/worlddate2text()
|
||||
return num2text((text2num(time2text(world.timeofday, "YYYY"))+544)) + "-" + time2text(world.timeofday, "MM-DD")
|
||||
#define DAY *864000
|
||||
#define DAYS *864000
|
||||
|
||||
proc/time_stamp()
|
||||
return time2text(world.timeofday, "hh:mm:ss")
|
||||
#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
|
||||
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)
|
||||
|
||||
/proc/stationtime2text()
|
||||
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(station_time_in_ticks, "hh:mm:ss")
|
||||
|
||||
/* Returns 1 if it is the selected month and day */
|
||||
proc/isDay(var/month, var/day)
|
||||
@@ -36,9 +75,7 @@ var/round_start_time = 0
|
||||
round_start_time = world.time
|
||||
return 1
|
||||
|
||||
#define round_duration_in_ticks (round_start_time ? world.time - round_start_time : 0)
|
||||
|
||||
/proc/round_duration_as_text()
|
||||
/proc/roundduration2text()
|
||||
if(!round_start_time)
|
||||
return "00:00"
|
||||
if(last_round_duration && world.time < next_duration_update)
|
||||
@@ -56,6 +93,14 @@ var/round_start_time = 0
|
||||
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
|
||||
|
||||
/hook/startup/proc/set_roundstart_hour()
|
||||
roundstart_hour = pick(2,7,12,17)
|
||||
return 1
|
||||
/*
|
||||
Returns "watch handle" (really just a timestamp)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user