From 80d83fd87739852de125b5fbf03114524b56024c Mon Sep 17 00:00:00 2001 From: Mark Suckerberg Date: Fri, 8 Dec 2023 21:36:16 -0600 Subject: [PATCH] time proc cleanup --- code/__DEFINES/time.dm | 2 +- code/__HELPERS/time.dm | 10 ++-------- code/game/gamemodes/dynamic/dynamic.dm | 10 +++++----- code/game/gamemodes/dynamic/dynamic_rulesets.dm | 2 +- .../gamemodes/dynamic/dynamic_rulesets_roundstart.dm | 2 +- code/modules/admin/verbs/adminhelp.dm | 4 ++-- code/modules/paperwork/fax_manager.dm | 2 +- 7 files changed, 13 insertions(+), 19 deletions(-) diff --git a/code/__DEFINES/time.dm b/code/__DEFINES/time.dm index 5c3fbfd6ccb5..494859934cdb 100644 --- a/code/__DEFINES/time.dm +++ b/code/__DEFINES/time.dm @@ -2,7 +2,7 @@ #define MIDNIGHT_ROLLOVER 864000 ///displays the current time into the round, with a lot of extra code just there for ensuring it looks okay after an entire day passes -#define ROUND_TIME ( "[world.time - SSticker.round_start_time > MIDNIGHT_ROLLOVER ? "[round((world.time - SSticker.round_start_time)/MIDNIGHT_ROLLOVER)]:[worldtime2text()]" : worldtime2text()]" ) +#define ROUND_TIME ( "[world.time - SSticker.round_start_time > MIDNIGHT_ROLLOVER ? "[round((world.time - SSticker.round_start_time)/MIDNIGHT_ROLLOVER)]:[game_timestamp()]" : game_timestamp()]" ) ///same as above, but based on real time of day #define ROUND_REALTIMEOFDAY ( "[REALTIMEOFDAY - SSticker.round_start_timeofday > MIDNIGHT_ROLLOVER ? "[round((REALTIMEOFDAY - SSticker.round_start_timeofday)/MIDNIGHT_ROLLOVER)]:[time2text(world.timeofday - SSticker.round_start_timeofday, "hh:mm:ss", 0)]" : time2text(world.timeofday - SSticker.round_start_timeofday, "hh:mm:ss", 0)]" ) diff --git a/code/__HELPERS/time.dm b/code/__HELPERS/time.dm index c3a2f9993625..a395552ee8d4 100644 --- a/code/__HELPERS/time.dm +++ b/code/__HELPERS/time.dm @@ -1,17 +1,11 @@ -//Returns the world time in english -/proc/worldtime2text() - return gameTimestamp("hh:mm:ss", world.time) - /proc/time_stamp(format = "YYYY-MM-DD hh:mm:ss", show_ds) var/time_string = time2text(world.timeofday, format) return show_ds ? "[time_string]:[world.timeofday % 10]" : time_string -/proc/gameTimestamp(format = "hh:mm:ss", wtime=null) - if(!wtime) - wtime = world.time +/proc/game_timestamp(format = "hh:mm:ss", wtime = world.time) return time2text(wtime - GLOB.timezoneOffset, format) -/proc/station_time(display_only = FALSE, wtime=world.time) +/proc/station_time(display_only = FALSE, wtime = world.time) return ((((wtime - SSticker.round_start_time) * SSticker.station_time_rate_multiplier) + SSticker.gametime_offset) % 864000) - (display_only? GLOB.timezoneOffset : 0) /proc/station_time_timestamp(format = "hh:mm:ss", wtime) diff --git a/code/game/gamemodes/dynamic/dynamic.dm b/code/game/gamemodes/dynamic/dynamic.dm index 78f19dbf1a89..b8dcd669d385 100644 --- a/code/game/gamemodes/dynamic/dynamic.dm +++ b/code/game/gamemodes/dynamic/dynamic.dm @@ -159,10 +159,10 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1) return if(threatadd > 0) create_threat(threatadd) - threat_log += "[worldtime2text()]: [key_name(usr)] increased threat by [threatadd] threat." + threat_log += "[game_timestamp()]: [key_name(usr)] increased threat by [threatadd] threat." else spend_threat(-threatadd) - threat_log += "[worldtime2text()]: [key_name(usr)] decreased threat by [-threatadd] threat." + threat_log += "[game_timestamp()]: [key_name(usr)] decreased threat by [-threatadd] threat." else if (href_list["injectlate"]) latejoin_injection_cooldown = 0 forced_injection = TRUE @@ -478,7 +478,7 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1) var/added_threat = starting_rule.scale_up(extra_rulesets_amount, threat) if(starting_rule.pre_execute()) spend_threat(starting_rule.cost + added_threat) - threat_log += "[worldtime2text()]: Roundstart [starting_rule.name] spent [starting_rule.cost + added_threat]. [starting_rule.scaling_cost ? "Scaled up[starting_rule.scaled_times]/3 times." : ""]" + threat_log += "[game_timestamp()]: Roundstart [starting_rule.name] spent [starting_rule.cost + added_threat]. [starting_rule.scaling_cost ? "Scaled up[starting_rule.scaled_times]/3 times." : ""]" if(starting_rule.flags & HIGHLANDER_RULESET) highlander_executed = TRUE else if(starting_rule.flags & ONLY_RULESET) @@ -572,7 +572,7 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1) new_rule.trim_candidates() if (new_rule.ready(forced)) spend_threat(new_rule.cost) - threat_log += "[worldtime2text()]: Forced rule [new_rule.name] spent [new_rule.cost]" + threat_log += "[game_timestamp()]: Forced rule [new_rule.name] spent [new_rule.cost]" if (new_rule.execute()) // This should never fail since ready() returned 1 if(new_rule.flags & HIGHLANDER_RULESET) highlander_executed = TRUE @@ -591,7 +591,7 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1) /datum/game_mode/dynamic/proc/execute_midround_latejoin_rule(sent_rule) var/datum/dynamic_ruleset/rule = sent_rule spend_threat(rule.cost) - threat_log += "[worldtime2text()]: [rule.ruletype] [rule.name] spent [rule.cost]" + threat_log += "[game_timestamp()]: [rule.ruletype] [rule.name] spent [rule.cost]" rule.pre_execute() if (rule.execute()) log_game("DYNAMIC: Injected a [rule.ruletype == "latejoin" ? "latejoin" : "midround"] ruleset [rule.name].") diff --git a/code/game/gamemodes/dynamic/dynamic_rulesets.dm b/code/game/gamemodes/dynamic/dynamic_rulesets.dm index 44e6a5310d17..1e6a2da4d867 100644 --- a/code/game/gamemodes/dynamic/dynamic_rulesets.dm +++ b/code/game/gamemodes/dynamic/dynamic_rulesets.dm @@ -166,7 +166,7 @@ /// This one only handles refunding the threat, override in ruleset to clean up the rest. /datum/dynamic_ruleset/proc/clean_up() mode.refund_threat(cost + (scaled_times * scaling_cost)) - mode.threat_log += "[worldtime2text()]: [ruletype] [name] refunded [cost + (scaled_times * scaling_cost)]. Failed to execute." + mode.threat_log += "[game_timestamp()]: [ruletype] [name] refunded [cost + (scaled_times * scaling_cost)]. Failed to execute." /// Gets weight of the ruleset /// Note that this decreases weight if repeatable is TRUE and repeatable_weight_decrease is higher than 0 diff --git a/code/game/gamemodes/dynamic/dynamic_rulesets_roundstart.dm b/code/game/gamemodes/dynamic/dynamic_rulesets_roundstart.dm index 29333ce332d4..8c8fe19d0a97 100644 --- a/code/game/gamemodes/dynamic/dynamic_rulesets_roundstart.dm +++ b/code/game/gamemodes/dynamic/dynamic_rulesets_roundstart.dm @@ -355,7 +355,7 @@ message_admins("Starting a round of extended.") log_game("Starting a round of extended.") mode.spend_threat(mode.threat) - mode.threat_log += "[worldtime2text()]: Extended ruleset set threat to 0." + mode.threat_log += "[game_timestamp()]: Extended ruleset set threat to 0." return TRUE ////////////////////////////////////////////// diff --git a/code/modules/admin/verbs/adminhelp.dm b/code/modules/admin/verbs/adminhelp.dm index 225a074b1477..eed725fc3154 100644 --- a/code/modules/admin/verbs/adminhelp.dm +++ b/code/modules/admin/verbs/adminhelp.dm @@ -494,9 +494,9 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new) dat += "[FOURSPACES][ticket_href("Refresh", ref_src)][FOURSPACES][ticket_href("Re-Title", ref_src, "retitle")]" if(state != AHELP_ACTIVE) dat += "[FOURSPACES][ticket_href("Reopen", ref_src, "reopen")]" - dat += "

