Skip to content

Commit

Permalink
optimize some random stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Helg2 committed Oct 23, 2024
1 parent 3aa2d66 commit 83c58f3
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 94 deletions.
24 changes: 13 additions & 11 deletions code/controllers/subsystem/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
29 changes: 16 additions & 13 deletions code/controllers/subsystem/mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions code/game/objects/items/reagent_containers/pill.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
. = ..()
Expand Down
97 changes: 36 additions & 61 deletions code/game/objects/items/storage/firstaid.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,123 +26,111 @@
/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 <i>-spontaneously-</i> 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)
new /obj/item/stack/medical/heal_pack/advanced/burn_pack(src)
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)
new /obj/item/reagent_containers/hypospray/autoinjector/tricordrazine(src)
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)
new /obj/item/reagent_containers/hypospray/autoinjector/dexalinplus(src)
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)
new /obj/item/storage/pill_bottle/kelotane(src)
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)
new /obj/item/reagent_containers/hypospray/autoinjector/tricordrazine(src)
new /obj/item/reagent_containers/hypospray/autoinjector/bicaridine(src)
new /obj/item/reagent_containers/hypospray/autoinjector/bicaridine(src)


/*
* Syringe Case
*/
Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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."
Expand All @@ -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))
Expand Down Expand Up @@ -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)
Expand All @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 83c58f3

Please sign in to comment.