Skip to content

Conversation

@Doomster14
Copy link

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)

…checks...

- Fix: When a stack containing poisoned items was moved/merged, the number of poisoned items could change somewhat. And if it was increased, the food could be tagged as having unknown poisoning cause.
- Overall, more accurate tracking of poisoning cause.
- Added debug output to the in-game debug log window when built in Debug configuration.
- Refactoring: A class for hypergeometric distribution generation is created, with tests performed in Debug configuration.
- Performance improvements.
- Added more sanity checks, the mod does nothing with stacks having invalid parameters.
- Debug symbols are disabled in Release configuration build, so build machine paths are not exposed.
- Multiple minor improvements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant