From 4a72162d0701df1ab47c9055d356cfb2fb812454 Mon Sep 17 00:00:00 2001 From: antropod Date: Fri, 12 Jun 2026 05:04:50 +0600 Subject: [PATCH] Fix for material tiles and walls not having material when constructed from last item in the stack (#96404) ## About The Pull Request Fixes #96244. Problem was that when you use last item in the stack, the stack gets qdel'd and the destructor is called. The destructor sets `mats_per_unit = null` for the object, and when custom materials applied to tile/wall it is null. Bug was caused by #92620. I'm not gonna review 272 files from that PR to see if I can delete that destructor, potentially breaking something else, so this is a lazy fix for the annoying bug which is 6 months old. ## Changelog :cl: fix: fixed material tiles and walls not having material when constructed from last item in the stack /:cl: --- code/datums/elements/uses_girder_wall_recipes.dm | 4 +++- code/game/objects/items/stacks/tiles/tile_types.dm | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/code/datums/elements/uses_girder_wall_recipes.dm b/code/datums/elements/uses_girder_wall_recipes.dm index b313f78200e..38593f89f54 100644 --- a/code/datums/elements/uses_girder_wall_recipes.dm +++ b/code/datums/elements/uses_girder_wall_recipes.dm @@ -82,6 +82,8 @@ structure.add_fingerprint(user) stack.add_fingerprint(user) + // Save refernce to the materials for the case when we place last tile in the stack + var/list/saved_mats_per_unit = stack.mats_per_unit if (!stack.use_tool(structure, user, recipe.make_delay, recipe.stack_amount, extra_checks = CALLBACK(src, PROC_REF(check_recipe), structure, user, recipe))) return @@ -103,7 +105,7 @@ qdel(structure) if (is_material_recipe) - wall.set_custom_materials(stack.mats_per_unit, recipe.stack_amount) + wall.set_custom_materials(saved_mats_per_unit, recipe.stack_amount) /// Checks if the user can do the wall recipe. /datum/element/uses_girder_wall_recipes/proc/check_recipe(obj/structure/structure, mob/living/user, datum/girder_wall_recipe/recipe) diff --git a/code/game/objects/items/stacks/tiles/tile_types.dm b/code/game/objects/items/stacks/tiles/tile_types.dm index c8f2c59d7c3..915fbf2af5e 100644 --- a/code/game/objects/items/stacks/tiles/tile_types.dm +++ b/code/game/objects/items/stacks/tiles/tile_types.dm @@ -1162,9 +1162,11 @@ merge_type = /obj/item/stack/tile/material /obj/item/stack/tile/material/place_tile(turf/open/target_plating, mob/user) + // Save refernce to the materials for the case when we place last tile in the stack + var/list/saved_mats_per_unit = mats_per_unit . = ..() var/turf/open/floor/material/floor = . - floor?.set_custom_materials(mats_per_unit) + floor?.set_custom_materials(saved_mats_per_unit) /obj/item/stack/tile/eighties name = "retro tile"