Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code maintenace of Stats Entities #4750

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions code/datums/mind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@
research_objective_interface = new()

/datum/mind/Destroy()
QDEL_NULL(initial_account)
QDEL_NULL(objective_memory)
QDEL_NULL(objective_interface)
QDEL_NULL(research_objective_interface)
current = null
original = null
ghost_mob = null
player_entity = null
return ..()

/datum/mind/proc/transfer_to(mob/living/new_character, force = FALSE)
Expand Down
4 changes: 4 additions & 0 deletions code/datums/statistics/entities/caste_stats.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
var/total_hits = 0
var/list/abilities_used = list() // types of /datum/entity/statistic, "tail sweep" = 10, "screech" = 2

/datum/entity/player_stats/caste/Destroy(force)
. = ..()
QDEL_LIST_ASSOC_VAL(abilities_used)

/datum/entity/player_stats/caste/proc/setup_ability(ability)
if(!ability)
return
Expand Down
8 changes: 4 additions & 4 deletions code/datums/statistics/entities/death_stats.dm
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,16 @@
new_death.detach()
return new_death

/mob/living/carbon/human/track_mob_death(cause, cause_mob)
. = ..(cause, cause_mob, job)
/mob/living/carbon/human/track_mob_death(datum/cause_data/cause_data, turf/death_loc)
. = ..()
if(statistic_exempt || !mind)
return
var/datum/entity/player_stats/human/human_stats = mind.setup_human_stats()
if(human_stats && human_stats.death_list)
human_stats.death_list.Insert(1, .)

/mob/living/carbon/xenomorph/track_mob_death(cause, cause_mob)
var/datum/entity/statistic/death/new_death = ..(cause, cause_mob, caste_type)
/mob/living/carbon/xenomorph/track_mob_death(datum/cause_data/cause_data, turf/death_loc)
var/datum/entity/statistic/death/new_death = ..()
if(!new_death)
return
new_death.is_xeno = TRUE // this was placed beneath the if below, which meant gibbing as a xeno wouldn't track properly in stats
Expand Down
15 changes: 11 additions & 4 deletions code/datums/statistics/entities/human_stats.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@
var/total_shots = 0
var/total_shots_hit = 0
var/total_screams = 0
var/datum/entity/weapon_stats/top_weapon = null // reference to /datum/entity/weapon_stats (like tac-shotty)
var/list/weapon_stats_list = list() // list of types /datum/entity/weapon_stats
var/list/job_stats_list = list() // list of types /datum/entity/job_stats
var/list/datum/entity/statistic/medal/medal_list = list() // list of all medals earned
var/list/weapon_stats_list = list() //! indexed list of types /datum/entity/weapon_stats
var/list/job_stats_list = list() //! indexed list of types /datum/entity/job_stats
var/datum/entity/weapon_stats/top_weapon //! reference to /datum/entity/weapon_stats (like tac-shotty)
var/list/datum/entity/statistic/medal/medal_list = list() //! list of all medals earned

/datum/entity/player_stats/human/Destroy(force)
. = ..()
QDEL_LIST_ASSOC_VAL(weapon_stats_list)
QDEL_LIST_ASSOC_VAL(job_stats_list)
QDEL_NULL(top_weapon)
QDEL_LIST(medal_list)

/datum/entity/player_stats/human/get_playtime(type)
if(!type)
Expand Down
14 changes: 7 additions & 7 deletions code/datums/statistics/entities/job_stats.dm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/datum/entity/player_stats/job
var/name = null
var/total_friendly_fire = null
var/total_revives = null
var/total_lives_saved = null
var/total_shots = null
var/total_shots_hit = null
var/total_screams = null
var/name
var/total_friendly_fire
var/total_revives
var/total_lives_saved
var/total_shots
var/total_shots_hit
var/total_screams
2 changes: 1 addition & 1 deletion code/datums/statistics/entities/panel_stats.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
update_panel_data(round_statistics)
ui_interact(user)

/datum/entity/player_entity/proc/ui_interact(mob/user, ui_key = "statistics", datum/nanoui/ui = null, force_open = 1)
/datum/entity/player_entity/proc/ui_interact(mob/user, ui_key = "statistics", datum/nanoui/ui, force_open = 1)
data["menu"] = menu
data["subMenu"] = subMenu
data["dataMenu"] = dataMenu
Expand Down
9 changes: 7 additions & 2 deletions code/datums/statistics/entities/player_entity.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
/datum/entity/player_entity
var/name
var/ckey // "cakey"
var/list/datum/entity/player_stats = list()
var/list/datum/entity/statistic/death/death_stats = list()
var/list/player_stats = list() //! Indeed list of /datum/entity/player_stats
var/list/death_stats = list() //! Indexed list of /datum/entity/statistic/death
var/menu = 0
var/subMenu = 0
var/dataMenu = 0
Expand All @@ -18,6 +18,11 @@
var/savefile_version
var/save_loaded = FALSE

