From 18002a78a11919a95bd8f795970c6174c0b550d5 Mon Sep 17 00:00:00 2001 From: Heroman3003 <31296024+Heroman3003@users.noreply.github.com> Date: Tue, 14 Mar 2023 18:06:35 +1000 Subject: [PATCH 1/2] Merge pull request #14681 from VOREStation/upstream-merge-9029 [MIRROR] Sheet storage has different caps per type. --- code/game/objects/effects/decals/crayon.dm | 2 +- .../food/kitchen/smartfridge/engineering.dm | 4 ++-- .../persistence/storage/smartfridge.dm | 16 ++++++++++++- code/modules/persistence/storage/storage.dm | 24 ++++++++++++------- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/code/game/objects/effects/decals/crayon.dm b/code/game/objects/effects/decals/crayon.dm index f983a480ff..248b9cfbb4 100644 --- a/code/game/objects/effects/decals/crayon.dm +++ b/code/game/objects/effects/decals/crayon.dm @@ -28,4 +28,4 @@ add_overlay(mainOverlay) add_overlay(shadeOverlay) - add_hiddenprint(usr) \ No newline at end of file + add_hiddenprint(usr) diff --git a/code/modules/food/kitchen/smartfridge/engineering.dm b/code/modules/food/kitchen/smartfridge/engineering.dm index 4f0d2bb9d8..cd656c6eba 100644 --- a/code/modules/food/kitchen/smartfridge/engineering.dm +++ b/code/modules/food/kitchen/smartfridge/engineering.dm @@ -1,4 +1,4 @@ -/obj/machinery/smartfridge/sheets //Is this used anywhere? It's not secure. +/obj/machinery/smartfridge/sheets name = "\improper Smart Sheet Storage" desc = "A storage unit for metals." icon_contents = "boxes" @@ -27,6 +27,6 @@ /obj/machinery/smartfridge/sheets/find_record(var/obj/item/O) for(var/datum/stored_item/stack/I as anything in item_records) - if(istype(O, I.item_path)) // Typecheck should evaluate material-specific subtype + if(O.type == I.item_path) // Typecheck should evaluate material-specific subtype return I return null diff --git a/code/modules/persistence/storage/smartfridge.dm b/code/modules/persistence/storage/smartfridge.dm index 1ffe9eb586..ef7b643ceb 100644 --- a/code/modules/persistence/storage/smartfridge.dm +++ b/code/modules/persistence/storage/smartfridge.dm @@ -32,6 +32,20 @@ max_storage = 250 stacks_go_missing = TRUE +/datum/persistent/storage/smartfridge/sheet_storage/variable_max + name = "variable max storage" + max_storage = list( + /obj/item/stack/material/steel = 150, + /obj/item/stack/material/glass = 150, + /obj/item/stack/material/copper = 150, + /obj/item/stack/material/wood = 150, + /obj/item/stack/material/plastic = 150, + /obj/item/stack/material/phoron = 100, + /obj/item/stack/material/plasteel = 50, + /obj/item/stack/material/cardboard = 50, + "default" = 10 + ) + /datum/persistent/storage/smartfridge/sheet_storage/generate_items(var/list/L) . = list() for(var/obj/item/stack/material/S as anything in L) @@ -97,4 +111,4 @@ var/obj/item/weapon/reagent_containers/food/snacks/grown/G = I.instances[1] if(!istype(G)) continue - .[G.plantname] = I.get_amount() // Store the seed type, because that's what's used to generate the fruit \ No newline at end of file + .[G.plantname] = I.get_amount() // Store the seed type, because that's what's used to generate the fruit diff --git a/code/modules/persistence/storage/storage.dm b/code/modules/persistence/storage/storage.dm index 58b23a6ce9..a1b16e39b1 100644 --- a/code/modules/persistence/storage/storage.dm +++ b/code/modules/persistence/storage/storage.dm @@ -2,7 +2,7 @@ name = "storage" entries_expire_at = 1 has_admin_data = TRUE - + // Don't use these for storage persistence. If someone takes some sheets out and puts them back in mixed in with // new sheets, how do you know the age of the stack? If you want sheets to 'decay', see go_missing_chance entries_decay_at = 0 @@ -28,15 +28,21 @@ var/list/item_list = get_storage_list(entry) var/list/storage_list = list() for(var/item in item_list) - storage_list[item] = min(stored, storage_list[item] + item_list[item]) // Can't store more than max_storage - - // stored gets reduced by qty stored, if greater than stored, - // previous assignment will handle overage, and we set to 0 - if(!store_per_type) - stored = max(stored - item_list[item], 0) - + if(islist(max_storage)) + if(!is_path_in_list(item, stored)) + stored[item] = stored["default"] + storage_list[item] = min(stored[item], storage_list[item] + item_list[item]) // Can't store more than max_storage + + else + storage_list[item] = min(stored, storage_list[item] + item_list[item]) // Can't store more than max_storage + + // stored gets reduced by qty stored, if greater than stored, + // previous assignment will handle overage, and we set to 0 + if(!store_per_type) + stored = max(stored - item_list[item], 0) + LAZYADDASSOC(., "items", storage_list) - + // Usage: returns list with structure: // list( // [type1] = [stored_quantity],