Topic: COOK_WEIGHT_DIV can hit nutrition value cap  (Read 5396 times)


caethan

« on: January 31, 2018, 06:40:09 AM »
I've only found this bug in the base game with dried bear cuts, but I can replicate it with modded items very easily. 

A raw bear cut has protein:29.  Dried cuts have their weight divided by 10, and their nutrition values multiplied by 10 so that the final cut contains the same amount of nutrition as the original cut.  For most cuts this works fine. For the dried bear cut, the protein value should be 290, but is instead 255.  This is presumably because that value is stored in a uint8 (i.e., a single byte) and the largest value that can be stored is 255.  This means that bear cuts are slightly less nutritious than expected when dried.

I can replicate this with modded items:  a processing step with COOK_WEIGHT_DIV:15 and a reconstitution step with COOK_WEIGHT_DIV:0.066666667.  If I process a sheep cut (raw: 0/12/19) I get a lighter processed cut that's hit the nutrition cap: (0/180/255) instead of (0/180/285) as expected.  If I then try and reconstitute the cut, the loss is permanent, down to (0/12/17).

Realistically speaking, of course, none of carb/fat/protein should be above 100, as my understanding is that those values indicate the percentage by weight of each nutrient.  But not sure the best way to resolve the bug for now!