mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-11 09:58:05 +00:00
feat: re-write persistent object ID tracker (#1888)
* feat: re-write persistent object ID tracker Features: - Remove random objectIDs entirely - Replace random objectIDs with persistentIDs - Remove the need to contact the MASTER server for a persistent ID - Add persistent ID logic to WorldServers that use transactions to guarantee unique IDs no matter when they are generated - Default character xml version to be the most recent one Fixes: - Return optional from GetModel (and check for nullopt where it may exist) - Regenerate inventory item ids on first login to be unique item IDs (fixes all those random IDs Pet IDs and subkeys are left alone and are assumed to be reserved (checks are there to prevent this) There is also duplicate check logic in place for properties and UGC/Models * Update comment and log * fix: sqlite transaction bug * fix colliding temp item ids temp items should not be saved. would cause issues between worlds as experienced before this commit
This commit is contained in:
@@ -5,36 +5,25 @@
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
|
||||
/*!
|
||||
\file ObjectIDManager.h
|
||||
\brief A manager for handling object ID generation
|
||||
/**
|
||||
* There are 2 types of IDs:
|
||||
* Persistent IDs - These are used for anything that needs to be persist between worlds.
|
||||
* Ephemeral IDs - These are used for any objects that only need to be unique for this world session.
|
||||
*/
|
||||
|
||||
//! The Object ID Manager
|
||||
namespace ObjectIDManager {
|
||||
//! Requests a persistent ID
|
||||
/*!
|
||||
\param callback The callback function
|
||||
|
||||
/**
|
||||
* @brief Returns a Persistent ID with the CHARACTER bit set.
|
||||
*
|
||||
* @return uint64_t A unique persistent ID with the CHARACTER bit set.
|
||||
*/
|
||||
void RequestPersistentID(const std::function<void(uint32_t)> callback);
|
||||
uint64_t GetPersistentID();
|
||||
|
||||
|
||||
//! Handles a persistent ID response
|
||||
/*!
|
||||
\param requestID The request ID
|
||||
\param persistentID The persistent ID
|
||||
*/
|
||||
void HandleRequestPersistentIDResponse(const uint64_t requestID, const uint32_t persistentID);
|
||||
|
||||
//! Generates an object ID server-sided
|
||||
/*!
|
||||
\return A generated object ID
|
||||
/**
|
||||
* @brief Generates an ephemeral object ID for non-persistent objects.
|
||||
*
|
||||
* @return uint32_t
|
||||
*/
|
||||
uint32_t GenerateObjectID();
|
||||
|
||||
//! Generates a random object ID server-sided
|
||||
/*!
|
||||
\return A generated object ID
|
||||
*/
|
||||
uint32_t GenerateRandomObjectID();
|
||||
};
|
||||
|
Reference in New Issue
Block a user