Make bulk items ammo for stacking, remove boxes and bags from solid food spawns

0.B has been a mixed bag for hoarders: on one hand, there’s more stuff to go out and find and haul back to base where it’ll most likely sit on a shelf where all it does is feed into your OCD scavenging, but on the other there appear to be more behind-the-scenes checks of said items, checks which become more apparent - and intrusive - as your stash goes. From what I’ve seen from my own playtime and reading the comments of other posters, it seems to be rooted in that said checks are done on a per-stack basis, and since a lot of your items sit in stacks of 1, that means a lot of stacks that have to be checked. 500 rags sitting in a square require 500 instances of a rag with position, condition and all the other per-stack info. Meanwhile, 500 nails sitting in the same tile, because they use charges for quantity, are just one instance of position, condition and whatever else, with one extra flag that says “there are 500 nails in this instance”.

So I did a little test. I went and edited some of the items in the Melee and Tools item files so that they looked like so:

"type":"AMMO", "id": "scrap", "symbol": ",", "color": "light_gray", "name": "scrap metal", "category": "spare_parts", "description": "An assortment of small bits of metal and scrap useful in all kinds of crafting", "price": 1000, "material": "steel", "weight": 113, "volume": 1, "bashing": 1, "cutting": 0, "to_hit": -2, "ammo_type" : "NULL", "damage" : 0, "pierce" : 0, "range" : 0, "dispersion" : 0, "recoil" : 0, "count" : 1

When I loaded my save, all the items were in separate instances of 1 charge each. Once moved into a new tile, though, they stacked like any other item that enjoys charge stacking, like copper wire and batteries - and performance improved considerably. What took ~3 seconds to process before now only takes 1 second. Tidying the house no longer takes hours upon hours upon hours of game-time and minutes of holding Enter or watching Move All shift stuff from one square to another.

Rags, fur, leather, plastic chunks, scrap metal, chunks and lumps of steel, circuit boards, amplifiers, converters, superglue, on and on - those are the kind of things you’ll get stupendous piles of if you like to grab everything you can, and as they are now are the culprits in hoard slowdowns because they stack as individual items. By making them ammo-type items, however, they’ll stack by charge as a single instance for the whole lot, though still retaining mass and volume, meaning thousands of less item reads across your whole stockpile.

You know what clued me into this, though? Food - vending machine food, specifically. Early on in the game, cookies and other crap were my staple foodsource and some of those bastards were loaded to the brim with snacks, and it was unloading the haul of a recent run that really started the grinding. Hundreds of boxes and bags, all counted as separate items, despite that the contents can be unloaded from them and stacked and moved around with no problem. Why not just remove the cardboard box and plastic bag containers from solid foodstuffs, then? Boxes are good only for burning and fletching (and there’re PLENTY of alternatives for both activities) and the only thing uniquely demanding plastic bags is raincoat making, which doesn’t matter since you can find tons of the damn things. Small plastic bottles, like for salt and gunpowder reagents, are also not in demand explicitly and a regular bottle or something else can always be used in their stead. have stuff spawn in them, then, unless their nature explicitly requires it like with liquids?

I like the first idea. Very simple, save-compatible, improves performance and improves inventory management (just one stack, like in advanced inventory).
One (tiny) feature it breaks is taking time to move things. Right now survivor will grab each item separately, new system would either require allowing grabbing whole mounds of rags or designing a volume/weight based move cost system with an extended action to “pour” items from one stack to the other. It could even extend the existing fluid pouring one.
Still certainly worth it even without the extended action stack management.

Mixed feelings about the lack of containers part. On one hand, most solid containers don’t add anything and could as well be replaced by simply moving the item out of the container and having 2 items spawn on the shelf or even removing the container altogether. On the other hand, cans preserve contents now.
Overall I think it’s worth it. Having containers for stuff like salt only means that the best course of action is unloading them and taking only the contents.
I’d even go further and allow liquid containers to stack, only counting the number of containers and total number of instances of the liquid. This would also work nicely with all the annoyingly non-stacking items like matchbooks, lighters and cash cards.

