mirror of https://github.com/OpenTTD/OpenTTD
(svn r12156) -Fix (r11454): Chance16I was now biased towards zero - round to nearest now
parent
044ca2bbf6
commit
b4f58ebae4
|
@ -88,7 +88,7 @@ static inline uint32 InteractiveRandomRange(uint16 max) { return _interactive_ra
|
||||||
static inline bool Chance16I(const uint a, const uint b, const uint32 r)
|
static inline bool Chance16I(const uint a, const uint b, const uint32 r)
|
||||||
{
|
{
|
||||||
assert(b != 0);
|
assert(b != 0);
|
||||||
return (uint16)r < (uint16)((a << 16) / b);
|
return (uint16)r < (uint16)(((a << 16) + b / 2) / b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue