mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Merge pull request #12861 from FartMaster69420/stack-patch
Fixing Stack Deletion
This commit is contained in:
@@ -1,13 +1,6 @@
|
|||||||
// Porting stack dragging/auto stacking from TG.
|
// Porting stack dragging/auto stacking from TG.
|
||||||
|
|
||||||
/obj/item/stack/proc/merge(obj/item/stack/S) //Merge src into S, as much as possible
|
/obj/item/stack/proc/merge(obj/item/stack/S) //Merge src into S, as much as possible
|
||||||
if(uses_charge || S.uses_charge) // This should realistically never happen, but in case it does lets avoid breaking things.
|
|
||||||
return
|
|
||||||
if(S.stacktype != stacktype)
|
|
||||||
return
|
|
||||||
if(S.amount >= S.max_amount)
|
|
||||||
return
|
|
||||||
|
|
||||||
var/transfer = get_amount()
|
var/transfer = get_amount()
|
||||||
transfer = min(transfer, S.max_amount - S.amount)
|
transfer = min(transfer, S.max_amount - S.amount)
|
||||||
if(pulledby)
|
if(pulledby)
|
||||||
@@ -18,7 +11,27 @@
|
|||||||
use(transfer)
|
use(transfer)
|
||||||
S.add(transfer)
|
S.add(transfer)
|
||||||
|
|
||||||
|
/obj/item/stack/proc/can_merge(obj/item/stack/S)
|
||||||
|
if(uses_charge || S.uses_charge) // This should realistically never happen, but in case it does lets avoid breaking things.
|
||||||
|
return
|
||||||
|
if(S.stacktype != stacktype)
|
||||||
|
return
|
||||||
|
if(S.amount >= S.max_amount)
|
||||||
|
return
|
||||||
|
if(!isturf(loc) || !isturf(S.loc))
|
||||||
|
return FALSE
|
||||||
|
if(src == S)
|
||||||
|
return FALSE
|
||||||
|
if(ismob(S.loc) || ismob(loc))
|
||||||
|
return FALSE
|
||||||
|
if(S.throwing || throwing)
|
||||||
|
return FALSE
|
||||||
|
if(S.amount < 1 || amount < 1)
|
||||||
|
return FALSE
|
||||||
|
return TRUE
|
||||||
|
|
||||||
/obj/item/stack/Crossed(var/atom/movable/AM)
|
/obj/item/stack/Crossed(var/atom/movable/AM)
|
||||||
if(isturf(AM.loc) && AM != src && istype(AM, src.type) && !AM.throwing)
|
if(istype(AM, src.type)) // Sanity so we don't try to merge non-stacks.
|
||||||
merge(AM)
|
if(can_merge(AM))
|
||||||
|
merge(AM)
|
||||||
return ..()
|
return ..()
|
||||||
Reference in New Issue
Block a user