From aa8abda597c70eaddafcea181143dc0c2653bf0b Mon Sep 17 00:00:00 2001 From: Novacat <35587478+Novacat@users.noreply.github.com> Date: Sat, 10 Apr 2021 08:35:59 -0400 Subject: [PATCH] Merge pull request #10117 from VOREStation/upstream-merge-8019 [MIRROR] Autolathes don't spam debug on first use --- code/datums/autolathe/autolathe.dm | 18 +++------- code/datums/autolathe/materials.dm | 53 +++++++++++------------------ code/modules/materials/materials.dm | 3 +- 3 files changed, 25 insertions(+), 49 deletions(-) diff --git a/code/datums/autolathe/autolathe.dm b/code/datums/autolathe/autolathe.dm index 03d1ca0fdd..bf36f2bfab 100644 --- a/code/datums/autolathe/autolathe.dm +++ b/code/datums/autolathe/autolathe.dm @@ -5,7 +5,7 @@ I = new path() if(!I) // Something has gone horribly wrong, or right. - log_debug("[name] created an Autolathe design without an assigned path. This is expected for only the Material Sheet generation.") + log_debug("[name] created an Autolathe design without an assigned path.") return if(I.matter && !resources) @@ -80,22 +80,12 @@ if(istype(M, /datum/material/alienalloy)) continue - var/obj/item/stack/material/Mat = new M.stack_type() - - if(Mat.name in items_by_name) - qdel(Mat) + var/obj/item/stack/material/S = M.stack_type + if(initial(S.name) in items_by_name) continue - var/datum/category_item/autolathe/materials/WorkDat = new(src) + var/datum/category_item/autolathe/materials/WorkDat = new(src, M) - WorkDat.name = "[Mat.name]" - WorkDat.resources = Mat.matter.Copy() - WorkDat.is_stack = TRUE - WorkDat.no_scale = TRUE - WorkDat.max_stack = Mat.max_amount - WorkDat.path = M.stack_type - - qdel(Mat) items |= WorkDat items_by_name[WorkDat.name] = WorkDat diff --git a/code/datums/autolathe/materials.dm b/code/datums/autolathe/materials.dm index 653fca8222..eb97d73b65 100644 --- a/code/datums/autolathe/materials.dm +++ b/code/datums/autolathe/materials.dm @@ -1,38 +1,23 @@ - -/datum/category_item/autolathe/materials/metal - name = "steel sheets" - path =/obj/item/stack/material/steel +/datum/category_item/autolathe/materials is_stack = TRUE - no_scale = TRUE //prevents material duplication exploits + no_scale = TRUE // Prevents material duplaction exploits -/datum/category_item/autolathe/materials/glass - name = "glass sheets" - path =/obj/item/stack/material/glass - is_stack = TRUE - no_scale = TRUE //prevents material duplication exploits +/datum/category_item/autolathe/materials/New(var/loc, var/mat) + if(istype(mat, /obj/item/stack/material)) + var/obj/item/stack/material/M = mat + name = M.name + resources = M.matter.Copy() + max_stack = M.max_amount + path = M.type + else if(istype(mat, /datum/material)) + var/datum/material/M = mat + var/obj/item/stack/material/S = M.stack_type + name = initial(S.name) + resources = M.get_matter() + max_stack = initial(S.max_amount) + path = S + . = ..() -/datum/category_item/autolathe/materials/rglass - name = "reinforced glass sheets" - path =/obj/item/stack/material/glass/reinforced - is_stack = TRUE - no_scale = TRUE //prevents material duplication exploits - -/datum/category_item/autolathe/materials/rods +/datum/category_item/autolathe/materials/rods // Not strictly a material, so they need their own define name = "metal rods" - path =/obj/item/stack/rods - is_stack = TRUE - no_scale = TRUE //prevents material duplication exploits - -/datum/category_item/autolathe/materials/plasteel - name = "plasteel sheets" - path =/obj/item/stack/material/plasteel - is_stack = TRUE - no_scale = TRUE //prevents material duplication exploits - resources = list(MAT_PLASTEEL = 2000) - -/datum/category_item/autolathe/materials/plastic - name = "plastic sheets" - path =/obj/item/stack/material/plastic - is_stack = TRUE - no_scale = TRUE //prevents material duplication exploits - resources = list(MAT_PLASTIC = 2000) + path =/obj/item/stack/rods \ No newline at end of file diff --git a/code/modules/materials/materials.dm b/code/modules/materials/materials.dm index 005b461679..acd3c5a809 100644 --- a/code/modules/materials/materials.dm +++ b/code/modules/materials/materials.dm @@ -53,9 +53,10 @@ var/list/name_to_material /proc/populate_material_list(force_remake=0) if(name_to_material && !force_remake) return // Already set up! name_to_material = list() - for(var/type in typesof(/datum/material) - /datum/material) + for(var/type in subtypesof(/datum/material)) var/datum/material/new_mineral = new type if(!new_mineral.name) + qdel(new_mineral) continue name_to_material[lowertext(new_mineral.name)] = new_mineral return 1