Opened at: [gameTimestamp(wtime = opened_at)] (Approx [DisplayTimeText(world.time - opened_at)] ago)" + dat += "

Opened at: [game_timestamp(wtime = opened_at)] (Approx [DisplayTimeText(world.time - opened_at)] ago)" if(closed_at) - dat += "
Closed at: [gameTimestamp(wtime = closed_at)] (Approx [DisplayTimeText(world.time - closed_at)] ago)" + dat += "
Closed at: [game_timestamp(wtime = closed_at)] (Approx [DisplayTimeText(world.time - closed_at)] ago)" dat += "

" if(initiator) dat += "Actions:
[full_monty(ref_src)]
" diff --git a/code/modules/paperwork/fax_manager.dm b/code/modules/paperwork/fax_manager.dm index bde646712b96..0107e440bec2 100644 --- a/code/modules/paperwork/fax_manager.dm +++ b/code/modules/paperwork/fax_manager.dm @@ -121,7 +121,7 @@ GLOBAL_DATUM_INIT(fax_manager, /datum/fax_manager, new) var/list/request = list() var/obj/item/paper/request/message = new() request["id_message"] = requests.len - request["time"] = gameTimestamp() + request["time"] = game_timestamp() request["sender"] = sender request["sender_fax_id"] = sender_fax.fax_id request["sender_fax_name"] = sender_fax.fax_name