use reference instead of pointer for cdclient data

This commit is contained in:
jadebenn
2024-01-05 14:50:49 -06:00
parent c575fd9a6c
commit 384083ea18
4 changed files with 55 additions and 59 deletions

View File

@@ -8,6 +8,7 @@
#include "eReplicaComponentType.h"
#include "ePetAbilityType.h"
#include "CDPetComponentTable.h"
#include "CDClientManager.h"
/*
* The current state of the pet AI
@@ -67,9 +68,50 @@ class PetComponent : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PET;
PetComponent(Entity* parentEntity, uint32_t componentId);
/**
* Pet information loaded from the CDClientDatabase
*/
CDPetComponent& m_PetInfo;
/**
* PetComponent constructor
* @param parentEntity The parent entity
* @param componentId The component id
*/
explicit PetComponent(Entity* parentEntity, uint32_t componentId) : Component{ parentEntity },
m_PetInfo{ CDClientManager::Instance().GetTable<CDPetComponentTable>()->GetByID(componentId) } {
m_ComponentId = componentId;
m_Interaction = LWOOBJID_EMPTY;
m_InteractType = PetInteractType::none;
m_Owner = LWOOBJID_EMPTY;
m_ModerationStatus = 0;
m_Tamer = LWOOBJID_EMPTY;
m_ModelId = LWOOBJID_EMPTY;
m_Timer = 0;
m_TimerAway = 0;
m_TimerBounce = 0;
m_DatabaseId = LWOOBJID_EMPTY;
m_Flags = PetFlag::SPAWNING; // Tameable
m_Ability = ePetAbilityType::Invalid;
m_StartPosition = m_Parent->GetPosition();
m_MovementAI = nullptr;
m_Preconditions = nullptr;
m_ReadyToInteract = false;
SetPetAiState(PetAiState::spawn);
SetIsHandlingInteraction(false);
std::string checkPreconditions = GeneralUtils::UTF16ToWTF8(parentEntity->GetVar<std::u16string>(u"CheckPrecondition"));
if (!checkPreconditions.empty()) {
SetPreconditions(checkPreconditions);
}
m_FollowRadius = 8.0f; //Game::zoneManager->GetPetFollowRadius(); // TODO: FIX THIS TO LOAD DYNAMICALLY
}
~PetComponent() override;
/**
* Serializes the pet
* @param outBitStream The output bitstream
@@ -439,11 +481,6 @@ private:
int32_t numValidPieces;
};
/**
* Pet information loaded from the CDClientDatabase
*/
CDPetComponent* m_PetInfo;
/**
* Cache of all the pets that are currently spawned, indexed by tamer
*/