/datum/entity/player_entity/Destroy(force)
QDEL_LIST_ASSOC_VAL(player_stats)
QDEL_LIST_ASSOC_VAL(death_stats)
return ..()

/datum/entity/player_entity/proc/get_playtime(branch, type)
var/playtime = 0
if(player_stats["[branch]"])
Expand Down
10 changes: 9 additions & 1 deletion code/datums/statistics/entities/player_stats.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@
var/total_rounds_played = 0
var/steps_walked = 0
var/round_played = FALSE
var/datum/entity/statistic/nemesis = null // "runner" = 3
var/datum/entity/statistic/nemesis // "runner" = 3
var/list/niche_stats = list() // list of type /datum/entity/statistic, "Total Executions" = number
var/list/humans_killed = list() // list of type /datum/entity/statistic, "jobname2" = number
var/list/xenos_killed = list() // list of type /datum/entity/statistic, "caste" = number
var/list/death_list = list() // list of type /datum/entity/death_stats
var/display_stat = TRUE

/datum/entity/player_stats/Destroy(force)
QDEL_NULL(nemesis)
QDEL_LIST_ASSOC_VAL(niche_stats)
QDEL_LIST_ASSOC_VAL(humans_killed)
QDEL_LIST_ASSOC_VAL(xenos_killed)
QDEL_LIST_ASSOC_VAL(death_list)
return ..()

/datum/entity/player_stats/proc/get_playtime()
return total_playtime

Expand Down
18 changes: 15 additions & 3 deletions code/datums/statistics/entities/round_stats.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var/total_slashes = 0

// untracked data
var/datum/entity/statistic/map/current_map = null // reference to current map
var/datum/entity/statistic/map/current_map // reference to current map
var/list/datum/entity/statistic/death/death_stats_list = list()

var/list/abilities_used = list() // types of /datum/entity/statistic, "tail sweep" = 10, "screech" = 2
Expand All @@ -37,8 +37,20 @@
var/list/job_stats_list = list() // list of types /datum/entity/job_stats

// nanoui data
var/round_data[0]
var/death_data[0]
var/list/round_data = list()
var/list/death_data = list()

/datum/entity/statistic/round/Destroy(force)
. = ..()
QDEL_NULL(current_map)
QDEL_LIST(death_stats_list)
QDEL_LIST_ASSOC_VAL(abilities_used)
QDEL_LIST_ASSOC_VAL(final_participants)
QDEL_LIST_ASSOC_VAL(hijack_participants)
QDEL_LIST_ASSOC_VAL(total_deaths)
QDEL_LIST_ASSOC_VAL(caste_stats_list)
QDEL_LIST_ASSOC_VAL(weapon_stats_list)
QDEL_LIST_ASSOC_VAL(job_stats_list)

/datum/entity_meta/statistic_round
entity_type = /datum/entity/statistic/round
Expand Down
25 changes: 16 additions & 9 deletions code/datums/statistics/entities/weapon_stats.dm
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
/datum/entity/weapon_stats
var/datum/entity/player = null // "deanthelis"
var/list/niche_stats = list() // list of type /datum/entity/statistic, "Total Reloads" = number
var/list/humans_killed = list() // list of type /datum/entity/statistic, "jobname2" = number
var/list/xenos_killed = list() // list of type /datum/entity/statistic, "caste" = number
var/name = null
var/datum/entity/player
var/list/niche_stats = list() //! Indexed list of /datum/entity/statistic, "Total Reloads" = number
var/list/humans_killed = list() //! Indexed list of /datum/entity/statistic, "jobname2" = number
var/list/xenos_killed = list() //! Indexed list of /datum/entity/statistic, "caste" = number
var/name
var/total_kills = 0
var/total_hits = null
var/total_shots = null
var/total_shots_hit = null
var/total_friendly_fire = null
var/total_hits
var/total_shots
var/total_shots_hit
var/total_friendly_fire
var/display_stat = TRUE

/datum/entity/weapon_stats/Destroy(force)
player = null
QDEL_LIST_ASSOC_VAL(niche_stats)
QDEL_LIST_ASSOC_VAL(humans_killed)
QDEL_LIST_ASSOC_VAL(xenos_killed)
return ..()

/datum/entity/weapon_stats/proc/count_human_kill(job_name)
if(!job_name)
return
Expand Down
6 changes: 6 additions & 0 deletions code/datums/statistics/entities/xeno_stats.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
var/list/caste_stats_list = list() // list of types /datum/entity/player_stats/caste
var/list/datum/entity/statistic/medal/medal_list = list() // list of all royal jelly earned

/datum/entity/player_stats/xeno/Destroy(force)
. = ..()
QDEL_NULL(top_caste)
QDEL_LIST_ASSOC_VAL(caste_stats_list)
QDEL_LIST(medal_list)

/datum/entity/player_stats/xeno/get_playtime(type)
if(!type || type == FACTION_XENOMORPH)
return ..()
Expand Down