From fe6be2100803b10f7954a28df25261ef1eca6411 Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Wed, 9 Aug 2023 22:08:18 -0700 Subject: [PATCH 1/5] fix raw reading --- dNavigation/dTerrain/RawFile.cpp | 24 +++++++++++++----------- dNavigation/dTerrain/RawFile.h | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/dNavigation/dTerrain/RawFile.cpp b/dNavigation/dTerrain/RawFile.cpp index d4496b2f..dfad9ca4 100644 --- a/dNavigation/dTerrain/RawFile.cpp +++ b/dNavigation/dTerrain/RawFile.cpp @@ -32,13 +32,15 @@ RawFile::RawFile(std::string fileName) { m_Chunks.push_back(chunk); } + m_FinalMesh = new RawMesh(); + this->GenerateFinalMeshFromChunks(); } RawFile::~RawFile() { - delete m_FinalMesh; + if (m_FinalMesh) delete m_FinalMesh; for (const auto* item : m_Chunks) { - delete item; + if (item) delete item; } } @@ -49,10 +51,14 @@ void RawFile::GenerateFinalMeshFromChunks() { for (const auto& vert : chunk->m_Mesh->m_Vertices) { auto tempVert = vert; - tempVert.SetX(tempVert.GetX() + (chunk->m_X / 4)); - tempVert.SetZ(tempVert.GetZ() + (chunk->m_Z / 4)); + // Scale X and Z by the chunk's position in the world + // Scale Y by the chunk's heightmap scale factor + tempVert.SetX(tempVert.GetX() + (chunk->m_X / chunk->m_HeightMap->m_ScaleFactor)); + tempVert.SetY(tempVert.GetY() / chunk->m_HeightMap->m_ScaleFactor); + tempVert.SetZ(tempVert.GetZ() + (chunk->m_Z / chunk->m_HeightMap->m_ScaleFactor)); - tempVert* chunk->m_HeightMap->m_ScaleFactor; + // Then scale it again for some reason + tempVert *= chunk->m_HeightMap->m_ScaleFactor; m_FinalMesh->m_Vertices.push_back(tempVert); } @@ -67,16 +73,12 @@ void RawFile::GenerateFinalMeshFromChunks() { void RawFile::WriteFinalMeshToOBJ(std::string path) { std::ofstream file(path); - std::string vertData; for (const auto& v : m_FinalMesh->m_Vertices) { - vertData += "v " + std::to_string(v.x) + " " + std::to_string(v.y) + " " + std::to_string(v.z) + "\n"; + file << "v " << v.x << ' ' << v.y << ' ' << v.z << '\n'; } for (int i = 0; i < m_FinalMesh->m_Triangles.size(); i += 3) { - vertData += "f " + std::to_string(*std::next(m_FinalMesh->m_Triangles.begin(), i) + 1) + " " + std::to_string(*std::next(m_FinalMesh->m_Triangles.begin(), i + 1) + 1) + " " + std::to_string(*std::next(m_FinalMesh->m_Triangles.begin(), i + 2) + 1) + "\n"; + file << "f " << *std::next(m_FinalMesh->m_Triangles.begin(), i) + 1 << ' ' << *std::next(m_FinalMesh->m_Triangles.begin(), i + 1) + 1 << ' ' << *std::next(m_FinalMesh->m_Triangles.begin(), i + 2) + 1 << '\n'; } - - file.write(vertData.c_str(), vertData.size()); - file.close(); } diff --git a/dNavigation/dTerrain/RawFile.h b/dNavigation/dTerrain/RawFile.h index 2a702c53..b1fb4024 100644 --- a/dNavigation/dTerrain/RawFile.h +++ b/dNavigation/dTerrain/RawFile.h @@ -24,5 +24,5 @@ private: uint32_t m_Height; std::vector m_Chunks; - RawMesh* m_FinalMesh; + RawMesh* m_FinalMesh = nullptr; }; From ad81e341da474cfa9209bd59c93d4d9074259878 Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Wed, 9 Aug 2023 22:13:20 -0700 Subject: [PATCH 2/5] add operator *= for vectors --- dCommon/NiPoint3.cpp | 7 +++++++ dCommon/NiPoint3.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/dCommon/NiPoint3.cpp b/dCommon/NiPoint3.cpp index 20780815..5ad06f30 100644 --- a/dCommon/NiPoint3.cpp +++ b/dCommon/NiPoint3.cpp @@ -136,6 +136,13 @@ NiPoint3& NiPoint3::operator+=(const NiPoint3& point) { return *this; } +NiPoint3& NiPoint3::operator*=(const float scalar) { + this->x *= scalar; + this->y *= scalar; + this->z *= scalar; + return *this; +} + //! Operator for subtraction of vectors NiPoint3 NiPoint3::operator-(const NiPoint3& point) const { return NiPoint3(this->x - point.x, this->y - point.y, this->z - point.z); diff --git a/dCommon/NiPoint3.h b/dCommon/NiPoint3.h index c956b654..44c3c383 100644 --- a/dCommon/NiPoint3.h +++ b/dCommon/NiPoint3.h @@ -138,6 +138,8 @@ public: //! Operator for addition of vectors NiPoint3& operator+=(const NiPoint3& point); + NiPoint3& operator*=(const float scalar); + //! Operator for subtraction of vectors NiPoint3 operator-(const NiPoint3& point) const; From 2cc13c64998a63649b8e9dcd0f5ce784444bd1df Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Thu, 10 Aug 2023 14:33:15 -0700 Subject: [PATCH 3/5] chore: Make serialize actually virtual (#1156) * Make serialize actually virtual * fix serialize and make update virutal * Update VendorComponent.h * Remove flag var * Update SoundTriggerComponent.h --------- Co-authored-by: Aaron Kimbrell --- dGame/Entity.cpp | 78 +++++++++---------- dGame/Entity.h | 1 - dGame/EntityManager.cpp | 6 -- dGame/EntityManager.h | 2 - dGame/dComponents/BaseCombatAIComponent.cpp | 2 +- dGame/dComponents/BaseCombatAIComponent.h | 2 +- dGame/dComponents/BouncerComponent.cpp | 2 +- dGame/dComponents/BouncerComponent.h | 2 +- dGame/dComponents/BuffComponent.cpp | 2 +- dGame/dComponents/BuffComponent.h | 2 +- dGame/dComponents/CharacterComponent.cpp | 2 +- dGame/dComponents/CharacterComponent.h | 2 +- dGame/dComponents/Component.cpp | 4 + dGame/dComponents/Component.h | 2 + .../ControllablePhysicsComponent.cpp | 8 +- .../ControllablePhysicsComponent.h | 3 +- dGame/dComponents/DestroyableComponent.cpp | 2 +- dGame/dComponents/DestroyableComponent.h | 2 +- dGame/dComponents/DonationVendorComponent.cpp | 4 +- dGame/dComponents/DonationVendorComponent.h | 2 +- dGame/dComponents/InventoryComponent.cpp | 6 +- dGame/dComponents/InventoryComponent.h | 3 +- dGame/dComponents/LUPExhibitComponent.cpp | 2 +- dGame/dComponents/LUPExhibitComponent.h | 2 +- .../dComponents/LevelProgressionComponent.cpp | 2 +- dGame/dComponents/LevelProgressionComponent.h | 2 +- dGame/dComponents/ModelComponent.cpp | 2 +- dGame/dComponents/ModelComponent.h | 2 +- dGame/dComponents/ModuleAssemblyComponent.cpp | 2 +- dGame/dComponents/ModuleAssemblyComponent.h | 2 +- dGame/dComponents/MovingPlatformComponent.cpp | 6 +- dGame/dComponents/MovingPlatformComponent.h | 4 +- dGame/dComponents/PetComponent.cpp | 2 +- dGame/dComponents/PetComponent.h | 2 +- dGame/dComponents/PhantomPhysicsComponent.cpp | 7 +- dGame/dComponents/PhantomPhysicsComponent.h | 3 +- .../PlayerForcedMovementComponent.cpp | 2 +- .../PlayerForcedMovementComponent.h | 2 +- dGame/dComponents/PossessableComponent.cpp | 2 +- dGame/dComponents/PossessableComponent.h | 2 +- dGame/dComponents/PossessorComponent.cpp | 2 +- dGame/dComponents/PossessorComponent.h | 2 +- dGame/dComponents/RacingControlComponent.cpp | 4 +- dGame/dComponents/RacingControlComponent.h | 4 +- dGame/dComponents/RebuildComponent.cpp | 2 +- dGame/dComponents/RebuildComponent.h | 2 +- dGame/dComponents/RenderComponent.cpp | 2 +- dGame/dComponents/RenderComponent.h | 2 +- .../RigidbodyPhantomPhysicsComponent.cpp | 2 +- .../RigidbodyPhantomPhysicsComponent.h | 2 +- .../dComponents/ScriptedActivityComponent.cpp | 2 +- dGame/dComponents/ScriptedActivityComponent.h | 2 +- .../dComponents/ShootingGalleryComponent.cpp | 2 +- dGame/dComponents/ShootingGalleryComponent.h | 2 +- dGame/dComponents/SimplePhysicsComponent.cpp | 2 +- dGame/dComponents/SimplePhysicsComponent.h | 2 +- dGame/dComponents/SkillComponent.cpp | 2 +- dGame/dComponents/SkillComponent.h | 2 +- dGame/dComponents/SoundTriggerComponent.cpp | 2 +- dGame/dComponents/SoundTriggerComponent.h | 3 +- dGame/dComponents/SwitchComponent.cpp | 2 +- dGame/dComponents/SwitchComponent.h | 2 +- dGame/dComponents/VehiclePhysicsComponent.cpp | 2 +- dGame/dComponents/VehiclePhysicsComponent.h | 2 +- dGame/dComponents/VendorComponent.cpp | 2 +- dGame/dComponents/VendorComponent.h | 4 +- dScripts/ScriptComponent.cpp | 2 +- dScripts/ScriptComponent.h | 2 +- .../DestroyableComponentTests.cpp | 4 +- 69 files changed, 113 insertions(+), 141 deletions(-) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 237cfa73..b5abe918 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -1020,62 +1020,60 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType */ bool destroyableSerialized = false; - bool bIsInitialUpdate = false; - if (packetType == eReplicaPacketType::CONSTRUCTION) bIsInitialUpdate = true; - unsigned int flags = 0; + bool bIsInitialUpdate = packetType == eReplicaPacketType::CONSTRUCTION; PossessableComponent* possessableComponent; if (TryGetComponent(eReplicaComponentType::POSSESSABLE, possessableComponent)) { - possessableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + possessableComponent->Serialize(outBitStream, bIsInitialUpdate); } ModuleAssemblyComponent* moduleAssemblyComponent; if (TryGetComponent(eReplicaComponentType::MODULE_ASSEMBLY, moduleAssemblyComponent)) { - moduleAssemblyComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + moduleAssemblyComponent->Serialize(outBitStream, bIsInitialUpdate); } ControllablePhysicsComponent* controllablePhysicsComponent; if (TryGetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS, controllablePhysicsComponent)) { - controllablePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + controllablePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate); } SimplePhysicsComponent* simplePhysicsComponent; if (TryGetComponent(eReplicaComponentType::SIMPLE_PHYSICS, simplePhysicsComponent)) { - simplePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + simplePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate); } RigidbodyPhantomPhysicsComponent* rigidbodyPhantomPhysics; if (TryGetComponent(eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS, rigidbodyPhantomPhysics)) { - rigidbodyPhantomPhysics->Serialize(outBitStream, bIsInitialUpdate, flags); + rigidbodyPhantomPhysics->Serialize(outBitStream, bIsInitialUpdate); } VehiclePhysicsComponent* vehiclePhysicsComponent; if (TryGetComponent(eReplicaComponentType::VEHICLE_PHYSICS, vehiclePhysicsComponent)) { - vehiclePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + vehiclePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate); } PhantomPhysicsComponent* phantomPhysicsComponent; if (TryGetComponent(eReplicaComponentType::PHANTOM_PHYSICS, phantomPhysicsComponent)) { - phantomPhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + phantomPhysicsComponent->Serialize(outBitStream, bIsInitialUpdate); } SoundTriggerComponent* soundTriggerComponent; if (TryGetComponent(eReplicaComponentType::SOUND_TRIGGER, soundTriggerComponent)) { - soundTriggerComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + soundTriggerComponent->Serialize(outBitStream, bIsInitialUpdate); } RacingSoundTriggerComponent* racingSoundTriggerComponent; if (TryGetComponent(eReplicaComponentType::RACING_SOUND_TRIGGER, racingSoundTriggerComponent)) { - racingSoundTriggerComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + racingSoundTriggerComponent->Serialize(outBitStream, bIsInitialUpdate); } BuffComponent* buffComponent; if (TryGetComponent(eReplicaComponentType::BUFF, buffComponent)) { - buffComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + buffComponent->Serialize(outBitStream, bIsInitialUpdate); DestroyableComponent* destroyableComponent; if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent)) { - destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + destroyableComponent->Serialize(outBitStream, bIsInitialUpdate); } destroyableSerialized = true; } @@ -1083,7 +1081,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType if (HasComponent(eReplicaComponentType::COLLECTIBLE)) { DestroyableComponent* destroyableComponent; if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) { - destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + destroyableComponent->Serialize(outBitStream, bIsInitialUpdate); } destroyableSerialized = true; outBitStream->Write(m_CollectibleID); // Collectable component @@ -1091,7 +1089,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType PetComponent* petComponent; if (TryGetComponent(eReplicaComponentType::PET, petComponent)) { - petComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + petComponent->Serialize(outBitStream, bIsInitialUpdate); } CharacterComponent* characterComponent; @@ -1099,7 +1097,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType PossessorComponent* possessorComponent; if (TryGetComponent(eReplicaComponentType::POSSESSOR, possessorComponent)) { - possessorComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + possessorComponent->Serialize(outBitStream, bIsInitialUpdate); } else { // Should never happen, but just to be safe outBitStream->Write0(); @@ -1107,7 +1105,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType LevelProgressionComponent* levelProgressionComponent; if (TryGetComponent(eReplicaComponentType::LEVEL_PROGRESSION, levelProgressionComponent)) { - levelProgressionComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + levelProgressionComponent->Serialize(outBitStream, bIsInitialUpdate); } else { // Should never happen, but just to be safe outBitStream->Write0(); @@ -1115,13 +1113,13 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType PlayerForcedMovementComponent* playerForcedMovementComponent; if (TryGetComponent(eReplicaComponentType::PLAYER_FORCED_MOVEMENT, playerForcedMovementComponent)) { - playerForcedMovementComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + playerForcedMovementComponent->Serialize(outBitStream, bIsInitialUpdate); } else { // Should never happen, but just to be safe outBitStream->Write0(); } - characterComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + characterComponent->Serialize(outBitStream, bIsInitialUpdate); } if (HasComponent(eReplicaComponentType::ITEM)) { @@ -1130,93 +1128,93 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType InventoryComponent* inventoryComponent; if (TryGetComponent(eReplicaComponentType::INVENTORY, inventoryComponent)) { - inventoryComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + inventoryComponent->Serialize(outBitStream, bIsInitialUpdate); } ScriptComponent* scriptComponent; if (TryGetComponent(eReplicaComponentType::SCRIPT, scriptComponent)) { - scriptComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + scriptComponent->Serialize(outBitStream, bIsInitialUpdate); } SkillComponent* skillComponent; if (TryGetComponent(eReplicaComponentType::SKILL, skillComponent)) { - skillComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + skillComponent->Serialize(outBitStream, bIsInitialUpdate); } BaseCombatAIComponent* baseCombatAiComponent; if (TryGetComponent(eReplicaComponentType::BASE_COMBAT_AI, baseCombatAiComponent)) { - baseCombatAiComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + baseCombatAiComponent->Serialize(outBitStream, bIsInitialUpdate); } RebuildComponent* rebuildComponent; if (TryGetComponent(eReplicaComponentType::QUICK_BUILD, rebuildComponent)) { DestroyableComponent* destroyableComponent; if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) { - destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + destroyableComponent->Serialize(outBitStream, bIsInitialUpdate); } destroyableSerialized = true; - rebuildComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + rebuildComponent->Serialize(outBitStream, bIsInitialUpdate); } MovingPlatformComponent* movingPlatformComponent; if (TryGetComponent(eReplicaComponentType::MOVING_PLATFORM, movingPlatformComponent)) { - movingPlatformComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + movingPlatformComponent->Serialize(outBitStream, bIsInitialUpdate); } SwitchComponent* switchComponent; if (TryGetComponent(eReplicaComponentType::SWITCH, switchComponent)) { - switchComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + switchComponent->Serialize(outBitStream, bIsInitialUpdate); } VendorComponent* vendorComponent; if (TryGetComponent(eReplicaComponentType::VENDOR, vendorComponent)) { - vendorComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + vendorComponent->Serialize(outBitStream, bIsInitialUpdate); } DonationVendorComponent* donationVendorComponent; if (TryGetComponent(eReplicaComponentType::DONATION_VENDOR, donationVendorComponent)) { - donationVendorComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + donationVendorComponent->Serialize(outBitStream, bIsInitialUpdate); } BouncerComponent* bouncerComponent; if (TryGetComponent(eReplicaComponentType::BOUNCER, bouncerComponent)) { - bouncerComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + bouncerComponent->Serialize(outBitStream, bIsInitialUpdate); } ScriptedActivityComponent* scriptedActivityComponent; if (TryGetComponent(eReplicaComponentType::SCRIPTED_ACTIVITY, scriptedActivityComponent)) { - scriptedActivityComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + scriptedActivityComponent->Serialize(outBitStream, bIsInitialUpdate); } ShootingGalleryComponent* shootingGalleryComponent; if (TryGetComponent(eReplicaComponentType::SHOOTING_GALLERY, shootingGalleryComponent)) { - shootingGalleryComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + shootingGalleryComponent->Serialize(outBitStream, bIsInitialUpdate); } RacingControlComponent* racingControlComponent; if (TryGetComponent(eReplicaComponentType::RACING_CONTROL, racingControlComponent)) { - racingControlComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + racingControlComponent->Serialize(outBitStream, bIsInitialUpdate); } LUPExhibitComponent* lupExhibitComponent; if (TryGetComponent(eReplicaComponentType::LUP_EXHIBIT, lupExhibitComponent)) { - lupExhibitComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + lupExhibitComponent->Serialize(outBitStream, bIsInitialUpdate); } ModelComponent* modelComponent; if (TryGetComponent(eReplicaComponentType::MODEL, modelComponent)) { - modelComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + modelComponent->Serialize(outBitStream, bIsInitialUpdate); } RenderComponent* renderComponent; if (TryGetComponent(eReplicaComponentType::RENDER, renderComponent)) { - renderComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + renderComponent->Serialize(outBitStream, bIsInitialUpdate); } if (modelComponent) { DestroyableComponent* destroyableComponent; if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) { - destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); + destroyableComponent->Serialize(outBitStream, bIsInitialUpdate); destroyableSerialized = true; } } @@ -1231,10 +1229,6 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType outBitStream->Write0(); } -void Entity::ResetFlags() { - // Unused -} - void Entity::UpdateXMLDoc(tinyxml2::XMLDocument* doc) { //This function should only ever be called from within Character, meaning doc should always exist when this is called. //Naturally, we don't include any non-player components in this update function. diff --git a/dGame/Entity.h b/dGame/Entity.h index ca007912..8680653f 100644 --- a/dGame/Entity.h +++ b/dGame/Entity.h @@ -174,7 +174,6 @@ public: void WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacketType packetType); void WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType packetType); - void ResetFlags(); void UpdateXMLDoc(tinyxml2::XMLDocument* doc); void Update(float deltaTime); diff --git a/dGame/EntityManager.cpp b/dGame/EntityManager.cpp index 28b5f526..699cc2a1 100644 --- a/dGame/EntityManager.cpp +++ b/dGame/EntityManager.cpp @@ -583,12 +583,6 @@ bool EntityManager::GetGhostingEnabled() const { return m_GhostingEnabled; } -void EntityManager::ResetFlags() { - for (const auto& e : m_Entities) { - e.second->ResetFlags(); - } -} - void EntityManager::ScheduleForKill(Entity* entity) { // Deactivate switches if they die if (!entity) diff --git a/dGame/EntityManager.h b/dGame/EntityManager.h index 9bea0618..693a4cc0 100644 --- a/dGame/EntityManager.h +++ b/dGame/EntityManager.h @@ -59,8 +59,6 @@ public: Entity* GetGhostCandidate(int32_t id); bool GetGhostingEnabled() const; - void ResetFlags(); - void ScheduleForKill(Entity* entity); void ScheduleForDeletion(LWOOBJID entity); diff --git a/dGame/dComponents/BaseCombatAIComponent.cpp b/dGame/dComponents/BaseCombatAIComponent.cpp index 5df43854..3afd3cc9 100644 --- a/dGame/dComponents/BaseCombatAIComponent.cpp +++ b/dGame/dComponents/BaseCombatAIComponent.cpp @@ -520,7 +520,7 @@ bool BaseCombatAIComponent::IsMech() { } -void BaseCombatAIComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void BaseCombatAIComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { outBitStream->Write(m_DirtyStateOrTarget || bIsInitialUpdate); if (m_DirtyStateOrTarget || bIsInitialUpdate) { outBitStream->Write(uint32_t(m_State)); diff --git a/dGame/dComponents/BaseCombatAIComponent.h b/dGame/dComponents/BaseCombatAIComponent.h index 8bf6140a..17b74e9c 100644 --- a/dGame/dComponents/BaseCombatAIComponent.h +++ b/dGame/dComponents/BaseCombatAIComponent.h @@ -53,7 +53,7 @@ public: ~BaseCombatAIComponent() override; void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; /** * Get the current behavioral state of the enemy diff --git a/dGame/dComponents/BouncerComponent.cpp b/dGame/dComponents/BouncerComponent.cpp index bbf928dc..a9a278e8 100644 --- a/dGame/dComponents/BouncerComponent.cpp +++ b/dGame/dComponents/BouncerComponent.cpp @@ -22,7 +22,7 @@ BouncerComponent::BouncerComponent(Entity* parent) : Component(parent) { BouncerComponent::~BouncerComponent() { } -void BouncerComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void BouncerComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { outBitStream->Write(m_PetEnabled); if (m_PetEnabled) { outBitStream->Write(m_PetBouncerEnabled); diff --git a/dGame/dComponents/BouncerComponent.h b/dGame/dComponents/BouncerComponent.h index 15665cc1..d372f5c7 100644 --- a/dGame/dComponents/BouncerComponent.h +++ b/dGame/dComponents/BouncerComponent.h @@ -17,7 +17,7 @@ public: BouncerComponent(Entity* parentEntity); ~BouncerComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; Entity* GetParentEntity() const; diff --git a/dGame/dComponents/BuffComponent.cpp b/dGame/dComponents/BuffComponent.cpp index 68b5182c..56480438 100644 --- a/dGame/dComponents/BuffComponent.cpp +++ b/dGame/dComponents/BuffComponent.cpp @@ -20,7 +20,7 @@ BuffComponent::BuffComponent(Entity* parent) : Component(parent) { BuffComponent::~BuffComponent() { } -void BuffComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void BuffComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { if (!bIsInitialUpdate) return; if (m_Buffs.empty()) { outBitStream->Write0(); diff --git a/dGame/dComponents/BuffComponent.h b/dGame/dComponents/BuffComponent.h index d9175883..61e7be5d 100644 --- a/dGame/dComponents/BuffComponent.h +++ b/dGame/dComponents/BuffComponent.h @@ -54,7 +54,7 @@ public: void UpdateXml(tinyxml2::XMLDocument* doc) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; diff --git a/dGame/dComponents/CharacterComponent.cpp b/dGame/dComponents/CharacterComponent.cpp index 10a4e9db..d5632989 100644 --- a/dGame/dComponents/CharacterComponent.cpp +++ b/dGame/dComponents/CharacterComponent.cpp @@ -70,7 +70,7 @@ bool CharacterComponent::LandingAnimDisabled(int zoneID) { CharacterComponent::~CharacterComponent() { } -void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { if (bIsInitialUpdate) { outBitStream->Write0(); diff --git a/dGame/dComponents/CharacterComponent.h b/dGame/dComponents/CharacterComponent.h index c367aefc..3a5c033b 100644 --- a/dGame/dComponents/CharacterComponent.h +++ b/dGame/dComponents/CharacterComponent.h @@ -70,7 +70,7 @@ public: void LoadFromXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; /** * Updates the rocket configuration using a LOT string separated by commas diff --git a/dGame/dComponents/Component.cpp b/dGame/dComponents/Component.cpp index ca018c29..1136456c 100644 --- a/dGame/dComponents/Component.cpp +++ b/dGame/dComponents/Component.cpp @@ -28,3 +28,7 @@ void Component::UpdateXml(tinyxml2::XMLDocument* doc) { void Component::LoadFromXml(tinyxml2::XMLDocument* doc) { } + +void Component::Serialize(RakNet::BitStream* outBitStream, bool isConstruction) { + +} diff --git a/dGame/dComponents/Component.h b/dGame/dComponents/Component.h index 9b0df9fd..c0debb0b 100644 --- a/dGame/dComponents/Component.h +++ b/dGame/dComponents/Component.h @@ -43,6 +43,8 @@ public: */ virtual void LoadFromXml(tinyxml2::XMLDocument* doc); + virtual void Serialize(RakNet::BitStream* outBitStream, bool isConstruction); + protected: /** diff --git a/dGame/dComponents/ControllablePhysicsComponent.cpp b/dGame/dComponents/ControllablePhysicsComponent.cpp index a658ccd7..de27149e 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.cpp +++ b/dGame/dComponents/ControllablePhysicsComponent.cpp @@ -74,7 +74,7 @@ void ControllablePhysicsComponent::Update(float deltaTime) { } -void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { //If this is a creation, then we assume the position is dirty, even when it isn't. //This is because new clients will still need to receive the position. //if (bIsInitialUpdate) m_DirtyPosition = true; @@ -181,12 +181,6 @@ void ControllablePhysicsComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { m_DirtyPosition = true; } -void ControllablePhysicsComponent::ResetFlags() { - m_DirtyAngularVelocity = false; - m_DirtyPosition = false; - m_DirtyVelocity = false; -} - void ControllablePhysicsComponent::UpdateXml(tinyxml2::XMLDocument* doc) { tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char"); if (!character) { diff --git a/dGame/dComponents/ControllablePhysicsComponent.h b/dGame/dComponents/ControllablePhysicsComponent.h index 470a7af4..384dfdac 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.h +++ b/dGame/dComponents/ControllablePhysicsComponent.h @@ -27,9 +27,8 @@ public: ~ControllablePhysicsComponent() override; void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; void LoadFromXml(tinyxml2::XMLDocument* doc) override; - void ResetFlags(); void UpdateXml(tinyxml2::XMLDocument* doc) override; /** diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index 4c726bad..0adf62f3 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -119,7 +119,7 @@ void DestroyableComponent::Reinitialize(LOT templateID) { } } -void DestroyableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags) { +void DestroyableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { if (bIsInitialUpdate) { outBitStream->Write1(); // always write these on construction outBitStream->Write(m_ImmuneToBasicAttackCount); diff --git a/dGame/dComponents/DestroyableComponent.h b/dGame/dComponents/DestroyableComponent.h index 5e5133b7..ed091066 100644 --- a/dGame/dComponents/DestroyableComponent.h +++ b/dGame/dComponents/DestroyableComponent.h @@ -24,7 +24,7 @@ public: DestroyableComponent(Entity* parentEntity); ~DestroyableComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; void LoadFromXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override; diff --git a/dGame/dComponents/DonationVendorComponent.cpp b/dGame/dComponents/DonationVendorComponent.cpp index f19ba9b7..7f85ea97 100644 --- a/dGame/dComponents/DonationVendorComponent.cpp +++ b/dGame/dComponents/DonationVendorComponent.cpp @@ -38,8 +38,8 @@ void DonationVendorComponent::SubmitDonation(uint32_t count) { m_DirtyDonationVendor = true; } -void DonationVendorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { - VendorComponent::Serialize(outBitStream, bIsInitialUpdate, flags); +void DonationVendorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { + VendorComponent::Serialize(outBitStream, bIsInitialUpdate); outBitStream->Write(bIsInitialUpdate || m_DirtyDonationVendor); if (bIsInitialUpdate || m_DirtyDonationVendor) { outBitStream->Write(m_PercentComplete); diff --git a/dGame/dComponents/DonationVendorComponent.h b/dGame/dComponents/DonationVendorComponent.h index 6c706bf9..d1743118 100644 --- a/dGame/dComponents/DonationVendorComponent.h +++ b/dGame/dComponents/DonationVendorComponent.h @@ -10,7 +10,7 @@ class DonationVendorComponent final : public VendorComponent { public: inline static const eReplicaComponentType ComponentType = eReplicaComponentType::DONATION_VENDOR; DonationVendorComponent(Entity* parent); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; uint32_t GetActivityID() {return m_ActivityId;}; void SubmitDonation(uint32_t count); diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 8689c0bc..3625defc 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -712,7 +712,7 @@ void InventoryComponent::UpdateXml(tinyxml2::XMLDocument* document) { } } -void InventoryComponent::Serialize(RakNet::BitStream* outBitStream, const bool bIsInitialUpdate, unsigned& flags) { +void InventoryComponent::Serialize(RakNet::BitStream* outBitStream, const bool bIsInitialUpdate) { if (bIsInitialUpdate || m_Dirty) { outBitStream->Write(true); @@ -770,10 +770,6 @@ void InventoryComponent::Serialize(RakNet::BitStream* outBitStream, const bool b outBitStream->Write(false); } -void InventoryComponent::ResetFlags() { - m_Dirty = false; -} - void InventoryComponent::Update(float deltaTime) { for (auto* set : m_Itemsets) { set->Update(deltaTime); diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index 801f9f51..ffb7a360 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -42,10 +42,9 @@ public: explicit InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document = nullptr); void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; void LoadXml(tinyxml2::XMLDocument* document); void UpdateXml(tinyxml2::XMLDocument* document) override; - void ResetFlags(); /** * Returns an inventory of the specified type, if it exists diff --git a/dGame/dComponents/LUPExhibitComponent.cpp b/dGame/dComponents/LUPExhibitComponent.cpp index deb3cc8c..151f2897 100644 --- a/dGame/dComponents/LUPExhibitComponent.cpp +++ b/dGame/dComponents/LUPExhibitComponent.cpp @@ -38,7 +38,7 @@ void LUPExhibitComponent::NextExhibit() { Game::entityManager->SerializeEntity(m_Parent); } -void LUPExhibitComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags) { +void LUPExhibitComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { outBitStream->Write1(); // Dirty flag? outBitStream->Write(m_Exhibit); } diff --git a/dGame/dComponents/LUPExhibitComponent.h b/dGame/dComponents/LUPExhibitComponent.h index 587d1b2f..510c42fe 100644 --- a/dGame/dComponents/LUPExhibitComponent.h +++ b/dGame/dComponents/LUPExhibitComponent.h @@ -16,7 +16,7 @@ public: LUPExhibitComponent(Entity* parent); ~LUPExhibitComponent(); void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; /** * After the timer runs out, this changes the currently exhibited LOT to the next one diff --git a/dGame/dComponents/LevelProgressionComponent.cpp b/dGame/dComponents/LevelProgressionComponent.cpp index 8163e736..265dd8e6 100644 --- a/dGame/dComponents/LevelProgressionComponent.cpp +++ b/dGame/dComponents/LevelProgressionComponent.cpp @@ -37,7 +37,7 @@ void LevelProgressionComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { m_CharacterVersion = static_cast(characterVersion); } -void LevelProgressionComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void LevelProgressionComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { outBitStream->Write(bIsInitialUpdate || m_DirtyLevelInfo); if (bIsInitialUpdate || m_DirtyLevelInfo) outBitStream->Write(m_Level); m_DirtyLevelInfo = false; diff --git a/dGame/dComponents/LevelProgressionComponent.h b/dGame/dComponents/LevelProgressionComponent.h index 06908a81..17ca8117 100644 --- a/dGame/dComponents/LevelProgressionComponent.h +++ b/dGame/dComponents/LevelProgressionComponent.h @@ -21,7 +21,7 @@ public: */ LevelProgressionComponent(Entity* parent); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; /** * Save data from this componennt to character XML diff --git a/dGame/dComponents/ModelComponent.cpp b/dGame/dComponents/ModelComponent.cpp index 74f614d1..ccdad281 100644 --- a/dGame/dComponents/ModelComponent.cpp +++ b/dGame/dComponents/ModelComponent.cpp @@ -8,7 +8,7 @@ ModelComponent::ModelComponent(Entity* parent) : Component(parent) { m_userModelID = m_Parent->GetVarAs(u"userModelID"); } -void ModelComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void ModelComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { // ItemComponent Serialization. Pets do not get this serialization. if (!m_Parent->HasComponent(eReplicaComponentType::PET)) { outBitStream->Write1(); diff --git a/dGame/dComponents/ModelComponent.h b/dGame/dComponents/ModelComponent.h index b5224869..c961bff0 100644 --- a/dGame/dComponents/ModelComponent.h +++ b/dGame/dComponents/ModelComponent.h @@ -17,7 +17,7 @@ public: ModelComponent(Entity* parent); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; /** * Returns the original position of the model diff --git a/dGame/dComponents/ModuleAssemblyComponent.cpp b/dGame/dComponents/ModuleAssemblyComponent.cpp index 8e197f0c..9089c14c 100644 --- a/dGame/dComponents/ModuleAssemblyComponent.cpp +++ b/dGame/dComponents/ModuleAssemblyComponent.cpp @@ -46,7 +46,7 @@ const std::u16string& ModuleAssemblyComponent::GetAssemblyPartsLOTs() const { return m_AssemblyPartsLOTs; } -void ModuleAssemblyComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void ModuleAssemblyComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { if (bIsInitialUpdate) { outBitStream->Write1(); diff --git a/dGame/dComponents/ModuleAssemblyComponent.h b/dGame/dComponents/ModuleAssemblyComponent.h index 39670c9a..6ee5f505 100644 --- a/dGame/dComponents/ModuleAssemblyComponent.h +++ b/dGame/dComponents/ModuleAssemblyComponent.h @@ -17,7 +17,7 @@ public: ModuleAssemblyComponent(Entity* parent); ~ModuleAssemblyComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; /** diff --git a/dGame/dComponents/MovingPlatformComponent.cpp b/dGame/dComponents/MovingPlatformComponent.cpp index f4dcdbe9..60d320f4 100644 --- a/dGame/dComponents/MovingPlatformComponent.cpp +++ b/dGame/dComponents/MovingPlatformComponent.cpp @@ -32,7 +32,7 @@ MoverSubComponent::MoverSubComponent(const NiPoint3& startPos) { MoverSubComponent::~MoverSubComponent() = default; -void MoverSubComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) const { +void MoverSubComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { outBitStream->Write(true); outBitStream->Write(static_cast(mState)); @@ -71,7 +71,7 @@ MovingPlatformComponent::~MovingPlatformComponent() { delete static_cast(m_MoverSubComponent); } -void MovingPlatformComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void MovingPlatformComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { // Here we don't serialize the moving platform to let the client simulate the movement if (!m_Serialize) { @@ -112,7 +112,7 @@ void MovingPlatformComponent::Serialize(RakNet::BitStream* outBitStream, bool bI if (m_MoverSubComponentType == eMoverSubComponentType::simpleMover) { // TODO } else { - mover->Serialize(outBitStream, bIsInitialUpdate, flags); + mover->Serialize(outBitStream, bIsInitialUpdate); } } } diff --git a/dGame/dComponents/MovingPlatformComponent.h b/dGame/dComponents/MovingPlatformComponent.h index 9e4c1ecf..bb83a538 100644 --- a/dGame/dComponents/MovingPlatformComponent.h +++ b/dGame/dComponents/MovingPlatformComponent.h @@ -38,7 +38,7 @@ public: MoverSubComponent(const NiPoint3& startPos); ~MoverSubComponent(); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) const; + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate); /** * The state the platform is currently in @@ -111,7 +111,7 @@ public: MovingPlatformComponent(Entity* parent, const std::string& pathName); ~MovingPlatformComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; /** * Stops all pathing, called when an entity starts a quick build associated with this platform diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index 7df08c60..5132af08 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -107,7 +107,7 @@ PetComponent::PetComponent(Entity* parent, uint32_t componentId): Component(pare result.finalize(); } -void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { const bool tamed = m_Owner != LWOOBJID_EMPTY; outBitStream->Write1(); // Always serialize as dirty for now diff --git a/dGame/dComponents/PetComponent.h b/dGame/dComponents/PetComponent.h index b3d089a9..4ca6a49e 100644 --- a/dGame/dComponents/PetComponent.h +++ b/dGame/dComponents/PetComponent.h @@ -26,7 +26,7 @@ public: explicit PetComponent(Entity* parentEntity, uint32_t componentId); ~PetComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; /** diff --git a/dGame/dComponents/PhantomPhysicsComponent.cpp b/dGame/dComponents/PhantomPhysicsComponent.cpp index 640281f8..866543b3 100644 --- a/dGame/dComponents/PhantomPhysicsComponent.cpp +++ b/dGame/dComponents/PhantomPhysicsComponent.cpp @@ -306,7 +306,7 @@ void PhantomPhysicsComponent::CreatePhysics() { m_HasCreatedPhysics = true; } -void PhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void PhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { outBitStream->Write(m_PositionInfoDirty || bIsInitialUpdate); if (m_PositionInfoDirty || bIsInitialUpdate) { outBitStream->Write(m_Position.x); @@ -348,11 +348,6 @@ void PhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bI } } -void PhantomPhysicsComponent::ResetFlags() { - m_EffectInfoDirty = false; - m_PositionInfoDirty = false; -} - void PhantomPhysicsComponent::Update(float deltaTime) { if (!m_dpEntity) return; diff --git a/dGame/dComponents/PhantomPhysicsComponent.h b/dGame/dComponents/PhantomPhysicsComponent.h index cc0d1844..e5769f40 100644 --- a/dGame/dComponents/PhantomPhysicsComponent.h +++ b/dGame/dComponents/PhantomPhysicsComponent.h @@ -32,8 +32,7 @@ public: PhantomPhysicsComponent(Entity* parent); ~PhantomPhysicsComponent() override; void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); - void ResetFlags(); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; /** * Creates the physics shape for this entity based on LDF data diff --git a/dGame/dComponents/PlayerForcedMovementComponent.cpp b/dGame/dComponents/PlayerForcedMovementComponent.cpp index 76993507..d511ad78 100644 --- a/dGame/dComponents/PlayerForcedMovementComponent.cpp +++ b/dGame/dComponents/PlayerForcedMovementComponent.cpp @@ -6,7 +6,7 @@ PlayerForcedMovementComponent::PlayerForcedMovementComponent(Entity* parent) : C PlayerForcedMovementComponent::~PlayerForcedMovementComponent() {} -void PlayerForcedMovementComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void PlayerForcedMovementComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { outBitStream->Write(m_DirtyInfo || bIsInitialUpdate); if (m_DirtyInfo || bIsInitialUpdate) { outBitStream->Write(m_PlayerOnRail); diff --git a/dGame/dComponents/PlayerForcedMovementComponent.h b/dGame/dComponents/PlayerForcedMovementComponent.h index 90708c9a..43781bab 100644 --- a/dGame/dComponents/PlayerForcedMovementComponent.h +++ b/dGame/dComponents/PlayerForcedMovementComponent.h @@ -19,7 +19,7 @@ public: PlayerForcedMovementComponent(Entity* parent); ~PlayerForcedMovementComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; /** * @brief Set the Player On Rail object diff --git a/dGame/dComponents/PossessableComponent.cpp b/dGame/dComponents/PossessableComponent.cpp index 5c45a6c1..509b1a07 100644 --- a/dGame/dComponents/PossessableComponent.cpp +++ b/dGame/dComponents/PossessableComponent.cpp @@ -27,7 +27,7 @@ PossessableComponent::PossessableComponent(Entity* parent, uint32_t componentId) result.finalize(); } -void PossessableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void PossessableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { outBitStream->Write(m_DirtyPossessable || bIsInitialUpdate); if (m_DirtyPossessable || bIsInitialUpdate) { m_DirtyPossessable = false; // reset flag diff --git a/dGame/dComponents/PossessableComponent.h b/dGame/dComponents/PossessableComponent.h index 2026c11e..be60bb77 100644 --- a/dGame/dComponents/PossessableComponent.h +++ b/dGame/dComponents/PossessableComponent.h @@ -18,7 +18,7 @@ public: PossessableComponent(Entity* parentEntity, uint32_t componentId); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; /** * @brief mounts the Entity diff --git a/dGame/dComponents/PossessorComponent.cpp b/dGame/dComponents/PossessorComponent.cpp index 8019f91c..0cb64956 100644 --- a/dGame/dComponents/PossessorComponent.cpp +++ b/dGame/dComponents/PossessorComponent.cpp @@ -26,7 +26,7 @@ PossessorComponent::~PossessorComponent() { } } -void PossessorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void PossessorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { outBitStream->Write(m_DirtyPossesor || bIsInitialUpdate); if (m_DirtyPossesor || bIsInitialUpdate) { m_DirtyPossesor = false; diff --git a/dGame/dComponents/PossessorComponent.h b/dGame/dComponents/PossessorComponent.h index 4456af27..d21695f0 100644 --- a/dGame/dComponents/PossessorComponent.h +++ b/dGame/dComponents/PossessorComponent.h @@ -23,7 +23,7 @@ public: PossessorComponent(Entity* parent); ~PossessorComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; /** * @brief Mounts the entity diff --git a/dGame/dComponents/RacingControlComponent.cpp b/dGame/dComponents/RacingControlComponent.cpp index 5de24445..7a4d98ea 100644 --- a/dGame/dComponents/RacingControlComponent.cpp +++ b/dGame/dComponents/RacingControlComponent.cpp @@ -424,9 +424,7 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t bu } } -void RacingControlComponent::Serialize(RakNet::BitStream* outBitStream, - bool bIsInitialUpdate, - unsigned int& flags) { +void RacingControlComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { // BEGIN Scripted Activity outBitStream->Write1(); diff --git a/dGame/dComponents/RacingControlComponent.h b/dGame/dComponents/RacingControlComponent.h index a81121e1..c713a759 100644 --- a/dGame/dComponents/RacingControlComponent.h +++ b/dGame/dComponents/RacingControlComponent.h @@ -110,8 +110,8 @@ public: RacingControlComponent(Entity* parentEntity); ~RacingControlComponent(); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); - void Update(float deltaTime); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Update(float deltaTime) override; /** * Invoked when a player loads into the zone. diff --git a/dGame/dComponents/RebuildComponent.cpp b/dGame/dComponents/RebuildComponent.cpp index e669489d..3f38c275 100644 --- a/dGame/dComponents/RebuildComponent.cpp +++ b/dGame/dComponents/RebuildComponent.cpp @@ -57,7 +57,7 @@ RebuildComponent::~RebuildComponent() { DespawnActivator(); } -void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { if (m_Parent->GetComponent(eReplicaComponentType::DESTROYABLE) == nullptr) { if (bIsInitialUpdate) { outBitStream->Write(false); diff --git a/dGame/dComponents/RebuildComponent.h b/dGame/dComponents/RebuildComponent.h index 09dd0465..cd266c1f 100644 --- a/dGame/dComponents/RebuildComponent.h +++ b/dGame/dComponents/RebuildComponent.h @@ -27,7 +27,7 @@ public: RebuildComponent(Entity* entity); ~RebuildComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; /** diff --git a/dGame/dComponents/RenderComponent.cpp b/dGame/dComponents/RenderComponent.cpp index 94f5fb5d..44663a17 100644 --- a/dGame/dComponents/RenderComponent.cpp +++ b/dGame/dComponents/RenderComponent.cpp @@ -54,7 +54,7 @@ RenderComponent::~RenderComponent() { m_Effects.clear(); } -void RenderComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void RenderComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { if (!bIsInitialUpdate) return; outBitStream->Write(m_Effects.size()); diff --git a/dGame/dComponents/RenderComponent.h b/dGame/dComponents/RenderComponent.h index cdf32160..24cfd16d 100644 --- a/dGame/dComponents/RenderComponent.h +++ b/dGame/dComponents/RenderComponent.h @@ -61,7 +61,7 @@ public: RenderComponent(Entity* entity, int32_t componentId = -1); ~RenderComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; /** diff --git a/dGame/dComponents/RigidbodyPhantomPhysicsComponent.cpp b/dGame/dComponents/RigidbodyPhantomPhysicsComponent.cpp index babd1974..5390db3a 100644 --- a/dGame/dComponents/RigidbodyPhantomPhysicsComponent.cpp +++ b/dGame/dComponents/RigidbodyPhantomPhysicsComponent.cpp @@ -15,7 +15,7 @@ RigidbodyPhantomPhysicsComponent::RigidbodyPhantomPhysicsComponent(Entity* paren RigidbodyPhantomPhysicsComponent::~RigidbodyPhantomPhysicsComponent() { } -void RigidbodyPhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void RigidbodyPhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { outBitStream->Write(m_IsDirty || bIsInitialUpdate); if (m_IsDirty || bIsInitialUpdate) { outBitStream->Write(m_Position.x); diff --git a/dGame/dComponents/RigidbodyPhantomPhysicsComponent.h b/dGame/dComponents/RigidbodyPhantomPhysicsComponent.h index 480f9b81..ba6a54a0 100644 --- a/dGame/dComponents/RigidbodyPhantomPhysicsComponent.h +++ b/dGame/dComponents/RigidbodyPhantomPhysicsComponent.h @@ -24,7 +24,7 @@ public: RigidbodyPhantomPhysicsComponent(Entity* parent); ~RigidbodyPhantomPhysicsComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; /** * Returns the position of this entity diff --git a/dGame/dComponents/ScriptedActivityComponent.cpp b/dGame/dComponents/ScriptedActivityComponent.cpp index 81b3e9a9..e971aa30 100644 --- a/dGame/dComponents/ScriptedActivityComponent.cpp +++ b/dGame/dComponents/ScriptedActivityComponent.cpp @@ -82,7 +82,7 @@ ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activit ScriptedActivityComponent::~ScriptedActivityComponent() = default; -void ScriptedActivityComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) const { +void ScriptedActivityComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { outBitStream->Write(true); outBitStream->Write(m_ActivityPlayers.size()); diff --git a/dGame/dComponents/ScriptedActivityComponent.h b/dGame/dComponents/ScriptedActivityComponent.h index 1d49a62d..455ac667 100644 --- a/dGame/dComponents/ScriptedActivityComponent.h +++ b/dGame/dComponents/ScriptedActivityComponent.h @@ -162,7 +162,7 @@ public: ~ScriptedActivityComponent() override; void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) const; + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; /** * Makes some entity join the minigame, if it's a lobbied one, the entity will be placed in the lobby diff --git a/dGame/dComponents/ShootingGalleryComponent.cpp b/dGame/dComponents/ShootingGalleryComponent.cpp index ed91ac96..92208598 100644 --- a/dGame/dComponents/ShootingGalleryComponent.cpp +++ b/dGame/dComponents/ShootingGalleryComponent.cpp @@ -17,7 +17,7 @@ void ShootingGalleryComponent::SetDynamicParams(const DynamicShootingGalleryPara Game::entityManager->SerializeEntity(m_Parent); } -void ShootingGalleryComponent::Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate, uint32_t& flags) const { +void ShootingGalleryComponent::Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate) { // Start ScriptedActivityComponent outBitStream->Write(true); if (m_CurrentPlayerID == LWOOBJID_EMPTY) { diff --git a/dGame/dComponents/ShootingGalleryComponent.h b/dGame/dComponents/ShootingGalleryComponent.h index c31575f1..bc1aa090 100644 --- a/dGame/dComponents/ShootingGalleryComponent.h +++ b/dGame/dComponents/ShootingGalleryComponent.h @@ -77,7 +77,7 @@ public: explicit ShootingGalleryComponent(Entity* parent); ~ShootingGalleryComponent(); - void Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate, uint32_t& flags) const; + void Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate) override; /** * Returns the static params for the shooting gallery diff --git a/dGame/dComponents/SimplePhysicsComponent.cpp b/dGame/dComponents/SimplePhysicsComponent.cpp index 54a2e616..3cd95169 100644 --- a/dGame/dComponents/SimplePhysicsComponent.cpp +++ b/dGame/dComponents/SimplePhysicsComponent.cpp @@ -33,7 +33,7 @@ SimplePhysicsComponent::SimplePhysicsComponent(uint32_t componentID, Entity* par SimplePhysicsComponent::~SimplePhysicsComponent() { } -void SimplePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void SimplePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { if (bIsInitialUpdate) { outBitStream->Write(m_ClimbableType != eClimbableType::CLIMBABLE_TYPE_NOT); outBitStream->Write(m_ClimbableType); diff --git a/dGame/dComponents/SimplePhysicsComponent.h b/dGame/dComponents/SimplePhysicsComponent.h index 51356710..4908c8ef 100644 --- a/dGame/dComponents/SimplePhysicsComponent.h +++ b/dGame/dComponents/SimplePhysicsComponent.h @@ -33,7 +33,7 @@ public: SimplePhysicsComponent(uint32_t componentID, Entity* parent); ~SimplePhysicsComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; /** * Returns the position of this entity diff --git a/dGame/dComponents/SkillComponent.cpp b/dGame/dComponents/SkillComponent.cpp index 5c1d221a..c32e1b43 100644 --- a/dGame/dComponents/SkillComponent.cpp +++ b/dGame/dComponents/SkillComponent.cpp @@ -485,7 +485,7 @@ SkillComponent::~SkillComponent() { Reset(); } -void SkillComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void SkillComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { if (bIsInitialUpdate) outBitStream->Write0(); } diff --git a/dGame/dComponents/SkillComponent.h b/dGame/dComponents/SkillComponent.h index 034e65ce..b157ad3d 100644 --- a/dGame/dComponents/SkillComponent.h +++ b/dGame/dComponents/SkillComponent.h @@ -64,7 +64,7 @@ public: explicit SkillComponent(Entity* parent); ~SkillComponent() override; - static void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; /** * Computes skill updates. Invokes CalculateUpdate. diff --git a/dGame/dComponents/SoundTriggerComponent.cpp b/dGame/dComponents/SoundTriggerComponent.cpp index 823d3ff4..dc7355db 100644 --- a/dGame/dComponents/SoundTriggerComponent.cpp +++ b/dGame/dComponents/SoundTriggerComponent.cpp @@ -55,7 +55,7 @@ SoundTriggerComponent::SoundTriggerComponent(Entity* parent) : Component(parent) if (!mixerName.empty()) this->m_MixerPrograms.push_back(MixerProgram(mixerName)); } -void SoundTriggerComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void SoundTriggerComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { outBitStream->Write(this->m_Dirty || bIsInitialUpdate); if (this->m_Dirty || bIsInitialUpdate) { outBitStream->Write(this->m_MusicCues.size()); diff --git a/dGame/dComponents/SoundTriggerComponent.h b/dGame/dComponents/SoundTriggerComponent.h index 6d42a2e3..3873d6ed 100644 --- a/dGame/dComponents/SoundTriggerComponent.h +++ b/dGame/dComponents/SoundTriggerComponent.h @@ -59,9 +59,8 @@ struct MixerProgram{ class SoundTriggerComponent : public Component { public: static const eReplicaComponentType ComponentType = eReplicaComponentType::SOUND_TRIGGER; - explicit SoundTriggerComponent(Entity* parent); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; void ActivateMusicCue(const std::string& name, float bordemTime = -1.0); void DeactivateMusicCue(const std::string& name); diff --git a/dGame/dComponents/SwitchComponent.cpp b/dGame/dComponents/SwitchComponent.cpp index eee54342..41dff9f5 100644 --- a/dGame/dComponents/SwitchComponent.cpp +++ b/dGame/dComponents/SwitchComponent.cpp @@ -21,7 +21,7 @@ SwitchComponent::~SwitchComponent() { } } -void SwitchComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void SwitchComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { outBitStream->Write(m_Active); } diff --git a/dGame/dComponents/SwitchComponent.h b/dGame/dComponents/SwitchComponent.h index fde3cfc0..f262f44c 100644 --- a/dGame/dComponents/SwitchComponent.h +++ b/dGame/dComponents/SwitchComponent.h @@ -25,7 +25,7 @@ public: Entity* GetParentEntity() const; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; /** * Sets whether the switch is on or off. diff --git a/dGame/dComponents/VehiclePhysicsComponent.cpp b/dGame/dComponents/VehiclePhysicsComponent.cpp index 684b135b..79b6cc82 100644 --- a/dGame/dComponents/VehiclePhysicsComponent.cpp +++ b/dGame/dComponents/VehiclePhysicsComponent.cpp @@ -72,7 +72,7 @@ void VehiclePhysicsComponent::SetDirtyAngularVelocity(bool val) { m_DirtyAngularVelocity = val; } -void VehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void VehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { outBitStream->Write(bIsInitialUpdate || m_DirtyPosition); if (bIsInitialUpdate || m_DirtyPosition) { diff --git a/dGame/dComponents/VehiclePhysicsComponent.h b/dGame/dComponents/VehiclePhysicsComponent.h index e314bef1..602fc135 100644 --- a/dGame/dComponents/VehiclePhysicsComponent.h +++ b/dGame/dComponents/VehiclePhysicsComponent.h @@ -33,7 +33,7 @@ public: VehiclePhysicsComponent(Entity* parentEntity); ~VehiclePhysicsComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; diff --git a/dGame/dComponents/VendorComponent.cpp b/dGame/dComponents/VendorComponent.cpp index 245ea9b1..e5e0f3d8 100644 --- a/dGame/dComponents/VendorComponent.cpp +++ b/dGame/dComponents/VendorComponent.cpp @@ -16,7 +16,7 @@ VendorComponent::VendorComponent(Entity* parent) : Component(parent) { RefreshInventory(true); } -void VendorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void VendorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { outBitStream->Write(bIsInitialUpdate || m_DirtyVendor); if (bIsInitialUpdate || m_DirtyVendor) { outBitStream->Write(m_HasStandardCostItems); diff --git a/dGame/dComponents/VendorComponent.h b/dGame/dComponents/VendorComponent.h index 4a9b582e..7924a928 100644 --- a/dGame/dComponents/VendorComponent.h +++ b/dGame/dComponents/VendorComponent.h @@ -22,7 +22,9 @@ class VendorComponent : public Component { public: inline static const eReplicaComponentType ComponentType = eReplicaComponentType::VENDOR; VendorComponent(Entity* parent); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void OnUse(Entity* originator) override; void RefreshInventory(bool isCreation = false); void SetupConstants(); diff --git a/dScripts/ScriptComponent.cpp b/dScripts/ScriptComponent.cpp index 272de5ab..2079d67a 100644 --- a/dScripts/ScriptComponent.cpp +++ b/dScripts/ScriptComponent.cpp @@ -17,7 +17,7 @@ ScriptComponent::~ScriptComponent() { } -void ScriptComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { +void ScriptComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { if (bIsInitialUpdate) { const auto& networkSettings = m_Parent->GetNetworkSettings(); auto hasNetworkSettings = !networkSettings.empty(); diff --git a/dScripts/ScriptComponent.h b/dScripts/ScriptComponent.h index 77dff5bf..98925eb4 100644 --- a/dScripts/ScriptComponent.h +++ b/dScripts/ScriptComponent.h @@ -24,7 +24,7 @@ public: ScriptComponent(Entity* parent, std::string scriptName, bool serialized, bool client = false); ~ScriptComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; /** * Returns the script that's attached to this entity diff --git a/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp b/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp index db9c033a..85507b4e 100644 --- a/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp @@ -41,7 +41,7 @@ protected: * Test Construction of a DestroyableComponent */ TEST_F(DestroyableTest, DestroyableComponentSerializeConstructionTest) { - destroyableComponent->Serialize(&bitStream, true, flags); + destroyableComponent->Serialize(&bitStream, true); // Assert that the full number of bits are present ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 748); { @@ -171,7 +171,7 @@ TEST_F(DestroyableTest, DestroyableComponentSerializeTest) { destroyableComponent->SetMaxHealth(1233.0f); // Now we test a serialization for correctness. - destroyableComponent->Serialize(&bitStream, false, flags); + destroyableComponent->Serialize(&bitStream, false); ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 422); { // Now read in the full serialized BitStream From beaceb947b74836def684448ab1a6d766c52a866 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Thu, 10 Aug 2023 16:35:12 -0500 Subject: [PATCH 4/5] fix: Properly read in scene metadata (#1170) * fix: Properly read in scene metadata * Fix reading in rental time and period from property path * remove useless name in var change hex to decimal so it's readable fix scene transistion loop logic * fix typoe and remove whitespace --- dZoneManager/Zone.cpp | 57 ++++++++++++++++++++++++------------------- dZoneManager/Zone.h | 36 ++++++++++++++++----------- 2 files changed, 54 insertions(+), 39 deletions(-) diff --git a/dZoneManager/Zone.cpp b/dZoneManager/Zone.cpp index 6b153706..99fbd6ff 100644 --- a/dZoneManager/Zone.cpp +++ b/dZoneManager/Zone.cpp @@ -54,22 +54,22 @@ void Zone::LoadZoneIntoMemory() { std::istream file(&buffer); if (file) { - BinaryIO::BinaryRead(file, m_ZoneFileFormatVersion); + BinaryIO::BinaryRead(file, m_FileFormatVersion); uint32_t mapRevision = 0; - if (m_ZoneFileFormatVersion >= Zone::ZoneFileFormatVersion::Alpha) BinaryIO::BinaryRead(file, mapRevision); + if (m_FileFormatVersion >= Zone::FileFormatVersion::Alpha) BinaryIO::BinaryRead(file, mapRevision); BinaryIO::BinaryRead(file, m_WorldID); if ((uint16_t)m_WorldID != m_ZoneID.GetMapID()) Game::logger->Log("Zone", "WorldID: %i doesn't match MapID %i! Is this intended?", m_WorldID, m_ZoneID.GetMapID()); AddRevision(LWOSCENEID_INVALID, mapRevision); - if (m_ZoneFileFormatVersion >= Zone::ZoneFileFormatVersion::Beta) { + if (m_FileFormatVersion >= Zone::FileFormatVersion::Beta) { BinaryIO::BinaryRead(file, m_Spawnpoint); BinaryIO::BinaryRead(file, m_SpawnpointRotation); } - if (m_ZoneFileFormatVersion <= Zone::ZoneFileFormatVersion::LateAlpha) { + if (m_FileFormatVersion <= Zone::FileFormatVersion::LateAlpha) { uint8_t sceneCount; BinaryIO::BinaryRead(file, sceneCount); m_SceneCount = sceneCount; @@ -93,14 +93,14 @@ void Zone::LoadZoneIntoMemory() { BinaryIO::BinaryRead(file, stringLength); m_ZoneDesc = BinaryIO::ReadString(file, stringLength); - if (m_ZoneFileFormatVersion >= Zone::ZoneFileFormatVersion::PreAlpha) { + if (m_FileFormatVersion >= Zone::FileFormatVersion::PreAlpha) { BinaryIO::BinaryRead(file, m_NumberOfSceneTransitionsLoaded); for (uint32_t i = 0; i < m_NumberOfSceneTransitionsLoaded; ++i) { LoadSceneTransition(file); } } - if (m_ZoneFileFormatVersion >= Zone::ZoneFileFormatVersion::EarlyAlpha) { + if (m_FileFormatVersion >= Zone::FileFormatVersion::EarlyAlpha) { BinaryIO::BinaryRead(file, m_PathDataLength); BinaryIO::BinaryRead(file, m_PathChunkVersion); // always should be 1 @@ -244,16 +244,29 @@ void Zone::LoadScene(std::istream& file) { scene.triggers.insert({ trigger->id, trigger }); } - BinaryIO::BinaryRead(file, scene.id); - BinaryIO::BinaryRead(file, scene.sceneType); - lwoSceneID.SetSceneID(scene.id); + if (m_FileFormatVersion >= Zone::FileFormatVersion::LatePreAlpha || m_FileFormatVersion < Zone::FileFormatVersion::PrePreAlpha) { + BinaryIO::BinaryRead(file, scene.id); + lwoSceneID.SetSceneID(scene.id); + } + if (m_FileFormatVersion >= Zone::FileFormatVersion::LatePreAlpha) { + BinaryIO::BinaryRead(file, scene.sceneType); + lwoSceneID.SetLayerID(scene.sceneType); - uint8_t sceneNameLength; - BinaryIO::BinaryRead(file, sceneNameLength); - scene.name = BinaryIO::ReadString(file, sceneNameLength); - file.ignore(3); + uint8_t sceneNameLength; + BinaryIO::BinaryRead(file, sceneNameLength); + scene.name = BinaryIO::ReadString(file, sceneNameLength); + } - lwoSceneID.SetLayerID(scene.sceneType); + if (m_FileFormatVersion == Zone::FileFormatVersion::LatePreAlpha){ + BinaryIO::BinaryRead(file, scene.unknown1); + BinaryIO::BinaryRead(file, scene.unknown2); + } + + if (m_FileFormatVersion >= Zone::FileFormatVersion::LatePreAlpha) { + BinaryIO::BinaryRead(file, scene.color_r); + BinaryIO::BinaryRead(file, scene.color_b); + BinaryIO::BinaryRead(file, scene.color_g); + } m_Scenes.insert(std::make_pair(lwoSceneID, scene)); m_NumberOfScenesLoaded++; @@ -345,7 +358,7 @@ const Path* Zone::GetPath(std::string name) const { void Zone::LoadSceneTransition(std::istream& file) { SceneTransition sceneTrans; - if (m_ZoneFileFormatVersion < Zone::ZoneFileFormatVersion::Auramar) { + if (m_FileFormatVersion < Zone::FileFormatVersion::Auramar) { uint8_t length; BinaryIO::BinaryRead(file, length); sceneTrans.name = BinaryIO::ReadString(file, length); @@ -353,7 +366,7 @@ void Zone::LoadSceneTransition(std::istream& file) { } //BR�THER MAY I HAVE SOME L��PS? - uint8_t loops = (m_ZoneFileFormatVersion < Zone::ZoneFileFormatVersion::EarlyAlpha || m_ZoneFileFormatVersion >= Zone::ZoneFileFormatVersion::Launch) ? 2 : 5; + uint8_t loops = (m_FileFormatVersion <= Zone::FileFormatVersion::LatePreAlpha || m_FileFormatVersion >= Zone::FileFormatVersion::Launch) ? 2 : 5; for (uint8_t i = 0; i < loops; ++i) { sceneTrans.points.push_back(LoadSceneTransitionInfo(file)); @@ -401,7 +414,7 @@ void Zone::LoadPath(std::istream& file) { } else if (path.pathType == PathType::Property) { BinaryIO::BinaryRead(file, path.property.pathType); BinaryIO::BinaryRead(file, path.property.price); - BinaryIO::BinaryRead(file, path.property.rentalTimeUnit); + BinaryIO::BinaryRead(file, path.property.rentalTime); BinaryIO::BinaryRead(file, path.property.associatedZone); if (path.pathVersion >= 5) { @@ -426,14 +439,12 @@ void Zone::LoadPath(std::istream& file) { if (path.pathVersion >= 7) { BinaryIO::BinaryRead(file, path.property.cloneLimit); BinaryIO::BinaryRead(file, path.property.repMultiplier); - BinaryIO::BinaryRead(file, path.property.rentalTimeUnit); + BinaryIO::BinaryRead(file, path.property.rentalPeriod); } if (path.pathVersion >= 8) { BinaryIO::BinaryRead(file, path.property.achievementRequired); - BinaryIO::BinaryRead(file, path.property.playerZoneCoords.x); - BinaryIO::BinaryRead(file, path.property.playerZoneCoords.y); - BinaryIO::BinaryRead(file, path.property.playerZoneCoords.z); + BinaryIO::BinaryRead(file, path.property.playerZoneCoords); BinaryIO::BinaryRead(file, path.property.maxBuildHeight); } } else if (path.pathType == PathType::Camera) { @@ -543,11 +554,7 @@ void Zone::LoadPath(std::istream& file) { if (ldfConfig) waypoint.config.push_back(ldfConfig); } } - path.pathWaypoints.push_back(waypoint); } - - - m_Paths.push_back(path); } diff --git a/dZoneManager/Zone.h b/dZoneManager/Zone.h index b3e72036..af9f6b55 100644 --- a/dZoneManager/Zone.h +++ b/dZoneManager/Zone.h @@ -18,6 +18,11 @@ struct SceneRef { uint32_t id; uint32_t sceneType; //0 = general, 1 = audio? std::string name; + NiPoint3 unknown1; + float unknown2; + uint8_t color_r; + uint8_t color_g; + uint8_t color_b; Level* level; std::map triggers; }; @@ -101,7 +106,7 @@ enum class PropertyType : int32_t { Headspace = 3 }; -enum class PropertyRentalTimeUnit : int32_t { +enum class PropertyRentalPeriod : uint32_t { Forever = 0, Seconds = 1, Minutes = 2, @@ -112,7 +117,7 @@ enum class PropertyRentalTimeUnit : int32_t { Years = 7 }; -enum class PropertyAchievmentRequired : int32_t { +enum class PropertyAchievmentRequired : uint32_t { None = 0, Builder = 1, Craftsman = 2, @@ -134,13 +139,14 @@ struct MovingPlatformPath { struct PropertyPath { PropertyPathType pathType; int32_t price; - PropertyRentalTimeUnit rentalTimeUnit; + uint32_t rentalTime; uint64_t associatedZone; std::string displayName; std::string displayDesc; PropertyType type; - int32_t cloneLimit; + uint32_t cloneLimit; float repMultiplier; + PropertyRentalPeriod rentalPeriod; PropertyAchievmentRequired achievementRequired; NiPoint3 playerZoneCoords; float maxBuildHeight; @@ -177,15 +183,17 @@ struct Path { class Zone { public: - enum class ZoneFileFormatVersion : uint32_t { //Times are guessed. - PreAlpha = 0x20, - EarlyAlpha = 0x23, - Alpha = 0x24, - LateAlpha = 0x25, - Beta = 0x26, - Launch = 0x27, - Auramar = 0x28, - Latest = 0x29 + enum class FileFormatVersion : uint32_t { //Times are guessed. + PrePreAlpha = 30, + PreAlpha = 32, + LatePreAlpha = 33, + EarlyAlpha = 35, + Alpha = 36, + LateAlpha = 37, + Beta = 38, + Launch = 39, + Auramar = 40, + Latest = 41 }; public: @@ -221,7 +229,7 @@ private: uint32_t m_NumberOfScenesLoaded; uint32_t m_NumberOfObjectsLoaded; uint32_t m_NumberOfSceneTransitionsLoaded; - ZoneFileFormatVersion m_ZoneFileFormatVersion; + FileFormatVersion m_FileFormatVersion; uint32_t m_CheckSum; uint32_t m_WorldID; //should be equal to the MapID NiPoint3 m_Spawnpoint; From 5eca25e42a41129641169f6b45e94abba9bb9dbe Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Thu, 10 Aug 2023 21:27:40 -0700 Subject: [PATCH 5/5] refactor: Move CDClient Database away from constructor queries (#1164) * Move away from constructor queries Fix up other large tables to have proper backup lookups Revert "idk im just dumb ig" This reverts commit 5d5be5df53b8959b42b291613d7db749a65a3585. idk im just dumb ig * Fix slow components registry lookup * add define for cdclient cache all * Update CDBehaviorParameterTable.cpp --- CMakeVariables.txt | 2 + dDatabase/CDClientDatabase.h | 10 +- dDatabase/CDClientManager.cpp | 86 ++++++++------ dDatabase/Tables/CDActivitiesTable.cpp | 8 +- dDatabase/Tables/CDActivitiesTable.h | 5 +- dDatabase/Tables/CDActivityRewardsTable.cpp | 7 +- dDatabase/Tables/CDActivityRewardsTable.h | 4 +- dDatabase/Tables/CDAnimationsTable.cpp | 29 +++++ dDatabase/Tables/CDAnimationsTable.h | 1 + dDatabase/Tables/CDBehaviorParameterTable.cpp | 18 +-- dDatabase/Tables/CDBehaviorParameterTable.h | 2 +- dDatabase/Tables/CDBehaviorTemplateTable.cpp | 5 +- dDatabase/Tables/CDBehaviorTemplateTable.h | 5 +- dDatabase/Tables/CDBrickIDTableTable.cpp | 4 +- dDatabase/Tables/CDBrickIDTableTable.h | 4 +- .../Tables/CDComponentsRegistryTable.cpp | 109 ++++++------------ dDatabase/Tables/CDComponentsRegistryTable.h | 4 +- dDatabase/Tables/CDCurrencyTableTable.cpp | 4 +- dDatabase/Tables/CDCurrencyTableTable.h | 4 +- .../Tables/CDDestructibleComponentTable.cpp | 6 +- .../Tables/CDDestructibleComponentTable.h | 4 +- dDatabase/Tables/CDEmoteTable.cpp | 40 +++---- dDatabase/Tables/CDEmoteTable.h | 5 +- dDatabase/Tables/CDFeatureGatingTable.cpp | 5 +- dDatabase/Tables/CDFeatureGatingTable.h | 5 +- .../Tables/CDInventoryComponentTable.cpp | 5 +- dDatabase/Tables/CDInventoryComponentTable.h | 4 +- dDatabase/Tables/CDItemComponentTable.cpp | 22 ++-- dDatabase/Tables/CDItemComponentTable.h | 2 +- dDatabase/Tables/CDItemSetSkillsTable.cpp | 5 +- dDatabase/Tables/CDItemSetSkillsTable.h | 4 +- dDatabase/Tables/CDItemSetsTable.cpp | 5 +- dDatabase/Tables/CDItemSetsTable.h | 4 +- .../Tables/CDLevelProgressionLookupTable.cpp | 7 +- .../Tables/CDLevelProgressionLookupTable.h | 6 +- dDatabase/Tables/CDLootMatrixTable.cpp | 5 +- dDatabase/Tables/CDLootMatrixTable.h | 4 +- dDatabase/Tables/CDLootTableTable.cpp | 5 +- dDatabase/Tables/CDLootTableTable.h | 4 +- dDatabase/Tables/CDMissionEmailTable.cpp | 5 +- dDatabase/Tables/CDMissionEmailTable.h | 4 +- .../Tables/CDMissionNPCComponentTable.cpp | 5 +- dDatabase/Tables/CDMissionNPCComponentTable.h | 4 +- dDatabase/Tables/CDMissionTasksTable.cpp | 9 +- dDatabase/Tables/CDMissionTasksTable.h | 4 +- dDatabase/Tables/CDMissionsTable.cpp | 3 +- dDatabase/Tables/CDMissionsTable.h | 4 +- .../Tables/CDMovementAIComponentTable.cpp | 7 +- dDatabase/Tables/CDMovementAIComponentTable.h | 4 +- dDatabase/Tables/CDObjectSkillsTable.cpp | 7 +- dDatabase/Tables/CDObjectSkillsTable.h | 4 +- dDatabase/Tables/CDObjectsTable.cpp | 34 +++--- dDatabase/Tables/CDObjectsTable.h | 2 +- dDatabase/Tables/CDPackageComponentTable.cpp | 5 +- dDatabase/Tables/CDPackageComponentTable.h | 4 +- dDatabase/Tables/CDPhysicsComponentTable.cpp | 37 +++--- dDatabase/Tables/CDPhysicsComponentTable.h | 5 +- .../CDPropertyEntranceComponentTable.cpp | 3 +- .../Tables/CDPropertyEntranceComponentTable.h | 4 +- dDatabase/Tables/CDPropertyTemplateTable.cpp | 2 +- dDatabase/Tables/CDPropertyTemplateTable.h | 2 +- .../CDProximityMonitorComponentTable.cpp | 7 +- .../Tables/CDProximityMonitorComponentTable.h | 4 +- dDatabase/Tables/CDRailActivatorComponent.cpp | 4 +- dDatabase/Tables/CDRailActivatorComponent.h | 4 +- dDatabase/Tables/CDRarityTableTable.cpp | 5 +- dDatabase/Tables/CDRarityTableTable.h | 2 +- dDatabase/Tables/CDRebuildComponentTable.cpp | 7 +- dDatabase/Tables/CDRebuildComponentTable.h | 4 +- dDatabase/Tables/CDRewardsTable.cpp | 32 ++--- dDatabase/Tables/CDRewardsTable.h | 7 +- dDatabase/Tables/CDScriptComponentTable.cpp | 3 +- dDatabase/Tables/CDScriptComponentTable.h | 2 +- dDatabase/Tables/CDSkillBehaviorTable.cpp | 11 +- dDatabase/Tables/CDSkillBehaviorTable.h | 4 +- dDatabase/Tables/CDVendorComponentTable.cpp | 5 +- dDatabase/Tables/CDVendorComponentTable.h | 4 +- dDatabase/Tables/CDZoneTableTable.cpp | 3 +- dDatabase/Tables/CDZoneTableTable.h | 2 +- .../dComponents/LevelProgressionComponent.cpp | 10 +- 80 files changed, 312 insertions(+), 424 deletions(-) diff --git a/CMakeVariables.txt b/CMakeVariables.txt index 67b78aac..732a615b 100644 --- a/CMakeVariables.txt +++ b/CMakeVariables.txt @@ -18,3 +18,5 @@ __maria_db_connector_compile_jobs__=1 __enable_testing__=1 # The path to OpenSSL. Change this if your OpenSSL install path is different than the default. OPENSSL_ROOT_DIR=/usr/local/opt/openssl@3/ +# Uncomment the below line to cache the entire CDClient into memory +# CDCLIENT_CACHE_ALL=1 diff --git a/dDatabase/CDClientDatabase.h b/dDatabase/CDClientDatabase.h index 59f69b7d..7f42918d 100644 --- a/dDatabase/CDClientDatabase.h +++ b/dDatabase/CDClientDatabase.h @@ -13,15 +13,7 @@ #include #include - // Enable this to cache all entries in each table for fast access, comes with more memory cost - //#define CDCLIENT_CACHE_ALL - -/*! - \file CDClientDatabase.hpp - \brief An interface between the CDClient.sqlite file and the server - */ - - //! The CDClient Database namespace +//! The CDClient Database namespace namespace CDClientDatabase { //! Opens a connection with the CDClient diff --git a/dDatabase/CDClientManager.cpp b/dDatabase/CDClientManager.cpp index 9df6ff31..32a6a5b1 100644 --- a/dDatabase/CDClientManager.cpp +++ b/dDatabase/CDClientManager.cpp @@ -38,43 +38,53 @@ #include "CDFeatureGatingTable.h" #include "CDRailActivatorComponent.h" +// Uncomment this to cache the full cdclient database into memory. This will make the server load faster, but will use more memory. +// A vanilla CDClient takes about 46MB of memory + the regular world data. +// #define CDCLIENT_CACHE_ALL + +#ifdef CDCLIENT_CACHE_ALL + #define CDCLIENT_DONT_CACHE_TABLE(x) x +#else + #define CDCLIENT_DONT_CACHE_TABLE(x) +#endif + CDClientManager::CDClientManager() { - CDActivityRewardsTable::Instance(); - CDAnimationsTable::Instance(); - CDBehaviorParameterTable::Instance(); - CDBehaviorTemplateTable::Instance(); - CDComponentsRegistryTable::Instance(); - CDCurrencyTableTable::Instance(); - CDDestructibleComponentTable::Instance(); - CDEmoteTableTable::Instance(); - CDInventoryComponentTable::Instance(); - CDItemComponentTable::Instance(); - CDItemSetsTable::Instance(); - CDItemSetSkillsTable::Instance(); - CDLevelProgressionLookupTable::Instance(); - CDLootMatrixTable::Instance(); - CDLootTableTable::Instance(); - CDMissionNPCComponentTable::Instance(); - CDMissionTasksTable::Instance(); - CDMissionsTable::Instance(); - CDObjectSkillsTable::Instance(); - CDObjectsTable::Instance(); - CDPhysicsComponentTable::Instance(); - CDRebuildComponentTable::Instance(); - CDScriptComponentTable::Instance(); - CDSkillBehaviorTable::Instance(); - CDZoneTableTable::Instance(); - CDVendorComponentTable::Instance(); - CDActivitiesTable::Instance(); - CDPackageComponentTable::Instance(); - CDProximityMonitorComponentTable::Instance(); - CDMovementAIComponentTable::Instance(); - CDBrickIDTableTable::Instance(); - CDRarityTableTable::Instance(); - CDMissionEmailTable::Instance(); - CDRewardsTable::Instance(); - CDPropertyEntranceComponentTable::Instance(); - CDPropertyTemplateTable::Instance(); - CDFeatureGatingTable::Instance(); - CDRailActivatorComponentTable::Instance(); + CDActivityRewardsTable::Instance().LoadValuesFromDatabase(); + CDActivitiesTable::Instance().LoadValuesFromDatabase(); + CDCLIENT_DONT_CACHE_TABLE(CDAnimationsTable::Instance().LoadValuesFromDatabase()); + CDBehaviorParameterTable::Instance().LoadValuesFromDatabase(); + CDBehaviorTemplateTable::Instance().LoadValuesFromDatabase(); + CDBrickIDTableTable::Instance().LoadValuesFromDatabase(); + CDComponentsRegistryTable::Instance().LoadValuesFromDatabase(); + CDCurrencyTableTable::Instance().LoadValuesFromDatabase(); + CDDestructibleComponentTable::Instance().LoadValuesFromDatabase(); + CDEmoteTableTable::Instance().LoadValuesFromDatabase(); + CDFeatureGatingTable::Instance().LoadValuesFromDatabase(); + CDInventoryComponentTable::Instance().LoadValuesFromDatabase(); + CDCLIENT_DONT_CACHE_TABLE(CDItemComponentTable::Instance().LoadValuesFromDatabase()); + CDItemSetSkillsTable::Instance().LoadValuesFromDatabase(); + CDItemSetsTable::Instance().LoadValuesFromDatabase(); + CDLevelProgressionLookupTable::Instance().LoadValuesFromDatabase(); + CDLootMatrixTable::Instance().LoadValuesFromDatabase(); + CDLootTableTable::Instance().LoadValuesFromDatabase(); + CDMissionEmailTable::Instance().LoadValuesFromDatabase(); + CDMissionNPCComponentTable::Instance().LoadValuesFromDatabase(); + CDMissionTasksTable::Instance().LoadValuesFromDatabase(); + CDMissionsTable::Instance().LoadValuesFromDatabase(); + CDMovementAIComponentTable::Instance().LoadValuesFromDatabase(); + CDObjectSkillsTable::Instance().LoadValuesFromDatabase(); + CDCLIENT_DONT_CACHE_TABLE(CDObjectsTable::Instance().LoadValuesFromDatabase()); + CDPhysicsComponentTable::Instance().LoadValuesFromDatabase(); + CDPackageComponentTable::Instance().LoadValuesFromDatabase(); + CDProximityMonitorComponentTable::Instance().LoadValuesFromDatabase(); + CDPropertyEntranceComponentTable::Instance().LoadValuesFromDatabase(); + CDPropertyTemplateTable::Instance().LoadValuesFromDatabase(); + CDRailActivatorComponentTable::Instance().LoadValuesFromDatabase(); + CDRarityTableTable::Instance().LoadValuesFromDatabase(); + CDRebuildComponentTable::Instance().LoadValuesFromDatabase(); + CDRewardsTable::Instance().LoadValuesFromDatabase(); + CDScriptComponentTable::Instance().LoadValuesFromDatabase(); + CDSkillBehaviorTable::Instance().LoadValuesFromDatabase(); + CDVendorComponentTable::Instance().LoadValuesFromDatabase(); + CDZoneTableTable::Instance().LoadValuesFromDatabase(); } diff --git a/dDatabase/Tables/CDActivitiesTable.cpp b/dDatabase/Tables/CDActivitiesTable.cpp index e1660d66..c967f724 100644 --- a/dDatabase/Tables/CDActivitiesTable.cpp +++ b/dDatabase/Tables/CDActivitiesTable.cpp @@ -1,7 +1,6 @@ #include "CDActivitiesTable.h" -CDActivitiesTable::CDActivitiesTable(void) { - +void CDActivitiesTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Activities"); @@ -55,8 +54,3 @@ std::vector CDActivitiesTable::Query(std::function CDActivitiesTable::GetEntries(void) const { - return this->entries; -} - diff --git a/dDatabase/Tables/CDActivitiesTable.h b/dDatabase/Tables/CDActivitiesTable.h index 4b60afbd..2e39d595 100644 --- a/dDatabase/Tables/CDActivitiesTable.h +++ b/dDatabase/Tables/CDActivitiesTable.h @@ -30,9 +30,10 @@ private: std::vector entries; public: - CDActivitiesTable(); + void LoadValuesFromDatabase(); + // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - std::vector GetEntries(void) const; + const std::vector& GetEntries() const { return this->entries; } }; diff --git a/dDatabase/Tables/CDActivityRewardsTable.cpp b/dDatabase/Tables/CDActivityRewardsTable.cpp index 65ef1101..a2434d19 100644 --- a/dDatabase/Tables/CDActivityRewardsTable.cpp +++ b/dDatabase/Tables/CDActivityRewardsTable.cpp @@ -1,6 +1,6 @@ #include "CDActivityRewardsTable.h" -CDActivityRewardsTable::CDActivityRewardsTable(void) { +void CDActivityRewardsTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -43,8 +43,3 @@ std::vector CDActivityRewardsTable::Query(std::function CDActivityRewardsTable::GetEntries(void) const { - return this->entries; -} - diff --git a/dDatabase/Tables/CDActivityRewardsTable.h b/dDatabase/Tables/CDActivityRewardsTable.h index b5503fb6..a177a3c0 100644 --- a/dDatabase/Tables/CDActivityRewardsTable.h +++ b/dDatabase/Tables/CDActivityRewardsTable.h @@ -18,10 +18,10 @@ private: std::vector entries; public: - CDActivityRewardsTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - std::vector GetEntries(void) const; + std::vector GetEntries() const; }; diff --git a/dDatabase/Tables/CDAnimationsTable.cpp b/dDatabase/Tables/CDAnimationsTable.cpp index 76ce0e5a..7244ddee 100644 --- a/dDatabase/Tables/CDAnimationsTable.cpp +++ b/dDatabase/Tables/CDAnimationsTable.cpp @@ -2,6 +2,35 @@ #include "GeneralUtils.h" #include "Game.h" + +void CDAnimationsTable::LoadValuesFromDatabase() { + auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Animations"); + while (!tableData.eof()) { + std::string animation_type = tableData.getStringField("animation_type", ""); + DluAssert(!animation_type.empty()); + AnimationGroupID animationGroupID = tableData.getIntField("animationGroupID", -1); + DluAssert(animationGroupID != -1); + + CDAnimation entry; + entry.animation_name = tableData.getStringField("animation_name", ""); + entry.chance_to_play = tableData.getFloatField("chance_to_play", 1.0f); + UNUSED_COLUMN(entry.min_loops = tableData.getIntField("min_loops", 0);) + UNUSED_COLUMN(entry.max_loops = tableData.getIntField("max_loops", 0);) + entry.animation_length = tableData.getFloatField("animation_length", 0.0f); + UNUSED_COLUMN(entry.hideEquip = tableData.getIntField("hideEquip", 0) == 1;) + UNUSED_COLUMN(entry.ignoreUpperBody = tableData.getIntField("ignoreUpperBody", 0) == 1;) + UNUSED_COLUMN(entry.restartable = tableData.getIntField("restartable", 0) == 1;) + UNUSED_COLUMN(entry.face_animation_name = tableData.getStringField("face_animation_name", "");) + UNUSED_COLUMN(entry.priority = tableData.getFloatField("priority", 0.0f);) + UNUSED_COLUMN(entry.blendTime = tableData.getFloatField("blendTime", 0.0f);) + + this->animations[CDAnimationKey(animation_type, animationGroupID)].push_back(entry); + tableData.nextRow(); + } + + tableData.finalize(); +} + bool CDAnimationsTable::CacheData(CppSQLite3Statement& queryToCache) { auto tableData = queryToCache.execQuery(); // If we received a bad lookup, cache it anyways so we do not run the query again. diff --git a/dDatabase/Tables/CDAnimationsTable.h b/dDatabase/Tables/CDAnimationsTable.h index 65f54d98..494d5cde 100644 --- a/dDatabase/Tables/CDAnimationsTable.h +++ b/dDatabase/Tables/CDAnimationsTable.h @@ -27,6 +27,7 @@ class CDAnimationsTable : public CDTable { typedef std::string AnimationID; typedef std::pair CDAnimationKey; public: + void LoadValuesFromDatabase(); /** * Given an animationType and the previousAnimationName played, return the next animationType to play. * If there are more than 1 animationTypes that can be played, one is selected at random but also does not allow diff --git a/dDatabase/Tables/CDBehaviorParameterTable.cpp b/dDatabase/Tables/CDBehaviorParameterTable.cpp index 8181245b..708bec4c 100644 --- a/dDatabase/Tables/CDBehaviorParameterTable.cpp +++ b/dDatabase/Tables/CDBehaviorParameterTable.cpp @@ -1,15 +1,15 @@ #include "CDBehaviorParameterTable.h" #include "GeneralUtils.h" -uint64_t GetHash(const uint32_t behaviorID, const uint32_t parameterID) { - uint64_t hash = behaviorID; - hash <<= 31U; - hash |= parameterID; +uint64_t GetKey(const uint32_t behaviorID, const uint32_t parameterID) { + uint64_t key = behaviorID; + key <<= 31U; + key |= parameterID; - return hash; + return key; } -CDBehaviorParameterTable::CDBehaviorParameterTable() { +void CDBehaviorParameterTable::LoadValuesFromDatabase() { auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM BehaviorParameter"); while (!tableData.eof()) { uint32_t behaviorID = tableData.getIntField("behaviorID", -1); @@ -21,7 +21,7 @@ CDBehaviorParameterTable::CDBehaviorParameterTable() { } else { parameterId = m_ParametersList.insert(std::make_pair(candidateStringToAdd, m_ParametersList.size())).first->second; } - uint64_t hash = GetHash(behaviorID, parameterId); + uint64_t hash = GetKey(behaviorID, parameterId); float value = tableData.getFloatField("value", -1.0f); m_Entries.insert(std::make_pair(hash, value)); @@ -34,7 +34,7 @@ CDBehaviorParameterTable::CDBehaviorParameterTable() { float CDBehaviorParameterTable::GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue) { auto parameterID = this->m_ParametersList.find(name); if (parameterID == this->m_ParametersList.end()) return defaultValue; - auto hash = GetHash(behaviorID, parameterID->second); + auto hash = GetKey(behaviorID, parameterID->second); // Search for specific parameter auto it = m_Entries.find(hash); @@ -45,7 +45,7 @@ std::map CDBehaviorParameterTable::GetParametersByBehaviorID uint64_t hashBase = behaviorID; std::map returnInfo; for (auto& [parameterString, parameterId] : m_ParametersList) { - uint64_t hash = GetHash(hashBase, parameterId); + uint64_t hash = GetKey(hashBase, parameterId); auto infoCandidate = m_Entries.find(hash); if (infoCandidate != m_Entries.end()) { returnInfo.insert(std::make_pair(parameterString, infoCandidate->second)); diff --git a/dDatabase/Tables/CDBehaviorParameterTable.h b/dDatabase/Tables/CDBehaviorParameterTable.h index 249caacf..3daa3aa3 100644 --- a/dDatabase/Tables/CDBehaviorParameterTable.h +++ b/dDatabase/Tables/CDBehaviorParameterTable.h @@ -12,7 +12,7 @@ private: std::unordered_map m_Entries; std::unordered_map m_ParametersList; public: - CDBehaviorParameterTable(); + void LoadValuesFromDatabase(); float GetValue(const uint32_t behaviorID, const std::string& name, const float defaultValue = 0); diff --git a/dDatabase/Tables/CDBehaviorTemplateTable.cpp b/dDatabase/Tables/CDBehaviorTemplateTable.cpp index 08bc86d1..c343ef85 100644 --- a/dDatabase/Tables/CDBehaviorTemplateTable.cpp +++ b/dDatabase/Tables/CDBehaviorTemplateTable.cpp @@ -1,6 +1,6 @@ #include "CDBehaviorTemplateTable.h" -CDBehaviorTemplateTable::CDBehaviorTemplateTable(void) { +void CDBehaviorTemplateTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -48,7 +48,7 @@ std::vector CDBehaviorTemplateTable::Query(std::function CDBehaviorTemplateTable::GetEntries(void) const { +const std::vector& CDBehaviorTemplateTable::GetEntries() const { return this->entries; } @@ -64,4 +64,3 @@ const CDBehaviorTemplate CDBehaviorTemplateTable::GetByBehaviorID(uint32_t behav return entry->second; } } - diff --git a/dDatabase/Tables/CDBehaviorTemplateTable.h b/dDatabase/Tables/CDBehaviorTemplateTable.h index f9ac9a09..49ce11f2 100644 --- a/dDatabase/Tables/CDBehaviorTemplateTable.h +++ b/dDatabase/Tables/CDBehaviorTemplateTable.h @@ -19,11 +19,12 @@ private: std::unordered_map entriesMappedByBehaviorID; std::unordered_set m_EffectHandles; public: - CDBehaviorTemplateTable(); + void LoadValuesFromDatabase(); + // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - std::vector GetEntries(void) const; + const std::vector& GetEntries(void) const; const CDBehaviorTemplate GetByBehaviorID(uint32_t behaviorID); }; diff --git a/dDatabase/Tables/CDBrickIDTableTable.cpp b/dDatabase/Tables/CDBrickIDTableTable.cpp index 9ad24d39..9be75f0b 100644 --- a/dDatabase/Tables/CDBrickIDTableTable.cpp +++ b/dDatabase/Tables/CDBrickIDTableTable.cpp @@ -1,6 +1,6 @@ #include "CDBrickIDTableTable.h" -CDBrickIDTableTable::CDBrickIDTableTable(void) { +void CDBrickIDTableTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -39,7 +39,7 @@ std::vector CDBrickIDTableTable::Query(std::function CDBrickIDTableTable::GetEntries(void) const { +const std::vector& CDBrickIDTableTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDBrickIDTableTable.h b/dDatabase/Tables/CDBrickIDTableTable.h index e2084caf..68c0b1b6 100644 --- a/dDatabase/Tables/CDBrickIDTableTable.h +++ b/dDatabase/Tables/CDBrickIDTableTable.h @@ -21,9 +21,9 @@ private: std::vector entries; public: - CDBrickIDTableTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - std::vector GetEntries(void) const; + const std::vector& GetEntries() const; }; diff --git a/dDatabase/Tables/CDComponentsRegistryTable.cpp b/dDatabase/Tables/CDComponentsRegistryTable.cpp index 32012f6c..ac547a24 100644 --- a/dDatabase/Tables/CDComponentsRegistryTable.cpp +++ b/dDatabase/Tables/CDComponentsRegistryTable.cpp @@ -1,27 +1,37 @@ #include "CDComponentsRegistryTable.h" #include "eReplicaComponentType.h" -#define CDCLIENT_CACHE_ALL - -CDComponentsRegistryTable::CDComponentsRegistryTable(void) { - -#ifdef CDCLIENT_CACHE_ALL - // First, get the size of the table - unsigned int size = 0; - auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ComponentsRegistry"); - while (!tableSize.eof()) { - size = tableSize.getIntField(0, 0); - - tableSize.nextRow(); - } - - tableSize.finalize(); - - // Reserve the size - //this->entries.reserve(size); - +void CDComponentsRegistryTable::LoadValuesFromDatabase() { // Now get the data auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ComponentsRegistry"); + while (!tableData.eof()) { + CDComponentsRegistry entry; + entry.id = tableData.getIntField("id", -1); + entry.component_type = static_cast(tableData.getIntField("component_type", 0)); + entry.component_id = tableData.getIntField("component_id", -1); + + this->mappedEntries.insert_or_assign(((uint64_t)entry.component_type) << 32 | ((uint64_t)entry.id), entry.component_id); + this->mappedEntries.insert_or_assign(entry.id, 0); + + tableData.nextRow(); + } + + tableData.finalize(); +} + +int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue) { + auto exists = mappedEntries.find(id); + if (exists != mappedEntries.end()) { + auto iter = mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id)); + return iter == mappedEntries.end() ? defaultValue : iter->second; + } + + // Now get the data. Get all components of this entity so we dont do a query for each component + auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM ComponentsRegistry WHERE id = ?;"); + query.bind(1, static_cast(id)); + + auto tableData = query.execQuery(); + while (!tableData.eof()) { CDComponentsRegistry entry; entry.id = tableData.getIntField("id", -1); @@ -33,61 +43,10 @@ CDComponentsRegistryTable::CDComponentsRegistryTable(void) { tableData.nextRow(); } - tableData.finalize(); -#endif -} - -int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue) { - const auto& iter = this->mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id)); - - if (iter == this->mappedEntries.end()) { - return defaultValue; - } - - return iter->second; - -#ifndef CDCLIENT_CACHE_ALL - // Now get the data - std::stringstream query; - - query << "SELECT * FROM ComponentsRegistry WHERE id = " << std::to_string(id); - - auto tableData = CDClientDatabase::ExecuteQuery(query.str()); - while (!tableData.eof()) { - CDComponentsRegistry entry; - entry.id = tableData.getIntField("id", -1); - entry.component_type = tableData.getIntField("component_type", -1); - entry.component_id = tableData.getIntField("component_id", -1); - - //this->entries.push_back(entry); - - //Darwin's stuff: - const auto& it = this->mappedEntries.find(entry.id); - if (it != mappedEntries.end()) { - const auto& iter = it->second.find(entry.component_type); - if (iter == it->second.end()) { - it->second.insert(std::make_pair(entry.component_type, entry.component_id)); - } - } else { - std::map map; - map.insert(std::make_pair(entry.component_type, entry.component_id)); - this->mappedEntries.insert(std::make_pair(entry.id, map)); - } - - tableData.nextRow(); - } - - tableData.finalize(); - - const auto& it2 = this->mappedEntries.find(id); - if (it2 != mappedEntries.end()) { - const auto& iter = it2->second.find(componentType); - if (iter != it2->second.end()) { - return iter->second; - } - } - - return defaultValue; -#endif + mappedEntries.insert_or_assign(id, 0); + + auto iter = this->mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id)); + + return iter == this->mappedEntries.end() ? defaultValue : iter->second; } diff --git a/dDatabase/Tables/CDComponentsRegistryTable.h b/dDatabase/Tables/CDComponentsRegistryTable.h index 990072c9..fc461989 100644 --- a/dDatabase/Tables/CDComponentsRegistryTable.h +++ b/dDatabase/Tables/CDComponentsRegistryTable.h @@ -13,9 +13,9 @@ struct CDComponentsRegistry { class CDComponentsRegistryTable : public CDTable { private: - std::map mappedEntries; //id, component_type, component_id + std::unordered_map mappedEntries; //id, component_type, component_id public: - CDComponentsRegistryTable(); + void LoadValuesFromDatabase(); int32_t GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue = 0); }; diff --git a/dDatabase/Tables/CDCurrencyTableTable.cpp b/dDatabase/Tables/CDCurrencyTableTable.cpp index 78a716f9..58c517f2 100644 --- a/dDatabase/Tables/CDCurrencyTableTable.cpp +++ b/dDatabase/Tables/CDCurrencyTableTable.cpp @@ -1,7 +1,7 @@ #include "CDCurrencyTableTable.h" //! Constructor -CDCurrencyTableTable::CDCurrencyTableTable(void) { +void CDCurrencyTableTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -43,7 +43,7 @@ std::vector CDCurrencyTableTable::Query(std::function CDCurrencyTableTable::GetEntries(void) const { +const std::vector& CDCurrencyTableTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDCurrencyTableTable.h b/dDatabase/Tables/CDCurrencyTableTable.h index ec700320..fd70a968 100644 --- a/dDatabase/Tables/CDCurrencyTableTable.h +++ b/dDatabase/Tables/CDCurrencyTableTable.h @@ -23,9 +23,9 @@ private: std::vector entries; public: - CDCurrencyTableTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - std::vector GetEntries(void) const; + const std::vector& GetEntries() const; }; diff --git a/dDatabase/Tables/CDDestructibleComponentTable.cpp b/dDatabase/Tables/CDDestructibleComponentTable.cpp index 4bbc8242..f92aec94 100644 --- a/dDatabase/Tables/CDDestructibleComponentTable.cpp +++ b/dDatabase/Tables/CDDestructibleComponentTable.cpp @@ -1,8 +1,6 @@ #include "CDDestructibleComponentTable.h" -//! Constructor -CDDestructibleComponentTable::CDDestructibleComponentTable(void) { - +void CDDestructibleComponentTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM DestructibleComponent"); @@ -52,7 +50,7 @@ std::vector CDDestructibleComponentTable::Query(std::fu return data; } -std::vector CDDestructibleComponentTable::GetEntries(void) const { +const std::vector& CDDestructibleComponentTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDDestructibleComponentTable.h b/dDatabase/Tables/CDDestructibleComponentTable.h index e42cf486..fb6ee4cd 100644 --- a/dDatabase/Tables/CDDestructibleComponentTable.h +++ b/dDatabase/Tables/CDDestructibleComponentTable.h @@ -25,9 +25,9 @@ private: std::vector entries; public: - CDDestructibleComponentTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - std::vector GetEntries(void) const; + const std::vector& GetEntries(void) const; }; diff --git a/dDatabase/Tables/CDEmoteTable.cpp b/dDatabase/Tables/CDEmoteTable.cpp index aacbdd55..77aa226c 100644 --- a/dDatabase/Tables/CDEmoteTable.cpp +++ b/dDatabase/Tables/CDEmoteTable.cpp @@ -1,40 +1,26 @@ #include "CDEmoteTable.h" -//! Constructor -CDEmoteTableTable::CDEmoteTableTable(void) { +void CDEmoteTableTable::LoadValuesFromDatabase() { auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Emotes"); while (!tableData.eof()) { - CDEmoteTable* entry = new CDEmoteTable(); - entry->ID = tableData.getIntField("id", -1); - entry->animationName = tableData.getStringField("animationName", ""); - entry->iconFilename = tableData.getStringField("iconFilename", ""); - entry->channel = tableData.getIntField("channel", -1); - entry->locked = tableData.getIntField("locked", -1) != 0; - entry->localize = tableData.getIntField("localize", -1) != 0; - entry->locState = tableData.getIntField("locStatus", -1); - entry->gateVersion = tableData.getStringField("gate_version", ""); + CDEmoteTable entry; + entry.ID = tableData.getIntField("id", -1); + entry.animationName = tableData.getStringField("animationName", ""); + entry.iconFilename = tableData.getStringField("iconFilename", ""); + entry.channel = tableData.getIntField("channel", -1); + entry.locked = tableData.getIntField("locked", -1) != 0; + entry.localize = tableData.getIntField("localize", -1) != 0; + entry.locState = tableData.getIntField("locStatus", -1); + entry.gateVersion = tableData.getStringField("gate_version", ""); - entries.insert(std::make_pair(entry->ID, entry)); + entries.insert(std::make_pair(entry.ID, entry)); tableData.nextRow(); } tableData.finalize(); } -//! Destructor -CDEmoteTableTable::~CDEmoteTableTable(void) { - for (auto e : entries) { - if (e.second) delete e.second; - } - - entries.clear(); -} - CDEmoteTable* CDEmoteTableTable::GetEmote(int id) { - for (auto e : entries) { - if (e.first == id) return e.second; - } - - return nullptr; + auto itr = entries.find(id); + return itr != entries.end() ? &itr->second : nullptr; } - diff --git a/dDatabase/Tables/CDEmoteTable.h b/dDatabase/Tables/CDEmoteTable.h index be40c86f..a49d1c45 100644 --- a/dDatabase/Tables/CDEmoteTable.h +++ b/dDatabase/Tables/CDEmoteTable.h @@ -28,11 +28,10 @@ struct CDEmoteTable { class CDEmoteTableTable : public CDTable { private: - std::map entries; + std::map entries; public: - CDEmoteTableTable(); - ~CDEmoteTableTable(); + void LoadValuesFromDatabase(); // Returns an emote by ID CDEmoteTable* GetEmote(int id); }; diff --git a/dDatabase/Tables/CDFeatureGatingTable.cpp b/dDatabase/Tables/CDFeatureGatingTable.cpp index 05fe69bf..5013dd13 100644 --- a/dDatabase/Tables/CDFeatureGatingTable.cpp +++ b/dDatabase/Tables/CDFeatureGatingTable.cpp @@ -1,7 +1,6 @@ #include "CDFeatureGatingTable.h" -//! Constructor -CDFeatureGatingTable::CDFeatureGatingTable(void) { +void CDFeatureGatingTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -53,7 +52,7 @@ bool CDFeatureGatingTable::FeatureUnlocked(const std::string& feature) const { return false; } -std::vector CDFeatureGatingTable::GetEntries(void) const { +const std::vector& CDFeatureGatingTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDFeatureGatingTable.h b/dDatabase/Tables/CDFeatureGatingTable.h index 7f536db5..9a978218 100644 --- a/dDatabase/Tables/CDFeatureGatingTable.h +++ b/dDatabase/Tables/CDFeatureGatingTable.h @@ -16,11 +16,12 @@ private: std::vector entries; public: - CDFeatureGatingTable(); + void LoadValuesFromDatabase(); + // Queries the table with a custom "where" clause std::vector Query(std::function predicate); bool FeatureUnlocked(const std::string& feature) const; - std::vector GetEntries(void) const; + const std::vector& GetEntries(void) const; }; diff --git a/dDatabase/Tables/CDInventoryComponentTable.cpp b/dDatabase/Tables/CDInventoryComponentTable.cpp index 2dc375ab..ffc8fee6 100644 --- a/dDatabase/Tables/CDInventoryComponentTable.cpp +++ b/dDatabase/Tables/CDInventoryComponentTable.cpp @@ -1,7 +1,6 @@ #include "CDInventoryComponentTable.h" -//! Constructor -CDInventoryComponentTable::CDInventoryComponentTable(void) { +void CDInventoryComponentTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -42,7 +41,7 @@ std::vector CDInventoryComponentTable::Query(std::function return data; } -std::vector CDInventoryComponentTable::GetEntries(void) const { +const std::vector& CDInventoryComponentTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDInventoryComponentTable.h b/dDatabase/Tables/CDInventoryComponentTable.h index cbc04d99..26d47ffe 100644 --- a/dDatabase/Tables/CDInventoryComponentTable.h +++ b/dDatabase/Tables/CDInventoryComponentTable.h @@ -15,9 +15,9 @@ private: std::vector entries; public: - CDInventoryComponentTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - std::vector GetEntries(void) const; + const std::vector& GetEntries() const; }; diff --git a/dDatabase/Tables/CDItemComponentTable.cpp b/dDatabase/Tables/CDItemComponentTable.cpp index 54afc417..5d6722f9 100644 --- a/dDatabase/Tables/CDItemComponentTable.cpp +++ b/dDatabase/Tables/CDItemComponentTable.cpp @@ -3,11 +3,7 @@ CDItemComponent CDItemComponentTable::Default = {}; -//! Constructor -CDItemComponentTable::CDItemComponentTable(void) { - Default = CDItemComponent(); - -#ifdef CDCLIENT_CACHE_ALL +void CDItemComponentTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ItemComponent"); @@ -55,13 +51,13 @@ CDItemComponentTable::CDItemComponentTable(void) { entry.currencyLOT = tableData.getIntField("currencyLOT", -1); entry.altCurrencyCost = tableData.getIntField("altCurrencyCost", -1); entry.subItems = tableData.getStringField("subItems", ""); - entry.audioEventUse = tableData.getStringField("audioEventUse", ""); + UNUSED_COLUMN(entry.audioEventUse = tableData.getStringField("audioEventUse", "")); entry.noEquipAnimation = tableData.getIntField("noEquipAnimation", -1) == 1 ? true : false; entry.commendationLOT = tableData.getIntField("commendationLOT", -1); entry.commendationCost = tableData.getIntField("commendationCost", -1); - entry.audioEquipMetaEventSet = tableData.getStringField("audioEquipMetaEventSet", ""); + UNUSED_COLUMN(entry.audioEquipMetaEventSet = tableData.getStringField("audioEquipMetaEventSet", "")); entry.currencyCosts = tableData.getStringField("currencyCosts", ""); - entry.ingredientInfo = tableData.getStringField("ingredientInfo", ""); + UNUSED_COLUMN(entry.ingredientInfo = tableData.getStringField("ingredientInfo", "")); entry.locStatus = tableData.getIntField("locStatus", -1); entry.forgeType = tableData.getIntField("forgeType", -1); entry.SellMultiplier = tableData.getFloatField("SellMultiplier", -1.0f); @@ -71,7 +67,6 @@ CDItemComponentTable::CDItemComponentTable(void) { } tableData.finalize(); -#endif } const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int skillID) { @@ -80,12 +75,10 @@ const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int s return it->second; } -#ifndef CDCLIENT_CACHE_ALL - std::stringstream query; + auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM ItemComponent WHERE id = ?;"); + query.bind(1, static_cast(skillID)); - query << "SELECT * FROM ItemComponent WHERE id = " << std::to_string(skillID); - - auto tableData = CDClientDatabase::ExecuteQuery(query.str()); + auto tableData = query.execQuery(); if (tableData.eof()) { entries.insert(std::make_pair(skillID, Default)); return Default; @@ -144,7 +137,6 @@ const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int s if (it2 != this->entries.end()) { return it2->second; } -#endif return Default; } diff --git a/dDatabase/Tables/CDItemComponentTable.h b/dDatabase/Tables/CDItemComponentTable.h index 11c34dd6..685e5acd 100644 --- a/dDatabase/Tables/CDItemComponentTable.h +++ b/dDatabase/Tables/CDItemComponentTable.h @@ -54,7 +54,7 @@ private: std::map entries; public: - CDItemComponentTable(); + void LoadValuesFromDatabase(); static std::map ParseCraftingCurrencies(const CDItemComponent& itemComponent); // Gets an entry by ID diff --git a/dDatabase/Tables/CDItemSetSkillsTable.cpp b/dDatabase/Tables/CDItemSetSkillsTable.cpp index f6b412ff..6fb1689e 100644 --- a/dDatabase/Tables/CDItemSetSkillsTable.cpp +++ b/dDatabase/Tables/CDItemSetSkillsTable.cpp @@ -1,7 +1,6 @@ #include "CDItemSetSkillsTable.h" -//! Constructor -CDItemSetSkillsTable::CDItemSetSkillsTable(void) { +void CDItemSetSkillsTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -41,7 +40,7 @@ std::vector CDItemSetSkillsTable::Query(std::function CDItemSetSkillsTable::GetEntries(void) const { +const std::vector& CDItemSetSkillsTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDItemSetSkillsTable.h b/dDatabase/Tables/CDItemSetSkillsTable.h index 8328c66b..07321a7f 100644 --- a/dDatabase/Tables/CDItemSetSkillsTable.h +++ b/dDatabase/Tables/CDItemSetSkillsTable.h @@ -14,11 +14,11 @@ private: std::vector entries; public: - CDItemSetSkillsTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - std::vector GetEntries(void) const; + const std::vector& GetEntries() const; std::vector GetBySkillID(unsigned int SkillSetID); }; diff --git a/dDatabase/Tables/CDItemSetsTable.cpp b/dDatabase/Tables/CDItemSetsTable.cpp index 0632ef13..de70e180 100644 --- a/dDatabase/Tables/CDItemSetsTable.cpp +++ b/dDatabase/Tables/CDItemSetsTable.cpp @@ -1,7 +1,6 @@ #include "CDItemSetsTable.h" -//! Constructor -CDItemSetsTable::CDItemSetsTable(void) { +void CDItemSetsTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -53,7 +52,7 @@ std::vector CDItemSetsTable::Query(std::function p return data; } -std::vector CDItemSetsTable::GetEntries(void) const { +const std::vector& CDItemSetsTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDItemSetsTable.h b/dDatabase/Tables/CDItemSetsTable.h index 6756e7fa..a3a738b1 100644 --- a/dDatabase/Tables/CDItemSetsTable.h +++ b/dDatabase/Tables/CDItemSetsTable.h @@ -26,10 +26,10 @@ private: std::vector entries; public: - CDItemSetsTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - std::vector GetEntries(void) const; + const std::vector& GetEntries(void) const; }; diff --git a/dDatabase/Tables/CDLevelProgressionLookupTable.cpp b/dDatabase/Tables/CDLevelProgressionLookupTable.cpp index 47a8fc0e..d0a6ca93 100644 --- a/dDatabase/Tables/CDLevelProgressionLookupTable.cpp +++ b/dDatabase/Tables/CDLevelProgressionLookupTable.cpp @@ -1,7 +1,6 @@ #include "CDLevelProgressionLookupTable.h" -//! Constructor -CDLevelProgressionLookupTable::CDLevelProgressionLookupTable(void) { +void CDLevelProgressionLookupTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -32,7 +31,6 @@ CDLevelProgressionLookupTable::CDLevelProgressionLookupTable(void) { tableData.finalize(); } -//! Queries the table with a custom "where" clause std::vector CDLevelProgressionLookupTable::Query(std::function predicate) { std::vector data = cpplinq::from(this->entries) @@ -42,8 +40,7 @@ std::vector CDLevelProgressionLookupTable::Query(std:: return data; } -//! Gets all the entries in the table -std::vector CDLevelProgressionLookupTable::GetEntries(void) const { +const std::vector& CDLevelProgressionLookupTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDLevelProgressionLookupTable.h b/dDatabase/Tables/CDLevelProgressionLookupTable.h index 070b2e0c..6b68bd0d 100644 --- a/dDatabase/Tables/CDLevelProgressionLookupTable.h +++ b/dDatabase/Tables/CDLevelProgressionLookupTable.h @@ -14,10 +14,10 @@ private: std::vector entries; public: - CDLevelProgressionLookupTable(); + void LoadValuesFromDatabase(); + // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - // Gets all the entries in the table - std::vector GetEntries(void) const; + const std::vector& GetEntries() const; }; diff --git a/dDatabase/Tables/CDLootMatrixTable.cpp b/dDatabase/Tables/CDLootMatrixTable.cpp index 8f25e8a3..27c01b30 100644 --- a/dDatabase/Tables/CDLootMatrixTable.cpp +++ b/dDatabase/Tables/CDLootMatrixTable.cpp @@ -1,7 +1,6 @@ #include "CDLootMatrixTable.h" -//! Constructor -CDLootMatrixTable::CDLootMatrixTable(void) { +void CDLootMatrixTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -47,7 +46,7 @@ std::vector CDLootMatrixTable::Query(std::function& CDLootMatrixTable::GetEntries(void) const { +const std::vector& CDLootMatrixTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDLootMatrixTable.h b/dDatabase/Tables/CDLootMatrixTable.h index c6035841..6ea012cb 100644 --- a/dDatabase/Tables/CDLootMatrixTable.h +++ b/dDatabase/Tables/CDLootMatrixTable.h @@ -20,10 +20,10 @@ private: std::vector entries; public: - CDLootMatrixTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - const std::vector& GetEntries(void) const; + const std::vector& GetEntries() const; }; diff --git a/dDatabase/Tables/CDLootTableTable.cpp b/dDatabase/Tables/CDLootTableTable.cpp index 0a46784a..17dfd641 100644 --- a/dDatabase/Tables/CDLootTableTable.cpp +++ b/dDatabase/Tables/CDLootTableTable.cpp @@ -1,7 +1,6 @@ #include "CDLootTableTable.h" -//! Constructor -CDLootTableTable::CDLootTableTable(void) { +void CDLootTableTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -46,7 +45,7 @@ std::vector CDLootTableTable::Query(std::function& CDLootTableTable::GetEntries(void) const { +const std::vector& CDLootTableTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDLootTableTable.h b/dDatabase/Tables/CDLootTableTable.h index ba6f207e..baa300b0 100644 --- a/dDatabase/Tables/CDLootTableTable.h +++ b/dDatabase/Tables/CDLootTableTable.h @@ -16,10 +16,10 @@ private: std::vector entries; public: - CDLootTableTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - const std::vector& GetEntries(void) const; + const std::vector& GetEntries() const; }; diff --git a/dDatabase/Tables/CDMissionEmailTable.cpp b/dDatabase/Tables/CDMissionEmailTable.cpp index ed855d8a..207d3815 100644 --- a/dDatabase/Tables/CDMissionEmailTable.cpp +++ b/dDatabase/Tables/CDMissionEmailTable.cpp @@ -1,7 +1,6 @@ #include "CDMissionEmailTable.h" -//! Constructor -CDMissionEmailTable::CDMissionEmailTable(void) { +void CDMissionEmailTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -48,7 +47,7 @@ std::vector CDMissionEmailTable::Query(std::function CDMissionEmailTable::GetEntries(void) const { +const std::vector& CDMissionEmailTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDMissionEmailTable.h b/dDatabase/Tables/CDMissionEmailTable.h index db2310d4..954da78e 100644 --- a/dDatabase/Tables/CDMissionEmailTable.h +++ b/dDatabase/Tables/CDMissionEmailTable.h @@ -20,9 +20,9 @@ private: std::vector entries; public: - CDMissionEmailTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - std::vector GetEntries(void) const; + const std::vector& GetEntries() const; }; diff --git a/dDatabase/Tables/CDMissionNPCComponentTable.cpp b/dDatabase/Tables/CDMissionNPCComponentTable.cpp index 5672ed67..59ea40b7 100644 --- a/dDatabase/Tables/CDMissionNPCComponentTable.cpp +++ b/dDatabase/Tables/CDMissionNPCComponentTable.cpp @@ -1,7 +1,6 @@ #include "CDMissionNPCComponentTable.h" -//! Constructor -CDMissionNPCComponentTable::CDMissionNPCComponentTable(void) { +void CDMissionNPCComponentTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -45,7 +44,7 @@ std::vector CDMissionNPCComponentTable::Query(std::functi } //! Gets all the entries in the table -std::vector CDMissionNPCComponentTable::GetEntries(void) const { +const std::vector& CDMissionNPCComponentTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDMissionNPCComponentTable.h b/dDatabase/Tables/CDMissionNPCComponentTable.h index a7aeb145..2b2b3303 100644 --- a/dDatabase/Tables/CDMissionNPCComponentTable.h +++ b/dDatabase/Tables/CDMissionNPCComponentTable.h @@ -16,12 +16,12 @@ private: std::vector entries; public: - CDMissionNPCComponentTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); // Gets all the entries in the table - std::vector GetEntries(void) const; + const std::vector& GetEntries() const; }; diff --git a/dDatabase/Tables/CDMissionTasksTable.cpp b/dDatabase/Tables/CDMissionTasksTable.cpp index f32dca1b..9795ea8f 100644 --- a/dDatabase/Tables/CDMissionTasksTable.cpp +++ b/dDatabase/Tables/CDMissionTasksTable.cpp @@ -1,7 +1,6 @@ #include "CDMissionTasksTable.h" -//! Constructor -CDMissionTasksTable::CDMissionTasksTable(void) { +void CDMissionTasksTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -56,16 +55,14 @@ std::vector CDMissionTasksTable::GetByMissionID(uint32_t missio for (auto& entry : this->entries) { if (entry.id == missionID) { - CDMissionTasks* task = const_cast(&entry); - - tasks.push_back(task); + tasks.push_back(&entry); } } return tasks; } -const std::vector& CDMissionTasksTable::GetEntries(void) const { +const std::vector& CDMissionTasksTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDMissionTasksTable.h b/dDatabase/Tables/CDMissionTasksTable.h index fa213faf..0b169db8 100644 --- a/dDatabase/Tables/CDMissionTasksTable.h +++ b/dDatabase/Tables/CDMissionTasksTable.h @@ -24,12 +24,12 @@ private: std::vector entries; public: - CDMissionTasksTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); std::vector GetByMissionID(uint32_t missionID); - const std::vector& GetEntries(void) const; + const std::vector& GetEntries() const; }; diff --git a/dDatabase/Tables/CDMissionsTable.cpp b/dDatabase/Tables/CDMissionsTable.cpp index d4ee40ae..37f0c81c 100644 --- a/dDatabase/Tables/CDMissionsTable.cpp +++ b/dDatabase/Tables/CDMissionsTable.cpp @@ -2,8 +2,7 @@ CDMissions CDMissionsTable::Default = {}; -//! Constructor -CDMissionsTable::CDMissionsTable(void) { +void CDMissionsTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; diff --git a/dDatabase/Tables/CDMissionsTable.h b/dDatabase/Tables/CDMissionsTable.h index e6a44b02..c8ddc2a3 100644 --- a/dDatabase/Tables/CDMissionsTable.h +++ b/dDatabase/Tables/CDMissionsTable.h @@ -65,12 +65,12 @@ private: std::vector entries; public: - CDMissionsTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); // Gets all the entries in the table - const std::vector& GetEntries(void) const; + const std::vector& GetEntries() const; const CDMissions* GetPtrByMissionID(uint32_t missionID) const; diff --git a/dDatabase/Tables/CDMovementAIComponentTable.cpp b/dDatabase/Tables/CDMovementAIComponentTable.cpp index 3b9cc4f4..35b46416 100644 --- a/dDatabase/Tables/CDMovementAIComponentTable.cpp +++ b/dDatabase/Tables/CDMovementAIComponentTable.cpp @@ -1,7 +1,6 @@ #include "CDMovementAIComponentTable.h" -//! Constructor -CDMovementAIComponentTable::CDMovementAIComponentTable(void) { +void CDMovementAIComponentTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -37,7 +36,6 @@ CDMovementAIComponentTable::CDMovementAIComponentTable(void) { tableData.finalize(); } -//! Queries the table with a custom "where" clause std::vector CDMovementAIComponentTable::Query(std::function predicate) { std::vector data = cpplinq::from(this->entries) @@ -47,8 +45,7 @@ std::vector CDMovementAIComponentTable::Query(std::functi return data; } -//! Gets all the entries in the table -std::vector CDMovementAIComponentTable::GetEntries(void) const { +const std::vector& CDMovementAIComponentTable::GetEntries(void) const { return this->entries; } diff --git a/dDatabase/Tables/CDMovementAIComponentTable.h b/dDatabase/Tables/CDMovementAIComponentTable.h index 84896e2c..b40694bd 100644 --- a/dDatabase/Tables/CDMovementAIComponentTable.h +++ b/dDatabase/Tables/CDMovementAIComponentTable.h @@ -19,10 +19,10 @@ private: std::vector entries; public: - CDMovementAIComponentTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); // Gets all the entries in the table - std::vector GetEntries(void) const; + const std::vector& GetEntries() const; }; diff --git a/dDatabase/Tables/CDObjectSkillsTable.cpp b/dDatabase/Tables/CDObjectSkillsTable.cpp index 2e8b3fb2..2439622c 100644 --- a/dDatabase/Tables/CDObjectSkillsTable.cpp +++ b/dDatabase/Tables/CDObjectSkillsTable.cpp @@ -1,7 +1,6 @@ #include "CDObjectSkillsTable.h" -//! Constructor -CDObjectSkillsTable::CDObjectSkillsTable(void) { +void CDObjectSkillsTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -33,7 +32,6 @@ CDObjectSkillsTable::CDObjectSkillsTable(void) { tableData.finalize(); } -//! Queries the table with a custom "where" clause std::vector CDObjectSkillsTable::Query(std::function predicate) { std::vector data = cpplinq::from(this->entries) @@ -43,7 +41,6 @@ std::vector CDObjectSkillsTable::Query(std::function CDObjectSkillsTable::GetEntries(void) const { +const std::vector& CDObjectSkillsTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDObjectSkillsTable.h b/dDatabase/Tables/CDObjectSkillsTable.h index 4ceaa447..bd9929e2 100644 --- a/dDatabase/Tables/CDObjectSkillsTable.h +++ b/dDatabase/Tables/CDObjectSkillsTable.h @@ -15,12 +15,12 @@ private: std::vector entries; public: - CDObjectSkillsTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); // Gets all the entries in the table - std::vector GetEntries(void) const; + const std::vector& GetEntries() const; }; diff --git a/dDatabase/Tables/CDObjectsTable.cpp b/dDatabase/Tables/CDObjectsTable.cpp index c68c3e6a..d3094b68 100644 --- a/dDatabase/Tables/CDObjectsTable.cpp +++ b/dDatabase/Tables/CDObjectsTable.cpp @@ -1,8 +1,6 @@ #include "CDObjectsTable.h" -//! Constructor -CDObjectsTable::CDObjectsTable(void) { -#ifdef CDCLIENT_CACHE_ALL +void CDObjectsTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Objects"); @@ -20,25 +18,24 @@ CDObjectsTable::CDObjectsTable(void) { CDObjects entry; entry.id = tableData.getIntField("id", -1); entry.name = tableData.getStringField("name", ""); - entry.placeable = tableData.getIntField("placeable", -1); + UNUSED_COLUMN(entry.placeable = tableData.getIntField("placeable", -1);) entry.type = tableData.getStringField("type", ""); - entry.description = tableData.getStringField("description", ""); - entry.localize = tableData.getIntField("localize", -1); - entry.npcTemplateID = tableData.getIntField("npcTemplateID", -1); - entry.displayName = tableData.getStringField("displayName", ""); + UNUSED_COLUMN(entry.description = tableData.getStringField("description", "");) + UNUSED_COLUMN(entry.localize = tableData.getIntField("localize", -1);) + UNUSED_COLUMN(entry.npcTemplateID = tableData.getIntField("npcTemplateID", -1);) + UNUSED_COLUMN(entry.displayName = tableData.getStringField("displayName", "");) entry.interactionDistance = tableData.getFloatField("interactionDistance", -1.0f); - entry.nametag = tableData.getIntField("nametag", -1); - entry._internalNotes = tableData.getStringField("_internalNotes", ""); - entry.locStatus = tableData.getIntField("locStatus", -1); - entry.gate_version = tableData.getStringField("gate_version", ""); - entry.HQ_valid = tableData.getIntField("HQ_valid", -1); + UNUSED_COLUMN(entry.nametag = tableData.getIntField("nametag", -1);) + UNUSED_COLUMN(entry._internalNotes = tableData.getStringField("_internalNotes", "");) + UNUSED_COLUMN(entry.locStatus = tableData.getIntField("locStatus", -1);) + UNUSED_COLUMN(entry.gate_version = tableData.getStringField("gate_version", "");) + UNUSED_COLUMN(entry.HQ_valid = tableData.getIntField("HQ_valid", -1);) this->entries.insert(std::make_pair(entry.id, entry)); tableData.nextRow(); } tableData.finalize(); -#endif m_default.id = 0; } @@ -49,12 +46,10 @@ const CDObjects& CDObjectsTable::GetByID(unsigned int LOT) { return it->second; } -#ifndef CDCLIENT_CACHE_ALL - std::stringstream query; + auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Objects WHERE id = ?;"); + query.bind(1, static_cast(LOT)); - query << "SELECT * FROM Objects WHERE id = " << std::to_string(LOT); - - auto tableData = CDClientDatabase::ExecuteQuery(query.str()); + auto tableData = query.execQuery(); if (tableData.eof()) { this->entries.insert(std::make_pair(LOT, m_default)); return m_default; @@ -88,7 +83,6 @@ const CDObjects& CDObjectsTable::GetByID(unsigned int LOT) { if (it2 != entries.end()) { return it2->second; } -#endif return m_default; } diff --git a/dDatabase/Tables/CDObjectsTable.h b/dDatabase/Tables/CDObjectsTable.h index 171eddef..3a776684 100644 --- a/dDatabase/Tables/CDObjectsTable.h +++ b/dDatabase/Tables/CDObjectsTable.h @@ -26,7 +26,7 @@ private: CDObjects m_default; public: - CDObjectsTable(); + void LoadValuesFromDatabase(); // Gets an entry by ID const CDObjects& GetByID(unsigned int LOT); }; diff --git a/dDatabase/Tables/CDPackageComponentTable.cpp b/dDatabase/Tables/CDPackageComponentTable.cpp index efb85eeb..8b955162 100644 --- a/dDatabase/Tables/CDPackageComponentTable.cpp +++ b/dDatabase/Tables/CDPackageComponentTable.cpp @@ -1,7 +1,6 @@ #include "CDPackageComponentTable.h" -//! Constructor -CDPackageComponentTable::CDPackageComponentTable(void) { +void CDPackageComponentTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -43,7 +42,7 @@ std::vector CDPackageComponentTable::Query(std::function CDPackageComponentTable::GetEntries(void) const { +const std::vector& CDPackageComponentTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDPackageComponentTable.h b/dDatabase/Tables/CDPackageComponentTable.h index 6c11ab39..7ee58761 100644 --- a/dDatabase/Tables/CDPackageComponentTable.h +++ b/dDatabase/Tables/CDPackageComponentTable.h @@ -14,9 +14,9 @@ private: std::vector entries; public: - CDPackageComponentTable(void); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - std::vector GetEntries(void) const; + const std::vector& GetEntries() const; }; diff --git a/dDatabase/Tables/CDPhysicsComponentTable.cpp b/dDatabase/Tables/CDPhysicsComponentTable.cpp index bb21ed7f..e17be4df 100644 --- a/dDatabase/Tables/CDPhysicsComponentTable.cpp +++ b/dDatabase/Tables/CDPhysicsComponentTable.cpp @@ -1,46 +1,35 @@ #include "CDPhysicsComponentTable.h" -CDPhysicsComponentTable::CDPhysicsComponentTable(void) { +void CDPhysicsComponentTable::LoadValuesFromDatabase() { auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PhysicsComponent"); while (!tableData.eof()) { - CDPhysicsComponent* entry = new CDPhysicsComponent(); - entry->id = tableData.getIntField("id", -1); - entry->bStatic = tableData.getIntField("static", -1) != 0; - entry->physicsAsset = tableData.getStringField("physics_asset", ""); + CDPhysicsComponent entry; + entry.id = tableData.getIntField("id", -1); + entry.bStatic = tableData.getIntField("static", -1) != 0; + entry.physicsAsset = tableData.getStringField("physics_asset", ""); UNUSED(entry->jump = tableData.getIntField("jump", -1) != 0); UNUSED(entry->doublejump = tableData.getIntField("doublejump", -1) != 0); - entry->speed = tableData.getFloatField("speed", -1); + entry.speed = tableData.getFloatField("speed", -1); UNUSED(entry->rotSpeed = tableData.getFloatField("rotSpeed", -1)); - entry->playerHeight = tableData.getFloatField("playerHeight"); - entry->playerRadius = tableData.getFloatField("playerRadius"); - entry->pcShapeType = tableData.getIntField("pcShapeType"); - entry->collisionGroup = tableData.getIntField("collisionGroup"); + entry.playerHeight = tableData.getFloatField("playerHeight"); + entry.playerRadius = tableData.getFloatField("playerRadius"); + entry.pcShapeType = tableData.getIntField("pcShapeType"); + entry.collisionGroup = tableData.getIntField("collisionGroup"); UNUSED(entry->airSpeed = tableData.getFloatField("airSpeed")); UNUSED(entry->boundaryAsset = tableData.getStringField("boundaryAsset")); UNUSED(entry->jumpAirSpeed = tableData.getFloatField("jumpAirSpeed")); UNUSED(entry->friction = tableData.getFloatField("friction")); UNUSED(entry->gravityVolumeAsset = tableData.getStringField("gravityVolumeAsset")); - m_entries.insert(std::make_pair(entry->id, entry)); + m_entries.insert(std::make_pair(entry.id, entry)); tableData.nextRow(); } tableData.finalize(); } -CDPhysicsComponentTable::~CDPhysicsComponentTable() { - for (auto e : m_entries) { - if (e.second) delete e.second; - } - - m_entries.clear(); -} - CDPhysicsComponent* CDPhysicsComponentTable::GetByID(unsigned int componentID) { - for (auto e : m_entries) { - if (e.first == componentID) return e.second; - } - - return nullptr; + auto itr = m_entries.find(componentID); + return itr != m_entries.end() ? &itr->second : nullptr; } diff --git a/dDatabase/Tables/CDPhysicsComponentTable.h b/dDatabase/Tables/CDPhysicsComponentTable.h index e63d337d..49f3b4c3 100644 --- a/dDatabase/Tables/CDPhysicsComponentTable.h +++ b/dDatabase/Tables/CDPhysicsComponentTable.h @@ -23,12 +23,11 @@ struct CDPhysicsComponent { class CDPhysicsComponentTable : public CDTable { public: - CDPhysicsComponentTable(); - ~CDPhysicsComponentTable(); + void LoadValuesFromDatabase(); static const std::string GetTableName() { return "PhysicsComponent"; }; CDPhysicsComponent* GetByID(unsigned int componentID); private: - std::map m_entries; + std::map m_entries; }; diff --git a/dDatabase/Tables/CDPropertyEntranceComponentTable.cpp b/dDatabase/Tables/CDPropertyEntranceComponentTable.cpp index 1fead45e..c1532c86 100644 --- a/dDatabase/Tables/CDPropertyEntranceComponentTable.cpp +++ b/dDatabase/Tables/CDPropertyEntranceComponentTable.cpp @@ -1,7 +1,6 @@ - #include "CDPropertyEntranceComponentTable.h" -CDPropertyEntranceComponentTable::CDPropertyEntranceComponentTable() { +void CDPropertyEntranceComponentTable::LoadValuesFromDatabase() { // First, get the size of the table size_t size = 0; diff --git a/dDatabase/Tables/CDPropertyEntranceComponentTable.h b/dDatabase/Tables/CDPropertyEntranceComponentTable.h index 925fd1be..5c7d0965 100644 --- a/dDatabase/Tables/CDPropertyEntranceComponentTable.h +++ b/dDatabase/Tables/CDPropertyEntranceComponentTable.h @@ -11,12 +11,12 @@ struct CDPropertyEntranceComponent { class CDPropertyEntranceComponentTable : public CDTable { public: - CDPropertyEntranceComponentTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause CDPropertyEntranceComponent GetByID(uint32_t id); // Gets all the entries in the table - [[nodiscard]] std::vector GetEntries() const { return entries; } + [[nodiscard]] const std::vector& GetEntries() const { return entries; } private: std::vector entries{}; CDPropertyEntranceComponent defaultEntry{}; diff --git a/dDatabase/Tables/CDPropertyTemplateTable.cpp b/dDatabase/Tables/CDPropertyTemplateTable.cpp index 4caa6dc5..4a1d666e 100644 --- a/dDatabase/Tables/CDPropertyTemplateTable.cpp +++ b/dDatabase/Tables/CDPropertyTemplateTable.cpp @@ -1,6 +1,6 @@ #include "CDPropertyTemplateTable.h" -CDPropertyTemplateTable::CDPropertyTemplateTable() { +void CDPropertyTemplateTable::LoadValuesFromDatabase() { // First, get the size of the table size_t size = 0; diff --git a/dDatabase/Tables/CDPropertyTemplateTable.h b/dDatabase/Tables/CDPropertyTemplateTable.h index cb075dbf..7261bdf9 100644 --- a/dDatabase/Tables/CDPropertyTemplateTable.h +++ b/dDatabase/Tables/CDPropertyTemplateTable.h @@ -10,7 +10,7 @@ struct CDPropertyTemplate { class CDPropertyTemplateTable : public CDTable { public: - CDPropertyTemplateTable(); + void LoadValuesFromDatabase(); static const std::string GetTableName() { return "PropertyTemplate"; }; CDPropertyTemplate GetByMapID(uint32_t mapID); diff --git a/dDatabase/Tables/CDProximityMonitorComponentTable.cpp b/dDatabase/Tables/CDProximityMonitorComponentTable.cpp index 688de056..ae0abac8 100644 --- a/dDatabase/Tables/CDProximityMonitorComponentTable.cpp +++ b/dDatabase/Tables/CDProximityMonitorComponentTable.cpp @@ -1,7 +1,6 @@ #include "CDProximityMonitorComponentTable.h" -//! Constructor -CDProximityMonitorComponentTable::CDProximityMonitorComponentTable(void) { +void CDProximityMonitorComponentTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -33,7 +32,6 @@ CDProximityMonitorComponentTable::CDProximityMonitorComponentTable(void) { tableData.finalize(); } -//! Queries the table with a custom "where" clause std::vector CDProximityMonitorComponentTable::Query(std::function predicate) { std::vector data = cpplinq::from(this->entries) @@ -43,8 +41,7 @@ std::vector CDProximityMonitorComponentTable::Query return data; } -//! Gets all the entries in the table -std::vector CDProximityMonitorComponentTable::GetEntries(void) const { +const std::vector& CDProximityMonitorComponentTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDProximityMonitorComponentTable.h b/dDatabase/Tables/CDProximityMonitorComponentTable.h index 38b7d43b..a50dd37e 100644 --- a/dDatabase/Tables/CDProximityMonitorComponentTable.h +++ b/dDatabase/Tables/CDProximityMonitorComponentTable.h @@ -15,9 +15,9 @@ private: std::vector entries; public: - CDProximityMonitorComponentTable(void); + void LoadValuesFromDatabase(); //! Queries the table with a custom "where" clause std::vector Query(std::function predicate); - std::vector GetEntries(void) const; + const std::vector& GetEntries() const; }; diff --git a/dDatabase/Tables/CDRailActivatorComponent.cpp b/dDatabase/Tables/CDRailActivatorComponent.cpp index 2ff8990d..34ec5826 100644 --- a/dDatabase/Tables/CDRailActivatorComponent.cpp +++ b/dDatabase/Tables/CDRailActivatorComponent.cpp @@ -1,7 +1,7 @@ #include "CDRailActivatorComponent.h" #include "GeneralUtils.h" -CDRailActivatorComponentTable::CDRailActivatorComponentTable() { +void CDRailActivatorComponentTable::LoadValuesFromDatabase() { auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM RailActivatorComponent;"); while (!tableData.eof()) { CDRailActivatorComponent entry; @@ -52,7 +52,7 @@ CDRailActivatorComponent CDRailActivatorComponentTable::GetEntryByID(int32_t id) return {}; } -std::vector CDRailActivatorComponentTable::GetEntries() const { +const std::vector& CDRailActivatorComponentTable::GetEntries() const { return m_Entries; } diff --git a/dDatabase/Tables/CDRailActivatorComponent.h b/dDatabase/Tables/CDRailActivatorComponent.h index 03dd0525..d06b2d36 100644 --- a/dDatabase/Tables/CDRailActivatorComponent.h +++ b/dDatabase/Tables/CDRailActivatorComponent.h @@ -22,10 +22,10 @@ struct CDRailActivatorComponent { class CDRailActivatorComponentTable : public CDTable { public: - CDRailActivatorComponentTable(); + void LoadValuesFromDatabase(); static const std::string GetTableName() { return "RailActivatorComponent"; }; [[nodiscard]] CDRailActivatorComponent GetEntryByID(int32_t id) const; - [[nodiscard]] std::vector GetEntries() const; + [[nodiscard]] const std::vector& GetEntries() const; private: static std::pair EffectPairFromString(std::string& str); std::vector m_Entries{}; diff --git a/dDatabase/Tables/CDRarityTableTable.cpp b/dDatabase/Tables/CDRarityTableTable.cpp index 0b1212c0..b0295a59 100644 --- a/dDatabase/Tables/CDRarityTableTable.cpp +++ b/dDatabase/Tables/CDRarityTableTable.cpp @@ -1,7 +1,6 @@ #include "CDRarityTableTable.h" -//! Constructor -CDRarityTableTable::CDRarityTableTable(void) { +void CDRarityTableTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -44,7 +43,7 @@ std::vector CDRarityTableTable::Query(std::function& CDRarityTableTable::GetEntries(void) const { +const std::vector& CDRarityTableTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDRarityTableTable.h b/dDatabase/Tables/CDRarityTableTable.h index 592346ed..2d28e4a5 100644 --- a/dDatabase/Tables/CDRarityTableTable.h +++ b/dDatabase/Tables/CDRarityTableTable.h @@ -31,7 +31,7 @@ private: std::vector entries; public: - CDRarityTableTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); diff --git a/dDatabase/Tables/CDRebuildComponentTable.cpp b/dDatabase/Tables/CDRebuildComponentTable.cpp index d5c386d1..f5706a28 100644 --- a/dDatabase/Tables/CDRebuildComponentTable.cpp +++ b/dDatabase/Tables/CDRebuildComponentTable.cpp @@ -1,7 +1,6 @@ #include "CDRebuildComponentTable.h" -//! Constructor -CDRebuildComponentTable::CDRebuildComponentTable(void) { +void CDRebuildComponentTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -39,7 +38,6 @@ CDRebuildComponentTable::CDRebuildComponentTable(void) { tableData.finalize(); } -//! Queries the table with a custom "where" clause std::vector CDRebuildComponentTable::Query(std::function predicate) { std::vector data = cpplinq::from(this->entries) @@ -49,8 +47,7 @@ std::vector CDRebuildComponentTable::Query(std::function CDRebuildComponentTable::GetEntries(void) const { +const std::vector& CDRebuildComponentTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDRebuildComponentTable.h b/dDatabase/Tables/CDRebuildComponentTable.h index db70a47d..fc78e904 100644 --- a/dDatabase/Tables/CDRebuildComponentTable.h +++ b/dDatabase/Tables/CDRebuildComponentTable.h @@ -21,10 +21,10 @@ private: std::vector entries; public: - CDRebuildComponentTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - std::vector GetEntries() const; + const std::vector& GetEntries() const; }; diff --git a/dDatabase/Tables/CDRewardsTable.cpp b/dDatabase/Tables/CDRewardsTable.cpp index 55672add..27c2344a 100644 --- a/dDatabase/Tables/CDRewardsTable.cpp +++ b/dDatabase/Tables/CDRewardsTable.cpp @@ -1,35 +1,27 @@ #include "CDRewardsTable.h" -CDRewardsTable::CDRewardsTable(void) { +void CDRewardsTable::LoadValuesFromDatabase() { auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Rewards"); while (!tableData.eof()) { - CDRewards* entry = new CDRewards(); - entry->id = tableData.getIntField("id", -1); - entry->levelID = tableData.getIntField("LevelID", -1); - entry->missionID = tableData.getIntField("MissionID", -1); - entry->rewardType = tableData.getIntField("RewardType", -1); - entry->value = tableData.getIntField("value", -1); - entry->count = tableData.getIntField("count", -1); + CDRewards entry; + entry.id = tableData.getIntField("id", -1); + entry.levelID = tableData.getIntField("LevelID", -1); + entry.missionID = tableData.getIntField("MissionID", -1); + entry.rewardType = tableData.getIntField("RewardType", -1); + entry.value = tableData.getIntField("value", -1); + entry.count = tableData.getIntField("count", -1); - m_entries.insert(std::make_pair(entry->id, entry)); + m_entries.insert(std::make_pair(entry.id, entry)); tableData.nextRow(); } tableData.finalize(); } -CDRewardsTable::~CDRewardsTable(void) { - for (auto e : m_entries) { - if (e.second) delete e.second; - } - - m_entries.clear(); -} - -std::vector CDRewardsTable::GetByLevelID(uint32_t levelID) { - std::vector result{}; +std::vector CDRewardsTable::GetByLevelID(uint32_t levelID) { + std::vector result{}; for (const auto& e : m_entries) { - if (e.second->levelID == levelID) result.push_back(e.second); + if (e.second.levelID == levelID) result.push_back(e.second); } return result; diff --git a/dDatabase/Tables/CDRewardsTable.h b/dDatabase/Tables/CDRewardsTable.h index 2e079a83..9c24397b 100644 --- a/dDatabase/Tables/CDRewardsTable.h +++ b/dDatabase/Tables/CDRewardsTable.h @@ -13,12 +13,11 @@ struct CDRewards { class CDRewardsTable : public CDTable { public: - CDRewardsTable(); - ~CDRewardsTable(); + void LoadValuesFromDatabase(); static const std::string GetTableName() { return "Rewards"; }; - std::vector GetByLevelID(uint32_t levelID); + std::vector GetByLevelID(uint32_t levelID); private: - std::map m_entries; + std::map m_entries; }; diff --git a/dDatabase/Tables/CDScriptComponentTable.cpp b/dDatabase/Tables/CDScriptComponentTable.cpp index 8050c139..1a922199 100644 --- a/dDatabase/Tables/CDScriptComponentTable.cpp +++ b/dDatabase/Tables/CDScriptComponentTable.cpp @@ -1,7 +1,6 @@ #include "CDScriptComponentTable.h" -//! Constructor -CDScriptComponentTable::CDScriptComponentTable(void) { +void CDScriptComponentTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; diff --git a/dDatabase/Tables/CDScriptComponentTable.h b/dDatabase/Tables/CDScriptComponentTable.h index 77453939..d2b7e7ae 100644 --- a/dDatabase/Tables/CDScriptComponentTable.h +++ b/dDatabase/Tables/CDScriptComponentTable.h @@ -15,7 +15,7 @@ private: CDScriptComponent m_ToReturnWhenNoneFound; public: - CDScriptComponentTable(); + void LoadValuesFromDatabase(); // Gets an entry by scriptID const CDScriptComponent& GetByID(unsigned int id); }; diff --git a/dDatabase/Tables/CDSkillBehaviorTable.cpp b/dDatabase/Tables/CDSkillBehaviorTable.cpp index c5df78ef..8ffbb5ce 100644 --- a/dDatabase/Tables/CDSkillBehaviorTable.cpp +++ b/dDatabase/Tables/CDSkillBehaviorTable.cpp @@ -1,8 +1,6 @@ #include "CDSkillBehaviorTable.h" -//#include "Logger.hpp" -//! Constructor -CDSkillBehaviorTable::CDSkillBehaviorTable(void) { +void CDSkillBehaviorTable::LoadValuesFromDatabase() { m_empty = CDSkillBehavior(); // First, get the size of the table @@ -51,13 +49,6 @@ CDSkillBehaviorTable::CDSkillBehaviorTable(void) { tableData.finalize(); } -//! Queries the table with a custom "where" clause -std::vector CDSkillBehaviorTable::Query(std::function predicate) { - std::vector data; //So MSVC shuts up - return data; -} - -//! Gets an entry by ID const CDSkillBehavior& CDSkillBehaviorTable::GetSkillByID(unsigned int skillID) { std::map::iterator it = this->entries.find(skillID); if (it != this->entries.end()) { diff --git a/dDatabase/Tables/CDSkillBehaviorTable.h b/dDatabase/Tables/CDSkillBehaviorTable.h index eb3094e0..5b1081cd 100644 --- a/dDatabase/Tables/CDSkillBehaviorTable.h +++ b/dDatabase/Tables/CDSkillBehaviorTable.h @@ -31,9 +31,7 @@ private: CDSkillBehavior m_empty; public: - CDSkillBehaviorTable(); - // Queries the table with a custom "where" clause - std::vector Query(std::function predicate); + void LoadValuesFromDatabase(); // Gets an entry by skillID const CDSkillBehavior& GetSkillByID(unsigned int skillID); diff --git a/dDatabase/Tables/CDVendorComponentTable.cpp b/dDatabase/Tables/CDVendorComponentTable.cpp index 17989dfb..0f963b04 100644 --- a/dDatabase/Tables/CDVendorComponentTable.cpp +++ b/dDatabase/Tables/CDVendorComponentTable.cpp @@ -1,7 +1,6 @@ #include "CDVendorComponentTable.h" -//! Constructor -CDVendorComponentTable::CDVendorComponentTable(void) { +void CDVendorComponentTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; @@ -45,7 +44,7 @@ std::vector CDVendorComponentTable::Query(std::function CDVendorComponentTable::GetEntries(void) const { +const std::vector& CDVendorComponentTable::GetEntries() const { return this->entries; } diff --git a/dDatabase/Tables/CDVendorComponentTable.h b/dDatabase/Tables/CDVendorComponentTable.h index f2666d7e..29854d49 100644 --- a/dDatabase/Tables/CDVendorComponentTable.h +++ b/dDatabase/Tables/CDVendorComponentTable.h @@ -16,10 +16,10 @@ private: std::vector entries; public: - CDVendorComponentTable(); + void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - std::vector GetEntries(void) const; + const std::vector& GetEntries(void) const; }; diff --git a/dDatabase/Tables/CDZoneTableTable.cpp b/dDatabase/Tables/CDZoneTableTable.cpp index bafbf8fe..1030593e 100644 --- a/dDatabase/Tables/CDZoneTableTable.cpp +++ b/dDatabase/Tables/CDZoneTableTable.cpp @@ -1,7 +1,6 @@ #include "CDZoneTableTable.h" -//! Constructor -CDZoneTableTable::CDZoneTableTable(void) { +void CDZoneTableTable::LoadValuesFromDatabase() { // First, get the size of the table unsigned int size = 0; diff --git a/dDatabase/Tables/CDZoneTableTable.h b/dDatabase/Tables/CDZoneTableTable.h index f844fd25..fef8096f 100644 --- a/dDatabase/Tables/CDZoneTableTable.h +++ b/dDatabase/Tables/CDZoneTableTable.h @@ -38,7 +38,7 @@ private: std::map m_Entries; public: - CDZoneTableTable(); + void LoadValuesFromDatabase(); // Queries the table with a zoneID to find. const CDZoneTable* Query(unsigned int zoneID); diff --git a/dGame/dComponents/LevelProgressionComponent.cpp b/dGame/dComponents/LevelProgressionComponent.cpp index 265dd8e6..9930bdef 100644 --- a/dGame/dComponents/LevelProgressionComponent.cpp +++ b/dGame/dComponents/LevelProgressionComponent.cpp @@ -56,19 +56,19 @@ void LevelProgressionComponent::HandleLevelUp() { // Tell the client we beginning to send level rewards. if (rewardingItem) GameMessages::NotifyLevelRewards(m_Parent->GetObjectID(), m_Parent->GetSystemAddress(), m_Level, rewardingItem); - for (auto* reward : rewards) { - switch (reward->rewardType) { + for (const auto& reward : rewards) { + switch (reward.rewardType) { case 0: - inventoryComponent->AddItem(reward->value, reward->count, eLootSourceType::LEVEL_REWARD); + inventoryComponent->AddItem(reward.value, reward.count, eLootSourceType::LEVEL_REWARD); break; case 4: { auto* items = inventoryComponent->GetInventory(eInventoryType::ITEMS); - items->SetSize(items->GetSize() + reward->value); + items->SetSize(items->GetSize() + reward.value); } break; case 9: - SetSpeedBase(static_cast(reward->value) ); + SetSpeedBase(static_cast(reward.value) ); controllablePhysicsComponent->SetSpeedMultiplier(GetSpeedBase() / 500.0f); break; case 11: