From 83c58f3073895cead5acc544f983d9f8617800fc Mon Sep 17 00:00:00 2001 From: Helg2 Date: Wed, 23 Oct 2024 13:44:44 +0300 Subject: [PATCH] optimize some random stuff --- code/controllers/subsystem/atoms.dm | 24 ++--- code/controllers/subsystem/mapping.dm | 29 +++--- .../objects/items/reagent_containers/pill.dm | 5 +- code/game/objects/items/storage/firstaid.dm | 97 +++++++------------ .../crates_lockers/closets/secure/medical.dm | 1 - code/game/turfs/turf.dm | 4 +- code/modules/lighting/lighting_turf.dm | 10 +- 7 files changed, 76 insertions(+), 94 deletions(-) diff --git a/code/controllers/subsystem/atoms.dm b/code/controllers/subsystem/atoms.dm index efdaab4d38e..6b0b114555b 100644 --- a/code/controllers/subsystem/atoms.dm +++ b/code/controllers/subsystem/atoms.dm @@ -89,20 +89,22 @@ SUBSYSTEM_DEF(atoms) count = length(atoms) for(var/I in 1 to count) var/atom/A = atoms[I] - if(!(A.flags_atom & INITIALIZED)) - CHECK_TICK - PROFILE_INIT_ATOM_BEGIN() - InitAtom(A, TRUE, mapload_arg) - PROFILE_INIT_ATOM_END(A) + if(A.flags_atom & INITIALIZED) + continue + CHECK_TICK + PROFILE_INIT_ATOM_BEGIN() + InitAtom(A, TRUE, mapload_arg) + PROFILE_INIT_ATOM_END(A) else count = 0 for(var/atom/A in world) - if(!(A.flags_atom & INITIALIZED)) - PROFILE_INIT_ATOM_BEGIN() - InitAtom(A, FALSE, mapload_arg) - PROFILE_INIT_ATOM_END(A) - ++count - CHECK_TICK + if(A.flags_atom & INITIALIZED) + continue + PROFILE_INIT_ATOM_BEGIN() + InitAtom(A, FALSE, mapload_arg) + PROFILE_INIT_ATOM_END(A) + ++count + CHECK_TICK testing("Initialized [count] atoms") pass(count) diff --git a/code/controllers/subsystem/mapping.dm b/code/controllers/subsystem/mapping.dm index 06568d24082..a6b95ecbe88 100644 --- a/code/controllers/subsystem/mapping.dm +++ b/code/controllers/subsystem/mapping.dm @@ -41,11 +41,12 @@ SUBSYSTEM_DEF(mapping) //dlete dis once #39770 is resolved /datum/controller/subsystem/mapping/proc/HACK_LoadMapConfig() - if(!configs) - configs = load_map_configs(ALL_MAPTYPES, error_if_missing = FALSE) - for(var/i in GLOB.clients) - var/client/C = i - winset(C, null, "mainwindow.title='[CONFIG_GET(string/title)] - [SSmapping.configs[SHIP_MAP].map_name]'") + if(configs) + return + configs = load_map_configs(ALL_MAPTYPES, error_if_missing = FALSE) + for(var/i in GLOB.clients) + var/client/C = i + winset(C, null, "mainwindow.title='[CONFIG_GET(string/title)] - [SSmapping.configs[SHIP_MAP].map_name]'") /datum/controller/subsystem/mapping/Initialize() HACK_LoadMapConfig() @@ -54,17 +55,19 @@ SUBSYSTEM_DEF(mapping) for(var/i in ALL_MAPTYPES) var/datum/map_config/MC = configs[i] - if(MC.defaulted) - var/old_config = configs[i] - configs[i] = global.config.defaultmaps[i] - if(!configs || configs[i].defaulted) - to_chat(world, span_boldannounce("Unable to load next or default map config, defaulting.")) - configs[i] = old_config + if(!MC.defaulted) + continue + var/old_config = configs[i] + configs[i] = global.config.defaultmaps[i] + if(!configs || configs[i].defaulted) + to_chat(world, span_boldannounce("Unable to load next or default map config, defaulting.")) + configs[i] = old_config if(configs[GROUND_MAP]) for(var/datum/game_mode/M AS in config.votable_modes) - if(!(M.config_tag in configs[GROUND_MAP].gamemodes)) - config.votable_modes -= M // remove invalid modes + if(M.config_tag in configs[GROUND_MAP].gamemodes) + continue + config.votable_modes -= M // remove invalid modes loadWorld() repopulate_sorted_areas() diff --git a/code/game/objects/items/reagent_containers/pill.dm b/code/game/objects/items/reagent_containers/pill.dm index c9ec3fa405d..1f82d994d15 100644 --- a/code/game/objects/items/reagent_containers/pill.dm +++ b/code/game/objects/items/reagent_containers/pill.dm @@ -14,8 +14,9 @@ /obj/item/reagent_containers/pill/Initialize(mapload) . = ..() - if(icon_state == "pill1") - icon_state = pill_id ? GLOB.randomized_pill_icons[pill_id] : pick(GLOB.randomized_pill_icons) + if(icon_state != "pill1") + return + icon_state = pill_id ? GLOB.randomized_pill_icons[pill_id] : pick(GLOB.randomized_pill_icons) /obj/item/reagent_containers/pill/attack_self(mob/user) . = ..() diff --git a/code/game/objects/items/storage/firstaid.dm b/code/game/objects/items/storage/firstaid.dm index bd6d20a34dc..18916cef271 100644 --- a/code/game/objects/items/storage/firstaid.dm +++ b/code/game/objects/items/storage/firstaid.dm @@ -16,6 +16,7 @@ slot_r_hand_str = 'icons/mob/inhands/equipment/medkits_right.dmi', ) icon_state = "firstaid" + base_icon_state = "firstaid" use_sound = 'sound/effects/toolbox.ogg' w_class = WEIGHT_CLASS_BULKY throw_speed = 2 @@ -25,38 +26,28 @@ /obj/item/explosive/grenade, ) var/empty = FALSE //whether the kit starts empty - var/icon_full //icon state to use when kit is full - -/obj/item/storage/firstaid/Initialize(mapload, ...) - . = ..() - icon_full = icon_state - if(empty) - icon_state = icon_state += "_empty" - else - fill_firstaid_kit() - /obj/item/storage/firstaid/update_icon_state() . = ..() if(!length(contents)) icon_state = icon_state += "_empty" else - icon_state = icon_full - - -//to fill medkits with stuff when spawned -/obj/item/storage/firstaid/proc/fill_firstaid_kit() - return + icon_state = base_icon_state +/obj/item/storage/firstaid/PopulateContents() + if(empty) + return + new /obj/item/healthanalyzer(src) /obj/item/storage/firstaid/fire name = "fire first-aid kit" desc = "It's an emergency medical kit for when the toxins lab -spontaneously- burns down." icon_state = "firefirstaid" + base_icon_state = "firefirstaid" item_state = "firefirstaid" -/obj/item/storage/firstaid/fire/fill_firstaid_kit() - new /obj/item/healthanalyzer(src) +/obj/item/storage/firstaid/fire/PopulateContents() + . = ..() new /obj/item/storage/pill_bottle/kelotane(src) new /obj/item/storage/pill_bottle/tramadol(src) new /obj/item/stack/medical/heal_pack/advanced/burn_pack(src) @@ -64,13 +55,13 @@ new /obj/item/storage/pill_bottle/packet/leporazine(src) new /obj/item/storage/syringe_case/burn(src) - /obj/item/storage/firstaid/regular icon_state = "firstaid" + base_icon_state = "firstaid" item_state = "firstaid" -/obj/item/storage/firstaid/regular/fill_firstaid_kit() - new /obj/item/healthanalyzer(src) +/obj/item/storage/firstaid/regular/PopulateContents() + . = ..() new /obj/item/stack/medical/heal_pack/gauze(src) new /obj/item/stack/medical/heal_pack/ointment(src) new /obj/item/reagent_containers/hypospray/autoinjector/combat(src) @@ -78,30 +69,29 @@ new /obj/item/reagent_containers/hypospray/autoinjector/tramadol(src) new /obj/item/stack/medical/splint(src) - /obj/item/storage/firstaid/toxin name = "toxin first aid" desc = "Used to treat when you have a high amount of toxins in your body." icon_state = "antitoxfirstaid" + base_icon_state = "antitoxfirstaid" item_state = "antitoxfirstaid" -/obj/item/storage/firstaid/toxin/fill_firstaid_kit() - new /obj/item/healthanalyzer(src) +/obj/item/storage/firstaid/toxin/PopulateContents() + . = ..() new /obj/item/storage/pill_bottle/dylovene(src) -// new /obj/item/storage/pill_bottle/packet/ryetalyn(src) new /obj/item/reagent_containers/hypospray/autoinjector/hypervene(src) new /obj/item/reagent_containers/hypospray/autoinjector/hypervene(src) new /obj/item/storage/syringe_case/tox(src) - /obj/item/storage/firstaid/o2 name = "oxygen deprivation first aid" desc = "A box full of oxygen goodies." icon_state = "o2firstaid" + base_icon_state = "o2firstaid" item_state = "o2firstaid" -/obj/item/storage/firstaid/o2/fill_firstaid_kit() - new /obj/item/healthanalyzer(src) +/obj/item/storage/firstaid/o2/PopulateContents() + . = ..() new /obj/item/storage/pill_bottle/dexalin(src) new /obj/item/storage/pill_bottle/inaprovaline(src) new /obj/item/reagent_containers/hypospray/autoinjector/dexalinplus(src) @@ -109,15 +99,15 @@ new /obj/item/reagent_containers/hypospray/autoinjector/dexalinplus(src) new /obj/item/storage/syringe_case/oxy(src) - /obj/item/storage/firstaid/adv name = "advanced first-aid kit" desc = "Contains advanced medical treatments." icon_state = "advfirstaid" + base_icon_state = "advfirstaid" item_state = "advfirstaid" -/obj/item/storage/firstaid/adv/fill_firstaid_kit() - new /obj/item/healthanalyzer(src) +/obj/item/storage/firstaid/adv/PopulateContents() + . = ..() new /obj/item/stack/medical/heal_pack/advanced/bruise_pack(src) new /obj/item/stack/medical/heal_pack/advanced/burn_pack(src) new /obj/item/storage/pill_bottle/bicaridine(src) @@ -125,15 +115,15 @@ new /obj/item/storage/pill_bottle/tramadol(src) new /obj/item/stack/medical/splint(src) - /obj/item/storage/firstaid/rad name = "radiation first-aid kit" desc = "Contains treatment for radiation exposure" icon_state = "purplefirstaid" + base_icon_state = "purplefirstaid" item_state = "purplefirstaid" -/obj/item/storage/firstaid/rad/fill_firstaid_kit() - new /obj/item/healthanalyzer(src) +/obj/item/storage/firstaid/rad/PopulateContents() + . = ..() new /obj/item/storage/pill_bottle/dylovene(src) new /obj/item/reagent_containers/hypospray/autoinjector/combat(src) new /obj/item/reagent_containers/hypospray/autoinjector/tricordrazine(src) @@ -141,7 +131,6 @@ new /obj/item/reagent_containers/hypospray/autoinjector/bicaridine(src) new /obj/item/reagent_containers/hypospray/autoinjector/bicaridine(src) - /* * Syringe Case */ @@ -159,9 +148,11 @@ /obj/item/reagent_containers/syringe, ) -/obj/item/storage/syringe_case/empty/Initialize(mapload, ...) - . = ..() +/obj/item/storage/syringe_case/PopulateContents() new /obj/item/reagent_containers/syringe(src) + +/obj/item/storage/syringe_case/empty/PopulateContents() + . = ..() new /obj/item/reagent_containers/glass/bottle/empty(src) new /obj/item/reagent_containers/glass/bottle/empty(src) @@ -171,7 +162,6 @@ /obj/item/storage/syringe_case/regular/PopulateContents() . = ..() - new /obj/item/reagent_containers/syringe(src) new /obj/item/reagent_containers/glass/bottle/inaprovaline(src) new /obj/item/reagent_containers/glass/bottle/tricordrazine(src) @@ -181,7 +171,6 @@ /obj/item/storage/syringe_case/burn/PopulateContents() . = ..() - new /obj/item/reagent_containers/syringe(src) new /obj/item/reagent_containers/glass/bottle/kelotane(src) new /obj/item/reagent_containers/glass/bottle/oxycodone(src) @@ -191,7 +180,6 @@ /obj/item/storage/syringe_case/tox/PopulateContents() . = ..() - new /obj/item/reagent_containers/syringe(src) new /obj/item/reagent_containers/glass/bottle/dylovene(src) new /obj/item/reagent_containers/glass/bottle/hypervene(src) @@ -201,7 +189,6 @@ /obj/item/storage/syringe_case/oxy/PopulateContents() . = ..() - new /obj/item/reagent_containers/syringe(src) new /obj/item/reagent_containers/glass/bottle/inaprovaline(src) new /obj/item/reagent_containers/glass/bottle/dexalin(src) @@ -211,7 +198,6 @@ /obj/item/storage/syringe_case/meralyne/PopulateContents() . = ..() - new /obj/item/reagent_containers/syringe(src) new /obj/item/reagent_containers/glass/bottle/meralyne(src) new /obj/item/reagent_containers/glass/bottle/meralyne(src) @@ -221,7 +207,6 @@ /obj/item/storage/syringe_case/dermaline/PopulateContents() . = ..() - new /obj/item/reagent_containers/syringe(src) new /obj/item/reagent_containers/glass/bottle/dermaline(src) new /obj/item/reagent_containers/glass/bottle/dermaline(src) @@ -231,7 +216,6 @@ /obj/item/storage/syringe_case/meraderm/PopulateContents() . = ..() - new /obj/item/reagent_containers/syringe(src) new /obj/item/reagent_containers/glass/bottle/meraderm(src) new /obj/item/reagent_containers/glass/bottle/meraderm(src) @@ -241,7 +225,6 @@ /obj/item/storage/syringe_case/nanoblood/PopulateContents() . = ..() - new /obj/item/reagent_containers/syringe(src) new /obj/item/reagent_containers/glass/bottle/nanoblood(src) new /obj/item/reagent_containers/glass/bottle/nanoblood(src) @@ -251,16 +234,13 @@ /obj/item/storage/syringe_case/tricordrazine/PopulateContents() . = ..() - new /obj/item/reagent_containers/syringe(src) new /obj/item/reagent_containers/glass/bottle/tricordrazine(src) new /obj/item/reagent_containers/glass/bottle/tricordrazine(src) - /* * Pill Bottles */ - /obj/item/storage/pill_bottle name = "pill bottle" desc = "It's an airtight container for storing medication." @@ -284,18 +264,17 @@ max_storage_space = 16 greyscale_config = /datum/greyscale_config/pillbottle greyscale_colors = "#d9cd07#f2cdbb" //default colors + refill_types = list(/obj/item/storage/pill_bottle) + refill_sound = 'sound/items/pills.ogg' var/pill_type_to_fill //type of pill to use to fill in the bottle in New() /// Short description in overlay var/description_overlay = "" - refill_types = list(/obj/item/storage/pill_bottle) - refill_sound = 'sound/items/pills.ogg' -/obj/item/storage/pill_bottle/Initialize(mapload, ...) - . = ..() - if(pill_type_to_fill) - for(var/i in 1 to max_storage_space) - new pill_type_to_fill(src) - update_icon() +/obj/item/storage/pill_bottle/PopulateContents() + if(!pill_type_to_fill) + return + for(var/i in 1 to max_storage_space) + new pill_type_to_fill(src) /obj/item/storage/pill_bottle/attackby(obj/item/I, mob/user, params) if(istype(I, /obj/item/reagent_containers/hypospray)) @@ -613,9 +592,7 @@ ) var/is_open = FALSE -/obj/item/storage/ai2/Initialize(mapload, ...) - . = ..() - +/obj/item/storage/ai2/PopulateContents() new /obj/item/storage/pill_bottle/penal/meralyne(src) new /obj/item/storage/pill_bottle/penal/dermaline(src) new /obj/item/storage/pill_bottle/penal/hyronalin(src) @@ -625,8 +602,6 @@ new /obj/item/reagent_containers/hypospray/autoinjector/pen/inaprovaline(src) new /obj/item/reagent_containers/hypospray/autoinjector/pen/hypervene(src) - update_icon() - /obj/item/storage/ai2/update_icon_state() cut_overlays() diff --git a/code/game/objects/structures/crates_lockers/closets/secure/medical.dm b/code/game/objects/structures/crates_lockers/closets/secure/medical.dm index 07777c888d3..580a09e09b8 100644 --- a/code/game/objects/structures/crates_lockers/closets/secure/medical.dm +++ b/code/game/objects/structures/crates_lockers/closets/secure/medical.dm @@ -59,7 +59,6 @@ icon_off = "secure_closed_medical_white" /obj/structure/closet/secure_closet/medical3/PopulateContents() - . = ..() new /obj/item/clothing/glasses/hud/health(src) new /obj/item/storage/belt/lifesaver/full(src) new /obj/item/storage/backpack/marine/satchel(src) diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index ba783d10d62..d5c5f485530 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -108,7 +108,7 @@ stack_trace("Incorrect turf deletion") changing_turf = FALSE if(force) - ..() + . = ..() //this will completely wipe turf state var/turf/B = new world.turf(src) for(var/A in B.contents) @@ -120,7 +120,7 @@ DISABLE_BITFIELD(flags_atom, INITIALIZED) soft_armor = null hard_armor = null - ..() + . = ..() return QDEL_HINT_IWILLGC /// WARNING WARNING diff --git a/code/modules/lighting/lighting_turf.dm b/code/modules/lighting/lighting_turf.dm index 71107ca43df..0b610d8aedd 100644 --- a/code/modules/lighting/lighting_turf.dm +++ b/code/modules/lighting/lighting_turf.dm @@ -8,10 +8,12 @@ var/tmp/list/atom/movable/lighting_mask/hybrid_lights_affecting /turf/Destroy(force) - if(hybrid_lights_affecting) - for(var/atom/movable/lighting_mask/mask AS in hybrid_lights_affecting) - LAZYREMOVE(mask.affecting_turfs, src) - hybrid_lights_affecting.Cut() + if(!hybrid_lights_affecting) + return ..() + + for(var/atom/movable/lighting_mask/mask AS in hybrid_lights_affecting) + LAZYREMOVE(mask.affecting_turfs, src) + hybrid_lights_affecting.Cut() return ..() /// Causes any affecting light sources to be queued for a visibility update, for example a door got opened.