Test changes

This commit is contained in:
EmosewaMC 2023-05-24 14:00:50 -07:00
parent 59387e5fe3
commit 8e16573f93
2 changed files with 16 additions and 5 deletions

View File

@ -48,11 +48,17 @@ void ObjectIDManager::HandleRequestPersistentIDResponse(uint64_t requestID, uint
//! Handles cases where we have to get a unique object ID synchronously
uint32_t ObjectIDManager::GenerateRandomObjectID() {
auto* objidmgr = ObjectIDManager::Instance();
bool coinFlip = rand() % 2;
if (objidmgr && coinFlip) {
Game::logger->Log("ObjectIDManager", "using new version");
return uni(objidmgr->rng);
} else {
Game::logger->Log("ObjectIDManager", "using old version");
std::random_device rd;
std::mt19937 rng(rd());
return uni(rng);
}
}

View File

@ -27,12 +27,17 @@ private:
uint32_t currentObjectID; //!< The current object ID
std::random_device rd;
std::mt19937 rng;
public:
//! The singleton instance
static ObjectIDManager* Instance() {
if (m_Address == 0) {
m_Address = new ObjectIDManager;
m_Address->rng = std::mt19937(m_Address->rd());
}
return m_Address;