mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-17 23:39:18 +02:00
Change RandomInt to Random overload and reuse global random engine.
This commit is contained in:
@@ -88,7 +88,7 @@ std::vector<std::string> scenarioloader_ui::get_random_trivia()
|
||||
json triviaData = json::parse(fileContent);
|
||||
|
||||
// select random
|
||||
int i = RandomInt(0, static_cast<int>(triviaData.size()) - 1);
|
||||
int i = Random(0, static_cast<int>(triviaData.size()) - 1);
|
||||
std::string triviaStr = triviaData[i]["text"];
|
||||
std::string background = triviaData[i]["background"];
|
||||
if (triviaData[i].contains("scenery"))
|
||||
|
||||
@@ -100,11 +100,10 @@ double Random(double a, double b)
|
||||
return dist(Global.random_engine);
|
||||
}
|
||||
|
||||
int RandomInt(int min, int max)
|
||||
int Random(int min, int max)
|
||||
{
|
||||
static std::mt19937 engine(std::random_device{}());
|
||||
std::uniform_int_distribution<int> dist(min, max);
|
||||
return dist(engine);
|
||||
return dist(Global.random_engine);
|
||||
}
|
||||
|
||||
std::string generate_uuid_v4()
|
||||
|
||||
@@ -65,7 +65,7 @@ inline long Round(double const f)
|
||||
}
|
||||
|
||||
double Random(double a, double b);
|
||||
int RandomInt(int min, int max);
|
||||
int Random(int min, int max);
|
||||
std::string generate_uuid_v4();
|
||||
double LocalRandom(double a, double b);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user