Skip to content

Commit

Permalink
Fixes Z-Copy breaking stat tabs & Adds in validation for MC stat pane…
Browse files Browse the repository at this point in the history
…ls (#9972)

* Adds in validation for the stat panel

* Fixes the error being wrong if the MC stat tab is wrong

* Corrects the z-copy stat entry
  • Loading branch information
PowerfulBacon authored Oct 7, 2023
1 parent 89d7b6d commit 0f1f301
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
2 changes: 1 addition & 1 deletion code/controllers/subsystem/zcopy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ SUBSYSTEM_DEF(zcopy)
"\tT: { T: [openspace_turfs] O: [openspace_overlays] } Sk: { T: [multiqueue_skips_turf] O: [multiqueue_skips_object] }",
"\tF: { H: [fixup_hit] M: [fixup_miss] N: [fixup_noop] FC: [fixup_cache.len] FKG: [fixup_known_good.len] }", // Fixup stats.
)
return ..() + entries.Join("\n")
return ..(entries.Join("\n"))

// 1, 2, 3..=7, 8
/datum/controller/subsystem/zcopy/proc/build_zstack_display()
Expand Down
1 change: 1 addition & 0 deletions code/modules/unit_tests/_unit_tests.dm
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
#include "ntnetwork_tests.dm"
#include "preference_species.dm"
#include "projectiles.dm"
#include "stat_mc.dm"
#include "subsystem_init.dm"
#include "subsystem_metric_sanity.dm"
#include "surgery_linking.dm"
Expand Down
58 changes: 58 additions & 0 deletions code/modules/unit_tests/stat_mc.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/datum/unit_test/stat_mc_validation/Run()
var/list/failures = list()
main_loop:
for (var/datum/controller/subsystem/ss in Master.subsystems)
var/list/result = ss.stat_entry()
// Accepted
if (isnull(result))
continue
// Rejected for not returning a list
if (!islist(result))
failures += "The subsystem [ss.name] has an invalid stat_entry proc, it did not return a list."
continue
// The list should be associative and contain stat types
for (var/key in result)
var/list/value = result[key]
if (!islist(value))
failures += "The subsystem [ss.name] has an invalid stat_entry proc, it does not properly use the new system of stat panel component types."
continue main_loop
var/comp_type = value["type"]
if (!comp_type)
failures += "The subsystem [ss.name] has an invalid stat_entry proc, it does not properly use the new system of stat panel component types."
continue main_loop
switch (comp_type)
if (STAT_TEXT)
var/text = value["text"]
if (isnull(text))
failures += "The subsystem [ss.name] has an invalid stat_entry proc, it contains a text component with no text parameter."
continue main_loop
continue
if (STAT_BUTTON)
var/text = value["text"]
var/action = value["action"]
if (isnull(text) || isnull(action))
failures += "The subsystem [ss.name] has an invalid stat_entry proc, it has a button which has either no text, or no action."
continue main_loop
continue
if (STAT_ATOM)
var/text = value["text"]
if (isnull(text))
failures += "The subsystem [ss.name] has an invalid stat_entry proc, it contains an atom component with no text parameter."
continue main_loop
continue
if (STAT_DIVIDER)
continue
if (STAT_VERB)
var/action = value["action"]
if (isnull(action))
failures += "The subsystem [ss.name] has an invalid stat_entry proc, it has a verb which has no action."
continue main_loop
continue
if (STAT_BLANK)
continue
else
failures += "The subsystem [ss.name] has an invalid stat_entry proc, it attempted to display a component with a type that was not recognised."
continue main_loop
if (!length(failures))
return
Fail(jointext(failures, "\n"))

0 comments on commit 0f1f301

Please sign in to comment.