From 1a0aaf31230c78ab84c4ffac97bdcef954f219df Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Wed, 6 Mar 2024 17:46:16 -0800 Subject: [PATCH 1/5] add info to debug logs (#1495) --- dGame/dUtilities/VanityUtilities.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dGame/dUtilities/VanityUtilities.cpp b/dGame/dUtilities/VanityUtilities.cpp index 0324ee1b..cb893da3 100644 --- a/dGame/dUtilities/VanityUtilities.cpp +++ b/dGame/dUtilities/VanityUtilities.cpp @@ -285,7 +285,7 @@ void ParseXml(const std::string& file) { } if (zoneID.value() != currentZoneID) { - LOG_DEBUG("Skipping location because it is in %i and not the current zone (%i)", zoneID.value(), currentZoneID); + LOG_DEBUG("Skipping (%s) %i location because it is in %i and not the current zone (%i)", name, lot, zoneID.value(), currentZoneID); continue; } From fcb89b3c7afae4738a05134235a8fda24a925ad1 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Wed, 6 Mar 2024 17:49:29 -0800 Subject: [PATCH 2/5] Remove multiple Script syntax (#1496) --- dGame/Entity.cpp | 132 +++++------------- dGame/Entity.h | 3 +- dGame/dBehaviors/SkillEventBehavior.cpp | 9 +- dGame/dComponents/CMakeLists.txt | 1 + dGame/dComponents/DestroyableComponent.cpp | 8 +- dGame/dComponents/MovingPlatformComponent.cpp | 8 +- dGame/dComponents/PetComponent.cpp | 16 +-- .../PropertyManagementComponent.cpp | 4 +- dGame/dComponents/QuickBuildComponent.cpp | 21 ++- .../dComponents}/ScriptComponent.cpp | 2 +- .../dComponents}/ScriptComponent.h | 2 +- dGame/dComponents/SkillComponent.cpp | 4 +- dGame/dComponents/TriggerComponent.cpp | 7 +- dGame/dGameMessages/GameMessageHandler.cpp | 8 +- dGame/dGameMessages/GameMessages.cpp | 24 +--- .../Map/NT/NtCombatChallengeDummy.cpp | 9 +- .../NT/NtCombatChallengeExplodingDummy.cpp | 8 +- dScripts/CMakeLists.txt | 1 - dScripts/CppScripts.cpp | 25 ++-- dScripts/CppScripts.h | 8 +- 20 files changed, 97 insertions(+), 203 deletions(-) rename {dScripts => dGame/dComponents}/ScriptComponent.cpp (95%) rename {dScripts => dGame/dComponents}/ScriptComponent.h (97%) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 9af811bc..23f65540 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -146,17 +146,15 @@ Entity::~Entity() { return; } - Entity* zoneControl = Game::entityManager->GetZoneControlEntity(); - for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) { - script->OnPlayerExit(zoneControl, this); + auto* zoneControl = Game::entityManager->GetZoneControlEntity(); + if (zoneControl) { + zoneControl->GetScript()->OnPlayerExit(zoneControl, this); } std::vector scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY); for (Entity* scriptEntity : scriptedActs) { if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds - for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) { - script->OnPlayerExit(scriptEntity, this); - } + scriptEntity->GetScript()->OnPlayerExit(scriptEntity, this); } } } @@ -762,9 +760,7 @@ void Entity::Initialize() { // Hacky way to trigger these when the object has had a chance to get constructed AddCallbackTimer(0, [this]() { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnStartup(this); - } + this->GetScript()->OnStartup(this); }); if (!m_Character && Game::entityManager->GetGhostingEnabled()) { @@ -839,15 +835,6 @@ bool Entity::HasComponent(const eReplicaComponentType componentId) const { return m_Components.find(componentId) != m_Components.end(); } -std::vector Entity::GetScriptComponents() { - std::vector comps; - - auto* scriptComponent = GetComponent(); - if (scriptComponent) comps.push_back(scriptComponent); - - return comps; -} - void Entity::Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName) { if (notificationName == "HitOrHealResult" || notificationName == "Hit") { auto* destroyableComponent = GetComponent(); @@ -1276,9 +1263,7 @@ void Entity::Update(const float deltaTime) { // Remove the timer from the list of timers first so that scripts and events can remove timers without causing iterator invalidation auto timerName = timer.GetName(); m_Timers.erase(m_Timers.begin() + timerPosition); - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnTimerDone(this, timerName); - } + GetScript()->OnTimerDone(this, timerName); TriggerEvent(eTriggerEventType::TIMER_DONE, this); } else { @@ -1324,9 +1309,7 @@ void Entity::Update(const float deltaTime) { Wake(); } - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnUpdate(this); - } + GetScript()->OnUpdate(this); for (const auto& pair : m_Components) { if (pair.second == nullptr) continue; @@ -1343,9 +1326,7 @@ void Entity::OnCollisionProximity(LWOOBJID otherEntity, const std::string& proxN Entity* other = Game::entityManager->GetEntity(otherEntity); if (!other) return; - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnProximityUpdate(this, other, proxName, status); - } + GetScript()->OnProximityUpdate(this, other, proxName, status); RocketLaunchpadControlComponent* rocketComp = GetComponent(); if (!rocketComp) return; @@ -1357,9 +1338,7 @@ void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) { auto* other = Game::entityManager->GetEntity(otherEntity); if (!other) return; - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnCollisionPhantom(this, other); - } + GetScript()->OnCollisionPhantom(this, other); for (const auto& callback : m_PhantomCollisionCallbacks) { callback(other); @@ -1398,9 +1377,7 @@ void Entity::OnCollisionLeavePhantom(const LWOOBJID otherEntity) { auto* other = Game::entityManager->GetEntity(otherEntity); if (!other) return; - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnOffCollisionPhantom(this, other); - } + GetScript()->OnOffCollisionPhantom(this, other); TriggerEvent(eTriggerEventType::EXIT, other); @@ -1417,46 +1394,32 @@ void Entity::OnCollisionLeavePhantom(const LWOOBJID otherEntity) { } void Entity::OnFireEventServerSide(Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnFireEventServerSide(this, sender, args, param1, param2, param3); - } + GetScript()->OnFireEventServerSide(this, sender, args, param1, param2, param3); } void Entity::OnActivityStateChangeRequest(LWOOBJID senderID, int32_t value1, int32_t value2, const std::u16string& stringValue) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnActivityStateChangeRequest(this, senderID, value1, value2, stringValue); - } + GetScript()->OnActivityStateChangeRequest(this, senderID, value1, value2, stringValue); } void Entity::OnCinematicUpdate(Entity* self, Entity* sender, eCinematicEvent event, const std::u16string& pathName, float_t pathTime, float_t totalTime, int32_t waypoint) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnCinematicUpdate(self, sender, event, pathName, pathTime, totalTime, waypoint); - } + GetScript()->OnCinematicUpdate(self, sender, event, pathName, pathTime, totalTime, waypoint); } void Entity::NotifyObject(Entity* sender, const std::string& name, int32_t param1, int32_t param2) { GameMessages::SendNotifyObject(GetObjectID(), sender->GetObjectID(), GeneralUtils::ASCIIToUTF16(name), UNASSIGNED_SYSTEM_ADDRESS); - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnNotifyObject(this, sender, name, param1, param2); - } + GetScript()->OnNotifyObject(this, sender, name, param1, param2); } void Entity::OnEmoteReceived(const int32_t emote, Entity* target) { - for (auto* script : CppScripts::GetEntityScripts(this)) { - script->OnEmoteReceived(this, emote, target); - } + GetScript()->OnEmoteReceived(this, emote, target); } void Entity::OnUse(Entity* originator) { TriggerEvent(eTriggerEventType::INTERACT, originator); - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnUse(this, originator); - } - - // component base class when + GetScript()->OnUse(this, originator); for (const auto& pair : m_Components) { if (pair.second == nullptr) continue; @@ -1466,82 +1429,63 @@ void Entity::OnUse(Entity* originator) { } void Entity::OnHitOrHealResult(Entity* attacker, int32_t damage) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnHitOrHealResult(this, attacker, damage); - } + GetScript()->OnHitOrHealResult(this, attacker, damage); } void Entity::OnHit(Entity* attacker) { TriggerEvent(eTriggerEventType::HIT, attacker); - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnHit(this, attacker); - } + GetScript()->OnHit(this, attacker); } void Entity::OnZonePropertyEditBegin() { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnZonePropertyEditBegin(this); - } + GetScript()->OnZonePropertyEditBegin(this); } void Entity::OnZonePropertyEditEnd() { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnZonePropertyEditEnd(this); - } + GetScript()->OnZonePropertyEditEnd(this); } void Entity::OnZonePropertyModelEquipped() { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnZonePropertyModelEquipped(this); - } + GetScript()->OnZonePropertyModelEquipped(this); } void Entity::OnZonePropertyModelPlaced(Entity* player) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnZonePropertyModelPlaced(this, player); - } + GetScript()->OnZonePropertyModelPlaced(this, player); } void Entity::OnZonePropertyModelPickedUp(Entity* player) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnZonePropertyModelPickedUp(this, player); - } + GetScript()->OnZonePropertyModelPickedUp(this, player); } void Entity::OnZonePropertyModelRemoved(Entity* player) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnZonePropertyModelRemoved(this, player); - } + GetScript()->OnZonePropertyModelRemoved(this, player); } void Entity::OnZonePropertyModelRemovedWhileEquipped(Entity* player) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnZonePropertyModelRemovedWhileEquipped(this, player); - } + GetScript()->OnZonePropertyModelRemovedWhileEquipped(this, player); } void Entity::OnZonePropertyModelRotated(Entity* player) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnZonePropertyModelRotated(this, player); - } + GetScript()->OnZonePropertyModelRotated(this, player); } void Entity::OnMessageBoxResponse(Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnMessageBoxResponse(this, sender, button, identifier, userData); - } + GetScript()->OnMessageBoxResponse(this, sender, button, identifier, userData); } void Entity::OnChoiceBoxResponse(Entity* sender, int32_t button, const std::u16string& buttonIdentifier, const std::u16string& identifier) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnChoiceBoxResponse(this, sender, button, buttonIdentifier, identifier); - } + GetScript()->OnChoiceBoxResponse(this, sender, button, buttonIdentifier, identifier); } void Entity::RequestActivityExit(Entity* sender, LWOOBJID player, bool canceled) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnRequestActivityExit(sender, player, canceled); - } + GetScript()->OnRequestActivityExit(sender, player, canceled); +} + +CppScripts::Script* const Entity::GetScript() { + auto* scriptComponent = GetComponent(); + auto* script = scriptComponent ? scriptComponent->GetScript() : CppScripts::GetInvalidScript(); + DluAssert(script != nullptr); + return script; } void Entity::Smash(const LWOOBJID source, const eKillType killType, const std::u16string& deathType) { @@ -1574,9 +1518,7 @@ void Entity::Kill(Entity* murderer, const eKillType killType) { //OMAI WA MOU, SHINDERIU - for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { - script->OnDie(this, murderer); - } + GetScript()->OnDie(this, murderer); if (m_Spawner != nullptr) { m_Spawner->NotifyOfEntityDeath(m_ObjectID); diff --git a/dGame/Entity.h b/dGame/Entity.h index a2d4d132..740d7c92 100644 --- a/dGame/Entity.h +++ b/dGame/Entity.h @@ -146,7 +146,8 @@ public: void AddComponent(eReplicaComponentType componentId, Component* component); - std::vector GetScriptComponents(); + // This is expceted to never return nullptr, an assert checks this. + CppScripts::Script* const GetScript(); void Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName); void Unsubscribe(LWOOBJID scriptObjId, const std::string& notificationName); diff --git a/dGame/dBehaviors/SkillEventBehavior.cpp b/dGame/dBehaviors/SkillEventBehavior.cpp index e007fbe2..2de801a2 100644 --- a/dGame/dBehaviors/SkillEventBehavior.cpp +++ b/dGame/dBehaviors/SkillEventBehavior.cpp @@ -3,15 +3,14 @@ #include "BehaviorContext.h" #include "EntityManager.h" #include "CppScripts.h" +#include "Entity.h" void SkillEventBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); auto* caster = Game::entityManager->GetEntity(context->originator); if (caster != nullptr && target != nullptr && this->m_effectHandle != nullptr && !this->m_effectHandle->empty()) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(target)) { - script->OnSkillEventFired(target, caster, *this->m_effectHandle); - } + target->GetScript()->OnSkillEventFired(target, caster, *this->m_effectHandle); } } @@ -21,8 +20,6 @@ SkillEventBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitSt auto* caster = Game::entityManager->GetEntity(context->originator); if (caster != nullptr && target != nullptr && this->m_effectHandle != nullptr && !this->m_effectHandle->empty()) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(target)) { - script->OnSkillEventFired(target, caster, *this->m_effectHandle); - } + target->GetScript()->OnSkillEventFired(target, caster, *this->m_effectHandle); } } diff --git a/dGame/dComponents/CMakeLists.txt b/dGame/dComponents/CMakeLists.txt index 9c58a0ea..c60e135f 100644 --- a/dGame/dComponents/CMakeLists.txt +++ b/dGame/dComponents/CMakeLists.txt @@ -48,6 +48,7 @@ set(DGAME_DCOMPONENTS_SOURCES "HavokVehiclePhysicsComponent.cpp" "VendorComponent.cpp" "MiniGameControlComponent.cpp" + "ScriptComponent.cpp" ) add_library(dComponents OBJECT ${DGAME_DCOMPONENTS_SOURCES}) diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index 39643baf..1b9b3285 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -785,16 +785,12 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType } Entity* zoneControl = Game::entityManager->GetZoneControlEntity(); - for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) { - script->OnPlayerDied(zoneControl, m_Parent); - } + if (zoneControl) zoneControl->GetScript()->OnPlayerDied(zoneControl, m_Parent); std::vector scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY); for (Entity* scriptEntity : scriptedActs) { if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds - for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) { - script->OnPlayerDied(scriptEntity, m_Parent); - } + scriptEntity->GetScript()->OnPlayerDied(scriptEntity, m_Parent); } } } diff --git a/dGame/dComponents/MovingPlatformComponent.cpp b/dGame/dComponents/MovingPlatformComponent.cpp index 77e90983..77acbb8d 100644 --- a/dGame/dComponents/MovingPlatformComponent.cpp +++ b/dGame/dComponents/MovingPlatformComponent.cpp @@ -183,9 +183,7 @@ void MovingPlatformComponent::StartPathing() { const auto travelNext = subComponent->mWaitTime + travelTime; m_Parent->AddCallbackTimer(travelTime, [subComponent, this] { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnWaypointReached(m_Parent, subComponent->mNextWaypointIndex); - } + this->m_Parent->GetScript()->OnWaypointReached(m_Parent, subComponent->mNextWaypointIndex); }); m_Parent->AddCallbackTimer(travelNext, [this] { @@ -295,9 +293,7 @@ void MovingPlatformComponent::ContinuePathing() { const auto travelNext = subComponent->mWaitTime + travelTime; m_Parent->AddCallbackTimer(travelTime, [subComponent, this] { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnWaypointReached(m_Parent, subComponent->mNextWaypointIndex); - } + this->m_Parent->GetScript()->OnWaypointReached(m_Parent, subComponent->mNextWaypointIndex); }); m_Parent->AddCallbackTimer(travelNext, [this] { diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index a016eb36..a6bb00fb 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -306,9 +306,7 @@ void PetComponent::OnUse(Entity* originator) { currentActivities.insert_or_assign(m_Tamer, m_Parent->GetObjectID()); // Notify the start of a pet taming minigame - for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnNotifyPetTamingMinigame(m_Parent, originator, ePetTamingNotifyType::BEGIN); - } + m_Parent->GetScript()->OnNotifyPetTamingMinigame(m_Parent, originator, ePetTamingNotifyType::BEGIN); } void PetComponent::Update(float deltaTime) { @@ -690,9 +688,7 @@ void PetComponent::RequestSetPetName(std::u16string name) { m_Tamer = LWOOBJID_EMPTY; // Notify the end of a pet taming minigame - for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::SUCCESS); - } + m_Parent->GetScript()->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::SUCCESS); } void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) { @@ -731,9 +727,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) { Game::entityManager->SerializeEntity(m_Parent); // Notify the end of a pet taming minigame - for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::QUIT); - } + m_Parent->GetScript()->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::QUIT); } void PetComponent::StartTimer() { @@ -782,9 +776,7 @@ void PetComponent::ClientFailTamingMinigame() { Game::entityManager->SerializeEntity(m_Parent); // Notify the end of a pet taming minigame - for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::FAILED); - } + m_Parent->GetScript()->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::FAILED); } void PetComponent::Wander() { diff --git a/dGame/dComponents/PropertyManagementComponent.cpp b/dGame/dComponents/PropertyManagementComponent.cpp index 0dfc04af..2acc6a5d 100644 --- a/dGame/dComponents/PropertyManagementComponent.cpp +++ b/dGame/dComponents/PropertyManagementComponent.cpp @@ -214,9 +214,7 @@ bool PropertyManagementComponent::Claim(const LWOOBJID playerId) { Database::Get()->InsertNewProperty(info, templateId, worldId); auto* zoneControlObject = Game::zoneManager->GetZoneControlObject(); - for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControlObject)) { - script->OnZonePropertyRented(zoneControlObject, entity); - } + if (zoneControlObject) zoneControlObject->GetScript()->OnZonePropertyRented(zoneControlObject, entity); return true; } diff --git a/dGame/dComponents/QuickBuildComponent.cpp b/dGame/dComponents/QuickBuildComponent.cpp index c8ca4407..e3aed82d 100644 --- a/dGame/dComponents/QuickBuildComponent.cpp +++ b/dGame/dComponents/QuickBuildComponent.cpp @@ -414,13 +414,11 @@ void QuickBuildComponent::StartQuickBuild(Entity* const user) { movingPlatform->OnQuickBuildInitilized(); } - for (auto* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnQuickBuildStart(m_Parent, user); - } + auto* script = m_Parent->GetScript(); + script->OnQuickBuildStart(m_Parent, user); // Notify scripts and possible subscribers - for (auto* script : CppScripts::GetEntityScripts(m_Parent)) - script->OnQuickBuildNotifyState(m_Parent, m_State); + script->OnQuickBuildNotifyState(m_Parent, m_State); for (const auto& cb : m_QuickBuildStateCallbacks) cb(m_State); } @@ -485,10 +483,9 @@ void QuickBuildComponent::CompleteQuickBuild(Entity* const user) { } // Notify scripts - for (auto* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnQuickBuildComplete(m_Parent, user); - script->OnQuickBuildNotifyState(m_Parent, m_State); - } + auto* script = m_Parent->GetScript(); + script->OnQuickBuildComplete(m_Parent, user); + script->OnQuickBuildNotifyState(m_Parent, m_State); // Notify subscribers for (const auto& callback : m_QuickBuildStateCallbacks) @@ -539,8 +536,7 @@ void QuickBuildComponent::ResetQuickBuild(const bool failed) { Game::entityManager->SerializeEntity(m_Parent); // Notify scripts and possible subscribers - for (auto* script : CppScripts::GetEntityScripts(m_Parent)) - script->OnQuickBuildNotifyState(m_Parent, m_State); + m_Parent->GetScript()->OnQuickBuildNotifyState(m_Parent, m_State); for (const auto& cb : m_QuickBuildStateCallbacks) cb(m_State); @@ -571,8 +567,7 @@ void QuickBuildComponent::CancelQuickBuild(Entity* const entity, const eQuickBui m_StateDirty = true; // Notify scripts and possible subscribers - for (auto* script : CppScripts::GetEntityScripts(m_Parent)) - script->OnQuickBuildNotifyState(m_Parent, m_State); + m_Parent->GetScript()->OnQuickBuildNotifyState(m_Parent, m_State); for (const auto& cb : m_QuickBuildStateCallbacks) cb(m_State); diff --git a/dScripts/ScriptComponent.cpp b/dGame/dComponents/ScriptComponent.cpp similarity index 95% rename from dScripts/ScriptComponent.cpp rename to dGame/dComponents/ScriptComponent.cpp index 57e6e832..d6bff5b5 100644 --- a/dScripts/ScriptComponent.cpp +++ b/dGame/dComponents/ScriptComponent.cpp @@ -41,7 +41,7 @@ void ScriptComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitial } } -CppScripts::Script* ScriptComponent::GetScript() { +CppScripts::Script* const ScriptComponent::GetScript() { return m_Script; } diff --git a/dScripts/ScriptComponent.h b/dGame/dComponents/ScriptComponent.h similarity index 97% rename from dScripts/ScriptComponent.h rename to dGame/dComponents/ScriptComponent.h index a1371109..adc7cc8b 100644 --- a/dScripts/ScriptComponent.h +++ b/dGame/dComponents/ScriptComponent.h @@ -30,7 +30,7 @@ public: * Returns the script that's attached to this entity * @return the script that's attached to this entity */ - CppScripts::Script* GetScript(); + CppScripts::Script* const GetScript(); /** * Sets whether the entity should be serialized, unused diff --git a/dGame/dComponents/SkillComponent.cpp b/dGame/dComponents/SkillComponent.cpp index 329246f4..2e6edacd 100644 --- a/dGame/dComponents/SkillComponent.cpp +++ b/dGame/dComponents/SkillComponent.cpp @@ -268,9 +268,7 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c behavior->Calculate(context, bitStream, { target, 0 }); - for (auto* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnSkillCast(m_Parent, skillId); - } + m_Parent->GetScript()->OnSkillCast(m_Parent, skillId); if (!context->foundTarget) { delete context; diff --git a/dGame/dComponents/TriggerComponent.cpp b/dGame/dComponents/TriggerComponent.cpp index 5d4415f8..e43ebc5d 100644 --- a/dGame/dComponents/TriggerComponent.cpp +++ b/dGame/dComponents/TriggerComponent.cpp @@ -13,7 +13,8 @@ #include "SkillComponent.h" #include "eEndBehavior.h" #include "PlayerManager.h" - +#include "Game.h" +#include "EntityManager.h" TriggerComponent::TriggerComponent(Entity* parent, const std::string triggerInfo): Component(parent) { m_Parent = parent; @@ -182,9 +183,7 @@ std::vector TriggerComponent::GatherTargets(LUTriggers::Command* comman } void TriggerComponent::HandleFireEvent(Entity* targetEntity, std::string args) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(targetEntity)) { - script->OnFireEventServerSide(targetEntity, m_Parent, args, 0, 0, 0); - } + targetEntity->GetScript()->OnFireEventServerSide(targetEntity, m_Parent, args, 0, 0, 0); } void TriggerComponent::HandleDestroyObject(Entity* targetEntity, std::string args){ diff --git a/dGame/dGameMessages/GameMessageHandler.cpp b/dGame/dGameMessages/GameMessageHandler.cpp index 3aab4b3d..d2432e36 100644 --- a/dGame/dGameMessages/GameMessageHandler.cpp +++ b/dGame/dGameMessages/GameMessageHandler.cpp @@ -136,16 +136,14 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream& inStream, const System } Entity* zoneControl = Game::entityManager->GetZoneControlEntity(); - for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) { - script->OnPlayerLoaded(zoneControl, entity); + if (zoneControl) { + zoneControl->GetScript()->OnPlayerLoaded(zoneControl, entity); } std::vector scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPT); for (Entity* scriptEntity : scriptedActs) { if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds - for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) { - script->OnPlayerLoaded(scriptEntity, entity); - } + scriptEntity->GetScript()->OnPlayerLoaded(scriptEntity, entity); } } diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 55b6907e..c144675b 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -5083,9 +5083,7 @@ void GameMessages::HandleRespondToMission(RakNet::BitStream& inStream, Entity* e return; } - for (CppScripts::Script* script : CppScripts::GetEntityScripts(offerer)) { - script->OnRespondToMission(offerer, missionID, Game::entityManager->GetEntity(playerID), reward); - } + offerer->GetScript()->OnRespondToMission(offerer, missionID, Game::entityManager->GetEntity(playerID), reward); } void GameMessages::HandleMissionDialogOK(RakNet::BitStream& inStream, Entity* entity) { @@ -5101,9 +5099,7 @@ void GameMessages::HandleMissionDialogOK(RakNet::BitStream& inStream, Entity* en inStream.Read(responder); player = Game::entityManager->GetEntity(responder); - for (CppScripts::Script* script : CppScripts::GetEntityScripts(entity)) { - script->OnMissionDialogueOK(entity, player, missionID, iMissionState); - } + if (entity) entity->GetScript()->OnMissionDialogueOK(entity, player, missionID, iMissionState); // Get the player's mission component MissionComponent* missionComponent = static_cast(player->GetComponent(eReplicaComponentType::MISSION)); @@ -5556,9 +5552,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream& inStream, Entity* ScriptComponent* script = static_cast(entity->GetComponent(eReplicaComponentType::SCRIPT)); - for (CppScripts::Script* script : CppScripts::GetEntityScripts(entity)) { - script->OnModularBuildExit(entity, character, count >= 3, modList); - } + entity->GetScript()->OnModularBuildExit(entity, character, count >= 3, modList); // Move remaining temp models back to models std::vector items; @@ -5734,16 +5728,14 @@ void GameMessages::HandleResurrect(RakNet::BitStream& inStream, Entity* entity) bool immediate = inStream.ReadBit(); Entity* zoneControl = Game::entityManager->GetZoneControlEntity(); - for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) { - script->OnPlayerResurrected(zoneControl, entity); + if (zoneControl) { + zoneControl->GetScript()->OnPlayerResurrected(zoneControl, entity); } std::vector scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY); for (Entity* scriptEntity : scriptedActs) { if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds - for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) { - script->OnPlayerResurrected(scriptEntity, entity); - } + scriptEntity->GetScript()->OnPlayerResurrected(scriptEntity, entity); } } } @@ -5977,9 +5969,7 @@ void GameMessages::HandlePlayerRailArrivedNotification(RakNet::BitStream& inStre const auto possibleRails = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR); for (auto* possibleRail : possibleRails) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(possibleRail)) { - script->OnPlayerRailArrived(possibleRail, entity, pathName, waypointNumber); - } + if (possibleRail) possibleRail->GetScript()->OnPlayerRailArrived(possibleRail, entity, pathName, waypointNumber); } } diff --git a/dScripts/02_server/Map/NT/NtCombatChallengeDummy.cpp b/dScripts/02_server/Map/NT/NtCombatChallengeDummy.cpp index 5be5a9b3..13dd73c8 100644 --- a/dScripts/02_server/Map/NT/NtCombatChallengeDummy.cpp +++ b/dScripts/02_server/Map/NT/NtCombatChallengeDummy.cpp @@ -1,5 +1,6 @@ #include "NtCombatChallengeDummy.h" #include "EntityManager.h" +#include "Entity.h" void NtCombatChallengeDummy::OnDie(Entity* self, Entity* killer) { const auto challengeObjectID = self->GetVar(u"challengeObjectID"); @@ -7,9 +8,7 @@ void NtCombatChallengeDummy::OnDie(Entity* self, Entity* killer) { auto* challengeObject = Game::entityManager->GetEntity(challengeObjectID); if (challengeObject != nullptr) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(challengeObject)) { - script->OnDie(challengeObject, killer); - } + challengeObject->GetScript()->OnDie(challengeObject, killer); } } @@ -19,8 +18,6 @@ void NtCombatChallengeDummy::OnHitOrHealResult(Entity* self, Entity* attacker, i auto* challengeObject = Game::entityManager->GetEntity(challengeObjectID); if (challengeObject != nullptr) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(challengeObject)) { - script->OnHitOrHealResult(challengeObject, attacker, damage); - } + challengeObject->GetScript()->OnHitOrHealResult(challengeObject, attacker, damage); } } diff --git a/dScripts/02_server/Map/NT/NtCombatChallengeExplodingDummy.cpp b/dScripts/02_server/Map/NT/NtCombatChallengeExplodingDummy.cpp index 4ae2b335..c384b26d 100644 --- a/dScripts/02_server/Map/NT/NtCombatChallengeExplodingDummy.cpp +++ b/dScripts/02_server/Map/NT/NtCombatChallengeExplodingDummy.cpp @@ -9,9 +9,7 @@ void NtCombatChallengeExplodingDummy::OnDie(Entity* self, Entity* killer) { auto* challengeObject = Game::entityManager->GetEntity(challengeObjectID); if (challengeObject != nullptr) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(challengeObject)) { - script->OnDie(challengeObject, killer); - } + challengeObject->GetScript()->OnDie(challengeObject, killer); } } @@ -32,9 +30,7 @@ void NtCombatChallengeExplodingDummy::OnHitOrHealResult(Entity* self, Entity* at auto* challengeObject = Game::entityManager->GetEntity(challengeObjectID); if (challengeObject != nullptr) { - for (CppScripts::Script* script : CppScripts::GetEntityScripts(challengeObject)) { - script->OnHitOrHealResult(challengeObject, attacker, damage); - } + challengeObject->GetScript()->OnHitOrHealResult(challengeObject, attacker, damage); } auto skillComponent = self->GetComponent(); if (skillComponent != nullptr) { diff --git a/dScripts/CMakeLists.txt b/dScripts/CMakeLists.txt index d5290f33..29f04be3 100644 --- a/dScripts/CMakeLists.txt +++ b/dScripts/CMakeLists.txt @@ -11,7 +11,6 @@ set(DSCRIPTS_SOURCES "InvalidScript.cpp" "NPCAddRemoveItem.cpp" "NtFactionSpyServer.cpp" - "ScriptComponent.cpp" "ScriptedPowerupSpawner.cpp" "SpawnPetBaseServer.cpp") diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index 1b66b447..9018c3f4 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -322,16 +322,18 @@ #include "WblRobotCitizen.h" namespace { - InvalidScript* invalidToReturn = new InvalidScript(); + // This is in the translation unit instead of the header to prevent wierd linker errors + InvalidScript* const InvalidToReturn = new InvalidScript(); std::map m_Scripts; }; -CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scriptName) { - if (m_Scripts.find(scriptName) != m_Scripts.end()) { - return m_Scripts[scriptName]; +CppScripts::Script* const CppScripts::GetScript(Entity* parent, const std::string& scriptName) { + auto itr = m_Scripts.find(scriptName); + if (itr != m_Scripts.end()) { + return itr->second; } - Script* script = invalidToReturn; + Script* script = InvalidToReturn; //VE / AG: if (scriptName == "scripts\\ai\\AG\\L_AG_SHIP_PLAYER_DEATH_TRIGGER.lua") @@ -950,7 +952,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr // handle invalid script reporting if the path is greater than zero and it's not an ignored script // information not really needed for sys admins but is for developers - else if (script == invalidToReturn) { + else if (script == InvalidToReturn) { if ((scriptName.length() > 0) && !((scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua") || (scriptName == "scripts\\02_server\\Enemy\\General\\L_BASE_ENEMY_SPIDERLING.lua") || (scriptName =="scripts\\ai\\FV\\L_ACT_NINJA_STUDENT.lua") || @@ -963,13 +965,6 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr return script; } -std::vector CppScripts::GetEntityScripts(Entity* entity) { - std::vector scripts; - std::vector comps = entity->GetScriptComponents(); - for (ScriptComponent* scriptComp : comps) { - if (scriptComp != nullptr) { - scripts.push_back(scriptComp->GetScript()); - } - } - return scripts; +CppScripts::Script* const CppScripts::GetInvalidScript() { + return InvalidToReturn; } diff --git a/dScripts/CppScripts.h b/dScripts/CppScripts.h index d005a14a..8d3b3b5d 100644 --- a/dScripts/CppScripts.h +++ b/dScripts/CppScripts.h @@ -357,6 +357,10 @@ namespace CppScripts { virtual void OnRequestActivityExit(Entity* sender, LWOOBJID player, bool canceled){}; }; - Script* GetScript(Entity* parent, const std::string& scriptName); - std::vector GetEntityScripts(Entity* entity); + Script* const GetScript(Entity* parent, const std::string& scriptName); + + // Get the invalid script. Would be a static variable of the namespace, but that would be + // more cluttery to use. Also this allows us to control where this invalid script is defined and initialized + // since we dont want anyone externally modifying it. + Script* const GetInvalidScript(); }; From fe4b29f64338f118f0df697691e5a26b51a33e19 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Wed, 6 Mar 2024 17:50:21 -0800 Subject: [PATCH 3/5] fix: commendation vendor cant accept missions (#1497) * fix: incorrect serialization for commendation * Update VendorComponent.h --- .../dComponents/AchievementVendorComponent.cpp | 17 +++++++++++++---- dGame/dComponents/AchievementVendorComponent.h | 4 +++- dGame/dComponents/VendorComponent.h | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/dGame/dComponents/AchievementVendorComponent.cpp b/dGame/dComponents/AchievementVendorComponent.cpp index 10a0ca29..006a2b6f 100644 --- a/dGame/dComponents/AchievementVendorComponent.cpp +++ b/dGame/dComponents/AchievementVendorComponent.cpp @@ -9,11 +9,15 @@ #include "UserManager.h" #include "CDMissionsTable.h" +AchievementVendorComponent::AchievementVendorComponent(Entity* parent) : VendorComponent(parent) { + RefreshInventory(true); +}; + bool AchievementVendorComponent::SellsItem(Entity* buyer, const LOT lot) { auto* missionComponent = buyer->GetComponent(); if (!missionComponent) return false; - if (m_PlayerPurchasableItems[buyer->GetObjectID()].contains(lot)){ + if (m_PlayerPurchasableItems[buyer->GetObjectID()].contains(lot)) { return true; } @@ -35,7 +39,7 @@ void AchievementVendorComponent::Buy(Entity* buyer, LOT lot, uint32_t count) { int itemCompID = compRegistryTable->GetByIDAndType(lot, eReplicaComponentType::ITEM); CDItemComponent itemComp = itemComponentTable->GetItemComponentByID(itemCompID); uint32_t costLOT = itemComp.commendationLOT; - + if (costLOT == -1 || !SellsItem(buyer, lot)) { auto* user = UserManager::Instance()->GetUser(buyer->GetSystemAddress()); CheatDetection::ReportCheat(user, buyer->GetSystemAddress(), "Attempted to buy item %i from achievement vendor %i that is not purchasable", lot, m_Parent->GetLOT()); @@ -44,7 +48,7 @@ void AchievementVendorComponent::Buy(Entity* buyer, LOT lot, uint32_t count) { } auto* inventoryComponent = buyer->GetComponent(); - if (!inventoryComponent) { + if (!inventoryComponent) { GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_FAIL); return; } @@ -69,4 +73,9 @@ void AchievementVendorComponent::Buy(Entity* buyer, LOT lot, uint32_t count) { inventoryComponent->AddItem(lot, count, eLootSourceType::VENDOR); GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_SUCCESS); -} \ No newline at end of file +} + +void AchievementVendorComponent::RefreshInventory(bool isCreation) { + SetHasStandardCostItems(true); + Game::entityManager->SerializeEntity(m_Parent); +} diff --git a/dGame/dComponents/AchievementVendorComponent.h b/dGame/dComponents/AchievementVendorComponent.h index bffd3983..ba6c7c2a 100644 --- a/dGame/dComponents/AchievementVendorComponent.h +++ b/dGame/dComponents/AchievementVendorComponent.h @@ -11,7 +11,9 @@ class Entity; class AchievementVendorComponent final : public VendorComponent { public: static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::ACHIEVEMENT_VENDOR; - AchievementVendorComponent(Entity* parent) : VendorComponent(parent) {}; + AchievementVendorComponent(Entity* parent); + + void RefreshInventory(bool isCreation = false) override; bool SellsItem(Entity* buyer, const LOT lot); void Buy(Entity* buyer, LOT lot, uint32_t count); diff --git a/dGame/dComponents/VendorComponent.h b/dGame/dComponents/VendorComponent.h index b5e9f5d0..432f1801 100644 --- a/dGame/dComponents/VendorComponent.h +++ b/dGame/dComponents/VendorComponent.h @@ -26,7 +26,7 @@ public: void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void OnUse(Entity* originator) override; - void RefreshInventory(bool isCreation = false); + virtual void RefreshInventory(bool isCreation = false); void SetupConstants(); bool SellsItem(const LOT item) const; float GetBuyScalar() const { return m_BuyScalar; } From 6e3b5acede696d07f45bb564d822f1b8e65cf8f4 Mon Sep 17 00:00:00 2001 From: jadebenn Date: Wed, 6 Mar 2024 23:45:04 -0600 Subject: [PATCH 4/5] chore: Less verbose name for enum underlying type casts (#1494) * Less verbose name for enum underlying type casts * Remove redundant call --- dCommon/GeneralUtils.h | 4 ++-- dNet/AuthPackets.cpp | 2 +- tests/dCommonTests/CMakeLists.txt | 2 +- .../{CastUnderlyingTypeTests.cpp => ToUnderlyingTests.cpp} | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) rename tests/dCommonTests/{CastUnderlyingTypeTests.cpp => ToUnderlyingTests.cpp} (68%) diff --git a/dCommon/GeneralUtils.h b/dCommon/GeneralUtils.h index f57be9a2..c3422b05 100644 --- a/dCommon/GeneralUtils.h +++ b/dCommon/GeneralUtils.h @@ -264,8 +264,8 @@ namespace GeneralUtils { * @returns The enum entry's value in its underlying type */ template - constexpr typename std::underlying_type_t CastUnderlyingType(const eType entry) noexcept { - return static_cast>(entry); + constexpr std::underlying_type_t ToUnderlying(const eType entry) noexcept { + return static_cast>(entry); } // on Windows we need to undef these or else they conflict with our numeric limits calls diff --git a/dNet/AuthPackets.cpp b/dNet/AuthPackets.cpp index dce7e8e9..a2bf731c 100644 --- a/dNet/AuthPackets.cpp +++ b/dNet/AuthPackets.cpp @@ -229,7 +229,7 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd RakNet::BitStream loginResponse; BitStreamUtils::WriteHeader(loginResponse, eConnectionType::CLIENT, eClientMessageType::LOGIN_RESPONSE); - loginResponse.Write(GeneralUtils::CastUnderlyingType(responseCode)); + loginResponse.Write(responseCode); // Event Gating loginResponse.Write(LUString(Game::config->GetValue("event_1"))); diff --git a/tests/dCommonTests/CMakeLists.txt b/tests/dCommonTests/CMakeLists.txt index cf0a03ed..ef7c4cba 100644 --- a/tests/dCommonTests/CMakeLists.txt +++ b/tests/dCommonTests/CMakeLists.txt @@ -1,7 +1,7 @@ set(DCOMMONTEST_SOURCES "AMFDeserializeTests.cpp" "Amf3Tests.cpp" - "CastUnderlyingTypeTests.cpp" + "ToUnderlyingTests.cpp" "HeaderSkipTest.cpp" "TestCDFeatureGatingTable.cpp" "TestLDFFormat.cpp" diff --git a/tests/dCommonTests/CastUnderlyingTypeTests.cpp b/tests/dCommonTests/ToUnderlyingTests.cpp similarity index 68% rename from tests/dCommonTests/CastUnderlyingTypeTests.cpp rename to tests/dCommonTests/ToUnderlyingTests.cpp index 9cdfcdd3..4cbf4635 100644 --- a/tests/dCommonTests/CastUnderlyingTypeTests.cpp +++ b/tests/dCommonTests/ToUnderlyingTests.cpp @@ -7,13 +7,13 @@ #include "eWorldMessageType.h" #define ASSERT_TYPE_EQ(TYPE, ENUM)\ - ASSERT_TRUE(typeid(TYPE) == typeid(GeneralUtils::CastUnderlyingType(static_cast(0)))); + ASSERT_TRUE(typeid(TYPE) == typeid(GeneralUtils::ToUnderlying(static_cast(0)))); #define ASSERT_TYPE_NE(TYPE, ENUM)\ - ASSERT_FALSE(typeid(TYPE) == typeid(GeneralUtils::CastUnderlyingType(static_cast(0)))); + ASSERT_FALSE(typeid(TYPE) == typeid(GeneralUtils::ToUnderlying(static_cast(0)))); // Verify that the underlying enum types are being cast correctly -TEST(CastUnderlyingTypeTests, VerifyCastUnderlyingType) { +TEST(ToUnderlyingTests, VerifyToUnderlying) { ASSERT_TYPE_EQ(uint8_t, eGameMasterLevel); ASSERT_TYPE_EQ(uint16_t, eGameMessageType); ASSERT_TYPE_EQ(uint32_t, eWorldMessageType) From 3a6313a3badcd173c7ddd8e5702a009efb65457a Mon Sep 17 00:00:00 2001 From: jadebenn Date: Wed, 6 Mar 2024 23:45:24 -0600 Subject: [PATCH 5/5] chore: Table Loading Improvements (#1492) * Assorted pet improvements * remove unecessary include * updates to address some feedback * fixed database code for testing * messinng around with tables * updated to address feedback * fix world hang * Remove at() in CDLootTableTable.cpp * Uncapitalize LOT variable * Uncapitalize LOT variable --- .../CDClientTables/CDLootTableTable.cpp | 6 ++-- .../CDClientTables/CDLootTableTable.h | 5 +-- .../CDClientTables/CDMissionEmailTable.cpp | 5 +-- .../CDClientTables/CDMissionEmailTable.h | 2 ++ .../CDMissionNPCComponentTable.cpp | 5 +-- .../CDMissionNPCComponentTable.h | 3 +- .../CDClientTables/CDMissionTasksTable.cpp | 7 ++-- .../CDClientTables/CDMissionTasksTable.h | 4 ++- .../CDClientTables/CDMissionsTable.cpp | 3 +- .../CDClientTables/CDMissionsTable.h | 1 - .../CDMovementAIComponentTable.cpp | 5 +-- .../CDMovementAIComponentTable.h | 2 ++ .../CDClientTables/CDObjectSkillsTable.cpp | 5 +-- .../CDClientTables/CDObjectSkillsTable.h | 2 ++ .../CDClientTables/CDObjectsTable.cpp | 35 +++++++++---------- .../CDClientTables/CDObjectsTable.h | 4 ++- .../CDPackageComponentTable.cpp | 3 +- .../CDClientTables/CDPackageComponentTable.h | 2 ++ .../CDPhysicsComponentTable.cpp | 33 +++++++++-------- .../CDClientTables/CDPhysicsComponentTable.h | 5 +-- dGame/dComponents/PetComponent.h | 1 - 21 files changed, 66 insertions(+), 72 deletions(-) diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDLootTableTable.cpp b/dDatabase/CDClientDatabase/CDClientTables/CDLootTableTable.cpp index d5e9d4dc..0781897f 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDLootTableTable.cpp +++ b/dDatabase/CDClientDatabase/CDClientTables/CDLootTableTable.cpp @@ -58,7 +58,7 @@ void CDLootTableTable::LoadValuesFromDatabase() { CDLootTable entry; uint32_t lootTableIndex = tableData.getIntField("LootTableIndex", -1); - entries[lootTableIndex].push_back(ReadRow(tableData)); + entries[lootTableIndex].emplace_back(ReadRow(tableData)); tableData.nextRow(); } for (auto& [id, table] : entries) { @@ -66,7 +66,7 @@ void CDLootTableTable::LoadValuesFromDatabase() { } } -const LootTableEntries& CDLootTableTable::GetTable(uint32_t tableId) { +const LootTableEntries& CDLootTableTable::GetTable(const uint32_t tableId) { auto& entries = GetEntriesMutable(); auto itr = entries.find(tableId); if (itr != entries.end()) { @@ -79,7 +79,7 @@ const LootTableEntries& CDLootTableTable::GetTable(uint32_t tableId) { while (!tableData.eof()) { CDLootTable entry; - entries[tableId].push_back(ReadRow(tableData)); + entries[tableId].emplace_back(ReadRow(tableData)); tableData.nextRow(); } SortTable(entries[tableId]); diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDLootTableTable.h b/dDatabase/CDClientDatabase/CDClientTables/CDLootTableTable.h index 416bd87a..c88ba03c 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDLootTableTable.h +++ b/dDatabase/CDClientDatabase/CDClientTables/CDLootTableTable.h @@ -3,6 +3,8 @@ // Custom Classes #include "CDTable.h" +#include + struct CDLootTable { uint32_t itemid; //!< The LOT of the item uint32_t LootTableIndex; //!< The Loot Table Index @@ -20,6 +22,5 @@ private: public: void LoadValuesFromDatabase(); // Queries the table with a custom "where" clause - const LootTableEntries& GetTable(uint32_t tableId); + const LootTableEntries& GetTable(const uint32_t tableId); }; - diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDMissionEmailTable.cpp b/dDatabase/CDClientDatabase/CDClientTables/CDMissionEmailTable.cpp index 1123bfec..5acaa906 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDMissionEmailTable.cpp +++ b/dDatabase/CDClientDatabase/CDClientTables/CDMissionEmailTable.cpp @@ -20,7 +20,7 @@ void CDMissionEmailTable::LoadValuesFromDatabase() { // Now get the data auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM MissionEmail"); while (!tableData.eof()) { - CDMissionEmail entry; + auto& entry = entries.emplace_back(); entry.ID = tableData.getIntField("ID", -1); entry.messageType = tableData.getIntField("messageType", -1); entry.notificationGroup = tableData.getIntField("notificationGroup", -1); @@ -30,11 +30,8 @@ void CDMissionEmailTable::LoadValuesFromDatabase() { entry.locStatus = tableData.getIntField("locStatus", -1); entry.gate_version = tableData.getStringField("gate_version", ""); - entries.push_back(entry); tableData.nextRow(); } - - tableData.finalize(); } //! Queries the table with a custom "where" clause diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDMissionEmailTable.h b/dDatabase/CDClientDatabase/CDClientTables/CDMissionEmailTable.h index ac2dba81..ea48b423 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDMissionEmailTable.h +++ b/dDatabase/CDClientDatabase/CDClientTables/CDMissionEmailTable.h @@ -3,6 +3,8 @@ // Custom Classes #include "CDTable.h" +#include + struct CDMissionEmail { uint32_t ID; uint32_t messageType; diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDMissionNPCComponentTable.cpp b/dDatabase/CDClientDatabase/CDClientTables/CDMissionNPCComponentTable.cpp index efe284d4..e475a998 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDMissionNPCComponentTable.cpp +++ b/dDatabase/CDClientDatabase/CDClientTables/CDMissionNPCComponentTable.cpp @@ -20,18 +20,15 @@ void CDMissionNPCComponentTable::LoadValuesFromDatabase() { // Now get the data auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM MissionNPCComponent"); while (!tableData.eof()) { - CDMissionNPCComponent entry; + auto& entry = entries.emplace_back(); entry.id = tableData.getIntField("id", -1); entry.missionID = tableData.getIntField("missionID", -1); entry.offersMission = tableData.getIntField("offersMission", -1) == 1 ? true : false; entry.acceptsMission = tableData.getIntField("acceptsMission", -1) == 1 ? true : false; entry.gate_version = tableData.getStringField("gate_version", ""); - entries.push_back(entry); tableData.nextRow(); } - - tableData.finalize(); } //! Queries the table with a custom "where" clause diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDMissionNPCComponentTable.h b/dDatabase/CDClientDatabase/CDClientTables/CDMissionNPCComponentTable.h index 1eba2fad..dde81251 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDMissionNPCComponentTable.h +++ b/dDatabase/CDClientDatabase/CDClientTables/CDMissionNPCComponentTable.h @@ -3,6 +3,8 @@ // Custom Classes #include "CDTable.h" +#include + struct CDMissionNPCComponent { uint32_t id; //!< The ID uint32_t missionID; //!< The Mission ID @@ -17,4 +19,3 @@ public: // Queries the table with a custom "where" clause std::vector Query(std::function predicate); }; - diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDMissionTasksTable.cpp b/dDatabase/CDClientDatabase/CDClientTables/CDMissionTasksTable.cpp index c5b6620f..b9584032 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDMissionTasksTable.cpp +++ b/dDatabase/CDClientDatabase/CDClientTables/CDMissionTasksTable.cpp @@ -20,7 +20,7 @@ void CDMissionTasksTable::LoadValuesFromDatabase() { // Now get the data auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM MissionTasks"); while (!tableData.eof()) { - CDMissionTasks entry; + auto& entry = entries.emplace_back(); entry.id = tableData.getIntField("id", -1); UNUSED(entry.locStatus = tableData.getIntField("locStatus", -1)); entry.taskType = tableData.getIntField("taskType", -1); @@ -35,11 +35,8 @@ void CDMissionTasksTable::LoadValuesFromDatabase() { UNUSED(entry.localize = tableData.getIntField("localize", -1) == 1 ? true : false); UNUSED(entry.gate_version = tableData.getStringField("gate_version", "")); - entries.push_back(entry); tableData.nextRow(); } - - tableData.finalize(); } std::vector CDMissionTasksTable::Query(std::function predicate) { @@ -51,7 +48,7 @@ std::vector CDMissionTasksTable::Query(std::function CDMissionTasksTable::GetByMissionID(uint32_t missionID) { +std::vector CDMissionTasksTable::GetByMissionID(const uint32_t missionID) { std::vector tasks; // TODO: this should not be linear(?) and also shouldnt need to be a pointer diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDMissionTasksTable.h b/dDatabase/CDClientDatabase/CDClientTables/CDMissionTasksTable.h index 97553359..60a21073 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDMissionTasksTable.h +++ b/dDatabase/CDClientDatabase/CDClientTables/CDMissionTasksTable.h @@ -3,6 +3,8 @@ // Custom Classes #include "CDTable.h" +#include + struct CDMissionTasks { uint32_t id; //!< The Mission ID that the task belongs to UNUSED(uint32_t locStatus); //!< ??? @@ -25,7 +27,7 @@ public: // Queries the table with a custom "where" clause std::vector Query(std::function predicate); - std::vector GetByMissionID(uint32_t missionID); + std::vector GetByMissionID(const uint32_t missionID); // TODO: Remove this and replace it with a proper lookup function. const CDTable::StorageType& GetEntries() const; diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.cpp b/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.cpp index 97dcde9f..c98254ea 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.cpp +++ b/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.cpp @@ -22,7 +22,7 @@ void CDMissionsTable::LoadValuesFromDatabase() { // Now get the data auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Missions"); while (!tableData.eof()) { - CDMissions entry; + auto& entry = entries.emplace_back(); entry.id = tableData.getIntField("id", -1); entry.defined_type = tableData.getStringField("defined_type", ""); entry.defined_subtype = tableData.getStringField("defined_subtype", ""); @@ -76,7 +76,6 @@ void CDMissionsTable::LoadValuesFromDatabase() { UNUSED(entry.locStatus = tableData.getIntField("locStatus", -1)); entry.reward_bankinventory = tableData.getIntField("reward_bankinventory", -1); - entries.push_back(entry); tableData.nextRow(); } tableData.finalize(); diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.h b/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.h index 5067f2e2..c5ae0e88 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.h +++ b/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.h @@ -75,4 +75,3 @@ public: static CDMissions Default; }; - diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDMovementAIComponentTable.cpp b/dDatabase/CDClientDatabase/CDClientTables/CDMovementAIComponentTable.cpp index 48964a59..cec27bb9 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDMovementAIComponentTable.cpp +++ b/dDatabase/CDClientDatabase/CDClientTables/CDMovementAIComponentTable.cpp @@ -20,7 +20,7 @@ void CDMovementAIComponentTable::LoadValuesFromDatabase() { // Now get the data auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM MovementAIComponent"); while (!tableData.eof()) { - CDMovementAIComponent entry; + auto& entry = entries.emplace_back(); entry.id = tableData.getIntField("id", -1); entry.MovementType = tableData.getStringField("MovementType", ""); entry.WanderChance = tableData.getFloatField("WanderChance", -1.0f); @@ -30,11 +30,8 @@ void CDMovementAIComponentTable::LoadValuesFromDatabase() { entry.WanderRadius = tableData.getFloatField("WanderRadius", -1.0f); entry.attachedPath = tableData.getStringField("attachedPath", ""); - entries.push_back(entry); tableData.nextRow(); } - - tableData.finalize(); } std::vector CDMovementAIComponentTable::Query(std::function predicate) { diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDMovementAIComponentTable.h b/dDatabase/CDClientDatabase/CDClientTables/CDMovementAIComponentTable.h index 34d01e3d..6671d945 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDMovementAIComponentTable.h +++ b/dDatabase/CDClientDatabase/CDClientTables/CDMovementAIComponentTable.h @@ -3,6 +3,8 @@ // Custom Classes #include "CDTable.h" +#include + struct CDMovementAIComponent { uint32_t id; std::string MovementType; diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDObjectSkillsTable.cpp b/dDatabase/CDClientDatabase/CDClientTables/CDObjectSkillsTable.cpp index 9933fe7f..a07446b5 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDObjectSkillsTable.cpp +++ b/dDatabase/CDClientDatabase/CDClientTables/CDObjectSkillsTable.cpp @@ -20,17 +20,14 @@ void CDObjectSkillsTable::LoadValuesFromDatabase() { // Now get the data auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ObjectSkills"); while (!tableData.eof()) { - CDObjectSkills entry; + auto &entry = entries.emplace_back(); entry.objectTemplate = tableData.getIntField("objectTemplate", -1); entry.skillID = tableData.getIntField("skillID", -1); entry.castOnType = tableData.getIntField("castOnType", -1); entry.AICombatWeight = tableData.getIntField("AICombatWeight", -1); - entries.push_back(entry); tableData.nextRow(); } - - tableData.finalize(); } std::vector CDObjectSkillsTable::Query(std::function predicate) { diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDObjectSkillsTable.h b/dDatabase/CDClientDatabase/CDClientTables/CDObjectSkillsTable.h index a2a8d440..731f6657 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDObjectSkillsTable.h +++ b/dDatabase/CDClientDatabase/CDClientTables/CDObjectSkillsTable.h @@ -3,6 +3,8 @@ // Custom Classes #include "CDTable.h" +#include + struct CDObjectSkills { uint32_t objectTemplate; //!< The LOT of the item uint32_t skillID; //!< The Skill ID of the object diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDObjectsTable.cpp b/dDatabase/CDClientDatabase/CDClientTables/CDObjectsTable.cpp index d1f6771e..738a13ac 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDObjectsTable.cpp +++ b/dDatabase/CDClientDatabase/CDClientTables/CDObjectsTable.cpp @@ -1,7 +1,7 @@ #include "CDObjectsTable.h" namespace { - CDObjects m_default; + CDObjects ObjDefault; }; void CDObjectsTable::LoadValuesFromDatabase() { @@ -20,8 +20,10 @@ void CDObjectsTable::LoadValuesFromDatabase() { auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Objects"); auto& entries = GetEntriesMutable(); while (!tableData.eof()) { - CDObjects entry; - entry.id = tableData.getIntField("id", -1); + const uint32_t lot = tableData.getIntField("id", 0); + + auto& entry = entries[lot]; + entry.id = lot; entry.name = tableData.getStringField("name", ""); UNUSED_COLUMN(entry.placeable = tableData.getIntField("placeable", -1);) entry.type = tableData.getStringField("type", ""); @@ -36,35 +38,34 @@ void CDObjectsTable::LoadValuesFromDatabase() { UNUSED_COLUMN(entry.gate_version = tableData.getStringField("gate_version", "");) UNUSED_COLUMN(entry.HQ_valid = tableData.getIntField("HQ_valid", -1);) - entries.insert(std::make_pair(entry.id, entry)); tableData.nextRow(); } - tableData.finalize(); - - m_default.id = 0; + ObjDefault.id = 0; } -const CDObjects& CDObjectsTable::GetByID(uint32_t LOT) { +const CDObjects& CDObjectsTable::GetByID(const uint32_t lot) { auto& entries = GetEntriesMutable(); - const auto& it = entries.find(LOT); + const auto& it = entries.find(lot); if (it != entries.end()) { return it->second; } auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Objects WHERE id = ?;"); - query.bind(1, static_cast(LOT)); + query.bind(1, static_cast(lot)); auto tableData = query.execQuery(); if (tableData.eof()) { - entries.insert(std::make_pair(LOT, m_default)); - return m_default; + entries.emplace(lot, ObjDefault); + return ObjDefault; } // Now get the data while (!tableData.eof()) { - CDObjects entry; - entry.id = tableData.getIntField("id", -1); + const uint32_t lot = tableData.getIntField("id", 0); + + auto& entry = entries[lot]; + entry.id = lot; entry.name = tableData.getStringField("name", ""); UNUSED(entry.placeable = tableData.getIntField("placeable", -1)); entry.type = tableData.getStringField("type", ""); @@ -79,17 +80,15 @@ const CDObjects& CDObjectsTable::GetByID(uint32_t LOT) { UNUSED(entry.gate_version = tableData.getStringField("gate_version", "")); UNUSED(entry.HQ_valid = tableData.getIntField("HQ_valid", -1)); - entries.insert(std::make_pair(entry.id, entry)); tableData.nextRow(); } tableData.finalize(); - const auto& it2 = entries.find(LOT); + const auto& it2 = entries.find(lot); if (it2 != entries.end()) { return it2->second; } - return m_default; + return ObjDefault; } - diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDObjectsTable.h b/dDatabase/CDClientDatabase/CDClientTables/CDObjectsTable.h index add21c8f..13bb90fa 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDObjectsTable.h +++ b/dDatabase/CDClientDatabase/CDClientTables/CDObjectsTable.h @@ -3,6 +3,8 @@ // Custom Classes #include "CDTable.h" +#include + struct CDObjects { uint32_t id; //!< The LOT of the object std::string name; //!< The internal name of the object @@ -24,6 +26,6 @@ class CDObjectsTable : public CDTable + struct CDPackageComponent { uint32_t id; uint32_t LootMatrixIndex; diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDPhysicsComponentTable.cpp b/dDatabase/CDClientDatabase/CDClientTables/CDPhysicsComponentTable.cpp index 34671f3c..050312b1 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDPhysicsComponentTable.cpp +++ b/dDatabase/CDClientDatabase/CDClientTables/CDPhysicsComponentTable.cpp @@ -4,32 +4,31 @@ void CDPhysicsComponentTable::LoadValuesFromDatabase() { auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PhysicsComponent"); auto& entries = GetEntriesMutable(); while (!tableData.eof()) { - CDPhysicsComponent entry; - entry.id = tableData.getIntField("id", -1); + const uint32_t componentID = tableData.getIntField("id", -1); + + auto& entry = entries[componentID]; + entry.id = componentID; 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); - UNUSED(entry->rotSpeed = tableData.getFloatField("rotSpeed", -1)); - entry.playerHeight = tableData.getFloatField("playerHeight"); - entry.playerRadius = tableData.getFloatField("playerRadius"); + UNUSED_COLUMN(entry.jump = tableData.getIntField("jump", -1) != 0;) + UNUSED_COLUMN(entry.doubleJump = tableData.getIntField("doublejump", -1) != 0;) + entry.speed = static_cast(tableData.getFloatField("speed", -1)); + UNUSED_COLUMN(entry.rotSpeed = tableData.getFloatField("rotSpeed", -1);) + entry.playerHeight = static_cast(tableData.getFloatField("playerHeight")); + entry.playerRadius = static_cast(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")); + UNUSED_COLUMN(entry.airSpeed = tableData.getFloatField("airSpeed");) + UNUSED_COLUMN(entry.boundaryAsset = tableData.getStringField("boundaryAsset");) + UNUSED_COLUMN(entry.jumpAirSpeed = tableData.getFloatField("jumpAirSpeed");) + UNUSED_COLUMN(entry.friction = tableData.getFloatField("friction");) + UNUSED_COLUMN(entry.gravityVolumeAsset = tableData.getStringField("gravityVolumeAsset");) - entries.insert(std::make_pair(entry.id, entry)); tableData.nextRow(); } - - tableData.finalize(); } -CDPhysicsComponent* CDPhysicsComponentTable::GetByID(uint32_t componentID) { +CDPhysicsComponent* CDPhysicsComponentTable::GetByID(const uint32_t componentID) { auto& entries = GetEntriesMutable(); auto itr = entries.find(componentID); return itr != entries.end() ? &itr->second : nullptr; diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDPhysicsComponentTable.h b/dDatabase/CDClientDatabase/CDClientTables/CDPhysicsComponentTable.h index f0a62139..b783a826 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDPhysicsComponentTable.h +++ b/dDatabase/CDClientDatabase/CDClientTables/CDPhysicsComponentTable.h @@ -1,5 +1,6 @@ #pragma once #include "CDTable.h" +#include #include struct CDPhysicsComponent { @@ -7,7 +8,7 @@ struct CDPhysicsComponent { bool bStatic; std::string physicsAsset; UNUSED(bool jump); - UNUSED(bool doublejump); + UNUSED(bool doubleJump); float speed; UNUSED(float rotSpeed); float playerHeight; @@ -26,5 +27,5 @@ public: void LoadValuesFromDatabase(); static const std::string GetTableName() { return "PhysicsComponent"; }; - CDPhysicsComponent* GetByID(uint32_t componentID); + CDPhysicsComponent* GetByID(const uint32_t componentID); }; diff --git a/dGame/dComponents/PetComponent.h b/dGame/dComponents/PetComponent.h index 0254c5f5..f4198cae 100644 --- a/dGame/dComponents/PetComponent.h +++ b/dGame/dComponents/PetComponent.h @@ -353,7 +353,6 @@ private: /** * Pet information loaded from the CDClientDatabase - * TODO: Switch to a reference when safe to do so */ CDPetComponent m_PetInfo; };