mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Common/Random: Add convenience template for simple arithmetic values
In cases where we just want a random value for a primitive arithmetic type, we can wrap this in a template to allow convenient direct assignment instead of keeping declaration and initialization separate (making it more difficult to use values uninitialized). This also allows the use of Common::Random with functions such as std::generate, making it more flexible in how random values can be generated.
This commit is contained in:
@ -169,8 +169,7 @@ static sockaddr_in6 MakeSinAddr(const TraversalInetAddress& addr)
|
||||
static void GetRandomHostId(TraversalHostId* hostId)
|
||||
{
|
||||
char buf[9];
|
||||
u32 num;
|
||||
Common::Random::Generate(&num, sizeof(num));
|
||||
const u32 num = Common::Random::GenerateValue<u32>();
|
||||
sprintf(buf, "%08x", num);
|
||||
memcpy(hostId->data(), buf, 8);
|
||||
}
|
||||
|
Reference in New Issue
Block a user