diff --git a/src/KingSystem/ActorSystem/actAiParam.h b/src/KingSystem/ActorSystem/actAiParam.h index e132ef8b..e775f7fd 100644 --- a/src/KingSystem/ActorSystem/actAiParam.h +++ b/src/KingSystem/ActorSystem/actAiParam.h @@ -82,6 +82,15 @@ public: return true; } + template + bool setAITreeVariable(const sead::SafeString& key, AIDefParamType type, const T& val) const { + auto* variable = static_cast(getAITreeVariablePointer(key, type, true)); + if (!variable) + return false; + *variable = val; + return true; + } + bool load(const Actor& actor, const ParamNameTypePairs& pairs, s32 count, sead::Heap* heap); void* getAITreeVariablePointer(const sead::SafeString& key, AIDefParamType type, bool x = false) const; diff --git a/src/KingSystem/ActorSystem/actAiQuery.cpp b/src/KingSystem/ActorSystem/actAiQuery.cpp index 87b7af6b..97f9ac33 100644 --- a/src/KingSystem/ActorSystem/actAiQuery.cpp +++ b/src/KingSystem/ActorSystem/actAiQuery.cpp @@ -84,7 +84,7 @@ bool Query::loadInt(const evfl::ParamAccessor& accessor, const sead::SafeString& if (!accessor.FindInt(&value, param.cstr())) return false; - return mParamPack.setVariable(param, AIDefParamType::Int, value); + return mParamPack.setAITreeVariable(param, AIDefParamType::Int, value); } bool Query::loadFloat(const evfl::ParamAccessor& accessor, const sead::SafeString& param) { @@ -92,7 +92,7 @@ bool Query::loadFloat(const evfl::ParamAccessor& accessor, const sead::SafeStrin if (!accessor.FindFloat(&value, param.cstr())) return false; - return mParamPack.setVariable(param, AIDefParamType::Float, value); + return mParamPack.setAITreeVariable(param, AIDefParamType::Float, value); } bool Query::loadBool(const evfl::ParamAccessor& accessor, const sead::SafeString& param) { @@ -100,7 +100,7 @@ bool Query::loadBool(const evfl::ParamAccessor& accessor, const sead::SafeString if (!accessor.FindBool(&value, param.cstr())) return false; - return mParamPack.setVariable(param, AIDefParamType::Bool, value); + return mParamPack.setAITreeVariable(param, AIDefParamType::Bool, value); } bool Query::getAITreeVariable(sead::SafeString** value, const sead::SafeString& param) const {