Stacks check for invalid amounts (#91656)

## About The Pull Request
Alleviates #91603

As in it does not fix it because i have not been able to reproduce it.
It now checks for invalid values and defaults to `amount`(which is 1)
during `Initialize()` and not null so we don't have to pass the number
`1` when creating a single sheet.
 
A stack trace is thrown for <= 0 sheet amounts so we can debug & fix
stuff

## Changelog
🆑
code: stacks error on invalid amounts, removed manual passing of number
`1` when creating a single stack in many cases
/🆑
This commit is contained in:
SyncIt21
2025-06-18 18:58:35 +05:30
committed by GitHub
parent b77a62719f
commit ff13dcadab
23 changed files with 48 additions and 40 deletions
+5 -3
View File
@@ -72,9 +72,11 @@
/// or until the cut heals, whichever comes first
var/absorption_rate
/obj/item/stack/Initialize(mapload, new_amount, merge = TRUE, list/mat_override=null, mat_amt=1)
if(new_amount != null)
amount = new_amount
/obj/item/stack/Initialize(mapload, new_amount = amount, merge = TRUE, list/mat_override=null, mat_amt=1)
amount = new_amount
if(amount <= 0)
stack_trace("invalid amount [amount]!")
return INITIALIZE_HINT_QDEL
while(amount > max_amount)
amount -= max_amount
new type(loc, max_amount, FALSE, mat_override, mat_amt)