From 1d309ef9665edd2e5f3c5240498c7684bf9b5e2b Mon Sep 17 00:00:00 2001 From: Casper3667 <8396443+Casper3667@users.noreply.github.com> Date: Wed, 2 Feb 2022 16:47:35 +0100 Subject: [PATCH] Fixes the ability to join a job as the wrong faction (#13059) --- .../preference_setup/occupation/occupation.dm | 13 ++++++++++++- html/changelogs/JobFix.yml | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 html/changelogs/JobFix.yml diff --git a/code/modules/client/preference_setup/occupation/occupation.dm b/code/modules/client/preference_setup/occupation/occupation.dm index 4093b45c6aa..59446ae37e5 100644 --- a/code/modules/client/preference_setup/occupation/occupation.dm +++ b/code/modules/client/preference_setup/occupation/occupation.dm @@ -287,15 +287,26 @@ ResetJobs() return TOPIC_REFRESH_UPDATE_PREVIEW + var/datum/species/S = pref.get_species_datum() var/datum/faction/faction = SSjobs.name_factions[pref.faction] - for(var/datum/job/job in faction.get_occupations()) + for(var/datum/job/job in SSjobs.occupations) for(var/department = 1 to NUM_JOB_DEPTS) if(pref.GetJobDepartment(job, department) & job.flag) + if(!(job in faction.get_occupations())) + to_client_chat(SPAN_DANGER("Your faction selection does not permit this job, [job.title] as [pref.faction].")) + to_client_chat(SPAN_DANGER("Your jobs have been reset due to this!")) + ResetJobs() + return TOPIC_REFRESH_UPDATE_PREVIEW if(pref.species in job.blacklisted_species) to_client_chat(SPAN_DANGER("Your faction selection does not permit this species-occupation combination, [pref.species] as [job.title].")) to_client_chat(SPAN_DANGER("Your jobs have been reset due to this!")) ResetJobs() return TOPIC_REFRESH_UPDATE_PREVIEW + if(!is_type_in_typecache(S, faction.allowed_species_types)) + to_client_chat(SPAN_DANGER("Your faction selection does not permit this species, [pref.species] as [pref.faction].")) + to_client_chat(SPAN_DANGER("Your jobs have been reset due to this!")) + ResetJobs() + return TOPIC_REFRESH_UPDATE_PREVIEW /datum/category_item/player_setup_item/occupation/proc/SetPlayerAltTitle(datum/job/job, new_title) // remove existing entry diff --git a/html/changelogs/JobFix.yml b/html/changelogs/JobFix.yml new file mode 100644 index 00000000000..fb512499696 --- /dev/null +++ b/html/changelogs/JobFix.yml @@ -0,0 +1,6 @@ +author: TheGreyWolf + +delete-after: True + +changes: + - bugfix: "The job code now checks if a given job & species preference is permitted for a given faction when loading a character."