diff --git a/dWorldServer/ObjectIDManager.cpp b/dWorldServer/ObjectIDManager.cpp index ef5fb9a5..36dcec2e 100644 --- a/dWorldServer/ObjectIDManager.cpp +++ b/dWorldServer/ObjectIDManager.cpp @@ -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() { - std::random_device rd; - - std::mt19937 rng(rd()); - - return uni(rng); + 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); + } } diff --git a/dWorldServer/ObjectIDManager.h b/dWorldServer/ObjectIDManager.h index deef89fd..1398ef79 100644 --- a/dWorldServer/ObjectIDManager.h +++ b/dWorldServer/ObjectIDManager.h @@ -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;