From f7e6cce7a9c7c89afd1e013294ed427ace08d350 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 8 Nov 2020 18:28:43 +0100 Subject: [PATCH] ksys/act: Implement final non-dev-only ActorParam function --- data/uking_functions.csv | 2 +- src/KingSystem/ActorSystem/actActorParam.cpp | 29 +++++++++++++++++++ src/KingSystem/ActorSystem/actActorParam.h | 1 + src/KingSystem/ActorSystem/actActorTemplate.h | 2 ++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/data/uking_functions.csv b/data/uking_functions.csv index d1cbdb0c..53dfdd8e 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -89065,7 +89065,7 @@ 0x0000007101186060,sub_7101186060,24,_ZN4ksys3act10ActorParam14freeLastHandleEv 0x0000007101186078,ActorParam::Load::setResourcePointer,28,_ZN4ksys3act10ActorParam11setResourceENS1_12ResourceTypeEPNS_7ParamIOE 0x0000007101186094,ActorParam::Load::loadPriority,472,_ZN4ksys3act10ActorParam11setPriorityERKN4sead14SafeStringBaseIcEE -0x000000710118626c,ActorParam::Load::checkClassAndPriority,424, +0x000000710118626c,ActorParam::Load::checkClassAndPriority,424,_ZN4ksys3act10ActorParam21setProfileAndPriorityEPKcS3_ 0x0000007101186414,nullsub_4613,4, 0x0000007101186418,nullsub_4614,4,_ZN4ksys3res10GParamList9doCreate_EPhjPN4sead4HeapE 0x000000710118641c,ResourceBgparamlist::doCreate,4,_ZThn632_N4ksys3res10GParamList9doCreate_EPhjPN4sead4HeapE diff --git a/src/KingSystem/ActorSystem/actActorParam.cpp b/src/KingSystem/ActorSystem/actActorParam.cpp index bcc3a045..b358375a 100644 --- a/src/KingSystem/ActorSystem/actActorParam.cpp +++ b/src/KingSystem/ActorSystem/actActorParam.cpp @@ -1,6 +1,9 @@ #include "KingSystem/ActorSystem/actActorParam.h" #include #include +#include "KingSystem/ActorSystem/actActorParamMgr.h" +#include "KingSystem/ActorSystem/actActorTemplate.h" +#include "KingSystem/Utils/Byaml.h" namespace ksys::act { @@ -125,4 +128,30 @@ bool ActorParam::setPriority(const sead::SafeString& priority) { return false; } +void ActorParam::setProfileAndPriority(const char* profile, const char* priority) { + mProfile = profile; + + al::ByamlIter* root = ActorTemplate::instance()->getRootIter(); + al::ByamlIter iter; + if (root->tryGetIterByKey(&iter, profile)) { + const char* profile_priority; + iter.tryGetStringByKey(&mClassName, "class"); + iter.tryGetStringByKey(&profile_priority, "priority"); + + if (setPriority(priority)) + return; + + if (setPriority(profile_priority)) + return; + + ActorParamMgr::instance()->getDebugMessage().log( + "[%s] アクタテンプレート %s の 処理順指定[%s:%s]は定義されていません", + mActorName.cstr(), profile, priority, profile_priority); + } else { + ActorParamMgr::instance()->getDebugMessage().log( + "[%s] アクタテンプレートに %s は定義されていません", mActorName.cstr(), profile); + setProfileAndPriority("Dummy", priority); + } +} + } // namespace ksys::act diff --git a/src/KingSystem/ActorSystem/actActorParam.h b/src/KingSystem/ActorSystem/actActorParam.h index 8726f0d5..88f563ec 100644 --- a/src/KingSystem/ActorSystem/actActorParam.h +++ b/src/KingSystem/ActorSystem/actActorParam.h @@ -139,6 +139,7 @@ private: void setResource(ResourceType type, ParamIO* param_io); bool setPriority(const sead::SafeString& priority); + void setProfileAndPriority(const char* profile, const char* priority); u16 _8 = 0; u8 _a = 0; diff --git a/src/KingSystem/ActorSystem/actActorTemplate.h b/src/KingSystem/ActorSystem/actActorTemplate.h index d45fc27b..dc2fbbe8 100644 --- a/src/KingSystem/ActorSystem/actActorTemplate.h +++ b/src/KingSystem/ActorSystem/actActorTemplate.h @@ -23,6 +23,8 @@ public: s32 getNumProfiles() const; const char* getProfileName(s32 idx) const; + al::ByamlIter* getRootIter() const { return mIter; } + private: al::ByamlIter* mIter = nullptr; };