Skip to content

Commit

Permalink
time proc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkSuckerberg committed Dec 9, 2023
1 parent 84c947c commit 80d83fd
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion code/__DEFINES/time.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)]" )

Expand Down
10 changes: 2 additions & 8 deletions code/__HELPERS/time.dm
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
10 changes: 5 additions & 5 deletions code/game/gamemodes/dynamic/dynamic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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].")
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/dynamic/dynamic_rulesets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/dynamic/dynamic_rulesets_roundstart.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

//////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions code/modules/admin/verbs/adminhelp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,9 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
dat += "</b>[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 += "<br><br>Opened at: [gameTimestamp(wtime = opened_at)] (Approx [DisplayTimeText(world.time - opened_at)] ago)"
dat += "<br><br>Opened at: [game_timestamp(wtime = opened_at)] (Approx [DisplayTimeText(world.time - opened_at)] ago)"
if(closed_at)
dat += "<br>Closed at: [gameTimestamp(wtime = closed_at)] (Approx [DisplayTimeText(world.time - closed_at)] ago)"
dat += "<br>Closed at: [game_timestamp(wtime = closed_at)] (Approx [DisplayTimeText(world.time - closed_at)] ago)"
dat += "<br><br>"
if(initiator)
dat += "<b>Actions:</b><br>[full_monty(ref_src)]<br>"
Expand Down
2 changes: 1 addition & 1 deletion code/modules/paperwork/fax_manager.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 80d83fd

Please sign in to comment.