Files
Bubberstation/code/modules/reta/reta_system.dm
John Willard aa4dc56835 Removes Station-time (more time changes) (#95744)
## About The Pull Request

Removes Station-Time entirely
Server Time is now NST (Nanotrasen Standard Time). SS13 takes place
exactly 540 years in the future of the current day, so every second is 1
second in-game.
Round Time is now PT (Pay-Time), how Nanotrasen keeps track of how long
the current rotation of Employees has been working for.

Telecomms uses NST due to its importance of being the communication to
the blackbox.

Autopsy report, clocks, scientific reports and requisitions use both
timestamps due to them being more official documents that NT may need to
know beyond just the current round (just for flavortext).

Pretty much everything else (Det scanner, PDA, IC logs, Time-of-Death,
AI law changes, Cyborg file downloading) uses PT

PT
<img width="305" height="217" alt="image"
src="https://github.com/user-attachments/assets/cef73025-6292-4f9c-8565-197397bda2ca"
/>
<img width="168" height="59" alt="image"
src="https://github.com/user-attachments/assets/a99db568-045d-45fc-8206-0d9a7b13c7d2"
/>
<img width="308" height="122" alt="image"
src="https://github.com/user-attachments/assets/37ca6f17-8916-4af2-9c91-0f0707038ca5"
/>



https://github.com/user-attachments/assets/29445051-c98b-4af3-a657-812083aab91a


Clock (Literate)
<img width="748" height="292" alt="image"
src="https://github.com/user-attachments/assets/c824e812-91b5-4737-858d-768336e9a7c4"
/>

Clock (Illiterate)
<img width="446" height="94" alt="image"
src="https://github.com/user-attachments/assets/90d5ea0d-eaff-4ced-aa31-ffdf0b4832a5"
/>

New paperwork time working properly

<img width="311" height="190" alt="image"
src="https://github.com/user-attachments/assets/6d048926-db61-4c91-893b-ce93e1ea7775"
/>

NST
<img width="800" height="115" alt="image"
src="https://github.com/user-attachments/assets/35ffde49-13c1-4ce7-ab24-858e48b608bd"
/>
<img width="1288" height="142" alt="image"
src="https://github.com/user-attachments/assets/40c30d16-e0de-4efc-b460-9486eeb901d6"
/>

# Other changes

1. Circuit time checker will now get the value of the given input (Hour,
Minute, Second) rather than the full dedisecond time converted into
hour/minutes/seconds

<img width="270" height="67" alt="image"
src="https://github.com/user-attachments/assets/097440cc-1c45-447f-9976-18de7f9c722c"
/>

2. Turns nightshift into a round event that'll last approximately 22
minutes
3. 12-hour pref (doesn't apply to the stat panel because it's global
info) & removal of "TCT" time

<img width="569" height="440" alt="image"
src="https://github.com/user-attachments/assets/d39083b1-d248-41c0-9a1c-b2398ca203a7"
/>

4. The chocolate pudding negative moodlet is now based on the server's
IRL time.
5. Admins can now use ``class``, ``style`` and ``background`` (they were
already given perms to use ``img`` so hiding background, which was
removed to prevent image embedding, is pointless)
6. Also fixes ``year`` being off on localhost.


## Why It's Good For The Game

Server Time is approximately 1s = 12s converted, not including it
desyncing from lag (I believe?).
This makes it pretty much impossible for people to actually use this as
a unit of measurement for in-game actions.
Different things also uses different timestamps which is a bit more
confusing.

The main change here is for accessibility and, hopefully, using time as
a source of immersion. "20 minutes ago" is no longer OOC, they're just
speaking in PT. There's no timezones in space, Nanotrasen Standard Time
is the closest there is, but Pay Time is how NT considers when you get
your paychecks, so it's what is more commonly used.

It also fixes major inconsistencies between "IC time" and "Station
time", things like breakfast moodlet was the first 15mins of the round
despite the round starting like 7 hours in? Nukies with an L6 SAW firing
down the halls was shooting like 1 bullet every 3 seconds (assuming 4
bullets per second), overall there was just a disconnect between how
long time actually is in the universe.

The secondary reason for this change (though it is what pushed me to
actually get around to making this change) is the greater stat-panel
removal. This hopes to lessen the dependence on the stat panel for
station-time by making it easier to understand, and the end-goal I have
is for this information to be limited to Admins & the AI (AI will get
the IC version with the accurate year), so until that happens I would
like to improve the use of station-time by making it consistent (for
example, you should only care for PT for IC, which is also what your PDA
displays), so that when it gets removed it won't leave players timeless.

If you haven't already, and is interested in helping remove the stat
panel, every entry that needs to be removed can be found here -
https://hackmd.io/443_dE5lRWeEAp9bjGcKYw?view

Closes https://github.com/tgstation/tgstation/issues/94988

## Changelog

🆑
del: Removed Station Time, now we use NST (Nanotrasen Standard Time),
which is IRL server time +540 years, and PT (Pay Time), the amount of
time since the round has started.
del: Station nightshift is now a Station event rather than being based
on Server time.
balance: Time circuit's Unit of Measure now tells the amount of time in
hour/minute/seconds rather than giving the whole time translated to
hours/minutes/seconds.
qol: Added a 12-hour clock pref for people who prefer it.
qol: Hovering over NST timestamps on official documents will now
translate how much it is in PT/Shift Time.
admin: Admins can now use style/class/background in their papercode.
/🆑

---------

Co-authored-by: Isratosh <Isratosh@hotmail.com>
2026-04-25 14:13:31 -06:00

320 lines
13 KiB
Plaintext

/**
* Request Emergency Temporary Access - RETA System
* Provides temporary department access when Requests Console emergency calls are made.
*/
/// Helper function for RETA-specific logging
/proc/log_reta(text)
WRITE_LOG(GLOB.reta_log, "[server_timestamp()] RETA: [text]")
log_game("RETA: [text]")
/proc/initialize_reta_system()
// Define which access flags are granted for each department
GLOB.reta_dept_grants = list(
"Medical" = list(ACCESS_MEDICAL, ACCESS_SURGERY),
"Security" = list(ACCESS_SECURITY, ACCESS_BRIG, ACCESS_BRIG_ENTRANCE),
"Engineering" = list(ACCESS_ENGINEERING, ACCESS_ATMOSPHERICS),
"Science" = list(ACCESS_SCIENCE, ACCESS_RESEARCH),
"Service" = list(ACCESS_SERVICE, ACCESS_BAR, ACCESS_KITCHEN, ACCESS_HYDROPONICS),
"Cargo" = list(ACCESS_CARGO),
"Mining" = list(ACCESS_MINING, ACCESS_MINING_STATION, ACCESS_CARGO),
"Command" = list(ACCESS_COMMAND), // Admin-only, not available through request consoles
)
/// Checks if an origin department is on cooldown for calling a target department
/proc/reta_on_cooldown(origin, target)
var/list/by_target = GLOB.reta_cooldown[origin]
if(!by_target)
return FALSE
var/next_ok = by_target[target] || 0
return world.time < next_ok
/// Sets a cooldown for an origin department calling a target department
/proc/reta_set_cooldown(origin, target, cd_ds)
if(!GLOB.reta_cooldown[origin])
GLOB.reta_cooldown[origin] = list()
GLOB.reta_cooldown[origin][target] = world.time + cd_ds
/// Tracks recent emergency calls for multiple department analysis
/proc/reta_track_call(origin, target)
var/list/call_info = list(
"time" = world.time,
"origin" = origin
)
if(!GLOB.reta_recent_calls[target])
GLOB.reta_recent_calls[target] = list()
GLOB.reta_recent_calls[target] += list(call_info)
// Clean old calls (older than 10 minutes)
var/cutoff_time = world.time - 6000 // 10 minutes
if(GLOB.reta_recent_calls[target])
var/list/recent_calls = GLOB.reta_recent_calls[target]
GLOB.reta_recent_calls[target] = recent_calls.Copy()
for(var/list/old_call in GLOB.reta_recent_calls[target])
if(old_call["time"] < cutoff_time)
GLOB.reta_recent_calls[target] -= list(old_call)
// Check for multiple calls scenario
if(LAZYLEN(GLOB.reta_recent_calls[target]) >= 3)
var/list/origins = list()
for(var/list/call_data in GLOB.reta_recent_calls[target])
origins |= call_data["origin"]
if(LAZYLEN(origins) >= 3)
message_admins("RETA: Multiple emergency scenario detected! [target] has been called by [english_list(origins)] in the last 10 minutes. Consider station-wide emergency protocols.")
log_game("RETA: Multiple department emergency - [target] called by [english_list(origins)]")
/// Finds eligible responders and grants them temporary access
/proc/reta_find_and_grant_access(target_dept, origin_dept, duration_ds)
. = 0
var/list/job_trims = GLOB.reta_job_trims[target_dept]
if(!LAZYLEN(job_trims))
log_reta("No job trims defined for department '[target_dept]'")
return FALSE
var/granted_count = 0
var/total_players_checked = 0
var/matching_trim_players = 0
// Check ID cards being carried by living players (fast and efficient)
for(var/mob/living/carbon/human/human_player as anything in GLOB.human_list)
// Only check players who are alive and have clients (actively playing)
if(!human_player.client || human_player.stat == DEAD)
continue
total_players_checked++
// Get their ID card (worn_id, hands, or belt)
var/obj/item/card/id/id_card = human_player.get_idcard(hand_first = FALSE)
if(!id_card || !id_card.trim)
continue
// Check if this card's trim matches the target department
if(!is_type_in_list(id_card.trim, job_trims))
continue
matching_trim_players++
if(id_card.grant_reta_access(origin_dept, duration_ds))
granted_count++
if(granted_count > 0)
// Register this as an active RETA grant for new cards
if(!GLOB.reta_active_grants[target_dept])
GLOB.reta_active_grants[target_dept] = list()
GLOB.reta_active_grants[target_dept][origin_dept] = world.time + duration_ds
// Set up automatic cleanup when the grant expires
addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(cleanup_expired_reta_grant), target_dept, origin_dept), duration_ds)
// Update all doors to show RETA lights for newly activated grants
update_all_doors_reta_lights()
log_reta("Granted temporary [origin_dept] access to [granted_count] [target_dept] department ID cards from a call by [origin_dept].")
. = TRUE
else
log_reta("No [target_dept] personnel found who needed [origin_dept] access from a call by [origin_dept]. (Checked [total_players_checked] living players, [matching_trim_players] had matching trims)")
return .
/// Populates the job trims list for RETA system
/proc/populate_reta_job_trims()
GLOB.reta_job_trims = list(
"Medical" = list(),
"Security" = list(),
"Engineering" = list(),
"Science" = list(),
"Service" = list(),
"Command" = list(),
"Cargo" = list(),
"Mining" = list()
)
log_game("RETA: Starting job trim population...")
var/total_trims = 0
for(var/job_trim_path in subtypesof(/datum/id_trim/job))
var/datum/id_trim/job/trim = new job_trim_path()
total_trims++
if(!trim.job)
log_game("RETA: Trim [job_trim_path] has no job")
continue
if(!trim.job.departments_bitflags)
log_game("RETA: Trim [job_trim_path] job [trim.job] has no departments_bitflags")
continue
if(trim.job.departments_bitflags & DEPARTMENT_BITFLAG_MEDICAL)
GLOB.reta_job_trims["Medical"] += job_trim_path
if(trim.job.departments_bitflags & DEPARTMENT_BITFLAG_SECURITY)
GLOB.reta_job_trims["Security"] += job_trim_path
if(trim.job.departments_bitflags & DEPARTMENT_BITFLAG_ENGINEERING)
GLOB.reta_job_trims["Engineering"] += job_trim_path
if(trim.job.departments_bitflags & DEPARTMENT_BITFLAG_SCIENCE)
GLOB.reta_job_trims["Science"] += job_trim_path
if(trim.job.departments_bitflags & DEPARTMENT_BITFLAG_SERVICE)
GLOB.reta_job_trims["Service"] += job_trim_path
if(trim.job.departments_bitflags & DEPARTMENT_BITFLAG_COMMAND)
GLOB.reta_job_trims["Command"] += job_trim_path
if(trim.job.departments_bitflags & DEPARTMENT_BITFLAG_CARGO)
GLOB.reta_job_trims["Cargo"] += job_trim_path
GLOB.reta_job_trims["Mining"] += job_trim_path // Mining uses CARGO bitflag
log_game("RETA: Processed [total_trims] trims. Final counts: Medical=[LAZYLEN(GLOB.reta_job_trims["Medical"])], Security=[LAZYLEN(GLOB.reta_job_trims["Security"])], Engineering=[LAZYLEN(GLOB.reta_job_trims["Engineering"])], Science=[LAZYLEN(GLOB.reta_job_trims["Science"])], Service=[LAZYLEN(GLOB.reta_job_trims["Service"])], Command=[LAZYLEN(GLOB.reta_job_trims["Command"])], Cargo=[LAZYLEN(GLOB.reta_job_trims["Cargo"])], Mining=[LAZYLEN(GLOB.reta_job_trims["Mining"])]")
/// Pushes UI updates to all consoles in the same origin department
/proc/reta_push_ui_updates(origin, target)
for(var/obj/machinery/requests_console/console in GLOB.reta_consoles_by_origin[origin])
console.ui_update()
/// Gets the department string for a user based on their job
/proc/reta_get_user_department(mob/user)
if(!user?.mind?.assigned_role)
return null
var/datum/job/job = user.mind.assigned_role
if(job.departments_bitflags & DEPARTMENT_BITFLAG_ENGINEERING)
return "Engineering"
if(job.departments_bitflags & DEPARTMENT_BITFLAG_SCIENCE)
return "Science"
if(job.departments_bitflags & DEPARTMENT_BITFLAG_CARGO)
return "Cargo"
if(job.departments_bitflags & DEPARTMENT_BITFLAG_SERVICE)
return "Service"
if(job.departments_bitflags & DEPARTMENT_BITFLAG_MEDICAL)
return "Medical"
if(job.departments_bitflags & DEPARTMENT_BITFLAG_SECURITY)
return "Security"
if(job.departments_bitflags & DEPARTMENT_BITFLAG_COMMAND)
return "Command"
return null
/// Gets the standardized department string from a console department name
/proc/reta_get_user_department_by_name(dept_name)
if(!dept_name)
return null
var/dept_lower = LOWER_TEXT(dept_name)
// Check for partial matches to handle variations in console naming
if(findtext(dept_lower, "engineering") || findtext(dept_lower, "engine"))
return "Engineering"
if(findtext(dept_lower, "science") || findtext(dept_lower, "research"))
return "Science"
if(findtext(dept_lower, "cargo") || findtext(dept_lower, "supply"))
return "Cargo"
if(findtext(dept_lower, "mining") || findtext(dept_lower, "mine"))
return "Mining"
if(findtext(dept_lower, "service") || findtext(dept_lower, "civilian"))
return "Service"
if(findtext(dept_lower, "medical") || findtext(dept_lower, "medbay"))
return "Medical"
if(findtext(dept_lower, "security") || findtext(dept_lower, "sec"))
return "Security"
if(findtext(dept_lower, "command") || findtext(dept_lower, "bridge"))
return "Command"
// Autonamed areas that belong to service department
if(findtext(dept_lower, "kitchen") || findtext(dept_lower, "bar") || findtext(dept_lower, "cafeteria") || findtext(dept_lower, "diner"))
return "Service"
if(findtext(dept_lower, "hydroponics") || findtext(dept_lower, "botany"))
return "Service"
if(findtext(dept_lower, "janitor") || findtext(dept_lower, "custodial"))
return "Service"
// Autonamed areas for medical
if(findtext(dept_lower, "pharmacy") || findtext(dept_lower, "chemistry") || findtext(dept_lower, "chem"))
return "Medical"
if(findtext(dept_lower, "morgue") || findtext(dept_lower, "virology"))
return "Medical"
if(findtext(dept_lower, "surgery") || findtext(dept_lower, "operating") || findtext(dept_lower, "cryo"))
return "Medical"
if(findtext(dept_lower, "patients") || findtext(dept_lower, "exam"))
return "Medical"
// Autonamed areas for engineering
if(findtext(dept_lower, "atmospherics") || findtext(dept_lower, "atmos"))
return "Engineering"
if(findtext(dept_lower, "supermatter") || findtext(dept_lower, "engine"))
return "Engineering"
if(findtext(dept_lower, "gravity") || findtext(dept_lower, "telecomm") || findtext(dept_lower, "tcomm"))
return "Engineering"
// Autonamed areas for science department
if(findtext(dept_lower, "xenobiology") || findtext(dept_lower, "xenobio"))
return "Science"
if(findtext(dept_lower, "robotics") || findtext(dept_lower, "genetics"))
return "Science"
if(findtext(dept_lower, "ordnance") || findtext(dept_lower, "cytology"))
return "Science"
// Handle specific autonamed areas that belong to security department
if(findtext(dept_lower, "brig") || findtext(dept_lower, "holding"))
return "Security"
if(findtext(dept_lower, "armory") || findtext(dept_lower, "checkpoint"))
return "Security"
return null
/// Cleans up an expired RETA grant from the active grants registry
/proc/cleanup_expired_reta_grant(target_dept, origin_dept)
if(!GLOB.reta_active_grants[target_dept])
return
GLOB.reta_active_grants[target_dept] -= origin_dept
if(!length(GLOB.reta_active_grants[target_dept]))
GLOB.reta_active_grants -= target_dept
log_reta("Cleaned up expired [origin_dept] grant for [target_dept] department")
// Update all doors to remove RETA lights for expired grants
update_all_doors_reta_lights()
/// Updates RETA lighting for all doors in the game
/proc/update_all_doors_reta_lights()
for(var/obj/machinery/door/airlock/door as anything in SSmachines.get_machines_by_type_and_subtypes(/obj/machinery/door/airlock))
door.update_appearance(UPDATE_OVERLAYS)
/// Applies any currently active RETA grants to a newly created/spawned ID card
/// This should be called when ID cards are created, spawned, or have their trim changed
/proc/apply_active_reta_grants_to_card(obj/item/card/id/id_card)
if(!id_card || !id_card.trim)
return
// If no active grants, nothing to do (prevents spam during round start)
if(!LAZYLEN(GLOB.reta_active_grants))
return
// Check if this card's department has any active incoming RETA grants
for(var/target_dept in GLOB.reta_active_grants)
var/list/job_trims = GLOB.reta_job_trims[target_dept]
if(!LAZYLEN(job_trims))
continue
// Check if this card's trim matches the target department
if(!is_type_in_list(id_card.trim, job_trims))
continue
log_reta("Card trim [id_card.trim] matches [target_dept] department - applying active grants")
// Apply all active grants for this department
for(var/origin_dept in GLOB.reta_active_grants[target_dept])
var/expiry_time = GLOB.reta_active_grants[target_dept][origin_dept]
if(world.time >= expiry_time)
continue // Grant expired, skip it
var/remaining_time = expiry_time - world.time
if(id_card.grant_reta_access(origin_dept, remaining_time))
log_reta("Auto-granted [origin_dept] access to newly created [id_card] ([target_dept] department)")
// Default config values
#define RETA_DEFAULT_DURATION_DS 3000 // 5 minutes
#define RETA_DEFAULT_COOLDOWN_DS 150 // 15 seconds
/// Initialize RETA config values
/proc/reta_init_config()
log_world("RETA: System initialized with duration=[CONFIG_GET(number/reta_duration_ds)]ds, cooldown=[CONFIG_GET(number/reta_dept_cooldown_ds)]ds, enabled=[CONFIG_GET(flag/reta_enabled)]")
#undef RETA_DEFAULT_DURATION_DS
#undef RETA_DEFAULT_COOLDOWN_DS