Fixes the RCL sometimes deleting itself when use() checks are called. (#32026)

* destroy upon empty general stack check

* Update stack.dm
This commit is contained in:
CRUNCH
2026-06-02 00:07:28 +00:00
committed by GitHub
parent 42a76b8e09
commit 34acc9eab3
2 changed files with 5 additions and 4 deletions
+5 -3
View File
@@ -38,6 +38,8 @@
var/parent_stack = FALSE
/// Whether this stack can be split into multiple independent stacks.
var/allow_splitting = TRUE
/// Whether this stack deletes itself when `amount` reaches 0.
var/destroy_upon_empty = TRUE
/obj/item/stack/examine(mob/user)
. = ..()
@@ -348,15 +350,15 @@
/**
* Returns TRUE if the item stack is the equivalent of a 0 amount item.
*
* Also deletes the item if delete_if_zero is TRUE and the stack does not have
* is_cyborg set to true.
* Arguments: `delete_if_zero`: Deletes the stack if `TRUE` and the stack does not have
* `is_cyborg` set to `TRUE` or `destroy_upon_empty` set to `FALSE`.
*/
/obj/item/stack/proc/is_zero_amount(delete_if_zero = TRUE)
if(is_cyborg)
return source.amount < cost
if(amount < 1)
if(delete_if_zero)
if(destroy_upon_empty && delete_if_zero)
qdel(src)
return TRUE
return FALSE