DarkflameServer/dMasterServer/ObjectIDManager.cpp

28 lines
677 B
C++
Raw Normal View History

#include "ObjectIDManager.h"
// Custom Classes
#include "Database.h"
#include "dLogger.h"
// Static Variables
2022-07-28 13:39:57 +00:00
ObjectIDManager* ObjectIDManager::m_Address = nullptr;
//! Initializes the manager
2022-07-28 13:39:57 +00:00
void ObjectIDManager::Initialize(dLogger* logger) {
this->mLogger = logger;
2023-10-10 00:40:48 +00:00
this->currentPersistentID = Database::Connection->GetObjectIDTracker();
}
//! Generates a new persistent ID
uint32_t ObjectIDManager::GeneratePersistentID(void) {
2022-07-28 13:39:57 +00:00
uint32_t toReturn = ++this->currentPersistentID;
2023-10-10 00:40:48 +00:00
Database::Connection->SetObjectIDTracker(toReturn);
2022-07-28 13:39:57 +00:00
return toReturn;
}
void ObjectIDManager::SaveToDatabase() {
2023-10-10 00:40:48 +00:00
Database::Connection->SetObjectIDTracker(this->currentPersistentID);
}