VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
Random.cpp
Go to the documentation of this file.
2#include <random>
3
4namespace VoltMod
5{
6
7std::size_t RandomIndex(std::size_t count)
8{
9 if (count == 0)
10 {
11 return 0;
12 }
13
14 // Seeded once per process; game code is single-threaded, so no synchronisation is needed.
15 static std::mt19937 rng{std::random_device{}()};
16 return std::uniform_int_distribution<std::size_t>(0, count - 1)(rng);
17}
18
19} // namespace VoltMod
std::size_t RandomIndex(std::size_t count)
Definition Random.cpp:7
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56