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;
|
||||
}
|
||||
|
||||
Value<Unit*>* CastVigilanceAction::GetTargetValue()
|
||||
Unit* CastVigilanceAction::GetTarget()
|
||||
{
|
||||
Group* group = bot->GetGroup();
|
||||
if (!group)
|
||||
{
|
||||
return new ManualSetValue<Unit*>(botAI, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Player* currentVigilanceTarget = nullptr;
|
||||
@@ -74,23 +74,23 @@ Value<Unit*>* CastVigilanceAction::GetTargetValue()
|
||||
// If no valid target, return nullptr
|
||||
if (!highestPriorityTarget)
|
||||
{
|
||||
return new ManualSetValue<Unit*>(botAI, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If the current target is already the highest-priority target, do nothing
|
||||
if (currentVigilanceTarget == highestPriorityTarget)
|
||||
{
|
||||
return new ManualSetValue<Unit*>(botAI, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Assign the new target
|
||||
Unit* targetUnit = highestPriorityTarget->ToUnit();
|
||||
if (targetUnit)
|
||||
{
|
||||
return new ManualSetValue<Unit*>(botAI, targetUnit);
|
||||
return targetUnit;
|
||||
}
|
||||
|
||||
return new ManualSetValue<Unit*>(botAI, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CastVigilanceAction::Execute(Event event)
|
||||
|
||||
@@ -140,7 +140,7 @@ class CastVigilanceAction : public BuffOnPartyAction
|
||||
public:
|
||||
CastVigilanceAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "vigilance") {}
|
||||
|
||||
Value<Unit*>* GetTargetValue() override;
|
||||
Unit* GetTarget() override;
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user