[Crash fix] Unit in world check for manual set value

This commit is contained in:
Yunfan Li
2024-06-06 00:14:25 +08:00
parent f0f176d66f
commit 7d1e17f92f
2 changed files with 9 additions and 0 deletions

View File

@@ -136,4 +136,12 @@ Unit* UnitCalculatedValue::Get()
if (value && value->IsInWorld())
return value;
return nullptr;
}
Unit* UnitManualSetValue::Get()
{
// Prevent crashing by InWorld check
if (value && value->IsInWorld())
return value;
return nullptr;
}

View File

@@ -323,6 +323,7 @@ class UnitManualSetValue : public ManualSetValue<Unit*>
ManualSetValue<Unit*>(botAI, defaultValue, name) { }
std::string const Format() override;
Unit* Get() override;
};
#endif