Paper matches from a matchbook don’t transfer out of the matchbook very well. Same for the charges from a disposable lighter into another, and the charges from a cash card (oh hey, card-reader scams!).

Treating items as charges causes no end of trouble internally, I’d prefer to go the other way with that and remake most items with charges as piles of individual items.

The only reason there’s an issue at all is that the active item processing code is incredibly dumb and iterates over every item in the map looking for active items instead of maintaining a list of just the active items. I’m working on rectifying that and predict the overhead will drop to virtually nothing once I’m done.

And no, we’re not going to merge a “quick fix” and put off the correct fix, there’s no telling what that would break.

How about, instead of turning almost every item into a stack, the player was given the ability to turn almost every item into a stack item and the stack items already in the game would get an individual item version. Now you could have every interaction between items use only the individual item without worrying about players having 40000+ batteries, nails and/ or rags, as they could be stored, by the player, as stack items with charges.

One way of doing it would be to have a command that created an abstract item that you could (a)ctivate and use on an item to create a stack item. Or you have the creation of the stack item be an option in the examination screen in the inventory. This stack item could then be interacted with to despawn exact copies of the original item, which would add charges to the stack item or to spawn items back into the game, which would reduce the charges. While not being able to use stack items in crafting would add to the amount of keypressing the player would have to make, you could offset this by giving the stack the ability to automatically gather all the items in the players inventory and on the ground within (crafting) range.

Perishable items and damage to the stack from environment or actions seem too complicated to pull out of the hat here and now, but perhaps some systems where they’d proportionally lose charges and spawn damaged or rotten versions of the item over time or when receiving damage.

And, more importantly, have (A) a wide variety of uses in crafting instead of the niches of boxes/bags/small plastic bottles and (B) contents which (usually) actually demand the need for a container in order to be handled.

I'd even go further and allow liquid containers to stack, only counting the number of containers and total number of instances of the liquid. This would also work nicely with all the annoyingly non-stacking items like matchbooks, lighters and cash cards.
THIS might be a bit much, since I'm not too sure how things like containers would work with a charge stack system owing to not having tried: could wind up with a situation where an entire stack has the capacity of only a single container.

Could you please elaborate? Not to play the “well I haven’t seen any problems, so OBVIOUSLY…” card, but being an end user means I’ve only got one perspective of the whole thing. Things like weapons and containers and tools with set capacities and whatnot like bottles and cans and lighters, yeah, I could see those possibly being a major problem if charge-stacked, but stuff without activation uses or self-contained self-consuming tools like Rags would basically be acting like bullets and medicine for storage purposes. The one thing I have noticed is that vehicles don’t register certain charge-stack weights properly for the purpose of mass when examining and dragging, but since that’s mostly an issue when doing things like large-scale construction projects at home that demand large quantities of a specific list of components that’s not too big issue.

I’d prefer to go the other way with that and remake most items with charges as piles of individual items.

The only reason there's an issue at all is that the active item processing code is incredibly dumb and iterates over every item in the map looking for active items instead of maintaining a list of just the active items. I'm working on rectifying that and predict the overhead will drop to virtually nothing once I'm done.
It goes quite a bit before that, though. From a player perspective, managing bulk stuff has always been a pain, and though advanced inventory management's made it less so it nevertheless still persists and especially now that we have disassembly and more construction projects that require lots of items that don't stack (stone walls, for example) and bulk crafting.
And no, we're not going to merge a "quick fix" and put off the correct fix, there's no telling what that would break.
I'm not suggesting a "quick fix" for anything, I'm just saying that we should apply a storage and handling system already used by a large number of items to several other items that would greatly benefit from said system and're functionally identical to items that already employ it (copper wire and solder charge-stacks, so why not circuit boards and other electronic bits used alongside them). The fact that this would help performance in the immediate term is just an added bonus.