summaryrefslogtreecommitdiff
path: root/src/KingSystem/ActorSystem
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-06-21 18:33:10 +0200
committerLéo Lam <leo@leolam.fr>2021-06-21 18:33:10 +0200
commit7d6938bc27bbc52a495096643d7257db9988f45f (patch)
treea1bb59afd1a572183b40d729abdcd3ebb7a548e9 /src/KingSystem/ActorSystem
parent4f2f4ede4fa051bb2456d5ea245d8176b4f90d65 (diff)
ksys/act: FIx Query loadBool, loadInt, loadFloat
Diffstat (limited to 'src/KingSystem/ActorSystem')
-rw-r--r--src/KingSystem/ActorSystem/actAiParam.h9
-rw-r--r--src/KingSystem/ActorSystem/actAiQuery.cpp6
2 files changed, 12 insertions, 3 deletions
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 <typename T>
+ bool setAITreeVariable(const sead::SafeString& key, AIDefParamType type, const T& val) const {
+ auto* variable = static_cast<T*>(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 {