mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-11 16:14:08 +01:00
6e9f2ccfc0
# Conflicts: # .github/workflows/compile_all_maps.yml # .github/workflows/run_integration_tests.yml # _maps/map_files/CatwalkStation/CatwalkStation_2023.dmm # code/_onclick/hud/credits.dm # code/controllers/subsystem/networks/id_access.dm # code/datums/diseases/advance/advance.dm # code/datums/diseases/advance/symptoms/heal.dm # code/game/machinery/doors/door.dm # code/game/objects/structures/crates_lockers/closets/secure/medical.dm # code/game/objects/structures/crates_lockers/closets/secure/security.dm # code/modules/antagonists/malf_ai/malf_ai_modules.dm # code/modules/jobs/job_types/_job.dm # code/modules/loadout/categories/accessories.dm # code/modules/loadout/loadout_helpers.dm # code/modules/loadout/loadout_items.dm # code/modules/loadout/loadout_preference.dm # code/modules/mob/living/silicon/robot/robot_defense.dm # code/modules/mod/mod_theme.dm # code/modules/projectiles/ammunition/energy/laser.dm # code/modules/reagents/reagent_containers/cups/drinks.dm # code/modules/shuttle/mobile_port/variants/supply.dm # code/modules/surgery/organs/internal/eyes/_eyes.dm # code/modules/unit_tests/screenshots/screenshot_antag_icons_heretic.png # icons/hud/screen_full.dmi
70 lines
2.9 KiB
Plaintext
70 lines
2.9 KiB
Plaintext
/datum/preference/loadout
|
|
savefile_key = "loadout_list"
|
|
savefile_identifier = PREFERENCE_CHARACTER
|
|
priority = PREFERENCE_PRIORITY_LOADOUT
|
|
can_randomize = FALSE
|
|
// BUBBER NOTE: This isn't accurate, this is now an assoc list of names to the stuff below. Yeah. - Rimi, the pref code slaughterer
|
|
// Loadout preference is an assoc list [item_path] = [loadout item information list]
|
|
//
|
|
// it may look something like
|
|
// - list(/obj/item/glasses = list())
|
|
// or
|
|
// - list(/obj/item/plush/lizard = list("name" = "Tests-The-Loadout", "color" = "#FF0000"))
|
|
|
|
// Loadouts are applied with job equip code.
|
|
/datum/preference/loadout/apply_to_human(mob/living/carbon/human/target, value)
|
|
return
|
|
|
|
// Sanitize on load to ensure no invalid paths from older saves get in
|
|
/datum/preference/loadout/deserialize(input, datum/preferences/preferences)
|
|
return sanitize_loadout_list(input, preferences.parent?.mob, preferences.parent) // SKYRAT EDIT CHANGE parent
|
|
|
|
// Default value is null - the loadout list is a lazylist
|
|
/datum/preference/loadout/create_default_value(datum/preferences/preferences)
|
|
return null
|
|
|
|
/datum/preference/loadout/is_valid(value)
|
|
return isnull(value) || islist(value)
|
|
|
|
/**
|
|
* Removes all invalid paths from loadout lists.
|
|
* This is a general sanitization for preference loading.
|
|
*
|
|
* Returns a list, or null if empty
|
|
*/
|
|
/datum/preference/loadout/proc/sanitize_loadout_list(list/passed_list, mob/optional_loadout_owner, client/owner_client) as /list // SKYRAT EDIT CHANGE - client/owner_client
|
|
var/list/sanitized_list
|
|
for(var/path in passed_list)
|
|
// Loading from json has each path in the list as a string that we need to convert back to typepath
|
|
var/obj/item/real_path = istext(path) ? text2path(path) : path
|
|
if(!ispath(real_path, /obj/item))
|
|
if(optional_loadout_owner)
|
|
to_chat(optional_loadout_owner, span_boldnotice("The following invalid item path was found \
|
|
in your character loadout: [real_path || "null"]. \
|
|
It has been removed, renamed, or is otherwise missing - \
|
|
You may want to check your loadout settings."))
|
|
continue
|
|
|
|
else if(!istype(GLOB.all_loadout_datums[real_path], /datum/loadout_item))
|
|
if(optional_loadout_owner)
|
|
to_chat(optional_loadout_owner, span_boldnotice("The following invalid loadout item was found \
|
|
in your character loadout: [real_path || "null"]. \
|
|
It has been removed, renamed, or is otherwise missing - \
|
|
You may want to check your loadout settings."))
|
|
continue
|
|
|
|
var/datum/loadout_item/loadout_item = GLOB.all_loadout_datums[real_path]
|
|
if(loadout_item.is_disabled())
|
|
continue // this just falls off silently
|
|
// SKYRAT EDIT ADDITION
|
|
else if(owner_client)
|
|
if(loadout_item?.ckeywhitelist && !(owner_client?.ckey in loadout_item.ckeywhitelist))
|
|
continue
|
|
// SKYRAT EDIT END
|
|
|
|
// Set into sanitize list using converted path key
|
|
var/list/data = passed_list[path]
|
|
LAZYSET(sanitized_list, real_path, LAZYLISTDUPLICATE(data))
|
|
|
|
return sanitized_list
|