diff --git a/code/__HELPERS/_lists.dm b/code/__HELPERS/_lists.dm index 557e6198750..49be273325a 100644 --- a/code/__HELPERS/_lists.dm +++ b/code/__HELPERS/_lists.dm @@ -126,45 +126,45 @@ /proc/typecache_filter_list_reverse(list/atoms, list/typecache) RETURN_TYPE(/list) . = list() - for(var/thing in atoms) - var/atom/A = thing - if(!typecache[A.type]) - . += A + for(var/atom/atom as anything in atoms) + if(!typecache[atom.type]) + . += atom /proc/typecache_filter_multi_list_exclusion(list/atoms, list/typecache_include, list/typecache_exclude) . = list() - for(var/thing in atoms) - var/atom/A = thing - if(typecache_include[A.type] && !typecache_exclude[A.type]) - . += A + for(var/atom/atom as anything in atoms) + if(typecache_include[atom.type] && !typecache_exclude[atom.type]) + . += atom -//Like typesof() or subtypesof(), but returns a typecache instead of a list +///Like typesof() or subtypesof(), but returns a typecache instead of a list /proc/typecacheof(path, ignore_root_path, only_root_path = FALSE) if(ispath(path)) - var/list/types = list() + var/list/types + var/list/output = list() if(only_root_path) - types = list(path) + output[path] = TRUE else types = ignore_root_path ? subtypesof(path) : typesof(path) - var/list/L = list() - for(var/T in types) - L[T] = TRUE - return L + for(var/T in types) + output[T] = TRUE + return output else if(islist(path)) var/list/pathlist = path - var/list/L = list() + var/list/output = list() if(ignore_root_path) - for(var/P in pathlist) - for(var/T in subtypesof(P)) - L[T] = TRUE + for(var/current_path in pathlist) + for(var/subtype in subtypesof(current_path)) + output[subtype] = TRUE + return output + + if(only_root_path) + for(var/current_path in pathlist) + output[current_path] = TRUE else - for(var/P in pathlist) - if(only_root_path) - L[P] = TRUE - else - for(var/T in typesof(P)) - L[T] = TRUE - return L + for(var/current_path in pathlist) + for(var/subpath in typesof(current_path)) + output[subpath] = TRUE + return output //Removes any null entries from the list //Returns TRUE if the list had nulls, FALSE otherwise diff --git a/code/__HELPERS/areas.dm b/code/__HELPERS/areas.dm index 46788ac8807..b8707e95304 100644 --- a/code/__HELPERS/areas.dm +++ b/code/__HELPERS/areas.dm @@ -42,12 +42,12 @@ GLOBAL_LIST_INIT(typecache_powerfailure_safe_areas, typecacheof(/area/engineerin /proc/create_area(mob/creator) // Passed into the above proc as list/break_if_found - var/static/area_or_turf_fail_types = typecacheof(list( + var/static/list/area_or_turf_fail_types = typecacheof(list( /turf/open/space, /area/shuttle, )) // Ignore these areas and dont let people expand them. They can expand into them though - var/static/blacklisted_areas = typecacheof(list( + var/static/list/blacklisted_areas = typecacheof(list( /area/space, )) var/list/turfs = detect_room(get_turf(creator), area_or_turf_fail_types, BP_MAX_ROOM_SIZE*2) diff --git a/code/__HELPERS/roundend.dm b/code/__HELPERS/roundend.dm index 08ba6defe4d..df8fdf83fde 100644 --- a/code/__HELPERS/roundend.dm +++ b/code/__HELPERS/roundend.dm @@ -495,7 +495,7 @@ var/station_vault = 0 ///How many players joined the round. var/total_players = GLOB.joined_player_list.len - var/list/typecache_bank = typecacheof(list(/datum/bank_account/department, /datum/bank_account/remote)) + var/static/list/typecache_bank = typecacheof(list(/datum/bank_account/department, /datum/bank_account/remote)) for(var/i in SSeconomy.bank_accounts_by_id) var/datum/bank_account/current_acc = SSeconomy.bank_accounts_by_id[i] if(typecache_bank[current_acc.type]) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index c2cdab2dfff..812820287f0 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -511,15 +511,13 @@ Turf and target are separate in case you want to teleport some distance from a t var/list/areas = list() if(subtypes) var/list/cache = typecacheof(areatype) - for(var/V in GLOB.sortedAreas) - var/area/A = V - if(cache[A.type]) - areas += V + for(var/area/area_to_check as anything in GLOB.sortedAreas) + if(cache[area_to_check.type]) + areas += area_to_check else - for(var/V in GLOB.sortedAreas) - var/area/A = V - if(A.type == areatype) - areas += V + for(var/area/area_to_check as anything in GLOB.sortedAreas) + if(area_to_check.type == areatype) + areas += area_to_check return areas //Takes: Area type as text string or as typepath OR an instance of the area. @@ -536,21 +534,19 @@ Turf and target are separate in case you want to teleport some distance from a t var/list/turfs = list() if(subtypes) var/list/cache = typecacheof(areatype) - for(var/V in GLOB.sortedAreas) - var/area/A = V - if(!cache[A.type]) + for(var/area/area_to_check as anything in GLOB.sortedAreas) + if(!cache[area_to_check.type]) continue - for(var/turf/T in A) - if(target_z == 0 || target_z == T.z) - turfs += T + for(var/turf/turf_in_area in area_to_check) + if(target_z == 0 || target_z == turf_in_area.z) + turfs += turf_in_area else - for(var/V in GLOB.sortedAreas) - var/area/A = V - if(A.type != areatype) + for(var/area/area_to_check as anything in GLOB.sortedAreas) + if(area_to_check.type != areatype) continue - for(var/turf/T in A) - if(target_z == 0 || target_z == T.z) - turfs += T + for(var/turf/turf_in_area in area_to_check) + if(target_z == 0 || target_z == turf_in_area.z) + turfs += turf_in_area return turfs /proc/get_cardinal_dir(atom/A, atom/B) diff --git a/code/controllers/subsystem/mapping.dm b/code/controllers/subsystem/mapping.dm index 5d7f699d58e..e43f1da1c03 100644 --- a/code/controllers/subsystem/mapping.dm +++ b/code/controllers/subsystem/mapping.dm @@ -298,7 +298,7 @@ Used by the AI doomsday and the self-destruct nuke. GLOBAL_LIST_EMPTY(the_station_areas) /datum/controller/subsystem/mapping/proc/generate_station_area_list() - var/list/station_areas_blacklist = typecacheof(list(/area/space, /area/mine, /area/ruin, /area/asteroid/nearstation)) + var/static/list/station_areas_blacklist = typecacheof(list(/area/space, /area/mine, /area/ruin, /area/asteroid/nearstation)) for(var/area/A in world) if (is_type_in_typecache(A, station_areas_blacklist)) continue diff --git a/code/datums/mutations/holy_mutation/honorbound.dm b/code/datums/mutations/holy_mutation/honorbound.dm index 3785d2c3287..fc72db7748c 100644 --- a/code/datums/mutations/holy_mutation/honorbound.dm +++ b/code/datums/mutations/holy_mutation/honorbound.dm @@ -143,7 +143,7 @@ /datum/mutation/human/honorbound/proc/bullet_guilt(datum/source, obj/projectile/proj) SIGNAL_HANDLER var/mob/living/shot_honorbound = source - var/guilty_projectiles = typecacheof(list( + var/static/list/guilty_projectiles = typecacheof(list( /obj/projectile/beam, /obj/projectile/bullet, /obj/projectile/magic, diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index 728ce320422..c2ad8d5966f 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -327,7 +327,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that var/list/areas_with_LS = list() var/list/areas_with_intercom = list() var/list/areas_with_camera = list() - var/list/station_areas_blacklist = typecacheof(list(/area/holodeck/rec_center, /area/shuttle, /area/engineering/supermatter, /area/science/test_area, /area/space, /area/solars, /area/mine, /area/ruin, /area/asteroid)) + var/static/list/station_areas_blacklist = typecacheof(list(/area/holodeck/rec_center, /area/shuttle, /area/engineering/supermatter, /area/science/test_area, /area/space, /area/solars, /area/mine, /area/ruin, /area/asteroid)) if(SSticker.current_state == GAME_STATE_STARTUP) to_chat(usr, "Game still loading, please hold!", confidential = TRUE) diff --git a/code/modules/capture_the_flag/capture_the_flag.dm b/code/modules/capture_the_flag/capture_the_flag.dm index 3af149df6bd..9bd0ad23eba 100644 --- a/code/modules/capture_the_flag/capture_the_flag.dm +++ b/code/modules/capture_the_flag/capture_the_flag.dm @@ -453,20 +453,20 @@ arena_reset = TRUE /obj/machinery/capture_the_flag/proc/reset_the_arena() - var/area/A = get_area(src) - var/list/ctf_object_typecache = typecacheof(list( + var/area/ctf_area = get_area(src) + var/static/list/ctf_object_typecache = typecacheof(list( /obj/machinery, /obj/effect/ctf, /obj/item/ctf )) - for(var/atm in A) - if (isturf(A) || ismob(A) || isarea(A)) + for(var/atom/movable/area_movable in ctf_area) + if (ismob(area_movable)) continue - if(isstructure(atm)) - var/obj/structure/S = atm - S.repair_damage(S.max_integrity - S.get_integrity()) - else if(!is_type_in_typecache(atm, ctf_object_typecache)) - qdel(atm) + if(isstructure(area_movable)) + var/obj/structure/ctf_structure = area_movable + ctf_structure.repair_damage(ctf_structure.max_integrity - ctf_structure.get_integrity()) + else if(!is_type_in_typecache(area_movable, ctf_object_typecache)) + qdel(area_movable) /obj/machinery/capture_the_flag/proc/stop_ctf() diff --git a/code/modules/events/anomaly.dm b/code/modules/events/anomaly.dm index 5a5da83fe81..8dfd13b7879 100644 --- a/code/modules/events/anomaly.dm +++ b/code/modules/events/anomaly.dm @@ -16,7 +16,7 @@ var/static/list/allowed_areas if(!allowed_areas) //Places that shouldn't explode - var/list/safe_area_types = typecacheof(list( + var/static/list/safe_area_types = typecacheof(list( /area/ai_monitored/turret_protected/ai, /area/ai_monitored/turret_protected/ai_upload, /area/engineering, @@ -28,7 +28,7 @@ ) //Subtypes from the above that actually should explode. - var/list/unsafe_area_subtypes = typecacheof(list(/area/engineering/break_room)) + var/static/list/unsafe_area_subtypes = typecacheof(list(/area/engineering/break_room)) allowed_areas = make_associative(GLOB.the_station_areas) - safe_area_types + unsafe_area_subtypes var/list/possible_areas = typecache_filter_list(GLOB.sortedAreas,allowed_areas) diff --git a/code/modules/events/stray_cargo.dm b/code/modules/events/stray_cargo.dm index c74fd4174e5..cab8e24ee46 100644 --- a/code/modules/events/stray_cargo.dm +++ b/code/modules/events/stray_cargo.dm @@ -67,7 +67,7 @@ var/static/list/allowed_areas if(!allowed_areas) ///Places that shouldn't explode - var/list/safe_area_types = typecacheof(list( + var/static/list/safe_area_types = typecacheof(list( /area/ai_monitored/turret_protected/ai, /area/ai_monitored/turret_protected/ai_upload, /area/engineering, @@ -75,7 +75,7 @@ ) ///Subtypes from the above that actually should explode. - var/list/unsafe_area_subtypes = typecacheof(list(/area/engineering/break_room)) + var/static/list/unsafe_area_subtypes = typecacheof(list(/area/engineering/break_room)) allowed_areas = make_associative(GLOB.the_station_areas) - safe_area_types + unsafe_area_subtypes var/list/possible_areas = typecache_filter_list(GLOB.sortedAreas,allowed_areas) if (length(possible_areas)) diff --git a/code/modules/mining/shelters.dm b/code/modules/mining/shelters.dm index 4d99d296c1f..992d769c63a 100644 --- a/code/modules/mining/shelters.dm +++ b/code/modules/mining/shelters.dm @@ -1,10 +1,10 @@ /datum/map_template/shelter var/shelter_id var/description - var/blacklisted_turfs - var/whitelisted_turfs - var/banned_areas - var/banned_objects + var/list/blacklisted_turfs + var/list/whitelisted_turfs + var/list/banned_areas + var/list/banned_objects /datum/map_template/shelter/New() . = ..() diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index 7261c44b369..ef211c962b8 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -212,8 +212,8 @@ */ var/atom/closest_atom var/closest_type = 0 - var/static/things_to_shock = typecacheof(list(/obj/machinery, /mob/living, /obj/structure, /obj/vehicle/ridden)) - var/static/blacklisted_tesla_types = typecacheof(list(/obj/machinery/atmospherics, + var/static/list/things_to_shock = typecacheof(list(/obj/machinery, /mob/living, /obj/structure, /obj/vehicle/ridden)) + var/static/list/blacklisted_tesla_types = typecacheof(list(/obj/machinery/atmospherics, /obj/machinery/portable_atmospherics, /obj/machinery/power/emitter, /obj/machinery/field/generator, diff --git a/code/modules/research/experimentor.dm b/code/modules/research/experimentor.dm index 9c73111a252..507afd762be 100644 --- a/code/modules/research/experimentor.dm +++ b/code/modules/research/experimentor.dm @@ -35,7 +35,6 @@ var/list/item_reactions = list() var/list/valid_items = list() //valid items for special reactions like transforming var/list/critical_items_typecache //items that can cause critical reactions - var/banned_typecache // items that won't be produced /obj/machinery/rnd/experimentor/proc/ConvertReqString2List(list/source_list) var/list/temp_list = params2list(source_list) @@ -46,7 +45,7 @@ /obj/machinery/rnd/experimentor/proc/SetTypeReactions() // Don't need to keep this typecache around, only used in this proc once. - var/list/banned_typecache = typecacheof(list( + var/static/list/banned_typecache = typecacheof(list( /obj/item/stock_parts/cell/infinite, /obj/item/grenade/chem_grenade/tuberculosis )) diff --git a/code/modules/spells/spell.dm b/code/modules/spells/spell.dm index f80a486b473..2b5c7ce92f1 100644 --- a/code/modules/spells/spell.dm +++ b/code/modules/spells/spell.dm @@ -198,7 +198,7 @@ GLOBAL_LIST_INIT(spells, typesof(/obj/effect/proc_holder/spell)) //needed for th var/mob/living/carbon/human/H = user - var/list/casting_clothes = typecacheof(list(/obj/item/clothing/suit/wizrobe, + var/static/list/casting_clothes = typecacheof(list(/obj/item/clothing/suit/wizrobe, /obj/item/clothing/suit/space/hardsuit/wizard, /obj/item/clothing/head/wizard, /obj/item/clothing/head/helmet/space/hardsuit/wizard, diff --git a/code/modules/spells/spell_types/aimed.dm b/code/modules/spells/spell_types/aimed.dm index fae440b77e7..f40f19b8c60 100644 --- a/code/modules/spells/spell_types/aimed.dm +++ b/code/modules/spells/spell_types/aimed.dm @@ -156,7 +156,7 @@ /obj/effect/proc_holder/spell/aimed/spell_cards/on_activation(mob/M) QDEL_NULL(lockon_component) - lockon_component = M.AddComponent(/datum/component/lockon_aiming, 5, typecacheof(list(/mob/living)), 1, null, CALLBACK(src, .proc/on_lockon_component)) + lockon_component = M.AddComponent(/datum/component/lockon_aiming, 5, GLOB.typecache_living, 1, null, CALLBACK(src, .proc/on_lockon_component)) /obj/effect/proc_holder/spell/aimed/spell_cards/proc/on_lockon_component(list/locked_weakrefs) if(!length(locked_weakrefs))