From 4976701f376b28271235a05882d6802542f37578 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Tue, 25 Apr 2023 13:17:40 -0500 Subject: [PATCH] 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 --- dChatServer/ChatPacketHandler.cpp | 17 +++++++++-------- dCommon/GeneralUtils.h | 9 +++++---- dCommon/dEnums/dCommonVars.h | 8 -------- dCommon/dEnums/eObjectBits.h | 13 +++++++++++++ dGame/Character.cpp | 9 +++++---- dGame/Entity.cpp | 5 +++-- dGame/EntityManager.cpp | 5 +++-- dGame/UserManager.cpp | 13 +++++++------ dGame/dBehaviors/ProjectileAttackBehavior.cpp | 3 ++- dGame/dComponents/PetComponent.cpp | 5 +++-- dGame/dComponents/PropertyEntranceComponent.cpp | 5 +++-- .../dComponents/PropertyManagementComponent.cpp | 16 ++++++++-------- dGame/dGameMessages/GameMessages.cpp | 9 +++++---- dGame/dInventory/Item.cpp | 7 ++++--- dGame/dUtilities/SlashCommandHandler.cpp | 5 +++-- dWorldServer/WorldServer.cpp | 9 +++++---- dZoneManager/dZoneManager.cpp | 4 ++-- 17 files changed, 80 insertions(+), 62 deletions(-) create mode 100644 dCommon/dEnums/eObjectBits.h diff --git a/dChatServer/ChatPacketHandler.cpp b/dChatServer/ChatPacketHandler.cpp index 592c3870..a0d508cb 100644 --- a/dChatServer/ChatPacketHandler.cpp +++ b/dChatServer/ChatPacketHandler.cpp @@ -12,6 +12,7 @@ #include "eAddFriendResponseType.h" #include "RakString.h" #include "dConfig.h" +#include "eObjectBits.h" extern PlayerContainer playerContainer; @@ -45,8 +46,8 @@ void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) { FriendData fd; fd.isFTP = false; // not a thing in DLU fd.friendID = res->getUInt(1); - GeneralUtils::SetBit(fd.friendID, static_cast(eObjectBits::OBJECT_BIT_PERSISTENT)); - GeneralUtils::SetBit(fd.friendID, static_cast(eObjectBits::OBJECT_BIT_CHARACTER)); + GeneralUtils::SetBit(fd.friendID, eObjectBits::PERSISTENT); + 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 if (fd.isBestFriend) player->countOfBestFriends += 1; @@ -178,10 +179,10 @@ void ChatPacketHandler::HandleFriendRequest(Packet* packet) { bestFriendStatus = oldBestFriendStatus; // Set the bits - GeneralUtils::SetBit(queryPlayerID, static_cast(eObjectBits::OBJECT_BIT_CHARACTER)); - GeneralUtils::SetBit(queryPlayerID, static_cast(eObjectBits::OBJECT_BIT_PERSISTENT)); - GeneralUtils::SetBit(queryFriendID, static_cast(eObjectBits::OBJECT_BIT_CHARACTER)); - GeneralUtils::SetBit(queryFriendID, static_cast(eObjectBits::OBJECT_BIT_PERSISTENT)); + GeneralUtils::SetBit(queryPlayerID, eObjectBits::CHARACTER); + GeneralUtils::SetBit(queryPlayerID, eObjectBits::PERSISTENT); + GeneralUtils::SetBit(queryFriendID, eObjectBits::CHARACTER); + GeneralUtils::SetBit(queryFriendID, eObjectBits::PERSISTENT); // 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 @@ -336,8 +337,8 @@ void ChatPacketHandler::HandleRemoveFriend(Packet* packet) { } // Convert friendID to LWOOBJID - GeneralUtils::SetBit(friendID, static_cast(eObjectBits::OBJECT_BIT_PERSISTENT)); - GeneralUtils::SetBit(friendID, static_cast(eObjectBits::OBJECT_BIT_CHARACTER)); + GeneralUtils::SetBit(friendID, eObjectBits::PERSISTENT); + GeneralUtils::SetBit(friendID, eObjectBits::CHARACTER); std::unique_ptr 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(playerID)); diff --git a/dCommon/GeneralUtils.h b/dCommon/GeneralUtils.h index 0555a45e..0a8a0a16 100644 --- a/dCommon/GeneralUtils.h +++ b/dCommon/GeneralUtils.h @@ -16,6 +16,7 @@ #include "dLogger.h" enum eInventoryType : uint32_t; +enum class eObjectBits : size_t; enum class eReplicaComponentType : uint32_t; /*! @@ -66,9 +67,9 @@ namespace GeneralUtils { //! Sets a bit on a numerical value template - void SetBit(T& value, size_t index) { + inline void SetBit(T& value, eObjectBits bits) { static_assert(std::is_arithmetic::value, "Not an arithmetic type"); - + auto index = static_cast(bits); if (index > (sizeof(T) * 8) - 1) { return; } @@ -78,9 +79,9 @@ namespace GeneralUtils { //! Clears a bit on a numerical value template - void ClearBit(T& value, size_t index) { + inline void ClearBit(T& value, eObjectBits bits) { static_assert(std::is_arithmetic::value, "Not an arithmetic type"); - + auto index = static_cast(bits); if (index > (sizeof(T) * 8 - 1)) { return; } diff --git a/dCommon/dEnums/dCommonVars.h b/dCommon/dEnums/dCommonVars.h index 16cae3c9..ff8ec836 100644 --- a/dCommon/dEnums/dCommonVars.h +++ b/dCommon/dEnums/dCommonVars.h @@ -177,14 +177,6 @@ union suchar { //=========== 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 enum eMatchUpdate : int { MATCH_UPDATE_PLAYER_JOINED = 0, diff --git a/dCommon/dEnums/eObjectBits.h b/dCommon/dEnums/eObjectBits.h new file mode 100644 index 00000000..b978aad6 --- /dev/null +++ b/dCommon/dEnums/eObjectBits.h @@ -0,0 +1,13 @@ +#ifndef __EOBJECTBITS__H__ +#define __EOBJECTBITS__H__ + +#include + +enum class eObjectBits : size_t { + PERSISTENT = 32, + CLIENT = 46, + SPAWNED = 58, + CHARACTER = 60 +}; + +#endif //!__EOBJECTBITS__H__ diff --git a/dGame/Character.cpp b/dGame/Character.cpp index b8d08854..98d6d0a9 100644 --- a/dGame/Character.cpp +++ b/dGame/Character.cpp @@ -18,6 +18,7 @@ #include "InventoryComponent.h" #include "eMissionTaskType.h" #include "eMissionState.h" +#include "eObjectBits.h" #include "eGameMasterLevel.h" Character::Character(uint32_t id, User* parentUser) { @@ -69,8 +70,8 @@ Character::Character(uint32_t id, User* parentUser) { //Set our objectID: m_ObjectID = m_ID; - m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_CHARACTER); - m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(m_ObjectID, eObjectBits::CHARACTER); + GeneralUtils::SetBit(m_ObjectID, eObjectBits::PERSISTENT); m_ParentUser = parentUser; m_OurEntity = nullptr; @@ -128,8 +129,8 @@ void Character::UpdateFromDatabase() { //Set our objectID: m_ObjectID = m_ID; - m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_CHARACTER); - m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(m_ObjectID, eObjectBits::CHARACTER); + GeneralUtils::SetBit(m_ObjectID, eObjectBits::PERSISTENT); m_OurEntity = nullptr; m_BuildMode = false; diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 595ab090..55e1b1ca 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -24,6 +24,7 @@ #include "Loot.h" #include "eMissionTaskType.h" #include "eTriggerEventType.h" +#include "eObjectBits.h" //Component includes: #include "Component.h" @@ -952,9 +953,9 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke if (m_ParentEntity != nullptr || m_SpawnerID != 0) { 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(eObjectBits::CLIENT))); 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(eObjectBits::CLIENT))); } else outBitStream->Write0(); outBitStream->Write(m_HasSpawnerNodeID); diff --git a/dGame/EntityManager.cpp b/dGame/EntityManager.cpp index d547cdb1..dc9a43f3 100644 --- a/dGame/EntityManager.cpp +++ b/dGame/EntityManager.cpp @@ -20,6 +20,7 @@ #include "MessageIdentifiers.h" #include "dConfig.h" #include "eTriggerEventType.h" +#include "eObjectBits.h" #include "eGameMasterLevel.h" #include "eReplicaComponentType.h" @@ -108,11 +109,11 @@ Entity* EntityManager::CreateEntity(EntityInfo info, User* user, Entity* parentE if (!controller && info.lot != 14) { // 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 if (info.spawnerID != 0) { - id = GeneralUtils::SetBit(id, OBJECT_BIT_SPAWNED); + GeneralUtils::SetBit(id, eObjectBits::SPAWNED); } } } diff --git a/dGame/UserManager.cpp b/dGame/UserManager.cpp index 4f0c456d..0e52bc52 100644 --- a/dGame/UserManager.cpp +++ b/dGame/UserManager.cpp @@ -23,6 +23,7 @@ #include "AssetManager.h" #include "CDClientDatabase.h" #include "dMessageIdentifiers.h" +#include "eObjectBits.h" #include "eGameMasterLevel.h" UserManager* UserManager::m_Address = nullptr; @@ -313,16 +314,16 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet) std::stringstream xml2; LWOOBJID lwoidforshirt = idforshirt; - lwoidforshirt = GeneralUtils::SetBit(lwoidforshirt, OBJECT_BIT_CHARACTER); - lwoidforshirt = GeneralUtils::SetBit(lwoidforshirt, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(lwoidforshirt, eObjectBits::CHARACTER); + GeneralUtils::SetBit(lwoidforshirt, eObjectBits::PERSISTENT); xml2 << xmlSave1 << ""; std::string xmlSave2 = xml2.str(); ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t idforpants) { LWOOBJID lwoidforpants = idforpants; - lwoidforpants = GeneralUtils::SetBit(lwoidforpants, OBJECT_BIT_CHARACTER); - lwoidforpants = GeneralUtils::SetBit(lwoidforpants, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(lwoidforpants, eObjectBits::CHARACTER); + GeneralUtils::SetBit(lwoidforpants, eObjectBits::PERSISTENT); std::stringstream xml3; xml3 << xmlSave2 << ""; @@ -480,8 +481,8 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet) } LWOOBJID objectID = PacketUtils::ReadPacketS64(8, packet); - objectID = GeneralUtils::ClearBit(objectID, OBJECT_BIT_CHARACTER); - objectID = GeneralUtils::ClearBit(objectID, OBJECT_BIT_PERSISTENT); + GeneralUtils::ClearBit(objectID, eObjectBits::CHARACTER); + GeneralUtils::ClearBit(objectID, eObjectBits::PERSISTENT); uint32_t charID = static_cast(objectID); Game::logger->Log("UserManager", "Received char rename request for ID: %llu (%u)", objectID, charID); diff --git a/dGame/dBehaviors/ProjectileAttackBehavior.cpp b/dGame/dBehaviors/ProjectileAttackBehavior.cpp index 3ce6c415..f65421cb 100644 --- a/dGame/dBehaviors/ProjectileAttackBehavior.cpp +++ b/dGame/dBehaviors/ProjectileAttackBehavior.cpp @@ -6,6 +6,7 @@ #include "dLogger.h" #include "SkillComponent.h" #include "../dWorldServer/ObjectIDManager.h" +#include "eObjectBits.h" void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { LWOOBJID target{}; @@ -107,7 +108,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt for (auto i = 0u; i < this->m_projectileCount; ++i) { auto id = static_cast(ObjectIDManager::Instance()->GenerateObjectID()); - id = GeneralUtils::SetBit(id, OBJECT_BIT_SPAWNED); + GeneralUtils::SetBit(id, eObjectBits::SPAWNED); bitStream->Write(id); diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index 090e5791..2dfaad27 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -22,6 +22,7 @@ #include "Database.h" #include "EntityInfo.h" #include "eMissionTaskType.h" +#include "eObjectBits.h" #include "eGameMasterLevel.h" std::unordered_map PetComponent::buildCache{}; @@ -551,8 +552,8 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) { LWOOBJID petSubKey = ObjectIDManager::Instance()->GenerateRandomObjectID(); - petSubKey = GeneralUtils::SetBit(petSubKey, OBJECT_BIT_CHARACTER); - petSubKey = GeneralUtils::SetBit(petSubKey, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(petSubKey, eObjectBits::CHARACTER); + GeneralUtils::SetBit(petSubKey, eObjectBits::PERSISTENT); m_DatabaseId = petSubKey; diff --git a/dGame/dComponents/PropertyEntranceComponent.cpp b/dGame/dComponents/PropertyEntranceComponent.cpp index c251dc96..5da9a3c4 100644 --- a/dGame/dComponents/PropertyEntranceComponent.cpp +++ b/dGame/dComponents/PropertyEntranceComponent.cpp @@ -12,6 +12,7 @@ #include "UserManager.h" #include "dLogger.h" #include "AMFFormat.h" +#include "eObjectBits.h" #include "eGameMasterLevel.h" 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 LWOOBJID ownerObjId = owner; - ownerObjId = GeneralUtils::SetBit(ownerObjId, OBJECT_BIT_CHARACTER); - ownerObjId = GeneralUtils::SetBit(ownerObjId, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(ownerObjId, eObjectBits::CHARACTER); + GeneralUtils::SetBit(ownerObjId, eObjectBits::PERSISTENT); // 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 = ?)"); diff --git a/dGame/dComponents/PropertyManagementComponent.cpp b/dGame/dComponents/PropertyManagementComponent.cpp index 0b05b10e..4b9e287f 100644 --- a/dGame/dComponents/PropertyManagementComponent.cpp +++ b/dGame/dComponents/PropertyManagementComponent.cpp @@ -19,6 +19,7 @@ #include "PropertyEntranceComponent.h" #include "InventoryComponent.h" #include "eMissionTaskType.h" +#include "eObjectBits.h" #include #include "CppScripts.h" @@ -66,8 +67,8 @@ PropertyManagementComponent::PropertyManagementComponent(Entity* parent) : Compo if (propertyEntry->next()) { this->propertyId = propertyEntry->getUInt64(1); this->owner = propertyEntry->getUInt64(2); - this->owner = GeneralUtils::SetBit(this->owner, OBJECT_BIT_CHARACTER); - this->owner = GeneralUtils::SetBit(this->owner, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(this->owner, eObjectBits::CHARACTER); + GeneralUtils::SetBit(this->owner, eObjectBits::PERSISTENT); this->clone_Id = propertyEntry->getInt(2); this->propertyName = propertyEntry->getString(5).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.emulator = EntityManager::Instance()->GetZoneControlEntity()->GetObjectID(); - LWOOBJID id = static_cast(persistentId) | 1ull << OBJECT_BIT_CLIENT; - - info.spawnerID = id; + info.spawnerID = persistentId; + GeneralUtils::SetBit(info.spawnerID, eObjectBits::CLIENT); const auto spawnerId = dZoneManager::Instance()->MakeSpawner(info); auto* spawner = dZoneManager::Instance()->GetSpawner(spawnerId); auto ldfModelBehavior = new LDFData(u"modelBehaviors", 0); - auto userModelID = new LDFData(u"userModelID", id); + auto userModelID = new LDFData(u"userModelID", info.spawnerID); auto modelType = new LDFData(u"modelType", 2); auto propertyObjectID = new LDFData(u"propertyObjectID", true); auto componentWhitelist = new LDFData(u"componentWhitelist", 1); @@ -622,8 +622,8 @@ void PropertyManagementComponent::Load() { //BBB property models need to have extra stuff set for them: if (lot == 14) { LWOOBJID blueprintID = lookupResult->getUInt(10); - blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_CHARACTER); - blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(blueprintID, eObjectBits::CHARACTER); + GeneralUtils::SetBit(blueprintID, eObjectBits::PERSISTENT); LDFBaseData* ldfBlueprintID = new LDFData(u"blueprintid", blueprintID); LDFBaseData* componentWhitelist = new LDFData(u"componentWhitelist", 1); diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 0fc32e2e..f5cbc811 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -34,6 +34,7 @@ #include "eRacingTaskParam.h" #include "eMissionTaskType.h" #include "eMissionState.h" +#include "eObjectBits.h" #include "eTriggerEventType.h" #include @@ -2575,14 +2576,14 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent //We need to get a new ID for our model first: ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t newID) { LWOOBJID newIDL = newID; - newIDL = GeneralUtils::SetBit(newIDL, OBJECT_BIT_CHARACTER); - newIDL = GeneralUtils::SetBit(newIDL, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(newIDL, eObjectBits::CHARACTER); + GeneralUtils::SetBit(newIDL, eObjectBits::PERSISTENT); ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t blueprintIDSmall) { blueprintIDSmall = ObjectIDManager::Instance()->GenerateRandomObjectID(); LWOOBJID blueprintID = blueprintIDSmall; - blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_CHARACTER); - blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(blueprintID, eObjectBits::CHARACTER); + GeneralUtils::SetBit(blueprintID, eObjectBits::PERSISTENT); //We need to get the propertyID: (stolen from Wincent's propertyManagementComp) const auto& worldId = dZoneManager::Instance()->GetZone()->GetZoneID(); diff --git a/dGame/dInventory/Item.cpp b/dGame/dInventory/Item.cpp index 5795ab12..62dffa12 100644 --- a/dGame/dInventory/Item.cpp +++ b/dGame/dInventory/Item.cpp @@ -16,6 +16,7 @@ #include "AssetManager.h" #include "InventoryComponent.h" #include "Loot.h" +#include "eObjectBits.h" #include "eReplicaComponentType.h" #include "CDBrickIDTableTable.h" @@ -77,13 +78,13 @@ Item::Item( LWOOBJID id = ObjectIDManager::GenerateRandomObjectID(); - id = GeneralUtils::SetBit(id, OBJECT_BIT_CHARACTER); - id = GeneralUtils::SetBit(id, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(id, eObjectBits::CHARACTER); + GeneralUtils::SetBit(id, eObjectBits::PERSISTENT); const auto type = static_cast(info->itemType); if (type == eItemType::MOUNT) { - id = GeneralUtils::SetBit(id, OBJECT_BIT_CLIENT); + GeneralUtils::SetBit(id, eObjectBits::CLIENT); } this->id = id; diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index 8693abe9..9c1bc611 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -75,6 +75,7 @@ #include "eMissionState.h" #include "TriggerComponent.h" #include "eServerDisconnectIdentifiers.h" +#include "eObjectBits.h" #include "eGameMasterLevel.h" #include "eReplicaComponentType.h" @@ -1029,8 +1030,8 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit accountId = result->getUInt(1); characterId = result->getUInt64(2); - characterId = GeneralUtils::SetBit(characterId, OBJECT_BIT_CHARACTER); - characterId = GeneralUtils::SetBit(characterId, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(characterId, eObjectBits::CHARACTER); + GeneralUtils::SetBit(characterId, eObjectBits::PERSISTENT); } } diff --git a/dWorldServer/WorldServer.cpp b/dWorldServer/WorldServer.cpp index 8a603878..71384207 100644 --- a/dWorldServer/WorldServer.cpp +++ b/dWorldServer/WorldServer.cpp @@ -64,6 +64,7 @@ #include "AMFFormat.h" #include "NiPoint3.h" #include "eServerDisconnectIdentifiers.h" +#include "eObjectBits.h" #include "ZCompression.h" @@ -968,8 +969,8 @@ void HandlePacket(Packet* packet) { LWOOBJID playerID = 0; inStream.Read(playerID); - playerID = GeneralUtils::ClearBit(playerID, OBJECT_BIT_CHARACTER); - playerID = GeneralUtils::ClearBit(playerID, OBJECT_BIT_PERSISTENT); + GeneralUtils::ClearBit(playerID, eObjectBits::CHARACTER); + GeneralUtils::ClearBit(playerID, eObjectBits::PERSISTENT); auto user = UserManager::Instance()->GetUser(packet->systemAddress); @@ -1123,8 +1124,8 @@ void HandlePacket(Packet* packet) { //Send message: { LWOOBJID blueprintID = res->getUInt(1); - blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_CHARACTER); - blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(blueprintID, eObjectBits::CHARACTER); + GeneralUtils::SetBit(blueprintID, eObjectBits::PERSISTENT); CBITSTREAM; PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_BLUEPRINT_SAVE_RESPONSE); diff --git a/dZoneManager/dZoneManager.cpp b/dZoneManager/dZoneManager.cpp index ac3a7008..1a40748d 100644 --- a/dZoneManager/dZoneManager.cpp +++ b/dZoneManager/dZoneManager.cpp @@ -11,6 +11,7 @@ #include "WorldConfig.h" #include "CDZoneTableTable.h" #include +#include "eObjectBits.h" #include "../dWorldServer/ObjectIDManager.h" @@ -133,8 +134,7 @@ LWOOBJID dZoneManager::MakeSpawner(SpawnerInfo info) { if (objectId == LWOOBJID_EMPTY) { objectId = ObjectIDManager::Instance()->GenerateObjectID(); - - objectId = GeneralUtils::SetBit(objectId, OBJECT_BIT_CLIENT); + GeneralUtils::SetBit(objectId, eObjectBits::CLIENT); info.spawnerID = objectId; }