makes a bunch of lists that use typecacheof() static. doesnt find out why its overtiming at all but what the hell it helps (#60147)

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
This commit is contained in:
Kylerace
2021-07-12 14:08:46 -07:00
committed by GitHub
parent 2620fb85ed
commit 5d6e93510f
15 changed files with 70 additions and 75 deletions
+26 -26
View File
@@ -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
+2 -2
View File
@@ -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)
+1 -1
View File
@@ -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])
+16 -20
View File
@@ -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)
+1 -1
View File
@@ -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
@@ -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,
+1 -1
View File
@@ -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)
@@ -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()
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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))
+4 -4
View File
@@ -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()
. = ..()
+2 -2
View File
@@ -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,
+1 -2
View File
@@ -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
))
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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))