Open gerdoe-jr opened 9 months ago
I don't understand what's different about the new code. Can you give example values where they differ?
I have no example values, but gameplay videos, you can see the difference
https://github.com/heinrich5991/libtw2/assets/51330274/ef04f236-0993-4d6b-80f0-d35b419cf066
https://github.com/heinrich5991/libtw2/assets/51330274/0e9e3913-4552-48b2-9e62-695c22485d71
If you can generate these examples, perhaps you could run both functions and issue a println!
statement when their result differs?
I was curious about the difference between those two functions as well. I created a small playground project to get value mismatches. https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=708e855ce0717c7690ccb6db3994cdb3
The difference happens when the updated value is still outside the range, but closer to the accepted range:
E.g. range -1..0, value 2, modifier -1. The old code outputted 0 (a bug, I think), the new code outputs 1. Thanks for the clear reproduction example, @Patiga!
@gerdoe-jr Can you create a pull request? :)
https://github.com/heinrich5991/libtw2/blob/b9286674da94d3d45b9c10ffce517af394e2d58c/world/src/lib.rs#L737-L748
After changing this code to next given hook problem disappears though