diff --git a/data/uking_functions.csv b/data/uking_functions.csv index 2e0bf207..d1cbdb0c 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -85591,18 +85591,18 @@ 0x0000007101089dd0,sub_7101089DD0,36,_ZN4ksys3res12ActorCapture9LightInfoD2Ev 0x0000007101089df4,j__ZdlPv_1143,4,_ZN4ksys3res12ActorCapture9LightInfoD0Ev 0x0000007101089f6c,sub_7101089F6C,100,_GLOBAL__sub_I_resResourceActorCapture.cpp? -0x0000007101089fd0,sub_7101089FD0,100, -0x000000710108a034,sub_710108A034,108, -0x000000710108a0a0,ActorTemplate::createInstance,148, -0x000000710108a134,sub_710108A134,60, -0x000000710108a170,sub_710108A170,60, -0x000000710108a1ac,ActorTemplate::init,76, -0x000000710108a1f8,ActorTemplate::getActorClassFromProfile,252, -0x000000710108a2f4,sub_710108A2F4,184, -0x000000710108a3ac,sub_710108A3AC,292, -0x000000710108a4d0,sub_710108A4D0,240, -0x000000710108a5c0,ActorTemplate::getNumEntries,8, -0x000000710108a5c8,ActorTemplate::getKeyNameByIdx,76, +0x0000007101089fd0,sub_7101089FD0,100,_ZN4ksys3act13ActorTemplate18SingletonDisposer_D2Ev +0x000000710108a034,sub_710108A034,108,_ZN4ksys3act13ActorTemplate18SingletonDisposer_D0Ev +0x000000710108a0a0,ActorTemplate::createInstance,148,_ZN4ksys3act13ActorTemplate14createInstanceEPN4sead4HeapE +0x000000710108a134,sub_710108A134,60,_ZN4ksys3act13ActorTemplateD1Ev +0x000000710108a170,sub_710108A170,60,_ZN4ksys3act13ActorTemplateD0Ev +0x000000710108a1ac,ActorTemplate::init,76,_ZN4ksys3act13ActorTemplate4initEPKhPN4sead4HeapE +0x000000710108a1f8,ActorTemplate::getActorClassFromProfile,252,_ZNK4ksys3act13ActorTemplate13getActorClassEPPKcS3_ +0x000000710108a2f4,sub_710108A2F4,184,_ZNK4ksys3act13ActorTemplate24getNumAttPriorityEntriesEPKc +0x000000710108a3ac,sub_710108A3AC,292,_ZNK4ksys3act13ActorTemplate14getAttPriorityEPPKcS3_i +0x000000710108a4d0,sub_710108A4D0,240,_ZNK4ksys3act13ActorTemplate17getAttDefPriorityEPPKcS3_ +0x000000710108a5c0,ActorTemplate::getNumEntries,8,_ZNK4ksys3act13ActorTemplate14getNumProfilesEv +0x000000710108a5c8,ActorTemplate::getKeyNameByIdx,76,_ZNK4ksys3act13ActorTemplate14getProfileNameEi 0x000000710108a614,nullsub_4457,4, 0x000000710108a618,sub_710108A618,8, 0x000000710108a620,sub_710108A620,8, diff --git a/src/KingSystem/ActorSystem/CMakeLists.txt b/src/KingSystem/ActorSystem/CMakeLists.txt index f328738b..5281ca87 100644 --- a/src/KingSystem/ActorSystem/CMakeLists.txt +++ b/src/KingSystem/ActorSystem/CMakeLists.txt @@ -12,6 +12,8 @@ target_sources(uking PRIVATE actActorParam.h actActorParamMgr.cpp actActorParamMgr.h + actActorTemplate.cpp + actActorTemplate.h actAiAction.cpp actAiAction.h actAiClass.cpp diff --git a/src/KingSystem/ActorSystem/actActorTemplate.cpp b/src/KingSystem/ActorSystem/actActorTemplate.cpp new file mode 100644 index 00000000..0daf5dae --- /dev/null +++ b/src/KingSystem/ActorSystem/actActorTemplate.cpp @@ -0,0 +1,90 @@ +#include "KingSystem/ActorSystem/actActorTemplate.h" +#include "KingSystem/ActorSystem/actActorParamMgr.h" +#include "KingSystem/Utils/Byaml.h" +#include "KingSystem/Utils/SafeDelete.h" + +namespace ksys::act { + +SEAD_SINGLETON_DISPOSER_IMPL(ActorTemplate) + +ActorTemplate::~ActorTemplate() { + util::safeDelete(mIter); +} + +void ActorTemplate::init(const u8* data, sead::Heap* heap) { + mIter = new (heap) al::ByamlIter(data); +} + +bool ActorTemplate::getActorClass(const char** actor_class, const char* profile) const { + *actor_class = "Dummy"; + al::ByamlIter iter; + if (mIter->tryGetIterByKey(&iter, profile)) { + if (iter.tryGetStringByKey(actor_class, "class")) + return true; + + ActorParamMgr::instance()->getDebugMessage().log("[%s] classの定義がありません", profile); + } else { + ActorParamMgr::instance()->getDebugMessage().log("[%s] 未定義のアクタタイプです", profile); + } + return false; +} + +s32 ActorTemplate::getNumAttPriorityEntries(const char* profile) const { + al::ByamlIter iter; + if (mIter->tryGetIterByKey(&iter, profile)) { + al::ByamlIter attpriority; + if (iter.tryGetIterByKey(&attpriority, "attpriority")) + return attpriority.getSize(); + } else { + ActorParamMgr::instance()->getDebugMessage().log("[%s] 未定義のアクタタイプです", profile); + } + return 0; +} + +bool ActorTemplate::getAttPriority(const char** priority, const char* profile, s32 idx) const { + *priority = "Obj"; + al::ByamlIter iter; + if (mIter->tryGetIterByKey(&iter, profile)) { + al::ByamlIter attpriority; + if (!iter.tryGetIterByKey(&attpriority, "attpriority")) + return false; + + if (attpriority.tryGetStringByIndex(priority, idx)) + return true; + + ActorParamMgr::instance()->getDebugMessage().log( + "[%s]指定できるアテンションの優先度のインデックスが範囲外です(%d)", profile, idx); + return false; + } + + ActorParamMgr::instance()->getDebugMessage().log("[%s] 未定義のアクタタイプです", profile); + return false; +} + +bool ActorTemplate::getAttDefPriority(const char** priority, const char* profile) const { + al::ByamlIter iter; + if (mIter->tryGetIterByKey(&iter, profile)) { + if (iter.tryGetStringByKey(priority, "attdefpriority")) + return true; + + ActorParamMgr::instance()->getDebugMessage().log( + "[%s] ActorTemplate.xmlでAttDefaultPriorityが未定義です", profile); + return false; + } + + ActorParamMgr::instance()->getDebugMessage().log("[%s] 未定義のアクタタイプです", profile); + return false; +} + +s32 ActorTemplate::getNumProfiles() const { + return mIter->getSize(); +} + +const char* ActorTemplate::getProfileName(s32 idx) const { + const char* name = nullptr; + al::ByamlIter iter; + mIter->tryGetIterAndKeyNameByIndex(&iter, &name, idx); + return name; +} + +} // namespace ksys::act diff --git a/src/KingSystem/ActorSystem/actActorTemplate.h b/src/KingSystem/ActorSystem/actActorTemplate.h new file mode 100644 index 00000000..d45fc27b --- /dev/null +++ b/src/KingSystem/ActorSystem/actActorTemplate.h @@ -0,0 +1,31 @@ +#pragma once + +#include +#include "KingSystem/Utils/Types.h" + +namespace al { +class ByamlIter; +} + +namespace ksys::act { + +class ActorTemplate { + SEAD_SINGLETON_DISPOSER(ActorTemplate) + virtual ~ActorTemplate(); + +public: + void init(const u8* data, sead::Heap* heap); + + bool getActorClass(const char** actor_class, const char* profile) const; + s32 getNumAttPriorityEntries(const char* profile) const; + bool getAttPriority(const char** priority, const char* profile, s32 idx) const; + bool getAttDefPriority(const char** priority, const char* profile) const; + s32 getNumProfiles() const; + const char* getProfileName(s32 idx) const; + +private: + al::ByamlIter* mIter = nullptr; +}; +KSYS_CHECK_SIZE_NX150(ActorTemplate, 0x30); + +} // namespace ksys::act diff --git a/src/KingSystem/System/DebugMessage.h b/src/KingSystem/System/DebugMessage.h index 96ab60da..953bee9a 100644 --- a/src/KingSystem/System/DebugMessage.h +++ b/src/KingSystem/System/DebugMessage.h @@ -8,12 +8,22 @@ namespace ksys { struct DebugMessage { + struct Buffer { + ~Buffer() { + if (buffer && _8) + buffer[0x44] = 1; + } + + char* buffer; + bool _8; + }; + DebugMessage() = default; explicit DebugMessage(const sead::SafeString& msg) : message(msg) {} virtual ~DebugMessage() { ; } - void log(const char* format, ...); + Buffer log(const char* format, ...); u64 _8 = 0; sead::FixedSafeString<64> message;