From ab3a127295e08c0facd9dd38d52a07d32da60a93 Mon Sep 17 00:00:00 2001 From: Emmett Gaines Date: Mon, 3 Feb 2020 10:17:13 -0500 Subject: [PATCH 1/2] Makes the global materials lookup lazily initialized --- code/__DEFINES/materials.dm | 4 -- code/__DEFINES/subsystems.dm | 1 - code/controllers/subsystem/materials.dm | 18 ++++----- code/datums/components/material_container.dm | 38 +++++++++---------- code/game/atoms.dm | 6 +-- code/game/machinery/autolathe.dm | 2 +- code/game/objects/items/apc_frame.dm | 4 +- code/game/objects/items/stacks/stack.dm | 6 +-- .../objects/structures/beds_chairs/chair.dm | 2 +- code/modules/antagonists/swarmer/swarmer.dm | 2 +- code/modules/cargo/exports/materials.dm | 4 +- .../kitchen_machinery/microwave.dm | 4 +- code/modules/hydroponics/biogenerator.dm | 8 ++-- code/modules/mining/machine_processing.dm | 2 +- code/modules/mining/mint.dm | 2 +- .../mob/living/silicon/robot/robot_modules.dm | 4 +- .../mob/living/simple_animal/hostile/goose.dm | 6 +-- code/modules/research/designs.dm | 4 +- 18 files changed, 56 insertions(+), 61 deletions(-) diff --git a/code/__DEFINES/materials.dm b/code/__DEFINES/materials.dm index 3c4a78ea7a5..601df51d77f 100644 --- a/code/__DEFINES/materials.dm +++ b/code/__DEFINES/materials.dm @@ -4,10 +4,6 @@ /// Hard materials, such as iron or metal #define MAT_CATEGORY_RIGID "rigid material" - -/// Gets the reference for the material type that was given -#define getmaterialref(A) (SSmaterials.materials[A] || A) - /// Flag for atoms, this flag ensures it isn't re-colored by materials. Useful for snowflake icons such as default toolboxes. #define MATERIAL_COLOR (1<<0) #define MATERIAL_ADD_PREFIX (1<<1) diff --git a/code/__DEFINES/subsystems.dm b/code/__DEFINES/subsystems.dm index 7a19c1ba9d2..f4246e19b3c 100644 --- a/code/__DEFINES/subsystems.dm +++ b/code/__DEFINES/subsystems.dm @@ -107,7 +107,6 @@ #define INIT_ORDER_INPUT 85 #define INIT_ORDER_VIS 80 #define INIT_ORDER_ACHIEVEMENTS 77 -#define INIT_ORDER_MATERIALS 76 #define INIT_ORDER_RESEARCH 75 #define INIT_ORDER_EVENTS 70 #define INIT_ORDER_JOBS 65 diff --git a/code/controllers/subsystem/materials.dm b/code/controllers/subsystem/materials.dm index 0dcc5e96997..58b8ec53542 100644 --- a/code/controllers/subsystem/materials.dm +++ b/code/controllers/subsystem/materials.dm @@ -7,12 +7,11 @@ These materials call on_applied() on whatever item they are applied to, common e SUBSYSTEM_DEF(materials) name = "Materials" - flags = SS_NO_FIRE - init_order = INIT_ORDER_MATERIALS + flags = SS_NO_FIRE | SS_NO_INIT ///Dictionary of material.type || material ref - var/list/materials = list() + var/list/materials = list() ///Dictionary of category || list of material refs - var/list/materials_by_category = list() + var/list/materials_by_category = list() ///List of stackcrafting recipes for materials using rigid materials var/list/rigid_stack_recipes = list( new /datum/stack_recipe("chair", /obj/structure/chair/greyscale, one_per_turf = TRUE, on_floor = TRUE, applies_mats = TRUE), @@ -20,14 +19,15 @@ SUBSYSTEM_DEF(materials) new /datum/stack_recipe("sink", /obj/structure/sink/greyscale, one_per_turf = TRUE, on_floor = TRUE, applies_mats = TRUE), ) -/datum/controller/subsystem/materials/Initialize(timeofday) - InitializeMaterials() - return ..() - ///Ran on initialize, populated the materials and materials_by_category dictionaries with their appropiate vars (See these variables for more info) -/datum/controller/subsystem/materials/proc/InitializeMaterials(timeofday) +/datum/controller/subsystem/materials/proc/InitializeMaterials() for(var/type in subtypesof(/datum/material)) var/datum/material/ref = new type materials[type] = ref for(var/c in ref.categories) materials_by_category[c] += list(ref) + +/datum/controller/subsystem/materials/proc/GetMaterialRef(datum/material/fakemat) + if(!materials) + InitializeMaterials() + return materials[fakemat] || fakemat diff --git a/code/datums/components/material_container.dm b/code/datums/components/material_container.dm index 9bf2dc3819e..29931c900ef 100644 --- a/code/datums/components/material_container.dm +++ b/code/datums/components/material_container.dm @@ -42,7 +42,7 @@ RegisterSignal(parent, COMSIG_PARENT_EXAMINE, .proc/OnExamine) for(var/mat in mat_list) //Make the assoc list ref | amount - var/datum/material/M = getmaterialref(mat) || mat + var/datum/material/M = SSmaterials.GetMaterialRef(mat) materials[M] = 0 /datum/component/material_container/proc/OnExamine(datum/source, mob/user) @@ -128,9 +128,9 @@ return primary_mat /// For inserting an amount of material -/datum/component/material_container/proc/insert_amount_mat(amt, var/datum/material/mat) +/datum/component/material_container/proc/insert_amount_mat(amt, var/datum/material/mat) if(!istype(mat)) - mat = getmaterialref(mat) + mat = SSmaterials.GetMaterialRef(mat) if(amt > 0 && has_space(amt)) var/total_amount_saved = total_amount if(mat) @@ -143,9 +143,9 @@ return FALSE /// Uses an amount of a specific material, effectively removing it. -/datum/component/material_container/proc/use_amount_mat(amt, var/datum/material/mat) +/datum/component/material_container/proc/use_amount_mat(amt, var/datum/material/mat) if(!istype(mat)) - mat = getmaterialref(mat) + mat = SSmaterials.GetMaterialRef(mat) var/amount = materials[mat] if(mat) if(amount >= amt) @@ -155,9 +155,9 @@ return FALSE /// Proc for transfering materials to another container. -/datum/component/material_container/proc/transer_amt_to(var/datum/component/material_container/T, amt, var/datum/material/mat) +/datum/component/material_container/proc/transer_amt_to(var/datum/component/material_container/T, amt, var/datum/material/mat) if(!istype(mat)) - mat = getmaterialref(mat) + mat = SSmaterials.GetMaterialRef(mat) if((amt==0)||(!T)||(!mat)) return FALSE if(amt<0) @@ -184,13 +184,13 @@ /datum/component/material_container/proc/use_materials(list/mats, multiplier=1) if(!mats || !length(mats)) return FALSE - + var/list/mats_to_remove = list() //Assoc list MAT | AMOUNT for(var/x in mats) //Loop through all required materials var/datum/material/req_mat = x if(!istype(req_mat)) - req_mat = getmaterialref(req_mat) //Get the ref if necesary + req_mat = SSmaterials.GetMaterialRef(req_mat) //Get the ref if necesary if(!materials[req_mat]) //Do we have the resource? return FALSE //Can't afford it var/amount_required = mats[x] * multiplier @@ -198,7 +198,7 @@ return FALSE //Can't afford it mats_to_remove[req_mat] += amount_required //Add it to the assoc list of things to remove continue - + var/total_amount_save = total_amount for(var/i in mats_to_remove) @@ -207,7 +207,7 @@ return total_amount_save - total_amount /// For spawning mineral sheets at a specific location. Used by machines to output sheets. -/datum/component/material_container/proc/retrieve_sheets(sheet_amt, var/datum/material/M, target = null) +/datum/component/material_container/proc/retrieve_sheets(sheet_amt, var/datum/material/M, target = null) if(!M.sheet_type) return 0 //Add greyscale sheet handling here later if(sheet_amt <= 0) @@ -231,7 +231,7 @@ /// Proc to get all the materials and dump them as sheets -/datum/component/material_container/proc/retrieve_all(target = null) +/datum/component/material_container/proc/retrieve_all(target = null) var/result = 0 for(var/MAT in materials) var/amount = materials[MAT] @@ -251,7 +251,7 @@ var/datum/material/req_mat = x if(!istype(req_mat)) if(ispath(req_mat)) //Is this an actual material, or is it a category? - req_mat = getmaterialref(req_mat) //Get the ref + req_mat = SSmaterials.GetMaterialRef(req_mat) //Get the ref else // Its a category. (For example MAT_CATEGORY_RIGID) if(!has_enough_of_category(req_mat, mats[x], multiplier)) //Do we have enough of this category? @@ -265,7 +265,7 @@ return TRUE /// Returns all the categories in a recipe. -/datum/component/material_container/proc/get_categories(list/mats) +/datum/component/material_container/proc/get_categories(list/mats) var/list/categories = list() for(var/x in mats) //Loop through all required materials if(!istext(x)) //This means its not a category @@ -275,12 +275,12 @@ /// Returns TRUE if you have enough of the specified material. -/datum/component/material_container/proc/has_enough_of_material(var/datum/material/req_mat, amount, multiplier=1) +/datum/component/material_container/proc/has_enough_of_material(var/datum/material/req_mat, amount, multiplier=1) if(!materials[req_mat]) //Do we have the resource? return FALSE //Can't afford it var/amount_required = amount * multiplier if(materials[req_mat] >= amount_required) // do we have enough of the resource? - return TRUE + return TRUE return FALSE //Can't afford it /// Returns TRUE if you have enough of a specified material category (Which could be multiple materials) @@ -292,7 +292,7 @@ return FALSE /// Turns a material amount into the amount of sheets it should output -/datum/component/material_container/proc/amount2sheet(amt) +/datum/component/material_container/proc/amount2sheet(amt) if(amt >= MINERAL_MATERIAL_AMOUNT) return round(amt / MINERAL_MATERIAL_AMOUNT) return FALSE @@ -314,7 +314,7 @@ return material_amount /// Returns the amount of a specific material in this container. -/datum/component/material_container/proc/get_material_amount(var/datum/material/mat) +/datum/component/material_container/proc/get_material_amount(var/datum/material/mat) if(!istype(mat)) - mat = getmaterialref(mat) + mat = SSmaterials.GetMaterialRef(mat) return(materials[mat]) diff --git a/code/game/atoms.dm b/code/game/atoms.dm index bf1c631c30c..bdc2c563f7a 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -161,7 +161,7 @@ var/temp_list = list() for(var/i in custom_materials) - temp_list[getmaterialref(i)] = custom_materials[i] //Get the proper instanced version + temp_list[SSmaterials.GetMaterialRef(i)] = custom_materials[i] //Get the proper instanced version custom_materials = null //Null the list to prepare for applying the materials properly set_custom_materials(temp_list) @@ -1204,7 +1204,7 @@ if(custom_materials) //Only runs if custom materials existed at first. Should usually be the case but check anyways for(var/i in custom_materials) - var/datum/material/custom_material = getmaterialref(i) + var/datum/material/custom_material = SSmaterials.GetMaterialRef(i) custom_material.on_removed(src, material_flags) //Remove the current materials if(!length(materials)) @@ -1213,7 +1213,7 @@ custom_materials = list() //Reset the list for(var/x in materials) - var/datum/material/custom_material = getmaterialref(x) + var/datum/material/custom_material = SSmaterials.GetMaterialRef(x) if(!(material_flags & MATERIAL_NO_EFFECTS)) custom_material.on_applied(src, materials[custom_material] * multiplier * material_modifier, material_flags) diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm index 97cfa97715c..32cf77212bf 100644 --- a/code/game/machinery/autolathe.dm +++ b/code/game/machinery/autolathe.dm @@ -142,7 +142,7 @@ /obj/machinery/autolathe/proc/AfterMaterialInsert(item_inserted, id_inserted, amount_inserted) if(istype(item_inserted, /obj/item/stack/ore/bluespace_crystal)) use_power(MINERAL_MATERIAL_AMOUNT / 10) - else if(custom_materials && custom_materials.len && custom_materials[getmaterialref(/datum/material/glass)]) + else if(custom_materials && custom_materials.len && custom_materials[SSmaterials.GetMaterialRef(/datum/material/glass)]) flick("autolathe_r",src)//plays glass insertion animation by default otherwise else flick("autolathe_o",src)//plays metal insertion animation diff --git a/code/game/objects/items/apc_frame.dm b/code/game/objects/items/apc_frame.dm index e5bdd85de23..7d98d227169 100644 --- a/code/game/objects/items/apc_frame.dm +++ b/code/game/objects/items/apc_frame.dm @@ -66,8 +66,8 @@ if(iswallturf(T)) T.attackby(src, user, params) - var/metal_amt = round(custom_materials[getmaterialref(/datum/material/iron)]/MINERAL_MATERIAL_AMOUNT) //Replace this shit later - var/glass_amt = round(custom_materials[getmaterialref(/datum/material/glass)]/MINERAL_MATERIAL_AMOUNT) //Replace this shit later + var/metal_amt = round(custom_materials[SSmaterials.GetMaterialRef(/datum/material/iron)]/MINERAL_MATERIAL_AMOUNT) //Replace this shit later + var/glass_amt = round(custom_materials[SSmaterials.GetMaterialRef(/datum/material/glass)]/MINERAL_MATERIAL_AMOUNT) //Replace this shit later if(W.tool_behaviour == TOOL_WRENCH && (metal_amt || glass_amt)) to_chat(user, "You dismantle [src].") diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index 832a63fac8c..aa21eb24460 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -52,7 +52,7 @@ mats_per_unit = list() var/in_process_mat_list = custom_materials.Copy() for(var/i in custom_materials) - mats_per_unit[getmaterialref(i)] = in_process_mat_list[i] + mats_per_unit[SSmaterials.GetMaterialRef(i)] = in_process_mat_list[i] custom_materials[i] *= amount . = ..() if(merge) @@ -62,7 +62,7 @@ var/list/temp_recipes = get_main_recipes() recipes = temp_recipes.Copy() if(material_type) - var/datum/material/M = getmaterialref(material_type) //First/main material + var/datum/material/M = SSmaterials.GetMaterialRef(material_type) //First/main material for(var/i in M.categories) switch(i) if(MAT_CATEGORY_RIGID) @@ -236,7 +236,7 @@ if(R.applies_mats && custom_materials && custom_materials.len) var/list/used_materials = list() for(var/i in custom_materials) - used_materials[getmaterialref(i)] = R.req_amount / R.res_amount * (MINERAL_MATERIAL_AMOUNT / custom_materials.len) + used_materials[SSmaterials.GetMaterialRef(i)] = R.req_amount / R.res_amount * (MINERAL_MATERIAL_AMOUNT / custom_materials.len) O.set_custom_materials(used_materials) //START: oh fuck i'm so sorry diff --git a/code/game/objects/structures/beds_chairs/chair.dm b/code/game/objects/structures/beds_chairs/chair.dm index 8bec5d3c4c5..916cbe061b1 100644 --- a/code/game/objects/structures/beds_chairs/chair.dm +++ b/code/game/objects/structures/beds_chairs/chair.dm @@ -314,7 +314,7 @@ if(remaining_mats) for(var/M=1 to remaining_mats) new stack_type(get_turf(loc)) - else if(custom_materials[getmaterialref(/datum/material/iron)]) + else if(custom_materials[SSmaterials.GetMaterialRef(/datum/material/iron)]) new /obj/item/stack/rods(get_turf(loc), 2) qdel(src) diff --git a/code/modules/antagonists/swarmer/swarmer.dm b/code/modules/antagonists/swarmer/swarmer.dm index ef315af4726..d2b20af0832 100644 --- a/code/modules/antagonists/swarmer/swarmer.dm +++ b/code/modules/antagonists/swarmer/swarmer.dm @@ -193,7 +193,7 @@ /obj/item/IntegrateAmount() //returns the amount of resources gained when eating this item if(custom_materials) - if(custom_materials[getmaterialref(/datum/material/iron)] || custom_materials[getmaterialref(/datum/material/glass)]) + if(custom_materials[SSmaterials.GetMaterialRef(/datum/material/iron)] || custom_materials[SSmaterials.GetMaterialRef(/datum/material/glass)]) return 1 return ..() diff --git a/code/modules/cargo/exports/materials.dm b/code/modules/cargo/exports/materials.dm index 09ce7dd6832..fa0281c621b 100644 --- a/code/modules/cargo/exports/materials.dm +++ b/code/modules/cargo/exports/materials.dm @@ -14,10 +14,10 @@ if(!isitem(O)) return 0 var/obj/item/I = O - if(!(getmaterialref(material_id) in I.custom_materials)) + if(!(SSmaterials.GetMaterialRef(material_id) in I.custom_materials)) return 0 - var/amount = I.custom_materials[getmaterialref(material_id)] + var/amount = I.custom_materials[SSmaterials.GetMaterialRef(material_id)] if(istype(I, /obj/item/stack/ore)) amount *= 0.8 // Station's ore redemption equipment is really goddamn good. diff --git a/code/modules/food_and_drinks/kitchen_machinery/microwave.dm b/code/modules/food_and_drinks/kitchen_machinery/microwave.dm index 72fc79754fd..58b7ede754b 100644 --- a/code/modules/food_and_drinks/kitchen_machinery/microwave.dm +++ b/code/modules/food_and_drinks/kitchen_machinery/microwave.dm @@ -310,8 +310,8 @@ for(var/obj/item/O in ingredients) O.microwave_act(src) if(O.custom_materials && length(O.custom_materials)) - if(O.custom_materials[getmaterialref(/datum/material/iron)]) - metal += O.custom_materials[getmaterialref(/datum/material/iron)] + if(O.custom_materials[SSmaterials.GetMaterialRef(/datum/material/iron)]) + metal += O.custom_materials[SSmaterials.GetMaterialRef(/datum/material/iron)] if(metal) spark() diff --git a/code/modules/hydroponics/biogenerator.dm b/code/modules/hydroponics/biogenerator.dm index 0e2f430d107..51544e3abe1 100644 --- a/code/modules/hydroponics/biogenerator.dm +++ b/code/modules/hydroponics/biogenerator.dm @@ -194,7 +194,7 @@ dat += "x5" if(ispath(D.build_path, /obj/item/stack)) dat += "x10" - dat += "([D.materials[getmaterialref(/datum/material/biomass)]/efficiency])
" + dat += "([D.materials[SSmaterials.GetMaterialRef(/datum/material/biomass)]/efficiency])
" dat += "" else dat += "
No container inside, please insert container.
" @@ -236,14 +236,14 @@ menustat = "void" /obj/machinery/biogenerator/proc/check_cost(list/materials, multiplier = 1, remove_points = TRUE) - if(materials.len != 1 || materials[1] != getmaterialref(/datum/material/biomass)) + if(materials.len != 1 || materials[1] != SSmaterials.GetMaterialRef(/datum/material/biomass)) return FALSE - if (materials[getmaterialref(/datum/material/biomass)]*multiplier/efficiency > points) + if (materials[SSmaterials.GetMaterialRef(/datum/material/biomass)]*multiplier/efficiency > points) menustat = "nopoints" return FALSE else if(remove_points) - points -= materials[getmaterialref(/datum/material/biomass)]*multiplier/efficiency + points -= materials[SSmaterials.GetMaterialRef(/datum/material/biomass)]*multiplier/efficiency update_icon() updateUsrDialog() return TRUE diff --git a/code/modules/mining/machine_processing.dm b/code/modules/mining/machine_processing.dm index 20536442b0e..78bc44263bc 100644 --- a/code/modules/mining/machine_processing.dm +++ b/code/modules/mining/machine_processing.dm @@ -86,7 +86,7 @@ proximity_monitor = new(src, 1) AddComponent(/datum/component/material_container, list(/datum/material/iron, /datum/material/glass, /datum/material/silver, /datum/material/gold, /datum/material/diamond, /datum/material/plasma, /datum/material/uranium, /datum/material/bananium, /datum/material/titanium, /datum/material/bluespace), INFINITY, TRUE, /obj/item/stack) stored_research = new /datum/techweb/specialized/autounlocking/smelter - selected_material = getmaterialref(/datum/material/iron) + selected_material = SSmaterials.GetMaterialRef(/datum/material/iron) /obj/machinery/mineral/processing_unit/Destroy() CONSOLE = null diff --git a/code/modules/mining/mint.dm b/code/modules/mining/mint.dm index be28e4980af..c01d5f2d7c6 100644 --- a/code/modules/mining/mint.dm +++ b/code/modules/mining/mint.dm @@ -31,7 +31,7 @@ /datum/material/plastic, /datum/material/runite ), MINERAL_MATERIAL_AMOUNT * 75, FALSE, /obj/item/stack) - chosen = getmaterialref(chosen) + chosen = SSmaterials.GetMaterialRef(chosen) /obj/machinery/mineral/mint/process() diff --git a/code/modules/mob/living/silicon/robot/robot_modules.dm b/code/modules/mob/living/silicon/robot/robot_modules.dm index fb3dfdb2152..0e3c5bfa5d9 100644 --- a/code/modules/mob/living/silicon/robot/robot_modules.dm +++ b/code/modules/mob/living/silicon/robot/robot_modules.dm @@ -83,8 +83,8 @@ if(is_type_in_list(S, list(/obj/item/stack/sheet/metal, /obj/item/stack/rods, /obj/item/stack/tile/plasteel))) if(S.custom_materials && custom_materials.len) - if(S.custom_materials[getmaterialref(/datum/material/iron)]) - S.cost = S.custom_materials[getmaterialref(/datum/material/iron)] * 0.25 + if(S.custom_materials[SSmaterials.GetMaterialRef(/datum/material/iron)]) + S.cost = S.custom_materials[SSmaterials.GetMaterialRef(/datum/material/iron)] * 0.25 S.source = get_or_create_estorage(/datum/robot_energy_storage/metal) else if(istype(S, /obj/item/stack/sheet/glass)) diff --git a/code/modules/mob/living/simple_animal/hostile/goose.dm b/code/modules/mob/living/simple_animal/hostile/goose.dm index 9b7621ed33e..2b76318ceff 100644 --- a/code/modules/mob/living/simple_animal/hostile/goose.dm +++ b/code/modules/mob/living/simple_animal/hostile/goose.dm @@ -48,7 +48,7 @@ nummies.Cut() nummies += loc.contents if(prob(5) && random_retaliate) - Retaliate() + Retaliate() /mob/living/simple_animal/hostile/retaliate/goose/handle_automated_action() if(length(nummies)) @@ -60,7 +60,7 @@ /mob/living/simple_animal/hostile/retaliate/goose/vomit/handle_automated_action() if(length(nummies)) var/obj/item/E = pick(nummies) - if(!(E.custom_materials && E.custom_materials[getmaterialref(/datum/material/plastic)])) + if(!(E.custom_materials && E.custom_materials[SSmaterials.GetMaterialRef(/datum/material/plastic)])) nummies -= E // remove non-plastic item from queue E = locate(/obj/item/reagent_containers/food) in nummies // find food if(E && E.loc == loc) @@ -70,7 +70,7 @@ /mob/living/simple_animal/hostile/retaliate/goose/proc/feed(obj/item/suffocator) if(stat == DEAD || choking) // plapatin I swear to god return FALSE - if(suffocator.custom_materials && suffocator.custom_materials[getmaterialref(/datum/material/plastic)]) // dumb goose'll swallow food or drink with plastic in it + if(suffocator.custom_materials && suffocator.custom_materials[SSmaterials.GetMaterialRef(/datum/material/plastic)]) // dumb goose'll swallow food or drink with plastic in it visible_message("[src] hungrily gobbles up \the [suffocator]! ") visible_message("[src] is choking on \the [suffocator]! ") suffocator.forceMove(src) diff --git a/code/modules/research/designs.dm b/code/modules/research/designs.dm index 4020c04e653..af645c30f54 100644 --- a/code/modules/research/designs.dm +++ b/code/modules/research/designs.dm @@ -49,11 +49,11 @@ other types of metals and chemistry for reagents). return ..() /datum/design/proc/InitializeMaterials() - var/list/temp_list = list() + var/list/temp_list = list() for(var/i in materials) //Go through all of our materials, get the subsystem instance, and then replace the list. var/amount = materials[i] if(!istext(i)) //Not a category, so get the ref the normal way - var/datum/material/M = getmaterialref(i) + var/datum/material/M = SSmaterials.GetMaterialRef(i) temp_list[M] = amount else temp_list[i] = amount From 2f7a273aea0fe24bb93fc19ffb5e5cc117d9b121 Mon Sep 17 00:00:00 2001 From: Emmett Gaines Date: Mon, 3 Feb 2020 12:40:44 -0500 Subject: [PATCH 2/2] Moves list creation to material init --- code/controllers/subsystem/materials.dm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/controllers/subsystem/materials.dm b/code/controllers/subsystem/materials.dm index 58b8ec53542..9813df6e747 100644 --- a/code/controllers/subsystem/materials.dm +++ b/code/controllers/subsystem/materials.dm @@ -9,9 +9,9 @@ SUBSYSTEM_DEF(materials) name = "Materials" flags = SS_NO_FIRE | SS_NO_INIT ///Dictionary of material.type || material ref - var/list/materials = list() + var/list/materials ///Dictionary of category || list of material refs - var/list/materials_by_category = list() + var/list/materials_by_category ///List of stackcrafting recipes for materials using rigid materials var/list/rigid_stack_recipes = list( new /datum/stack_recipe("chair", /obj/structure/chair/greyscale, one_per_turf = TRUE, on_floor = TRUE, applies_mats = TRUE), @@ -21,6 +21,8 @@ SUBSYSTEM_DEF(materials) ///Ran on initialize, populated the materials and materials_by_category dictionaries with their appropiate vars (See these variables for more info) /datum/controller/subsystem/materials/proc/InitializeMaterials() + materials = list() + materials_by_category = list() for(var/type in subtypesof(/datum/material)) var/datum/material/ref = new type materials[type] = ref