[*] Inline RNG header functions

This commit is contained in:
Reece Wilson 2021-07-13 13:13:21 +01:00
parent 1ff63f3479
commit d9f9bba3c9

View File

@ -65,29 +65,27 @@ namespace Aurora::RNG
string[i] = pair.first[static_cast<int>(idx)];
}
}
static bool RngBoolean()
{
AuUInt8 x[1];
Read<true>(x);
return x[0] > 127;
}
static AuUInt8 RngByte()
static inline AuUInt8 RngByte()
{
AuUInt8 x[1];
Read<true>(x);
return x[0];
}
static inline bool RngBoolean()
{
return RngByte() > 127;
}
template<typename T>
static T &RngArray(T *items, AuUInt count)
static inline T &RngArray(T *items, AuUInt count)
{
return items[static_cast<int>(std::floor(static_cast<float>(RngByte()) / 255.f * static_cast<float>(count - 1))];
}
template<typename T>
static T &RngVector(const AuList<T> &items)
static inline T &RngVector(const AuList<T> &items)
{
return RngArray(items.data(), items.size());
}