Skip to content

Commit

Permalink
[MIRROR] Moves the departmental delivery area check to a unit test so…
Browse files Browse the repository at this point in the history
… it stops spamming logs (#2486) (#3323)

* Moves the departmental delivery area check to a unit test so it stops spamming logs (#83215)

## About The Pull Request

So, thanks to the map not being loaded yet when jobs are initialized,
the logs are needlessly spammed by a check that can never pass.

![image](https://github.com/tgstation/tgstation/assets/49160555/add92847-9d41-49b0-a951-4f40fdfd283f)

Also adds some possible locations to engineering and science

As such, I just moved all this logging stuff and screaming at
mappers/coders into a unit test. I honestly only have very vague
understanding of how these work so someone with more knowledge please
check if I did everything right.

* Moves the departmental delivery area check to a unit test so it stops spamming logs

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: Waterpig <[email protected]>
Co-authored-by: NovaBot13 <[email protected]>
  • Loading branch information
4 people authored May 16, 2024
1 parent 2d54e1e commit d1aa68e
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 11 deletions.
1 change: 1 addition & 0 deletions _maps/gateway_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"load_all_away_missions": true,
"ignored_unit_tests": [
"/datum/unit_test/antag_moodlets",
"/datum/unit_test/cargo_dep_order_locations",
"/datum/unit_test/job_roundstart_spawnpoints",
"/datum/unit_test/required_map_items",
"/datum/unit_test/space_dragon_expiration",
Expand Down
1 change: 1 addition & 0 deletions _maps/multiz_debug.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"map_path": "map_files/debug",
"map_file": "multiz.dmm",
"ignored_unit_tests": [
"/datum/unit_test/cargo_dep_order_locations",
"/datum/unit_test/job_roundstart_spawnpoints",
"/datum/unit_test/required_map_items",
"/datum/unit_test/spy_bounty"
Expand Down
1 change: 1 addition & 0 deletions _maps/runtimestation.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"map_file": "runtimestation.dmm",
"space_ruin_levels": 1,
"ignored_unit_tests": [
"/datum/unit_test/cargo_dep_order_locations",
"/datum/unit_test/job_roundstart_spawnpoints",
"/datum/unit_test/required_map_items",
"/datum/unit_test/spy_bounty"
Expand Down
20 changes: 9 additions & 11 deletions code/modules/jobs/departments/departments.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@
/// A list of generic access flags people in this department generally have.
var/list/department_access = list()

/datum/job_department/New()
. = ..()
for(var/delivery_area_type in department_delivery_areas)
if(GLOB.areas_by_type[delivery_area_type])
return
//every area fallback didn't exist on this map so throw a mapping error and set some generic area that uuuh please exist okay
log_mapping("[type] has no valid areas to deliver to on this map, add some more fallback areas to its \"department_delivery_areas\" var.")
department_delivery_areas = list(/area/station/hallway/primary/central) //if this doesn't exist like honestly fuck your map man

/// Handles adding jobs to the department and setting up the job bitflags.
/datum/job_department/proc/add_job(datum/job/job)
department_jobs += job
Expand Down Expand Up @@ -111,7 +102,10 @@
label_class = "engineering"
ui_color = "#dfb567"
nation_prefixes = list("Atomo", "Engino", "Power", "Teleco")
department_delivery_areas = list(/area/station/engineering/main)
department_delivery_areas = list(
/area/station/engineering/main,
/area/station/engineering/lobby,
)
associated_cargo_groups = list("Engineering", "Engine Construction", "Canisters & Materials")
head_of_staff_access = ACCESS_CE
department_access = REGION_ACCESS_ENGINEERING
Expand Down Expand Up @@ -144,7 +138,11 @@
label_class = "science"
ui_color = "#c973c9"
nation_prefixes = list("Sci", "Griffa", "Geneti", "Explosi", "Mecha", "Xeno", "Nani", "Cyto")
department_delivery_areas = list(/area/station/science/research)
department_delivery_areas = list(
/area/station/science/research,
/area/station/science/lobby,
/area/station/science/lab,
)
associated_cargo_groups = list("Science", "Livestock", "Canisters & Materials")
head_of_staff_access = ACCESS_RD
department_access = REGION_ACCESS_RESEARCH
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 @@ -109,6 +109,7 @@
#include "cable_powernets.dm"
#include "card_mismatch.dm"
#include "cardboard_cutouts.dm"
#include "cargo_dep_order_locations.dm"
#include "cargo_selling.dm"
#include "chain_pull_through_space.dm"
#include "changeling.dm"
Expand Down
18 changes: 18 additions & 0 deletions code/modules/unit_tests/cargo_dep_order_locations.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/datum/unit_test/cargo_dep_order_locations

/datum/unit_test/cargo_dep_order_locations/Run()
for(var/datum/job_department/department as anything in SSjob.joinable_departments)
var/delivery_areas = department.department_delivery_areas
if(!length(delivery_areas))
continue
if(check_valid_delivery_location(delivery_areas))
continue
TEST_FAIL("[department.type] failed to find a valid delivery location on this map.")


/datum/unit_test/cargo_dep_order_locations/proc/check_valid_delivery_location(list/delivery_areas)
for(var/delivery_area_type in delivery_areas)

if(GLOB.areas_by_type[delivery_area_type])
return TRUE
return FALSE

0 comments on commit d1aa68e

Please sign in to comment.