Files
Bubberstation/code/game/objects/items/stacks/sheets/light.dm
Arkatos1 ead0e859db Merge type variable fixes and unit test (#55173)
This PR fixes a case where certain materials caused issues when working with stacking machines, because they did not have set merge_type from the get go, which meant that initial() of that variable returned null.

To clarify further - if /obj/item/stack does not have set merge_type, it is generated merge_type upon Initialize(), which is the same as its typepath. For example, currently /obj/item/stack/sheet/bluespace_crystal does not have any merge_type set, and it is given merge_type = /obj/item/stack/sheet/bluespace_crystal upon Initialize(). Each Initialize(). Again and again.

There are quite a bit of these cases in the codebase, especially if its some older code. I have gone through them and set all of them their set merge_type, which they would inevitably receive anyway upon initializing and it fixes a bug mentioned above.

To prevent this happening again, I have also included unit test to check if merge types are set for stacks, included exceptions are usually abstract paths like /obj/item/stack/sheet/mineral, which contains zero behavior on its own and does not spawn unless done via admin tools.
2020-11-26 21:05:52 -05:00

38 lines
1.2 KiB
Plaintext

/obj/item/stack/light_w
name = "wired glass tile"
singular_name = "wired glass floor tile"
desc = "A glass tile, which is wired, somehow."
icon = 'icons/obj/tiles.dmi'
icon_state = "glass_wire"
w_class = WEIGHT_CLASS_NORMAL
force = 3
throwforce = 5
throw_speed = 3
throw_range = 7
flags_1 = CONDUCT_1
max_amount = 60
grind_results = list(/datum/reagent/silicon = 20, /datum/reagent/copper = 5)
merge_type = /obj/item/stack/light_w
/obj/item/stack/light_w/attackby(obj/item/O, mob/user, params)
if(istype(O, /obj/item/stack/sheet/metal))
var/obj/item/stack/sheet/metal/M = O
if (M.use(1))
var/obj/item/L = new /obj/item/stack/tile/light(user.drop_location())
to_chat(user, "<span class='notice'>You make a light tile.</span>")
L.add_fingerprint(user)
use(1)
else
to_chat(user, "<span class='warning'>You need one metal sheet to finish the light tile!</span>")
else
return ..()
/obj/item/stack/light_w/wirecutter_act(mob/living/user, obj/item/I)
. = ..()
var/atom/Tsec = user.drop_location()
var/obj/item/stack/cable_coil/CC = new (Tsec, 5)
CC.add_fingerprint(user)
var/obj/item/stack/sheet/glass/G = new (Tsec)
G.add_fingerprint(user)
use(1)