1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-12 16:58:39 +00:00

Add API for restoring PseudoRandom and PcgRandom state (#14123)

This commit is contained in:
sfence 2024-01-16 23:20:52 +01:00 committed by GitHub
parent 8093044f07
commit ceaa7e2fb0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 155 additions and 29 deletions

View file

@ -76,6 +76,11 @@ public:
return (next() % (max - min + 1)) + min;
}
// Allow save and restore of state
inline s32 getState() const
{
return m_next;
}
private:
s32 m_next;
};
@ -94,6 +99,9 @@ public:
void bytes(void *out, size_t len);
s32 randNormalDist(s32 min, s32 max, int num_trials=6);
// Allow save and restore of state
void getState(u64 state[2]) const;
void setState(const u64 state[2]);
private:
u64 m_state;
u64 m_inc;