From 7d1e17f92fe68a3abf288db52589ae5d390c969b Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Thu, 6 Jun 2024 00:14:25 +0800 Subject: [PATCH] [Crash fix] Unit in world check for manual set value --- src/strategy/Value.cpp | 8 ++++++++ src/strategy/Value.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/strategy/Value.cpp b/src/strategy/Value.cpp index 4f64319e..464e0d1f 100644 --- a/src/strategy/Value.cpp +++ b/src/strategy/Value.cpp @@ -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; } \ No newline at end of file diff --git a/src/strategy/Value.h b/src/strategy/Value.h index 9ab4b89a..9cba6efe 100644 --- a/src/strategy/Value.h +++ b/src/strategy/Value.h @@ -323,6 +323,7 @@ class UnitManualSetValue : public ManualSetValue ManualSetValue(botAI, defaultValue, name) { } std::string const Format() override; + Unit* Get() override; }; #endif