mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Fix GetGuidValue crash
This commit is contained in:
@@ -113,3 +113,27 @@ std::string const ObjectGuidListCalculatedValue::Format()
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
Unit* UnitCalculatedValue::Get()
|
||||
{
|
||||
if (checkInterval < 2) {
|
||||
PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_VALUE, this->getName(), this->context ? &this->context->performanceStack : nullptr);
|
||||
value = Calculate();
|
||||
if (pmo)
|
||||
pmo->finish();
|
||||
} else {
|
||||
time_t now = getMSTime();
|
||||
if (!lastCheckTime || now - lastCheckTime >= checkInterval)
|
||||
{
|
||||
lastCheckTime = now;
|
||||
PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_VALUE, this->getName(), this->context ? &this->context->performanceStack : nullptr);
|
||||
value = Calculate();
|
||||
if (pmo)
|
||||
pmo->finish();
|
||||
}
|
||||
}
|
||||
// Prevent crashing by InWorld check
|
||||
if (value && value->IsInWorld())
|
||||
return value;
|
||||
return nullptr;
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "ObjectGuid.h"
|
||||
#include "PerformanceMonitor.h"
|
||||
#include "Timer.h"
|
||||
#include "Unit.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
@@ -257,6 +258,7 @@ class UnitCalculatedValue : public CalculatedValue<Unit*>
|
||||
UnitCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int32 checkInterval = 1);
|
||||
|
||||
std::string const Format() override;
|
||||
Unit* Get() override;
|
||||
};
|
||||
|
||||
class CDPairCalculatedValue : public CalculatedValue<CreatureData const*>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
bool NeedCureTrigger::IsActive()
|
||||
{
|
||||
Unit* target = GetTarget();
|
||||
return target && botAI->HasAuraToDispel(target, dispelType);
|
||||
return target && target->IsInWorld() && botAI->HasAuraToDispel(target, dispelType);
|
||||
}
|
||||
|
||||
Value<Unit*>* PartyMemberNeedCureTrigger::GetTargetValue()
|
||||
|
||||
Reference in New Issue
Block a user