Fix GetGuidValue crash

This commit is contained in:
Yunfan Li
2024-02-10 12:10:52 +08:00
parent db1adf35c1
commit 4091ba3e5a
3 changed files with 27 additions and 1 deletions

View File

@@ -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;
}