Condense item stacks with charges only when they are mergeable #50613
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Bugfixes "Smoking rack condensing disparate items into one stack"
Purpose of change
Fixes #40007
Fixes #48384
Smoking racks condense the charges of the items inserted based just on item type, ignoring other significant differences (normal meat vs. mutant meat in #40007, calorie counts in #48384). Another one would be relative rot, currently the smoking rack can turn stacks of old meat into fresh ones and vice versa.
The exact same problem exists for mills, which is also fixed by this PR.
Describe the solution
This PR uses
item::merge_charges
to determine if charges should be merged or not. This causes disparate components to be tracked separately. Next to that, it uses display_name when examining smoking racks / mills so the differences can be inspected visually.While testing I found that comestibles with the
cooks_like
field ignore relative rot, i.e. they are always created completely fresh. Since it is somewhat related (it can still turn old food into fresh), and the fix is just two lines, I've added that as well.Describe alternatives you've considered
This change affects component tracking in all items that use charges, not just smoking rack and mill contents. Therefore I considered doing this just for comestibles to reduce the chance of bugs. However, distinguishing components the same way the inventory does could be useful everywhere.
Testing
Tested item stacking in smoking racks / mills, tested components of crafting results. See screenshots below.
Additional context
Smoker contents separating by type of meat:
Mill contents separating by freshness:
Messages upon inserting food:
Old and fresh components being tracked separately: