ciplogic / fheroes2enh

Free Heroes 2 - Enhanced
Other
134 stars 19 forks source link

battle_interface: lighting bolt segfault. Stop passing negative lower value for Rand(uint, uint) #14

Closed kamiccolo closed 6 years ago

kamiccolo commented 6 years ago

I presume, that was the root cause for the bug mentioned on the [issue #12].

Rand::Get(-20, 20) should have made compiler complain, because first argument is invalid. Oh well, it was not. So, here we go, passing proper non-negative value as a first argument and keeping the functionality.

ciplogic commented 6 years ago

I can see that is better to fix Ran::Get(...) to give signed int, instead of this fix.

So, if you don't mind, change Rand::Get(uint, unit) to be on form: Rand::Get(int, int).

I can see fixing all issues and future ones.

kamiccolo commented 6 years ago

Well, technically it should not have compiled. So I'm presuming that there is some more fuckery involved or I just don't get C++ anymore. Bare in mind, that all the places where Rand::Get is being used will have to change then.

ciplogic commented 6 years ago

It should be fixed now. Thank you for fix.