[+] IRandomDevice::ToSeed()

This commit is contained in:
Reece Wilson 2022-12-28 20:07:41 +00:00
parent dbbcd14b57
commit dcc9205ea6
3 changed files with 17 additions and 3 deletions

View File

@ -24,6 +24,8 @@ namespace Aurora::RNG
virtual double NextDecimal() = 0;
virtual float NextNumber(float min, float max) = 0;
virtual AuUInt32 NextIndex(AuUInt32 uCount /* = max + 1*/) = 0;
virtual Memory::MemoryViewRead ToSeed() = 0;
template<typename T, int N>
inline void NextFillArray(T(&array)[N])

View File

@ -144,7 +144,17 @@ namespace Aurora::RNG
auto range = max - min;
return NextDecimal() * range + min;
}
AuMemoryViewRead RandomDevice::ToSeed()
{
if (this->def_.bSecure)
{
return {};
}
return this->fast_.state;
}
AUKN_SYM IRandomDevice *RandomNew(const Aurora::RNG::RandomDef &def)
{
auto pDevice = _new RandomDevice();
@ -158,8 +168,8 @@ namespace Aurora::RNG
return pDevice;
}
AUKN_SYM void RandomRelease(IRandomDevice *pStream)
AUKN_SYM void RandomRelease(IRandomDevice *pDevice)
{
AuSafeDelete<RandomDevice*>(pStream);
AuSafeDelete<RandomDevice *>(pDevice);
}
}

View File

@ -27,6 +27,8 @@ namespace Aurora::RNG
float NextNumber(float min, float max) override;
AuUInt32 NextIndex(AuUInt32 uCount /* = max + 1*/) override;
AuMemoryViewRead ToSeed() override;
void Init(const RandomDef &def);
private: