-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[CR]Eating code rewrite #15057
[CR]Eating code rewrite #15057
Conversation
Hmm, interesting. Some of the inefficiency could also be mitigated by allowing for traits/mutations to specify in their JSON entries what materials are forbidden. That doesn't simplfy the many glorious interactions between traits like for how human flesh is handled though, or for "picking out the inedible bits" sorta things. Plus even then it's beyond the scope of this PR, which looks like a hefty amount of changing already. ^^" |
interactive = false; | ||
} | ||
|
||
const char *itname = food.tname().c_str(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tname
returns a temporary, c_str
does as well. Both are per invalid after the full expression. In other words: don't store the result of c_str
, store the result of tname
as string (not reference).
If one or a few of these mechanics REALLY get in the way of cleaning things up, I'm on board to just ditch them. |
I managed to unwrap it, looks like it was just scattered all over the place rather than actually complex. |
What the heck is slimespawner doing in eating code? |
Eating -> excess energy -> slime spawning activates
|
I think it's ready. I tested what I expected to go wrong and the new code seemed to work correctly. Removed double prompt for "you're full, eat it?". Before, you could get this message once for being full (over-nutrition) and once for going over capacity (over-nutrition or over-slaking). Added (or restored?) a message on pizza scraping. I fixed some minor bugs with original code:
Minor balancing changes:
There is some unfortunate code duplication that could (should?) be yanked out in some later PRs:
There are some minor inconsistencies in handling specific "food"stuffs: fertilizer and alcohol metabolism are handled in iuse, making them skip some checks. Not a problem, but player won't be warned that some of that extra nutrition will go to waste on overconsumption. Also won't be lost on vomiting. |
@@ -7,6 +7,7 @@ src/basecamp.cpp | |||
src/cata_utility.cpp | |||
src/char_validity_check.cpp | |||
src/clzones.cpp | |||
src/consumption.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for this.
Motivation:
player::eat
is huge, ugly, full of giant nearly-identicalif
blocks, hard to maintain, and didn't get a solid cleanup in a whileCharacter
with a relatively low amount of work (compared to the rewrite itself). NPCs will want to eat some time, so that distant player/npc split should keep eating code accessible for both.Changes to code itself:
if( carnivore && eaten->made_of(fruit) && eaten->made_of(veggy) ... )
blocks to use vectors of banned and allowed foodstuffs. Much easier to maintainif
s by bonus amount (most positive on the top)if
blocks to a function:stomach_capacity
Changes to game mechanics:
Problems:
Character
yet because of morale effects and addictionsTODO: