diff --git a/Source/Core/Common/TraversalClient.cpp b/Source/Core/Common/TraversalClient.cpp index 02fe5ee26e..f17ce0d921 100644 --- a/Source/Core/Common/TraversalClient.cpp +++ b/Source/Core/Common/TraversalClient.cpp @@ -7,9 +7,10 @@ static void GetRandomishBytes(u8* buf, size_t size) { // We don't need high quality random numbers (which might not be available), // just non-repeating numbers! - srand(enet_time_get()); + static std::mt19937 prng(enet_time_get()); + static std::uniform_int_distribution u8_distribution(0, 255); for (size_t i = 0; i < size; i++) - buf[i] = rand() & 0xff; + buf[i] = u8_distribution(prng); } TraversalClient::TraversalClient(ENetHost* netHost, const std::string& server, const u16 port) diff --git a/Source/Core/Common/TraversalClient.h b/Source/Core/Common/TraversalClient.h index 0263d863fb..ddfb38fce1 100644 --- a/Source/Core/Common/TraversalClient.h +++ b/Source/Core/Common/TraversalClient.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "Common/Common.h" #include "Common/Thread.h"