diff --git a/_maps/map_files/PubbyStation/job_changes.dm b/_maps/map_files/PubbyStation/job_changes.dm deleted file mode 100644 index 726601725b..0000000000 --- a/_maps/map_files/PubbyStation/job_changes.dm +++ /dev/null @@ -1,20 +0,0 @@ -#define JOB_MODIFICATION_MAP_NAME "PubbyStation" - -/datum/job/hos/New() - ..() - MAP_JOB_CHECK - access += ACCESS_CREMATORIUM - minimal_access += ACCESS_CREMATORIUM - -/datum/job/warden/New() - ..() - MAP_JOB_CHECK - access += ACCESS_CREMATORIUM - minimal_access += ACCESS_CREMATORIUM - -/datum/job/officer/New() - ..() - MAP_JOB_CHECK - access += ACCESS_CREMATORIUM - minimal_access += ACCESS_CREMATORIUM - diff --git a/_maps/pubbystation.json b/_maps/pubbystation.json index f99cca57c5..acf49b773b 100644 --- a/_maps/pubbystation.json +++ b/_maps/pubbystation.json @@ -7,5 +7,10 @@ "whiteship": "whiteship_pubby", "ferry": "ferry_fancy", "cargo": "cargo_box" - } + }, + "job_access_add": { + "/datum/job/hos": [27], + "/datum/job/officer": [27], + "/datum/job/detective": [27] + } } diff --git a/code/__DEFINES/maps.dm b/code/__DEFINES/maps.dm index c5c2dd58c2..854b6c9dcf 100644 --- a/code/__DEFINES/maps.dm +++ b/code/__DEFINES/maps.dm @@ -20,11 +20,6 @@ Multi-Z stations are supported and multi-Z mining and away missions would require only minor tweaks. */ -// helpers for modifying jobs, used in various job_changes.dm files -#define MAP_JOB_CHECK if(SSmapping.config.map_name != JOB_MODIFICATION_MAP_NAME) { return; } -#define MAP_JOB_CHECK_BASE if(SSmapping.config.map_name != JOB_MODIFICATION_MAP_NAME) { return ..(); } -#define MAP_REMOVE_JOB(jobpath) /datum/job/##jobpath/map_check() { return (SSmapping.config.map_name != JOB_MODIFICATION_MAP_NAME) && ..() } - #define SPACERUIN_MAP_EDGE_PAD 15 // traits diff --git a/code/controllers/subsystem/job.dm b/code/controllers/subsystem/job.dm index 4f59992ace..a81b062d5a 100644 --- a/code/controllers/subsystem/job.dm +++ b/code/controllers/subsystem/job.dm @@ -55,9 +55,10 @@ SUBSYSTEM_DEF(job) continue if(!job.config_check()) continue - if(!job.map_check()) //Even though we initialize before mapping, this is fine because the config is loaded at new + if(!job.map_check(SSmapping.config)) //Even though we initialize before mapping, this is fine because the config is loaded at new testing("Removed [job.type] due to map config"); continue + job.process_map_overrides(SSmapping.config) occupations += job name_occupations[job.title] = job type_occupations[J] = job diff --git a/code/modules/jobs/job_types/_job.dm b/code/modules/jobs/job_types/_job.dm index 0feceaf1a8..b0ac5248c1 100644 --- a/code/modules/jobs/job_types/_job.dm +++ b/code/modules/jobs/job_types/_job.dm @@ -73,6 +73,31 @@ /// Starting skill modifiers. var/list/starting_modifiers +/** + * Checks if we should be created on a certain map + */ +/datum/job/proc/map_check(datum/map_config/C) + return (length(C.job_whitelist)? (type in C.job_whitelist) : !(type in C.job_blacklist)) + +/** + * Processes map specific overrides + */ +/datum/job/proc/process_map_overrides(datum/map_config/C) + if(type in C.job_override_spawn_positions) + spawn_positions = C.job_override_spawn_positions[type] + if(type in C.job_override_total_positions) + total_positions = C.job_override_total_positions[type] + if(type in C.job_access_override) + access = C.job_access_override[type] + minimal_access = access + else + if(type in C.job_access_add) + access += C.job_access_add[type] + minimal_access += C.job_access_add[type] + if(type in C.job_access_remove) + access -= C.job_access_add[type] + minimal_access -= C.job_access_remove[type] + //Only override this proc //H is usually a human unless an /equip override transformed it /datum/job/proc/after_spawn(mob/living/H, mob/M, latejoin = FALSE) @@ -175,9 +200,6 @@ /datum/job/proc/config_check() return TRUE -/datum/job/proc/map_check() - return TRUE - /datum/job/proc/radio_help_message(mob/M) to_chat(M, "Prefix your message with :h to speak on your department's radio. To see other prefixes, look closely at your headset.") diff --git a/code/modules/jobs/map_changes/map_changes.dm b/code/modules/jobs/map_changes/map_changes.dm deleted file mode 100644 index 575075037b..0000000000 --- a/code/modules/jobs/map_changes/map_changes.dm +++ /dev/null @@ -1,4 +0,0 @@ -//this needs to come after the job_types subfolder to keep the correct ordering - -#include "..\..\..\..\_maps\map_files\PubbyStation\job_changes.dm" -#undef JOB_MODIFICATION_MAP_NAME \ No newline at end of file diff --git a/code/modules/mapping/map_config.dm b/code/modules/mapping/map_config.dm index c03ef65f43..d18ca1e1e3 100644 --- a/code/modules/mapping/map_config.dm +++ b/code/modules/mapping/map_config.dm @@ -43,6 +43,21 @@ /// Orientation to load in by default. var/orientation = SOUTH //byond defaults to placing everyting SOUTH. + /// Jobs whitelist - if this is not empty, ONLY these jobs are allowed. Overrides blacklist. + var/list/job_whitelist + /// Jobs blacklist - if this is not empty, jobs in this aren't allowed. + var/list/job_blacklist + /// Job spawn position mod - type = number + var/list/job_override_spawn_positions + /// Job total position mod - type = number + var/list/job_override_total_positions + /// Add these accesses to jobs - type = list() + var/list/job_access_add + /// Remove these accesses from jobs - type = list() + var/list/job_access_remove + /// Override job accesses - type = list() - overrides everything else + var/list/job_access_override + /proc/load_map_config(filename = "data/next_map.json", default_to_box, delete_after, error_if_missing = TRUE) var/datum/map_config/config = new if (default_to_box) @@ -161,6 +176,69 @@ allow_custom_shuttles = json["allow_custom_shuttles"] != FALSE + if("job_whitelist" in json) + job_whitelist = list() + for(var/path in json["job_whitelist"]) + var/type = text2path(path) + if(!path) + log_config("map datum [config_filename] failed to validate path [path] in job overrides.") + continue + job_whitelist += type + + if("job_blacklist" in json) + job_blacklist = list() + for(var/path in json["job_blacklist"]) + var/type = text2path(path) + if(!path) + log_config("map datum [config_filename] failed to validate path [path] in job overrides.") + continue + job_blacklist += type + + if("job_override_spawn_positions" in json) + job_override_spawn_positions = list() + for(var/path in json["job_override_spawn_positions"]) + var/type = text2path(path) + if(!path) + log_config("map datum [config_filename] failed to validate path [path] in job overrides.") + continue + job_override_spawn_positions += type + + if("job_override_total_positions" in json) + job_override_total_positions = list() + for(var/path in json["job_override_total_positions"]) + var/type = text2path(path) + if(!path) + log_config("map datum [config_filename] failed to validate path [path] in job overrides.") + continue + job_override_total_positions += type + + if("job_access_add" in json) + job_access_add = list() + for(var/path in json["job_acces_add"]) + var/type = text2path(path) + if(!path) + log_config("map datum [config_filename] failed to validate path [path] in job overrides.") + continue + job_access_add[type] = json["job_access_add"] + + if("job_access_remove" in json) + job_access_remove = list() + for(var/path in json["job_acces_add"]) + var/type = text2path(path) + if(!path) + log_config("map datum [config_filename] failed to validate path [path] in job overrides.") + continue + job_access_remove[type] = json["job_access_remove"] + + if("job_access_override" in json) + job_access_override = list() + for(var/path in json["job_acces_add"]) + var/type = text2path(path) + if(!path) + log_config("map datum [config_filename] failed to validate path [path] in job overrides.") + continue + job_access_override[type] = json["job_access_override"] + defaulted = FALSE return TRUE #undef CHECK_EXISTS @@ -190,6 +268,13 @@ jsonlist["announcertype"] = announcertype jsonlist["orientation"] = orientation jsonlist["allow_custom_shuttles"] = allow_custom_shuttles + jsonlist["job_whitelist"] = job_whitelist + jsonlist["job_blacklist"] = job_blacklist + jsonlist["job_override_spawn_positions"] = job_override_spawn_positions + jsonlist["job_override_total_positions"] = job_override_total_positions + jsonlist["job_access_add"] = job_access_add + jsonlist["job_access_remove"] = job_access_remove + jsonlist["job_access_override"] = job_access_override if(fexists("data/next_map.json")) fdel("data/next_map.json") var/F = file("data/next_map.json") diff --git a/tgstation.dme b/tgstation.dme index 23f262d7a5..b3541599ff 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -2274,7 +2274,6 @@ #include "code\modules\jobs\job_types\station_engineer.dm" #include "code\modules\jobs\job_types\virologist.dm" #include "code\modules\jobs\job_types\warden.dm" -#include "code\modules\jobs\map_changes\map_changes.dm" #include "code\modules\keybindings\bindings_atom.dm" #include "code\modules\keybindings\bindings_client.dm" #include "code\modules\keybindings\focus.dm"