diff options
author | frosch <frosch@openttd.org> | 2010-04-17 11:49:25 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-04-17 11:49:25 +0000 |
commit | 184fa43df2e14c73162e641bc9bc83e403f069ed (patch) | |
tree | d24d525121ba0120bd172975ee2e0784035f7128 /src/core/random_func.hpp | |
parent | cd20724d201b5b04c8dfac49b6b885ea988165ed (diff) | |
download | openttd-184fa43df2e14c73162e641bc9bc83e403f069ed.tar.xz |
(svn r19652) -Fix: RandomRange() is used for bigger ranges in many cases, so generally extent it to handle 32 bits.
Diffstat (limited to 'src/core/random_func.hpp')
-rw-r--r-- | src/core/random_func.hpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/core/random_func.hpp b/src/core/random_func.hpp index 03d49d718..e0e31a08c 100644 --- a/src/core/random_func.hpp +++ b/src/core/random_func.hpp @@ -48,7 +48,7 @@ struct Randomizer { * @param max the maximum value of the returned random number * @return the random number */ - uint32 Next(uint16 max); + uint32 Next(uint32 max); /** * (Re)set the state of the random number generator. @@ -92,16 +92,15 @@ void SetRandomSeed(uint32 seed); #endif uint32 DoRandom(int line, const char *file); #define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__) - uint DoRandomRange(uint max, int line, const char *file); + uint32 DoRandomRange(uint32 max, int line, const char *file); #else static FORCEINLINE uint32 Random() { return _random.Next(); } - static FORCEINLINE uint32 RandomRange(uint max) + static FORCEINLINE uint32 RandomRange(uint32 max) { - assert(max <= UINT16_MAX); return _random.Next(max); } #endif @@ -111,7 +110,7 @@ static FORCEINLINE uint32 InteractiveRandom() return _interactive_random.Next(); } -static FORCEINLINE uint32 InteractiveRandomRange(uint16 max) +static FORCEINLINE uint32 InteractiveRandomRange(uint32 max) { return _interactive_random.Next(max); } |