breakout object bits into scoped enum (#997)

* breakout object bits into enum class
tested that things still work as expected
use the inplace set bits where appropiate

* add inline
This commit is contained in:
Aaron Kimbrell 2023-04-25 13:17:40 -05:00 committed by GitHub
parent de1ddd3125
commit 4976701f37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 80 additions and 62 deletions

View File

@ -12,6 +12,7 @@
#include "eAddFriendResponseType.h" #include "eAddFriendResponseType.h"
#include "RakString.h" #include "RakString.h"
#include "dConfig.h" #include "dConfig.h"
#include "eObjectBits.h"
extern PlayerContainer playerContainer; extern PlayerContainer playerContainer;
@ -45,8 +46,8 @@ void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) {
FriendData fd; FriendData fd;
fd.isFTP = false; // not a thing in DLU fd.isFTP = false; // not a thing in DLU
fd.friendID = res->getUInt(1); fd.friendID = res->getUInt(1);
GeneralUtils::SetBit(fd.friendID, static_cast<size_t>(eObjectBits::OBJECT_BIT_PERSISTENT)); GeneralUtils::SetBit(fd.friendID, eObjectBits::PERSISTENT);
GeneralUtils::SetBit(fd.friendID, static_cast<size_t>(eObjectBits::OBJECT_BIT_CHARACTER)); GeneralUtils::SetBit(fd.friendID, eObjectBits::CHARACTER);
fd.isBestFriend = res->getInt(2) == 3; //0 = friends, 1 = left_requested, 2 = right_requested, 3 = both_accepted - are now bffs fd.isBestFriend = res->getInt(2) == 3; //0 = friends, 1 = left_requested, 2 = right_requested, 3 = both_accepted - are now bffs
if (fd.isBestFriend) player->countOfBestFriends += 1; if (fd.isBestFriend) player->countOfBestFriends += 1;
@ -178,10 +179,10 @@ void ChatPacketHandler::HandleFriendRequest(Packet* packet) {
bestFriendStatus = oldBestFriendStatus; bestFriendStatus = oldBestFriendStatus;
// Set the bits // Set the bits
GeneralUtils::SetBit(queryPlayerID, static_cast<size_t>(eObjectBits::OBJECT_BIT_CHARACTER)); GeneralUtils::SetBit(queryPlayerID, eObjectBits::CHARACTER);
GeneralUtils::SetBit(queryPlayerID, static_cast<size_t>(eObjectBits::OBJECT_BIT_PERSISTENT)); GeneralUtils::SetBit(queryPlayerID, eObjectBits::PERSISTENT);
GeneralUtils::SetBit(queryFriendID, static_cast<size_t>(eObjectBits::OBJECT_BIT_CHARACTER)); GeneralUtils::SetBit(queryFriendID, eObjectBits::CHARACTER);
GeneralUtils::SetBit(queryFriendID, static_cast<size_t>(eObjectBits::OBJECT_BIT_PERSISTENT)); GeneralUtils::SetBit(queryFriendID, eObjectBits::PERSISTENT);
// Since this player can either be the friend of someone else or be friends with someone else // Since this player can either be the friend of someone else or be friends with someone else
// their column in the database determines what bit gets set. When the value hits 3, they // their column in the database determines what bit gets set. When the value hits 3, they
@ -336,8 +337,8 @@ void ChatPacketHandler::HandleRemoveFriend(Packet* packet) {
} }
// Convert friendID to LWOOBJID // Convert friendID to LWOOBJID
GeneralUtils::SetBit(friendID, static_cast<size_t>(eObjectBits::OBJECT_BIT_PERSISTENT)); GeneralUtils::SetBit(friendID, eObjectBits::PERSISTENT);
GeneralUtils::SetBit(friendID, static_cast<size_t>(eObjectBits::OBJECT_BIT_CHARACTER)); GeneralUtils::SetBit(friendID, eObjectBits::CHARACTER);
std::unique_ptr<sql::PreparedStatement> deletestmt(Database::CreatePreppedStmt("DELETE FROM friends WHERE (player_id = ? AND friend_id = ?) OR (player_id = ? AND friend_id = ?) LIMIT 1;")); std::unique_ptr<sql::PreparedStatement> deletestmt(Database::CreatePreppedStmt("DELETE FROM friends WHERE (player_id = ? AND friend_id = ?) OR (player_id = ? AND friend_id = ?) LIMIT 1;"));
deletestmt->setUInt(1, static_cast<uint32_t>(playerID)); deletestmt->setUInt(1, static_cast<uint32_t>(playerID));

View File

@ -16,6 +16,7 @@
#include "dLogger.h" #include "dLogger.h"
enum eInventoryType : uint32_t; enum eInventoryType : uint32_t;
enum class eObjectBits : size_t;
enum class eReplicaComponentType : uint32_t; enum class eReplicaComponentType : uint32_t;
/*! /*!
@ -66,9 +67,9 @@ namespace GeneralUtils {
//! Sets a bit on a numerical value //! Sets a bit on a numerical value
template <typename T> template <typename T>
void SetBit(T& value, size_t index) { inline void SetBit(T& value, eObjectBits bits) {
static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type"); static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type");
auto index = static_cast<size_t>(bits);
if (index > (sizeof(T) * 8) - 1) { if (index > (sizeof(T) * 8) - 1) {
return; return;
} }
@ -78,9 +79,9 @@ namespace GeneralUtils {
//! Clears a bit on a numerical value //! Clears a bit on a numerical value
template <typename T> template <typename T>
void ClearBit(T& value, size_t index) { inline void ClearBit(T& value, eObjectBits bits) {
static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type"); static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type");
auto index = static_cast<size_t>(bits);
if (index > (sizeof(T) * 8 - 1)) { if (index > (sizeof(T) * 8 - 1)) {
return; return;
} }

View File

@ -177,14 +177,6 @@ union suchar {
//=========== LU ENUMS ============ //=========== LU ENUMS ============
//! An enum for object ID bits
enum eObjectBits : int32_t {
OBJECT_BIT_PERSISTENT = 32, //!< The 32 bit index
OBJECT_BIT_CLIENT = 46, //!< The 46 bit index
OBJECT_BIT_SPAWNED = 58, //!< The 58 bit index
OBJECT_BIT_CHARACTER = 60 //!< The 60 bit index
};
//! An enum for MatchUpdate types //! An enum for MatchUpdate types
enum eMatchUpdate : int { enum eMatchUpdate : int {
MATCH_UPDATE_PLAYER_JOINED = 0, MATCH_UPDATE_PLAYER_JOINED = 0,

View File

@ -0,0 +1,13 @@
#ifndef __EOBJECTBITS__H__
#define __EOBJECTBITS__H__
#include <cstdint>
enum class eObjectBits : size_t {
PERSISTENT = 32,
CLIENT = 46,
SPAWNED = 58,
CHARACTER = 60
};
#endif //!__EOBJECTBITS__H__

View File

@ -18,6 +18,7 @@
#include "InventoryComponent.h" #include "InventoryComponent.h"
#include "eMissionTaskType.h" #include "eMissionTaskType.h"
#include "eMissionState.h" #include "eMissionState.h"
#include "eObjectBits.h"
#include "eGameMasterLevel.h" #include "eGameMasterLevel.h"
Character::Character(uint32_t id, User* parentUser) { Character::Character(uint32_t id, User* parentUser) {
@ -69,8 +70,8 @@ Character::Character(uint32_t id, User* parentUser) {
//Set our objectID: //Set our objectID:
m_ObjectID = m_ID; m_ObjectID = m_ID;
m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_CHARACTER); GeneralUtils::SetBit(m_ObjectID, eObjectBits::CHARACTER);
m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_PERSISTENT); GeneralUtils::SetBit(m_ObjectID, eObjectBits::PERSISTENT);
m_ParentUser = parentUser; m_ParentUser = parentUser;
m_OurEntity = nullptr; m_OurEntity = nullptr;
@ -128,8 +129,8 @@ void Character::UpdateFromDatabase() {
//Set our objectID: //Set our objectID:
m_ObjectID = m_ID; m_ObjectID = m_ID;
m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_CHARACTER); GeneralUtils::SetBit(m_ObjectID, eObjectBits::CHARACTER);
m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_PERSISTENT); GeneralUtils::SetBit(m_ObjectID, eObjectBits::PERSISTENT);
m_OurEntity = nullptr; m_OurEntity = nullptr;
m_BuildMode = false; m_BuildMode = false;

View File

@ -24,6 +24,7 @@
#include "Loot.h" #include "Loot.h"
#include "eMissionTaskType.h" #include "eMissionTaskType.h"
#include "eTriggerEventType.h" #include "eTriggerEventType.h"
#include "eObjectBits.h"
//Component includes: //Component includes:
#include "Component.h" #include "Component.h"
@ -952,9 +953,9 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke
if (m_ParentEntity != nullptr || m_SpawnerID != 0) { if (m_ParentEntity != nullptr || m_SpawnerID != 0) {
outBitStream->Write1(); outBitStream->Write1();
if (m_ParentEntity != nullptr) outBitStream->Write(GeneralUtils::SetBit(m_ParentEntity->GetObjectID(), OBJECT_BIT_CLIENT)); if (m_ParentEntity != nullptr) outBitStream->Write(GeneralUtils::SetBit(m_ParentEntity->GetObjectID(), static_cast<uint32_t>(eObjectBits::CLIENT)));
else if (m_Spawner != nullptr && m_Spawner->m_Info.isNetwork) outBitStream->Write(m_SpawnerID); else if (m_Spawner != nullptr && m_Spawner->m_Info.isNetwork) outBitStream->Write(m_SpawnerID);
else outBitStream->Write(GeneralUtils::SetBit(m_SpawnerID, OBJECT_BIT_CLIENT)); else outBitStream->Write(GeneralUtils::SetBit(m_SpawnerID, static_cast<uint32_t>(eObjectBits::CLIENT)));
} else outBitStream->Write0(); } else outBitStream->Write0();
outBitStream->Write(m_HasSpawnerNodeID); outBitStream->Write(m_HasSpawnerNodeID);

View File

@ -20,6 +20,7 @@
#include "MessageIdentifiers.h" #include "MessageIdentifiers.h"
#include "dConfig.h" #include "dConfig.h"
#include "eTriggerEventType.h" #include "eTriggerEventType.h"
#include "eObjectBits.h"
#include "eGameMasterLevel.h" #include "eGameMasterLevel.h"
#include "eReplicaComponentType.h" #include "eReplicaComponentType.h"
@ -108,11 +109,11 @@ Entity* EntityManager::CreateEntity(EntityInfo info, User* user, Entity* parentE
if (!controller && info.lot != 14) { if (!controller && info.lot != 14) {
// The client flags means the client should render the entity // The client flags means the client should render the entity
id = GeneralUtils::SetBit(id, OBJECT_BIT_CLIENT); GeneralUtils::SetBit(id, eObjectBits::CLIENT);
// Spawned entities require the spawned flag to render // Spawned entities require the spawned flag to render
if (info.spawnerID != 0) { if (info.spawnerID != 0) {
id = GeneralUtils::SetBit(id, OBJECT_BIT_SPAWNED); GeneralUtils::SetBit(id, eObjectBits::SPAWNED);
} }
} }
} }

View File

@ -23,6 +23,7 @@
#include "AssetManager.h" #include "AssetManager.h"
#include "CDClientDatabase.h" #include "CDClientDatabase.h"
#include "dMessageIdentifiers.h" #include "dMessageIdentifiers.h"
#include "eObjectBits.h"
#include "eGameMasterLevel.h" #include "eGameMasterLevel.h"
UserManager* UserManager::m_Address = nullptr; UserManager* UserManager::m_Address = nullptr;
@ -313,16 +314,16 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
std::stringstream xml2; std::stringstream xml2;
LWOOBJID lwoidforshirt = idforshirt; LWOOBJID lwoidforshirt = idforshirt;
lwoidforshirt = GeneralUtils::SetBit(lwoidforshirt, OBJECT_BIT_CHARACTER); GeneralUtils::SetBit(lwoidforshirt, eObjectBits::CHARACTER);
lwoidforshirt = GeneralUtils::SetBit(lwoidforshirt, OBJECT_BIT_PERSISTENT); GeneralUtils::SetBit(lwoidforshirt, eObjectBits::PERSISTENT);
xml2 << xmlSave1 << "<i l=\"" << shirtLOT << "\" id=\"" << lwoidforshirt << "\" s=\"0\" c=\"1\" eq=\"1\" b=\"1\"/>"; xml2 << xmlSave1 << "<i l=\"" << shirtLOT << "\" id=\"" << lwoidforshirt << "\" s=\"0\" c=\"1\" eq=\"1\" b=\"1\"/>";
std::string xmlSave2 = xml2.str(); std::string xmlSave2 = xml2.str();
ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t idforpants) { ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t idforpants) {
LWOOBJID lwoidforpants = idforpants; LWOOBJID lwoidforpants = idforpants;
lwoidforpants = GeneralUtils::SetBit(lwoidforpants, OBJECT_BIT_CHARACTER); GeneralUtils::SetBit(lwoidforpants, eObjectBits::CHARACTER);
lwoidforpants = GeneralUtils::SetBit(lwoidforpants, OBJECT_BIT_PERSISTENT); GeneralUtils::SetBit(lwoidforpants, eObjectBits::PERSISTENT);
std::stringstream xml3; std::stringstream xml3;
xml3 << xmlSave2 << "<i l=\"" << pantsLOT << "\" id=\"" << lwoidforpants << "\" s=\"1\" c=\"1\" eq=\"1\" b=\"1\"/>"; xml3 << xmlSave2 << "<i l=\"" << pantsLOT << "\" id=\"" << lwoidforpants << "\" s=\"1\" c=\"1\" eq=\"1\" b=\"1\"/>";
@ -480,8 +481,8 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet)
} }
LWOOBJID objectID = PacketUtils::ReadPacketS64(8, packet); LWOOBJID objectID = PacketUtils::ReadPacketS64(8, packet);
objectID = GeneralUtils::ClearBit(objectID, OBJECT_BIT_CHARACTER); GeneralUtils::ClearBit(objectID, eObjectBits::CHARACTER);
objectID = GeneralUtils::ClearBit(objectID, OBJECT_BIT_PERSISTENT); GeneralUtils::ClearBit(objectID, eObjectBits::PERSISTENT);
uint32_t charID = static_cast<uint32_t>(objectID); uint32_t charID = static_cast<uint32_t>(objectID);
Game::logger->Log("UserManager", "Received char rename request for ID: %llu (%u)", objectID, charID); Game::logger->Log("UserManager", "Received char rename request for ID: %llu (%u)", objectID, charID);

View File

@ -6,6 +6,7 @@
#include "dLogger.h" #include "dLogger.h"
#include "SkillComponent.h" #include "SkillComponent.h"
#include "../dWorldServer/ObjectIDManager.h" #include "../dWorldServer/ObjectIDManager.h"
#include "eObjectBits.h"
void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
LWOOBJID target{}; LWOOBJID target{};
@ -107,7 +108,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt
for (auto i = 0u; i < this->m_projectileCount; ++i) { for (auto i = 0u; i < this->m_projectileCount; ++i) {
auto id = static_cast<LWOOBJID>(ObjectIDManager::Instance()->GenerateObjectID()); auto id = static_cast<LWOOBJID>(ObjectIDManager::Instance()->GenerateObjectID());
id = GeneralUtils::SetBit(id, OBJECT_BIT_SPAWNED); GeneralUtils::SetBit(id, eObjectBits::SPAWNED);
bitStream->Write(id); bitStream->Write(id);

View File

@ -22,6 +22,7 @@
#include "Database.h" #include "Database.h"
#include "EntityInfo.h" #include "EntityInfo.h"
#include "eMissionTaskType.h" #include "eMissionTaskType.h"
#include "eObjectBits.h"
#include "eGameMasterLevel.h" #include "eGameMasterLevel.h"
std::unordered_map<LOT, PetComponent::PetPuzzleData> PetComponent::buildCache{}; std::unordered_map<LOT, PetComponent::PetPuzzleData> PetComponent::buildCache{};
@ -551,8 +552,8 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
LWOOBJID petSubKey = ObjectIDManager::Instance()->GenerateRandomObjectID(); LWOOBJID petSubKey = ObjectIDManager::Instance()->GenerateRandomObjectID();
petSubKey = GeneralUtils::SetBit(petSubKey, OBJECT_BIT_CHARACTER); GeneralUtils::SetBit(petSubKey, eObjectBits::CHARACTER);
petSubKey = GeneralUtils::SetBit(petSubKey, OBJECT_BIT_PERSISTENT); GeneralUtils::SetBit(petSubKey, eObjectBits::PERSISTENT);
m_DatabaseId = petSubKey; m_DatabaseId = petSubKey;

View File

@ -12,6 +12,7 @@
#include "UserManager.h" #include "UserManager.h"
#include "dLogger.h" #include "dLogger.h"
#include "AMFFormat.h" #include "AMFFormat.h"
#include "eObjectBits.h"
#include "eGameMasterLevel.h" #include "eGameMasterLevel.h"
PropertyEntranceComponent::PropertyEntranceComponent(uint32_t componentID, Entity* parent) : Component(parent) { PropertyEntranceComponent::PropertyEntranceComponent(uint32_t componentID, Entity* parent) : Component(parent) {
@ -243,8 +244,8 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
// Convert owner char id to LWOOBJID // Convert owner char id to LWOOBJID
LWOOBJID ownerObjId = owner; LWOOBJID ownerObjId = owner;
ownerObjId = GeneralUtils::SetBit(ownerObjId, OBJECT_BIT_CHARACTER); GeneralUtils::SetBit(ownerObjId, eObjectBits::CHARACTER);
ownerObjId = GeneralUtils::SetBit(ownerObjId, OBJECT_BIT_PERSISTENT); GeneralUtils::SetBit(ownerObjId, eObjectBits::PERSISTENT);
// Query to get friend and best friend fields // Query to get friend and best friend fields
auto friendCheck = Database::CreatePreppedStmt("SELECT best_friend FROM friends WHERE (player_id = ? AND friend_id = ?) OR (player_id = ? AND friend_id = ?)"); auto friendCheck = Database::CreatePreppedStmt("SELECT best_friend FROM friends WHERE (player_id = ? AND friend_id = ?) OR (player_id = ? AND friend_id = ?)");

View File

@ -19,6 +19,7 @@
#include "PropertyEntranceComponent.h" #include "PropertyEntranceComponent.h"
#include "InventoryComponent.h" #include "InventoryComponent.h"
#include "eMissionTaskType.h" #include "eMissionTaskType.h"
#include "eObjectBits.h"
#include <vector> #include <vector>
#include "CppScripts.h" #include "CppScripts.h"
@ -66,8 +67,8 @@ PropertyManagementComponent::PropertyManagementComponent(Entity* parent) : Compo
if (propertyEntry->next()) { if (propertyEntry->next()) {
this->propertyId = propertyEntry->getUInt64(1); this->propertyId = propertyEntry->getUInt64(1);
this->owner = propertyEntry->getUInt64(2); this->owner = propertyEntry->getUInt64(2);
this->owner = GeneralUtils::SetBit(this->owner, OBJECT_BIT_CHARACTER); GeneralUtils::SetBit(this->owner, eObjectBits::CHARACTER);
this->owner = GeneralUtils::SetBit(this->owner, OBJECT_BIT_PERSISTENT); GeneralUtils::SetBit(this->owner, eObjectBits::PERSISTENT);
this->clone_Id = propertyEntry->getInt(2); this->clone_Id = propertyEntry->getInt(2);
this->propertyName = propertyEntry->getString(5).c_str(); this->propertyName = propertyEntry->getString(5).c_str();
this->propertyDescription = propertyEntry->getString(6).c_str(); this->propertyDescription = propertyEntry->getString(6).c_str();
@ -372,16 +373,15 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
info.emulated = true; info.emulated = true;
info.emulator = EntityManager::Instance()->GetZoneControlEntity()->GetObjectID(); info.emulator = EntityManager::Instance()->GetZoneControlEntity()->GetObjectID();
LWOOBJID id = static_cast<LWOOBJID>(persistentId) | 1ull << OBJECT_BIT_CLIENT; info.spawnerID = persistentId;
GeneralUtils::SetBit(info.spawnerID, eObjectBits::CLIENT);
info.spawnerID = id;
const auto spawnerId = dZoneManager::Instance()->MakeSpawner(info); const auto spawnerId = dZoneManager::Instance()->MakeSpawner(info);
auto* spawner = dZoneManager::Instance()->GetSpawner(spawnerId); auto* spawner = dZoneManager::Instance()->GetSpawner(spawnerId);
auto ldfModelBehavior = new LDFData<LWOOBJID>(u"modelBehaviors", 0); auto ldfModelBehavior = new LDFData<LWOOBJID>(u"modelBehaviors", 0);
auto userModelID = new LDFData<LWOOBJID>(u"userModelID", id); auto userModelID = new LDFData<LWOOBJID>(u"userModelID", info.spawnerID);
auto modelType = new LDFData<int>(u"modelType", 2); auto modelType = new LDFData<int>(u"modelType", 2);
auto propertyObjectID = new LDFData<bool>(u"propertyObjectID", true); auto propertyObjectID = new LDFData<bool>(u"propertyObjectID", true);
auto componentWhitelist = new LDFData<int>(u"componentWhitelist", 1); auto componentWhitelist = new LDFData<int>(u"componentWhitelist", 1);
@ -622,8 +622,8 @@ void PropertyManagementComponent::Load() {
//BBB property models need to have extra stuff set for them: //BBB property models need to have extra stuff set for them:
if (lot == 14) { if (lot == 14) {
LWOOBJID blueprintID = lookupResult->getUInt(10); LWOOBJID blueprintID = lookupResult->getUInt(10);
blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_CHARACTER); GeneralUtils::SetBit(blueprintID, eObjectBits::CHARACTER);
blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_PERSISTENT); GeneralUtils::SetBit(blueprintID, eObjectBits::PERSISTENT);
LDFBaseData* ldfBlueprintID = new LDFData<LWOOBJID>(u"blueprintid", blueprintID); LDFBaseData* ldfBlueprintID = new LDFData<LWOOBJID>(u"blueprintid", blueprintID);
LDFBaseData* componentWhitelist = new LDFData<int>(u"componentWhitelist", 1); LDFBaseData* componentWhitelist = new LDFData<int>(u"componentWhitelist", 1);

View File

@ -34,6 +34,7 @@
#include "eRacingTaskParam.h" #include "eRacingTaskParam.h"
#include "eMissionTaskType.h" #include "eMissionTaskType.h"
#include "eMissionState.h" #include "eMissionState.h"
#include "eObjectBits.h"
#include "eTriggerEventType.h" #include "eTriggerEventType.h"
#include <sstream> #include <sstream>
@ -2575,14 +2576,14 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
//We need to get a new ID for our model first: //We need to get a new ID for our model first:
ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t newID) { ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t newID) {
LWOOBJID newIDL = newID; LWOOBJID newIDL = newID;
newIDL = GeneralUtils::SetBit(newIDL, OBJECT_BIT_CHARACTER); GeneralUtils::SetBit(newIDL, eObjectBits::CHARACTER);
newIDL = GeneralUtils::SetBit(newIDL, OBJECT_BIT_PERSISTENT); GeneralUtils::SetBit(newIDL, eObjectBits::PERSISTENT);
ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t blueprintIDSmall) { ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t blueprintIDSmall) {
blueprintIDSmall = ObjectIDManager::Instance()->GenerateRandomObjectID(); blueprintIDSmall = ObjectIDManager::Instance()->GenerateRandomObjectID();
LWOOBJID blueprintID = blueprintIDSmall; LWOOBJID blueprintID = blueprintIDSmall;
blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_CHARACTER); GeneralUtils::SetBit(blueprintID, eObjectBits::CHARACTER);
blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_PERSISTENT); GeneralUtils::SetBit(blueprintID, eObjectBits::PERSISTENT);
//We need to get the propertyID: (stolen from Wincent's propertyManagementComp) //We need to get the propertyID: (stolen from Wincent's propertyManagementComp)
const auto& worldId = dZoneManager::Instance()->GetZone()->GetZoneID(); const auto& worldId = dZoneManager::Instance()->GetZone()->GetZoneID();

View File

@ -16,6 +16,7 @@
#include "AssetManager.h" #include "AssetManager.h"
#include "InventoryComponent.h" #include "InventoryComponent.h"
#include "Loot.h" #include "Loot.h"
#include "eObjectBits.h"
#include "eReplicaComponentType.h" #include "eReplicaComponentType.h"
#include "CDBrickIDTableTable.h" #include "CDBrickIDTableTable.h"
@ -77,13 +78,13 @@ Item::Item(
LWOOBJID id = ObjectIDManager::GenerateRandomObjectID(); LWOOBJID id = ObjectIDManager::GenerateRandomObjectID();
id = GeneralUtils::SetBit(id, OBJECT_BIT_CHARACTER); GeneralUtils::SetBit(id, eObjectBits::CHARACTER);
id = GeneralUtils::SetBit(id, OBJECT_BIT_PERSISTENT); GeneralUtils::SetBit(id, eObjectBits::PERSISTENT);
const auto type = static_cast<eItemType>(info->itemType); const auto type = static_cast<eItemType>(info->itemType);
if (type == eItemType::MOUNT) { if (type == eItemType::MOUNT) {
id = GeneralUtils::SetBit(id, OBJECT_BIT_CLIENT); GeneralUtils::SetBit(id, eObjectBits::CLIENT);
} }
this->id = id; this->id = id;

View File

@ -75,6 +75,7 @@
#include "eMissionState.h" #include "eMissionState.h"
#include "TriggerComponent.h" #include "TriggerComponent.h"
#include "eServerDisconnectIdentifiers.h" #include "eServerDisconnectIdentifiers.h"
#include "eObjectBits.h"
#include "eGameMasterLevel.h" #include "eGameMasterLevel.h"
#include "eReplicaComponentType.h" #include "eReplicaComponentType.h"
@ -1029,8 +1030,8 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
accountId = result->getUInt(1); accountId = result->getUInt(1);
characterId = result->getUInt64(2); characterId = result->getUInt64(2);
characterId = GeneralUtils::SetBit(characterId, OBJECT_BIT_CHARACTER); GeneralUtils::SetBit(characterId, eObjectBits::CHARACTER);
characterId = GeneralUtils::SetBit(characterId, OBJECT_BIT_PERSISTENT); GeneralUtils::SetBit(characterId, eObjectBits::PERSISTENT);
} }
} }

View File

@ -64,6 +64,7 @@
#include "AMFFormat.h" #include "AMFFormat.h"
#include "NiPoint3.h" #include "NiPoint3.h"
#include "eServerDisconnectIdentifiers.h" #include "eServerDisconnectIdentifiers.h"
#include "eObjectBits.h"
#include "ZCompression.h" #include "ZCompression.h"
@ -968,8 +969,8 @@ void HandlePacket(Packet* packet) {
LWOOBJID playerID = 0; LWOOBJID playerID = 0;
inStream.Read(playerID); inStream.Read(playerID);
playerID = GeneralUtils::ClearBit(playerID, OBJECT_BIT_CHARACTER); GeneralUtils::ClearBit(playerID, eObjectBits::CHARACTER);
playerID = GeneralUtils::ClearBit(playerID, OBJECT_BIT_PERSISTENT); GeneralUtils::ClearBit(playerID, eObjectBits::PERSISTENT);
auto user = UserManager::Instance()->GetUser(packet->systemAddress); auto user = UserManager::Instance()->GetUser(packet->systemAddress);
@ -1123,8 +1124,8 @@ void HandlePacket(Packet* packet) {
//Send message: //Send message:
{ {
LWOOBJID blueprintID = res->getUInt(1); LWOOBJID blueprintID = res->getUInt(1);
blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_CHARACTER); GeneralUtils::SetBit(blueprintID, eObjectBits::CHARACTER);
blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_PERSISTENT); GeneralUtils::SetBit(blueprintID, eObjectBits::PERSISTENT);
CBITSTREAM; CBITSTREAM;
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_BLUEPRINT_SAVE_RESPONSE); PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_BLUEPRINT_SAVE_RESPONSE);

View File

@ -11,6 +11,7 @@
#include "WorldConfig.h" #include "WorldConfig.h"
#include "CDZoneTableTable.h" #include "CDZoneTableTable.h"
#include <chrono> #include <chrono>
#include "eObjectBits.h"
#include "../dWorldServer/ObjectIDManager.h" #include "../dWorldServer/ObjectIDManager.h"
@ -133,8 +134,7 @@ LWOOBJID dZoneManager::MakeSpawner(SpawnerInfo info) {
if (objectId == LWOOBJID_EMPTY) { if (objectId == LWOOBJID_EMPTY) {
objectId = ObjectIDManager::Instance()->GenerateObjectID(); objectId = ObjectIDManager::Instance()->GenerateObjectID();
GeneralUtils::SetBit(objectId, eObjectBits::CLIENT);
objectId = GeneralUtils::SetBit(objectId, OBJECT_BIT_CLIENT);
info.spawnerID = objectId; info.spawnerID = objectId;
} }