mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 19:13:07 +01:00
@@ -426,7 +426,6 @@ namespace OpenRCT2
|
||||
}
|
||||
|
||||
gScenarioTicks = 0;
|
||||
util_srand((uint32_t)time(nullptr));
|
||||
input_reset_place_obj_modifier();
|
||||
viewport_init_all();
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
# include <cstring>
|
||||
# include <iterator>
|
||||
# include <memory>
|
||||
# include <random>
|
||||
# include <string>
|
||||
|
||||
enum MASTER_SERVER_STATUS
|
||||
@@ -307,10 +308,14 @@ private:
|
||||
static constexpr char hexChars[] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||
};
|
||||
|
||||
std::random_device rd;
|
||||
std::uniform_int_distribution<int32_t> dist(0, static_cast<int32_t>(std::size(hexChars) - 1));
|
||||
|
||||
char key[17];
|
||||
for (int32_t i = 0; i < 16; i++)
|
||||
{
|
||||
int32_t hexCharIndex = util_rand() % std::size(hexChars);
|
||||
int32_t hexCharIndex = dist(rd);
|
||||
key[i] = hexChars[hexCharIndex];
|
||||
}
|
||||
key[std::size(key) - 1] = 0;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <cctype>
|
||||
#include <cmath>
|
||||
#include <ctime>
|
||||
#include <random>
|
||||
|
||||
int32_t squaredmetres_to_squaredfeet(int32_t squaredMetres)
|
||||
{
|
||||
@@ -526,15 +527,10 @@ bool str_is_null_or_empty(const char* str)
|
||||
return str == nullptr || str[0] == 0;
|
||||
}
|
||||
|
||||
void util_srand(int32_t source)
|
||||
{
|
||||
srand(source);
|
||||
}
|
||||
|
||||
// Caveat: rand() might only return values up to 0x7FFF, which is the minimum specified in the C standard.
|
||||
uint32_t util_rand()
|
||||
{
|
||||
return rand();
|
||||
thread_local std::mt19937 _prng(std::random_device{}());
|
||||
return _prng();
|
||||
}
|
||||
|
||||
#define CHUNK (128 * 1024)
|
||||
|
||||
@@ -50,7 +50,6 @@ char* strcasestr(const char* haystack, const char* needle);
|
||||
bool utf8_is_bom(const char* str);
|
||||
bool str_is_null_or_empty(const char* str);
|
||||
|
||||
void util_srand(int32_t source);
|
||||
uint32_t util_rand();
|
||||
|
||||
uint8_t* util_zlib_deflate(const uint8_t* data, size_t data_in_size, size_t* data_out_size);
|
||||
|
||||
@@ -136,8 +136,6 @@ void mapgen_generate(mapgen_settings* settings)
|
||||
int32_t x, y, mapSize, floorTexture, wallTexture, waterLevel;
|
||||
TileElement* tileElement;
|
||||
|
||||
util_srand((int32_t)platform_get_ticks());
|
||||
|
||||
mapSize = settings->mapSize;
|
||||
floorTexture = settings->floor;
|
||||
wallTexture = settings->wall;
|
||||
|
||||
Reference in New Issue
Block a user