From 904751a05603a01a7cf4c259c780c4dec49c5425 Mon Sep 17 00:00:00 2001 From: Drulikar Date: Thu, 30 May 2024 18:15:49 -0700 Subject: [PATCH] Fix names of breaker switches Better futureproof breaker switch blacklisting --- code/__HELPERS/lists.dm | 19 +++++++++++++------ code/game/machinery/bio-dome_floodlights.dm | 4 ++-- code/game/machinery/colony_floodlights.dm | 11 ++++++++--- code/game/machinery/hybrisa_lights.dm | 8 ++++---- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/code/__HELPERS/lists.dm b/code/__HELPERS/lists.dm index a1b38b48f754..02e0f2cf3a8b 100644 --- a/code/__HELPERS/lists.dm +++ b/code/__HELPERS/lists.dm @@ -41,12 +41,19 @@ return list[index] return -//Checks for specific types in a list -/proc/is_type_in_list(atom/A, list/L) - for(var/type in L) - if(istype(A, type)) - return 1 - return 0 +///Checks if the needle atom is any type in the type_list +/proc/is_type_in_list(atom/needle, list/type_list) + for(var/type in type_list) + if(istype(needle, type)) + return TRUE + return FALSE + +///Checks if the needle path derives from any in the path_list +/proc/is_path_in_list(needle, list/path_list) + for(var/path in path_list) + if(ispath(needle, path)) + return TRUE + return FALSE //Removes any null entries from the list /proc/listclearnulls(list/list) diff --git a/code/game/machinery/bio-dome_floodlights.dm b/code/game/machinery/bio-dome_floodlights.dm index c96b2601a93a..1dbc1813bd13 100644 --- a/code/game/machinery/bio-dome_floodlights.dm +++ b/code/game/machinery/bio-dome_floodlights.dm @@ -1,5 +1,5 @@ /obj/structure/machinery/colony_floodlight_switch/hydro_floodlight_switch - name = "Biodome Floodlight Switch" + name = "biodome floodlight switch" icon = 'icons/obj/structures/machinery/power.dmi' icon_state = "panelnopower" desc = "This switch controls the floodlights surrounding the archaeology complex. It only functions when there is power." @@ -14,7 +14,7 @@ icon_state = "paneloff" /obj/structure/machinery/hydro_floodlight // TODO: Repath under /obj/structure/machinery/colony_floodlight - name = "Biodome Floodlight" + name = "biodome floodlight" icon = 'icons/obj/structures/machinery/big_floodlight.dmi' icon_state = "flood_s_off" density = TRUE diff --git a/code/game/machinery/colony_floodlights.dm b/code/game/machinery/colony_floodlights.dm index e62552b2791c..11cc8881a222 100644 --- a/code/game/machinery/colony_floodlights.dm +++ b/code/game/machinery/colony_floodlights.dm @@ -24,9 +24,14 @@ GLOBAL_LIST_INIT(all_breaker_switches, list()) /obj/structure/machinery/colony_floodlight_switch/Initialize(mapload, ...) . = ..() for(var/obj/structure/machinery/colony_floodlight_switch/other_switch as anything in GLOB.all_breaker_switches) - if(!length(other_switch.machinery_type_whitelist)) - continue - machinery_type_blacklist |= other_switch.machinery_type_whitelist + // blacklist anything other switches whitelist if theres subtype overlap + for(var/other_whitelisted in other_switch.machinery_type_whitelist) + if(is_path_in_list(other_whitelisted, machinery_type_whitelist)) + machinery_type_blacklist |= other_whitelisted + for(var/our_whitelisted in machinery_type_whitelist) + if(is_path_in_list(our_whitelisted, other_switch.machinery_type_whitelist)) + other_switch.machinery_type_blacklist |= our_whitelisted + GLOB.all_breaker_switches += src return INITIALIZE_HINT_LATELOAD diff --git a/code/game/machinery/hybrisa_lights.dm b/code/game/machinery/hybrisa_lights.dm index 6208e9e4d46b..1c6a948ec3f2 100644 --- a/code/game/machinery/hybrisa_lights.dm +++ b/code/game/machinery/hybrisa_lights.dm @@ -1,6 +1,6 @@ // Hybrisa Electrical Stuff /obj/structure/machinery/colony_floodlight_switch/electrified_fence_switch - name = "Colony Electrified Fence Switch" + name = "colony electrified fence switch" icon = 'icons/obj/structures/props/hybrisarandomprops.dmi' icon_state = "panelnopower" desc = "This switch controls the electrified fences. It only functions when there is power." @@ -45,7 +45,7 @@ // Hybrisa Streetlights /obj/structure/machinery/colony_floodlight/street - name = "Colony Streetlight" + name = "colony streetlight" icon = 'icons/obj/structures/props/64x64_hybrisarandomprops.dmi' icon_state = "street_off" layer = ABOVE_XENO_LAYER @@ -101,10 +101,10 @@ // Engineer Floor lights /obj/structure/machinery/colony_floodlight_switch/engineerconsole_switch - name = "Giant Alien Console" + name = "giant alien console" icon = 'icons/obj/structures/props/64x64_hybrisarandomprops.dmi' icon_state = "engineerconsole" - desc = "A Giant Alien console of some kind, unlike anything you've ever seen before. Who knows the purpose of this strange technology..." + desc = "A giant alien console of some kind, unlike anything you've ever seen before. Who knows the purpose of this strange technology..." use_power = USE_POWER_NONE needs_power = FALSE ispowered = TRUE