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:
parent
8093044f07
commit
ceaa7e2fb0
9 changed files with 155 additions and 29 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue