mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 08:35:20 +02:00
Add API for restoring PseudoRandom and PcgRandom state (#14123)
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user