mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-20 06:32:56 +00:00
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may not be viewable. --> <!-- You can view Contributing.MD for a detailed description of the pull request process. --> ## About The Pull Request Gives the players a redacted version of the logs, ckeys filtered out for public logging purposes. <!-- Please make sure to actually test your PRs. If you have not tested your PR mention it. --> ## Why It's Good For The Game You can prove your cases in ahelps and appeals, reports, easier. ## Proof Of Testing  ## Changelog <!-- If your PR modifies aspects of the game that can be concretely observed by players or admins you should add a changelog. If your change does NOT meet this description, remove this section. Be sure to properly mark your PRs to prevent unnecessary GBP loss. You can read up on GBP and it's effects on PRs in the tgstation guides for contributors. Please note that maintainers freely reserve the right to remove and add tags should they deem it appropriate. You can attempt to finagle the system all you want, but it's best to shoot for clear communication right off the bat. --> 🆑 admin: added public log folder, and logging. /🆑 <!-- Both 🆑's are required for the changelog to work! You can put your name to the right of the first 🆑 if you want to overwrite your GitHub username as author ingame. --> <!-- You can use multiple of the same prefix (they're only used for the icon ingame) and delete the unneeded ones. Despite some of the tags, changelogs should generally represent how a player might be affected by the changes rather than a summary of the PR's contents. --> <!-- By opening a pull request. You have read and understood the repository rules located on the main README.md on this project. --> --------- Co-authored-by: projectkepler-RU <99981766+projectkepler-ru@users.noreply.github.com> Co-authored-by: Waterpig <49160555+Majkl-J@users.noreply.github.com>
103 lines
3.1 KiB
Plaintext
103 lines
3.1 KiB
Plaintext
/// A "snapshot" of dynamic at an important point in time.
|
|
/// Exported to JSON in the dynamic.json log file.
|
|
/datum/dynamic_snapshot
|
|
/// The remaining midround threat
|
|
var/remaining_threat
|
|
|
|
/// The world.time when the snapshot was taken
|
|
var/time
|
|
|
|
/// The total number of players in the server
|
|
var/total_players
|
|
|
|
/// The number of alive players
|
|
var/alive_players
|
|
|
|
/// The number of dead players
|
|
var/dead_players
|
|
|
|
/// The number of observers
|
|
var/observers
|
|
|
|
/// The number of alive antags
|
|
var/alive_antags
|
|
|
|
/// The rulesets chosen this snapshot
|
|
var/datum/dynamic_snapshot_ruleset/ruleset_chosen
|
|
|
|
/// The cached serialization of this snapshot
|
|
var/serialization
|
|
|
|
/// A ruleset chosen during a snapshot
|
|
/datum/dynamic_snapshot_ruleset
|
|
/// The name of the ruleset chosen
|
|
var/name
|
|
|
|
/// If it is a round start ruleset, how much it was scaled by
|
|
var/scaled
|
|
|
|
/// The number of assigned antags
|
|
var/assigned
|
|
|
|
/datum/dynamic_snapshot_ruleset/New(datum/dynamic_ruleset/ruleset)
|
|
name = ruleset.name
|
|
assigned = ruleset.assigned.len
|
|
|
|
if (istype(ruleset, /datum/dynamic_ruleset/roundstart))
|
|
scaled = ruleset.scaled_times
|
|
|
|
/// Convert the snapshot to an associative list
|
|
/datum/dynamic_snapshot/proc/to_list()
|
|
if (!isnull(serialization))
|
|
return serialization
|
|
|
|
serialization = list(
|
|
"remaining_threat" = remaining_threat,
|
|
"time" = time,
|
|
"total_players" = total_players,
|
|
"alive_players" = alive_players,
|
|
"dead_players" = dead_players,
|
|
"observers" = observers,
|
|
"alive_antags" = alive_antags,
|
|
"ruleset_chosen" = list(
|
|
"name" = ruleset_chosen.name,
|
|
"scaled" = ruleset_chosen.scaled,
|
|
"assigned" = ruleset_chosen.assigned,
|
|
),
|
|
)
|
|
|
|
return serialization
|
|
|
|
/// Updates the log for the current snapshots.
|
|
/datum/controller/subsystem/dynamic/proc/update_log()
|
|
var/list/serialized = list()
|
|
serialized["threat_level"] = threat_level
|
|
serialized["round_start_budget"] = initial_round_start_budget
|
|
serialized["mid_round_budget"] = threat_level - initial_round_start_budget
|
|
serialized["shown_threat"] = shown_threat
|
|
|
|
var/list/serialized_snapshots = list()
|
|
for (var/datum/dynamic_snapshot/snapshot as anything in snapshots)
|
|
serialized_snapshots += list(snapshot.to_list())
|
|
serialized["snapshots"] = serialized_snapshots
|
|
|
|
rustg_file_write(json_encode(serialized), "[GLOB.log_directory]/dynamic.json")
|
|
rustg_file_write(json_encode(serialized), "[GLOB.public_log_directory]/dynamic.json") // BUBBER EDIT
|
|
|
|
/// Creates a new snapshot with the given rulesets chosen, and writes to the JSON output.
|
|
/datum/controller/subsystem/dynamic/proc/new_snapshot(datum/dynamic_ruleset/ruleset_chosen)
|
|
var/datum/dynamic_snapshot/new_snapshot = new
|
|
|
|
new_snapshot.remaining_threat = mid_round_budget
|
|
new_snapshot.time = world.time
|
|
new_snapshot.alive_players = GLOB.alive_player_list.len
|
|
new_snapshot.dead_players = GLOB.dead_player_list.len
|
|
new_snapshot.observers = GLOB.current_observers_list.len
|
|
new_snapshot.total_players = new_snapshot.alive_players + new_snapshot.dead_players + new_snapshot.observers
|
|
new_snapshot.alive_antags = GLOB.current_living_antags.len
|
|
new_snapshot.ruleset_chosen = new /datum/dynamic_snapshot_ruleset(ruleset_chosen)
|
|
|
|
LAZYADD(snapshots, new_snapshot)
|
|
|
|
update_log()
|