mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 06:00:16 +01:00
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.
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
#include "keybinding_init.dm"
|
||||
#include "machine_disassembly.dm"
|
||||
#include "medical_wounds.dm"
|
||||
#include "merge_type.dm"
|
||||
#include "metabolizing.dm"
|
||||
#include "outfit_sanity.dm"
|
||||
#include "pills.dm"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/datum/unit_test/merge_type/Run()
|
||||
var/list/blacklist = list(/obj/item/stack/sheet,
|
||||
/obj/item/stack/sheet/mineral,
|
||||
/obj/item/stack/ore,
|
||||
/obj/item/stack/spacecash,
|
||||
/obj/item/stack/license_plates,
|
||||
/obj/item/stack/tile/mineral,
|
||||
/obj/item/stack/tile)
|
||||
|
||||
var/list/paths = subtypesof(/obj/item/stack) - blacklist
|
||||
|
||||
for(var/stackpath in paths)
|
||||
var/obj/item/stack/stack = stackpath
|
||||
if(!initial(stack.merge_type))
|
||||
Fail("([stack]) lacks set merge_type variable!")
|
||||
Reference in New Issue
Block a user