mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-06 06:32:56 +01:00
Make util_rand thread safe
This commit is contained in:
@@ -426,7 +426,6 @@ namespace OpenRCT2
|
||||
}
|
||||
|
||||
gScenarioTicks = 0;
|
||||
util_srand((uint32_t)time(nullptr));
|
||||
input_reset_place_obj_modifier();
|
||||
viewport_init_all();
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
#include <ctime>
|
||||
#include <random>
|
||||
|
||||
static std::mt19937 _prng;
|
||||
|
||||
int32_t squaredmetres_to_squaredfeet(int32_t squaredMetres)
|
||||
{
|
||||
// 1 metre squared = 10.7639104 feet squared
|
||||
@@ -529,13 +527,9 @@ bool str_is_null_or_empty(const char* str)
|
||||
return str == nullptr || str[0] == 0;
|
||||
}
|
||||
|
||||
void util_srand(int32_t source)
|
||||
{
|
||||
_prng.seed(source);
|
||||
}
|
||||
|
||||
uint32_t util_rand()
|
||||
{
|
||||
thread_local std::mt19937 _prng(std::random_device{}());
|
||||
return _prng();
|
||||
}
|
||||
|
||||
|
||||
@@ -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