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

Fix issue with foods not inheriting anything during canning #35048

Merged
merged 4 commits into from
Oct 30, 2019

Conversation

Davi-DeGanne
Copy link
Contributor

Summary

SUMMARY: Bugfixes "Fix issue with foods not inheriting anything during canning"

Purpose of change

Fixes #32564
Fixes other bugs as well (see below).

Describe the solution

The crafting finalization process was attempting to perform the following operations on the can/jar/container rather than the food contained within:

  • Flag inheritance
  • Poison inheritance
  • Assigning components (which governs kcal/vitamin inheritance)
  • Rot carryover
  • Temperature assignment

So all these systems weren't working when crafting contained food. I changed it so that when the crafted item is a non-empty container, the contents undergo these operations rather than the container.

Testing

Craft soup twice with identical ingredients, except craft one canned, and the other not. They should have identical vitamins and calories.
I tested it myself with a few different recipes and it seems to work.

@ZhilkinSerg ZhilkinSerg added <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 labels Oct 26, 2019
@Davi-DeGanne
Copy link
Contributor Author

A note for code reviewers:

For some reason, I don't like that I used a pointer here (though granted, that's most likely because I'm still not very experienced with using them so they scare me). Was there a good way to get content_ptr as a reference rather than a pointer? And would that have been a better solution for any reason? Or am I overthinking this and it's fine as is?

@esotericist
Copy link
Contributor

A note for code reviewers:

For some reason, I don't like that I used a pointer here (though granted, that's most likely because I'm still not very experienced with using them so they scare me). Was there a good way to get content_ptr as a reference rather than a pointer? And would that have been a better solution for any reason? Or am I overthinking this and it's fine as is?

A pointer to an object is implicitly a reference to that object.

src/crafting.cpp Outdated Show resolved Hide resolved
@Davi-DeGanne
Copy link
Contributor Author

A pointer to an object is implicitly a reference to that object.

Hmm I worded my question poorly due to lack of knowledge of the nomenclature. I guess I meant, is there any way to end up with

item &content;

instead of

 item *content_ptr;

and is it preferable for any reason?

src/crafting.cpp Outdated Show resolved Hide resolved
Co-Authored-By: Kevin Granade <kevin.granade@gmail.com>
@kevingranade kevingranade merged commit 43b7d5f into CleverRaven:master Oct 30, 2019
@Davi-DeGanne Davi-DeGanne deleted the canning-inheritance-fix branch October 30, 2019 09:59
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.

Jarring/Canning woods soup does not inherit its ingredients vitamins and calories
4 participants