Bug fix. Better poisoning cause tracking. Optimizations. Etc. #1
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.
Greetings.
Please, accept my pull request. I optimized your Poisoned Food Stack Fix mod, and while testing it, I also found a RimWorld oddity that led to a bug you tried to fix. Fixed now. Described in commit message and commented in the code.
The committed assembly is built in Visual Studio 16. You may wish to rebuild.
Also, your last edit to About.xml was not copied to Steam Workshop:
(C) the mod significantly reduces the risk of food poisoning for large-volume foods such as pemmican, and (D)
Here is a debug log showing the fixed bug in action. To reproduce it, the 1st return operator in SplitFoodPoisonablePostfix method should be commented out, reintroducing the bug. A stack of 3 items is ordered to be merged with a stack of 8 items. One extra poisoned item appears in a carried stack, and the cause is set to Unknown.
==================== Splitting ====================
Preliminary: MealSimple98779 of 1 pcs at 33.33334% (IncompetentCook) and MealSimple110204 of 2 pcs at 33.33334% (IncompetentCook)
Poisoned: 1/3 in total
Split: 0/1 pcs at 0% (Unknown) and 1/2 pcs at 50% (IncompetentCook)
==================== Splitting ====================
Odd: MealSimple110204 of 2 pcs at 50% (IncompetentCook) is split to self
Preliminary: MealSimple110204 of 2 pcs at 50% (IncompetentCook) and MealSimple110204 of 2 pcs at 50% (IncompetentCook)
Poisoned: 2/4 in total
Split: 2/2 pcs at 100% (Unknown) and 0/2 pcs at 100% (Unknown)
==================== Absorbing prefix ====================
Stack MealSimple69933 of 8 pcs at 25% (IncompetentCook)
==================== Absorbing postfix ====================
Preliminary: MealSimple69933 of 8(10) pcs at 40% (Unknown) after absorbing 2 pcs from MealSimple110204 of 2 pcs at 100% (Unknown)