Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Condense item stacks with charges only when they are mergeable #50613

Merged

Conversation

ferociousdork
Copy link
Contributor

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:
smoker_contents

Mill contents separating by freshness:
mill_contents

Messages upon inserting food:
messages

Old and fresh components being tracked separately:
separate_components

…how display_name when examining smoking rack and mill; Fix rot for cooks_like comestibles
@actual-nh actual-nh added <Bugfix> This is a fix for a bug (or closes open issue) Crafting / Construction / Recipes Includes: Uncrafting / Disassembling Items: Food / Vitamins Comestibles and drinks [C++] Changes (can be) made in C++. Previously named `Code` labels Aug 8, 2021
@actual-nh
Copy link
Contributor

actual-nh commented Aug 8, 2021

Do make sure this doesn't make the "can't mix liquids from two sources" problem worse - as in adding it to more things. (Things with different nutrition should be mergeable, just with the result as a weighted average of the inputs' nutrition values.)

@ferociousdork
Copy link
Contributor Author

It doesn't make it worse, but it does nothing to make it better either. If two stacks are currently being separated in the inventory, they are now also separated in the smoking rack / mill.

@kevingranade kevingranade merged commit 2f6beb7 into CleverRaven:master Aug 14, 2021
@ferociousdork ferociousdork deleted the condense_charges_mergeable branch August 15, 2021 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Crafting / Construction / Recipes Includes: Uncrafting / Disassembling Items: Food / Vitamins Comestibles and drinks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

smoking rack overrides meat calorie counts Smoking rack turning normal meat into mutant meat and vice versa
3 participants