Files
FalloutFalconandGitHub 13266d8c55 Job sorting using department order for Jobs (#96835)
## About The Pull Request
Reworks the code for job sorting so that job order is ADDED onto
department order, to create a sorted list that properly mimmics how its
acctually displayed in game (which is the only way its used anyway)
This means we can shift all the display orders to be inner-department,
meaning we can cut down the size of indecies you have to shift to update
a job(if any)

Also adds a unit test to ensure jobs and departments dont overlap orders
to prevent any odd sorting behavoirs
## Why It's Good For The Game
Prevents having to shift a ton of entires every time a job is sorted or
removed.
Creates a more sensible ordering so we dont have stuff like assistant
being 1, prisoner being 40, despite the fact that they are displayed
grouped.

The only playing facing change is the command roles now get sorted how
there departments appear in the order.
<img width="1012" height="658" alt="image"
src="https://github.com/user-attachments/assets/e641cdd1-a9b8-4f32-be19-f133b8c987dd"
/>
Old order for reference (putting the hos higher up makes alot of sense
here tbh)
<img width="268" height="200" alt="image"
src="https://github.com/user-attachments/assets/42737704-8527-4dee-bac2-a09279d3b64e"
/>
## Changelog
🆑
refactor: Job sorting is based on department
/🆑
2026-07-09 16:53:44 +02:00

29 lines
1.4 KiB
Plaintext

/// Tests to ensure each job with a display order has a unique index.
/datum/unit_test/job_display_order
/datum/unit_test/job_display_order/Run()
var/alist/unique_indexes = alist()
// joinable_occupations instead of all_occupations because human_ai and ai have the same index otherwise... Is this a source of flaky fails..? Unsure
for(var/datum/job/job in SSjob.joinable_occupations)
var/jobs_display_order = job.display_order_with_department()
if(!jobs_display_order || !job.display_order)
TEST_FAIL("[job] has no set display order.")
else if(unique_indexes["[jobs_display_order]"])
TEST_FAIL("[job] has the same index as [unique_indexes["[jobs_display_order]"]] of: [jobs_display_order].")
else
unique_indexes["[jobs_display_order]"] = job
/// Tests to ensure each department has a unique index.
/datum/unit_test/department_display_order
/datum/unit_test/department_display_order/Run()
var/alist/unique_indexes = alist()
for(var/datum/job_department/department in SSjob.joinable_departments)
var/departments_display_order = department.display_order
if(!departments_display_order)
TEST_FAIL("[department] has no set display order.")
else if(unique_indexes["[departments_display_order]"])
TEST_FAIL("[department] has the same index as [unique_indexes["[departments_display_order]"]] of: [departments_display_order].")
else
unique_indexes["[departments_display_order]"] = department