diff options
-rw-r--r-- | src/server/game/Server/WorldSocket.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Warden/WardenWin.cpp | 2 | ||||
-rw-r--r-- | src/server/shared/Utilities/Util.cpp | 8 | ||||
-rw-r--r-- | src/server/shared/Utilities/Util.h | 25 |
4 files changed, 15 insertions, 22 deletions
diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index fa884090bfa..6ef986dbd22 100644 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -31,7 +31,7 @@ using boost::asio::ip::tcp; using boost::asio::streambuf; WorldSocket::WorldSocket(tcp::socket&& socket) - : _socket(std::move(socket)), _authSeed(static_cast<uint32>(rand32())), _OverSpeedPings(0), _worldSession(nullptr) + : _socket(std::move(socket)), _authSeed(rand32()), _OverSpeedPings(0), _worldSession(nullptr) { } diff --git a/src/server/game/Warden/WardenWin.cpp b/src/server/game/Warden/WardenWin.cpp index 5c3a86988db..da6a7dc1929 100644 --- a/src/server/game/Warden/WardenWin.cpp +++ b/src/server/game/Warden/WardenWin.cpp @@ -281,7 +281,7 @@ void WardenWin::RequestData() } case MODULE_CHECK: { - uint32 seed = static_cast<uint32>(rand32()); + uint32 seed = rand32(); buff << uint32(seed); HmacHash hmac(4, (uint8*)&seed); hmac.UpdateData(wd->Str); diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp index d1799913d41..bf40b8ec352 100644 --- a/src/server/shared/Utilities/Util.cpp +++ b/src/server/shared/Utilities/Util.cpp @@ -63,17 +63,17 @@ float frand(float min, float max) return float(GetRng()->Random() * (max - min) + min); } -int32 rand32() +uint32 rand32() { - return int32(GetRng()->BRandom()); + return GetRng()->BRandom(); } -double rand_norm(void) +double rand_norm() { return GetRng()->Random(); } -double rand_chance(void) +double rand_chance() { return GetRng()->Random() * 100.0; } diff --git a/src/server/shared/Utilities/Util.h b/src/server/shared/Utilities/Util.h index c95e0e3cfa3..0680b91e0fe 100644 --- a/src/server/shared/Utilities/Util.h +++ b/src/server/shared/Utilities/Util.h @@ -76,30 +76,23 @@ std::string secsToTimeString(uint64 timeInSecs, bool shortText = false, bool hou uint32 TimeStringToSecs(const std::string& timestring); std::string TimeToTimestampStr(time_t t); -/* Return a random number in the range min..max; (max-min) must be smaller than 32768. */ +/* Return a random number in the range min..max. */ int32 irand(int32 min, int32 max); -/* Return a random number in the range min..max (inclusive). For reliable results, the difference -* between max and min should be less than RAND32_MAX. */ +/* Return a random number in the range min..max (inclusive). */ uint32 urand(uint32 min, uint32 max); -/* Return a random number in the range 0 .. RAND32_MAX. */ -int32 rand32(); +/* Return a random number in the range 0 .. UINT32_MAX. */ +uint32 rand32(); /* Return a random number in the range min..max */ float frand(float min, float max); -/* Return a random double from 0.0 to 1.0 (exclusive). Floats support only 7 valid decimal digits. - * A double supports up to 15 valid decimal digits and is used internally (RAND32_MAX has 10 digits). - * With an FPU, there is usually no difference in performance between float and double. -*/ -double rand_norm(void); - -/* Return a random double from 0.0 to 99.9999999999999. Floats support only 7 valid decimal digits. - * A double supports up to 15 valid decimal digits and is used internally (RAND32_MAX has 10 digits). - * With an FPU, there is usually no difference in performance between float and double. -*/ -double rand_chance(void); +/* Return a random double from 0.0 to 1.0 (exclusive). */ +double rand_norm(); + +/* Return a random double from 0.0 to 100.0 (exclusive). */ +double rand_chance(); /* Return true if a random roll fits in the specified chance (range 0-100). */ inline bool roll_chance_f(float chance) |