mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Fix possible mem leak on vigilance
This commit is contained in:
@@ -13,12 +13,12 @@ bool CastSunderArmorAction::isUseful()
|
|||||||
return !aura || aura->GetStackAmount() < 5 || aura->GetDuration() <= 6000;
|
return !aura || aura->GetStackAmount() < 5 || aura->GetDuration() <= 6000;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value<Unit*>* CastVigilanceAction::GetTargetValue()
|
Unit* CastVigilanceAction::GetTarget()
|
||||||
{
|
{
|
||||||
Group* group = bot->GetGroup();
|
Group* group = bot->GetGroup();
|
||||||
if (!group)
|
if (!group)
|
||||||
{
|
{
|
||||||
return new ManualSetValue<Unit*>(botAI, nullptr);
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player* currentVigilanceTarget = nullptr;
|
Player* currentVigilanceTarget = nullptr;
|
||||||
@@ -74,23 +74,23 @@ Value<Unit*>* CastVigilanceAction::GetTargetValue()
|
|||||||
// If no valid target, return nullptr
|
// If no valid target, return nullptr
|
||||||
if (!highestPriorityTarget)
|
if (!highestPriorityTarget)
|
||||||
{
|
{
|
||||||
return new ManualSetValue<Unit*>(botAI, nullptr);
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the current target is already the highest-priority target, do nothing
|
// If the current target is already the highest-priority target, do nothing
|
||||||
if (currentVigilanceTarget == highestPriorityTarget)
|
if (currentVigilanceTarget == highestPriorityTarget)
|
||||||
{
|
{
|
||||||
return new ManualSetValue<Unit*>(botAI, nullptr);
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign the new target
|
// Assign the new target
|
||||||
Unit* targetUnit = highestPriorityTarget->ToUnit();
|
Unit* targetUnit = highestPriorityTarget->ToUnit();
|
||||||
if (targetUnit)
|
if (targetUnit)
|
||||||
{
|
{
|
||||||
return new ManualSetValue<Unit*>(botAI, targetUnit);
|
return targetUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ManualSetValue<Unit*>(botAI, nullptr);
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CastVigilanceAction::Execute(Event event)
|
bool CastVigilanceAction::Execute(Event event)
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ class CastVigilanceAction : public BuffOnPartyAction
|
|||||||
public:
|
public:
|
||||||
CastVigilanceAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "vigilance") {}
|
CastVigilanceAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "vigilance") {}
|
||||||
|
|
||||||
Value<Unit*>* GetTargetValue() override;
|
Unit* GetTarget() override;
|
||||||
bool Execute(Event event) override;
|
bool Execute(Event event) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user