From 3aba465c0bd06bb5b512e26b25adcbbbe0d8f40d Mon Sep 17 00:00:00 2001
From: SyncIt21 <110812394+SyncIt21@users.noreply.github.com>
Date: Fri, 11 Jul 2025 11:59:49 +0530
Subject: [PATCH] Material sheets show their proper amounts on crate manifests
(#92033)
## About The Pull Request
- Fixes #76802

## Changelog
:cl:
fix: material sheets show their proper amounts on crate manifests
/:cl:
---
code/modules/cargo/order.dm | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/code/modules/cargo/order.dm b/code/modules/cargo/order.dm
index ef6484f21fc..66987b3f0a1 100644
--- a/code/modules/cargo/order.dm
+++ b/code/modules/cargo/order.dm
@@ -141,8 +141,12 @@
manifest_text += "Contents:
"
manifest_text += "
"
var/container_contents = list() // Associative list with the format (item_name = nÂș of occurrences, ...)
- for(var/atom/movable/AM in container.contents - manifest_paper)
- container_contents[AM.name]++
+ for(var/obj/item/stuff in container.contents - manifest_paper)
+ if(isstack(stuff))
+ var/obj/item/stack/thing = stuff
+ container_contents[thing.singular_name] += thing.amount
+ continue
+ container_contents[stuff.name]++
if((manifest_paper.errors & MANIFEST_ERROR_CONTENTS) && container_contents)
if(HAS_TRAIT(container, TRAIT_NO_MANIFEST_CONTENTS_ERROR))
manifest_paper.errors &= ~MANIFEST_ERROR_CONTENTS
@@ -150,7 +154,7 @@
for(var/iteration in 1 to rand(1, round(container.contents.len * 0.5))) // Remove anywhere from one to half of the items
var/missing_item = pick(container_contents)
container_contents[missing_item]--
- if(container_contents[missing_item] == 0) // To avoid 0s and negative values on the manifest
+ if(!container_contents[missing_item]) // To avoid 0s and negative values on the manifest
container_contents -= missing_item