mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-24 14:37:25 +00:00
chore: Convert heap allocation to optional (#1553)
* chore: Convert heap allocation to optional * Update dGame/dComponents/PetComponent.h Default-initialize
This commit is contained in:
parent
99e7349f6c
commit
8fdc212cda
@ -40,7 +40,7 @@ std::unordered_map<LWOOBJID, LWOOBJID> PetComponent::activePets{};
|
|||||||
* Maps all the pet lots to a flag indicating that the player has caught it. All basic pets have been guessed by ObjID
|
* Maps all the pet lots to a flag indicating that the player has caught it. All basic pets have been guessed by ObjID
|
||||||
* while the faction ones could be checked using their respective missions.
|
* while the faction ones could be checked using their respective missions.
|
||||||
*/
|
*/
|
||||||
std::map<LOT, int32_t> PetComponent::petFlags = {
|
const std::map<LOT, int32_t> PetComponent::petFlags{
|
||||||
{ 3050, 801 }, // Elephant
|
{ 3050, 801 }, // Elephant
|
||||||
{ 3054, 803 }, // Cat
|
{ 3054, 803 }, // Cat
|
||||||
{ 3195, 806 }, // Triceratops
|
{ 3195, 806 }, // Triceratops
|
||||||
@ -87,7 +87,6 @@ PetComponent::PetComponent(Entity* parentEntity, uint32_t componentId) : Compone
|
|||||||
m_StartPosition = NiPoint3Constant::ZERO;
|
m_StartPosition = NiPoint3Constant::ZERO;
|
||||||
m_MovementAI = nullptr;
|
m_MovementAI = nullptr;
|
||||||
m_TresureTime = 0;
|
m_TresureTime = 0;
|
||||||
m_Preconditions = nullptr;
|
|
||||||
|
|
||||||
std::string checkPreconditions = GeneralUtils::UTF16ToWTF8(parentEntity->GetVar<std::u16string>(u"CheckPrecondition"));
|
std::string checkPreconditions = GeneralUtils::UTF16ToWTF8(parentEntity->GetVar<std::u16string>(u"CheckPrecondition"));
|
||||||
|
|
||||||
@ -158,7 +157,7 @@ void PetComponent::OnUse(Entity* originator) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Preconditions != nullptr && !m_Preconditions->Check(originator, true)) {
|
if (m_Preconditions.has_value() && !m_Preconditions->Check(originator, true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1086,6 +1085,6 @@ void PetComponent::LoadPetNameFromModeration() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PetComponent::SetPreconditions(std::string& preconditions) {
|
void PetComponent::SetPreconditions(const std::string& preconditions) {
|
||||||
m_Preconditions = new PreconditionExpression(preconditions);
|
m_Preconditions = std::make_optional<PreconditionExpression>(preconditions);
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ public:
|
|||||||
* Sets preconditions for the pet that need to be met before it can be tamed
|
* Sets preconditions for the pet that need to be met before it can be tamed
|
||||||
* @param conditions the preconditions to set
|
* @param conditions the preconditions to set
|
||||||
*/
|
*/
|
||||||
void SetPreconditions(std::string& conditions);
|
void SetPreconditions(const std::string& conditions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the entity that this component belongs to
|
* Returns the entity that this component belongs to
|
||||||
@ -258,7 +258,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Flags that indicate that a player has tamed a pet, indexed by the LOT of the pet
|
* Flags that indicate that a player has tamed a pet, indexed by the LOT of the pet
|
||||||
*/
|
*/
|
||||||
static std::map<LOT, int32_t> petFlags;
|
static const std::map<LOT, int32_t> petFlags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ID of the component in the pet component table
|
* The ID of the component in the pet component table
|
||||||
@ -349,7 +349,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Preconditions that need to be met before an entity can tame this pet
|
* Preconditions that need to be met before an entity can tame this pet
|
||||||
*/
|
*/
|
||||||
PreconditionExpression* m_Preconditions;
|
std::optional<PreconditionExpression> m_Preconditions{};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pet information loaded from the CDClientDatabase
|
* Pet information loaded from the CDClientDatabase
|
||||||
|
Loading…
Reference in New Issue
Block a user