mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-21 21:17:25 +00:00
Test changes
This commit is contained in:
parent
59387e5fe3
commit
8e16573f93
@ -48,11 +48,17 @@ void ObjectIDManager::HandleRequestPersistentIDResponse(uint64_t requestID, uint
|
|||||||
|
|
||||||
//! Handles cases where we have to get a unique object ID synchronously
|
//! Handles cases where we have to get a unique object ID synchronously
|
||||||
uint32_t ObjectIDManager::GenerateRandomObjectID() {
|
uint32_t ObjectIDManager::GenerateRandomObjectID() {
|
||||||
std::random_device rd;
|
auto* objidmgr = ObjectIDManager::Instance();
|
||||||
|
bool coinFlip = rand() % 2;
|
||||||
std::mt19937 rng(rd());
|
if (objidmgr && coinFlip) {
|
||||||
|
Game::logger->Log("ObjectIDManager", "using new version");
|
||||||
return uni(rng);
|
return uni(objidmgr->rng);
|
||||||
|
} else {
|
||||||
|
Game::logger->Log("ObjectIDManager", "using old version");
|
||||||
|
std::random_device rd;
|
||||||
|
std::mt19937 rng(rd());
|
||||||
|
return uni(rng);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,12 +27,17 @@ private:
|
|||||||
|
|
||||||
uint32_t currentObjectID; //!< The current object ID
|
uint32_t currentObjectID; //!< The current object ID
|
||||||
|
|
||||||
|
std::random_device rd;
|
||||||
|
|
||||||
|
std::mt19937 rng;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! The singleton instance
|
//! The singleton instance
|
||||||
static ObjectIDManager* Instance() {
|
static ObjectIDManager* Instance() {
|
||||||
if (m_Address == 0) {
|
if (m_Address == 0) {
|
||||||
m_Address = new ObjectIDManager;
|
m_Address = new ObjectIDManager;
|
||||||
|
m_Address->rng = std::mt19937(m_Address->rd());
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_Address;
|
return m_Address;
|
||||||
|
Loading…
Reference in New Issue
Block a user