forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stomach code refactor (CleverRaven#35143)
* Remove unused methods from stomach.cpp * Combine several methods so stomach.cpp is simpler There were several issues with the previous implementation of the stomach_contents class. For instance, using the class required intricate knowledge of its implementation. Additionally, the most important and commonly performed task, digesting food every half-hour, required calling four specific methods in a specific order, when they could easily be combined into one method. Overall, the class suffered from over-complexity and I decided to fix this by making the following changes: Combined store_water, calculate_absorbed, store_absorbed, and bowel_movement into one method, "digest". Removed references to calories_absorbed and vitamins_absorbed, as these are no longer used after the above change. Combined pass_rates and absorb_rates: stomach-types never absorbed anything, and guts-types passed so slowly as to be inconsequential, so these concepts were combined into digest_rates. Whether a stomach_contents is a stomach or guts is now decided when the object is constructed; it was already that way in practice, I just made it official. * Make all_nutrition_starve_test far more strict Now that vitamins aren't disappearing, this test can be tuned to make sure that vitamins are being absorbed into the body correctly. * Implement suggestions from KorGgenT - Replace auto with type specification. - Add const where applicable - Replaces 'player' type parameters with 'needs_rates' Co-Authored-By: Curtis Merrill <[email protected]> * Remove unused #includes * Refactor ingest function The previous ingest function in stomach.cpp used the 'player' object, which we are moving away from. Since the only call of that function was in the 'player' scope, it was trivial to move that code there and call the new, more generalized ingest function instead. * Fix bug with stomach capacity calculation Stomach capacity was always based on the player's mutations, no matter who owned said stomach. Now the capacity function takes a Character reference as a parameter, and uses that Character's mutations instead.
- Loading branch information
1 parent
6fdb4f7
commit 927e94d
Showing
10 changed files
with
199 additions
and
423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.