From ffe38d0076fd487bae46edd092171469ec08d439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Thu, 12 Nov 2020 16:03:03 +0100 Subject: [PATCH] ksys/act: Implement more ActorParamMgr functions --- data/uking_functions.csv | 76 ++-- src/KingSystem/ActorSystem/actActorParam.cpp | 6 +- src/KingSystem/ActorSystem/actActorParam.h | 21 +- .../ActorSystem/actActorParamMgr.cpp | 392 ++++++++++++++++-- src/KingSystem/ActorSystem/actActorParamMgr.h | 29 +- src/KingSystem/Resource/resResourceASList.h | 6 +- .../Resource/resResourceActorLink.h | 88 ++-- .../Resource/resResourceAttClientList.h | 6 +- .../Resource/resResourceMgrTask.cpp | 8 +- src/KingSystem/Resource/resResourceMgrTask.h | 5 +- .../Resource/resResourceRagdollConfigList.h | 10 +- src/KingSystem/Resource/resSystem.cpp | 9 + src/KingSystem/Resource/resSystem.h | 4 + src/KingSystem/Resource/resTextureHandleMgr.h | 3 + src/KingSystem/Utils/ParamIO.h | 5 +- 15 files changed, 559 insertions(+), 109 deletions(-) diff --git a/data/uking_functions.csv b/data/uking_functions.csv index dcf6561e..bcf91c2d 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -90950,12 +90950,12 @@ 0x00000071011680d4,ActorParam::ctor,372,_ZN4ksys3act13ActorParamMgrC1Ev 0x0000007101168248,ActorParam::init,6612, 0x0000007101169c1c,sub_7101169C1C,248,_ZN4sead9SafeArrayIN4ksys3res6HandleELi28EED2Ev -0x0000007101169d14,sub_7101169D14,8, -0x0000007101169d1c,sub_7101169D1C,316, +0x0000007101169d14,sub_7101169D14,8,_ZNK4ksys3act13ActorParamMgr9checkPathERKN4sead14SafeStringBaseIcEE +0x0000007101169d1c,sub_7101169D1C,316,_ZN4ksys3act13ActorParamMgr10allocParamEPKcPb 0x0000007101169e58,ActorParam::getLoad,620,_ZNK4ksys3act13ActorParamMgr8getParamEPKcPPNS0_10ActorParamE? 0x000000710116a0c4,ActorParam::prepareLoad,404,_ZN4ksys3act13ActorParamMgr9loadParamEPKcPNS_3res6HandleEPvj -0x000000710116a258,ActorParam::loadActorFiles,492, -0x000000710116a444,ActorParam::loadActorPack,284,_ZN4ksys3act13ActorParamMgr13loadActorPackEPNS_3res6HandleERKN4sead14SafeStringBaseIcEEj +0x000000710116a258,ActorParam::loadActorFiles,492,_ZN4ksys3act13ActorParamMgr9loadFilesEPNS0_10ActorParamEPN4sead4HeapEPNS_3res6HandleEPvj +0x000000710116a444,ActorParam::loadActorPack,284,_ZN4ksys3act13ActorParamMgr20requestLoadActorPackEPNS_3res6HandleERKN4sead14SafeStringBaseIcEEj 0x000000710116a560,sub_710116A560,224, 0x000000710116a640,sub_710116A640,548, 0x000000710116a864,ActorParam::__auto0,144, @@ -91010,34 +91010,34 @@ 0x0000007101173114,sub_7101173114,828, 0x0000007101173450,sub_7101173450,828, 0x000000710117378c,sub_710117378C,828, -0x0000007101173ac8,sub_7101173AC8,1788, -0x00000071011741c4,ActorParam::lockCsAndUnload,52, -0x00000071011741f8,act::checkResourceIsInPackAndSetPackRes2,420, -0x000000710117439c,ActorParam::tapLoadActorPack,560, -0x00000071011745cc,ActorParam::loadActorLink,1876, -0x0000007101174d20,sub_7101174D20,1876, -0x0000007101175474,sub_7101175474,1876, -0x0000007101175bc8,sub_7101175BC8,1876, -0x000000710117631c,sub_710117631C,1876, -0x0000007101176a70,sub_7101176A70,1876, -0x00000071011771c4,sub_71011771C4,1876, -0x0000007101177918,sub_7101177918,1876, -0x000000710117806c,sub_710117806C,1876, -0x00000071011787c0,ActorParam::loadAiprog,1876, -0x0000007101178f14,sub_7101178F14,1876, -0x0000007101179668,sub_7101179668,1876, -0x0000007101179dbc,sub_7101179DBC,1876, -0x000000710117a510,sub_710117A510,1876, -0x000000710117ac64,sub_710117AC64,1876, -0x000000710117b3b8,sub_710117B3B8,1876, -0x000000710117bb0c,sub_710117BB0C,1876, -0x000000710117c260,sub_710117C260,1876, -0x000000710117c9b4,sub_710117C9B4,1876, -0x000000710117d108,sub_710117D108,1876, -0x000000710117d85c,sub_710117D85C,1876, -0x000000710117dfb0,sub_710117DFB0,1876, -0x000000710117e704,sub_710117E704,1876, -0x000000710117ee58,sub_710117EE58,1876, +0x0000007101173ac8,sub_7101173AC8,1788,_ZN4ksys3act13ActorParamMgr14loadFilesStep2EPNS0_10ActorParamEPN4sead4HeapEPNS_3res6HandleEPvj +0x00000071011741c4,ActorParam::lockCsAndUnload,52,_ZN4ksys3act13ActorParamMgr11unloadParamEPNS0_10ActorParamE +0x00000071011741f8,act::checkResourceIsInPackAndSetPackRes2,420,_ZN4ksys3act13ActorParamMgr24prepareLoadFromActorPackEPN4sead22BufferedSafeStringBaseIcEEPNS_3res11LoadRequestEPvRKNS2_14SafeStringBaseIcEESD_SD_PNS6_6HandleEjSD_ +0x000000710117439c,ActorParam::tapLoadActorPack,560,_ZN4ksys3act13ActorParamMgr13loadActorPackEPNS_3res6HandleERKN4sead14SafeStringBaseIcEEj +0x00000071011745cc,ActorParam::loadActorLink,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res9ActorLinkEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x0000007101174d20,sub_7101174D20,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res9ModelListEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x0000007101175474,sub_7101175474,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res4UMiiEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x0000007101175bc8,sub_7101175BC8,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res6ASListEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x000000710117631c,sub_710117631C,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res13AttClientListEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x0000007101176a70,sub_7101176A70,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res17RagdollConfigListEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x00000071011771c4,sub_71011771C4,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res2ASEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x0000007101177918,sub_7101177918,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res9AttClientEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x000000710117806c,sub_710117806C,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res13RagdollConfigEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x00000071011787c0,ActorParam::loadAiprog,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res9AIProgramEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x0000007101178f14,sub_7101178F14,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res10GParamListEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x0000007101179668,sub_7101179668,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res7PhysicsEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x0000007101179dbc,sub_7101179DBC,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res8ChemicalEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x000000710117a510,sub_710117A510,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res11DamageParamEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x000000710117ac64,sub_710117AC64,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res18RagdollBlendWeightEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x000000710117b3b8,sub_710117B3B8,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res9AwarenessEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x000000710117bb0c,sub_710117BB0C,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res4DropEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x000000710117c260,sub_710117C260,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res4ShopEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x000000710117c9b4,sub_710117C9B4,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res6RecipeEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x000000710117d108,sub_710117D108,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res3LodEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x000000710117d85c,sub_710117D85C,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res10AIScheduleEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x000000710117dfb0,sub_710117DFB0,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res11BoneControlEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x000000710117e704,sub_710117E704,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res13LifeConditionEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj +0x000000710117ee58,sub_710117EE58,1876,_ZN4ksys3act13ActorParamMgr8loadFileINS_3res8AnimInfoEEEPT_PNS0_10ActorParamENS7_12ResourceTypeEPKcSB_SB_PNS3_6HandleEPvj 0x000000710117f5ac,sub_710117F5AC,376, 0x000000710117f724,sub_710117F724,8, 0x000000710117f72c,ActorParam::getBgparamlist,36,_ZNK4ksys3act13ActorParamMgr18getDummyGParamListEv @@ -91245,7 +91245,7 @@ 0x00000071011858c0,ActorParam::Data::doUnload,440,_ZN4ksys3act10ActorParam10deleteDataEv 0x0000007101185a78,sub_7101185A78,68,_ZN4ksys3act10ActorParamD0Ev 0x0000007101185abc,ActorParam::Load::deleteRes2,164,_ZN4ksys3act10ActorParam16deleteResHandlesEv -0x0000007101185b60,ActorParam::Load::isDummyParamResource,136,_ZNK4ksys3act10ActorParam12isDummyParamENS_3res9ActorLink5Users4UserE +0x0000007101185b60,ActorParam::Load::isDummyParamResource,136,_ZNK4ksys3act10ActorParam12isDummyParamENS_3res9ActorLink4UserE 0x0000007101185be8,ActorParam::Load::constructRes2,188,_ZN4ksys3act10ActorParam15allocResHandlesEPN4sead4HeapEji 0x0000007101185ca4,ActorParam::Event::incRefCount,72,_ZN4ksys3act10ActorParam12incrementRefEv 0x0000007101185cec,ActorParam::Data::unload,124,_ZN4ksys3act10ActorParam12decrementRefEv @@ -91258,7 +91258,7 @@ 0x0000007101186078,ActorParam::Load::setResourcePointer,28,_ZN4ksys3act10ActorParam11setResourceENS1_12ResourceTypeEPNS_7ParamIOE 0x0000007101186094,ActorParam::Load::loadPriority,472,_ZN4ksys3act10ActorParam11setPriorityERKN4sead14SafeStringBaseIcEE 0x000000710118626c,ActorParam::Load::checkClassAndPriority,424,_ZN4ksys3act10ActorParam21setProfileAndPriorityEPKcS3_ -0x0000007101186414,nullsub_4613,4, +0x0000007101186414,nullsub_4613,4,_ZN4ksys3act10ActorParam14onLoadFinishedEPNS0_13ActorParamMgrE 0x0000007101186418,nullsub_4614,4,_ZN4ksys3res10GParamList9doCreate_EPhjPN4sead4HeapE 0x000000710118641c,ResourceBgparamlist::doCreate,4,_ZThn632_N4ksys3res10GParamList9doCreate_EPhjPN4sead4HeapE 0x0000007101186420,Bgparamlist::parse,22480,_ZN4ksys3res10GParamList6parse_EPhmPN4sead4HeapE @@ -93180,7 +93180,7 @@ 0x000000710120a4d4,nullsub_4699,4,_ZN4ksys3res17MemoryTaskRequestD2Ev 0x000000710120a4d8,res::ResourceMgrTask::load,1292, 0x000000710120a9e4,canUseSdCard,8,_ZNK4ksys3res15ResourceMgrTask12canUseSdCardEv -0x000000710120a9ec,return_0_0,8,_ZNK4ksys3res15ResourceMgrTask11returnFalseEv +0x000000710120a9ec,return_0_0,8,_ZNK4ksys3res15ResourceMgrTask10isHostPathERKN4sead14SafeStringBaseIcEE 0x000000710120a9f4,res::ResourceMgrTask::dropSFromExtensionForBfevflBcamanimAndBarslist,756,_ZNK4ksys3res15ResourceMgrTask26dropSFromExtensionIfNeededERKN4sead14SafeStringBaseIcEERNS2_22BufferedSafeStringBaseIcEEiS6_ 0x000000710120ace8,res::ResourceMgrTask::unloadSeadResource,84,_ZN4ksys3res15ResourceMgrTask18unloadSeadResourceEPN4sead8ResourceE 0x000000710120ad3c,res::ResourceMgrTask::getResourceSize,328,_ZNK4ksys3res15ResourceMgrTask15getResourceSizeERKN4sead14SafeStringBaseIcEEPNS2_10FileDeviceE @@ -93203,7 +93203,7 @@ 0x000000710120b5a8,res::ResourceMgrTask::setCompactionStopped,104,_ZN4ksys3res15ResourceMgrTask20setCompactionStoppedEb? 0x000000710120b610,sub_710120B610,28, 0x000000710120b62c,sub_710120B62C,28, -0x000000710120b648,res::ResourceMgrTask::setStruct10OnTempResLoader,60, +0x000000710120b648,res::ResourceMgrTask::setStruct10OnTempResLoader,60,_ZN4ksys3res15ResourceMgrTask22initTempResourceLoaderEPNS0_18TempResourceLoaderERNS2_7InitArgE 0x000000710120b684,res::ResourceMgrTask::repairAllHandlesForSync,24, 0x000000710120b69c,sub_710120B69C,16, 0x000000710120b6ac,sub_710120B6AC,8,_ZN4ksys3res15ResourceMgrTask11returnTrue1Ev @@ -93317,7 +93317,7 @@ 0x00000071012131a4,res::clearAllCaches,16, 0x00000071012131b4,res::clearAllCaches2,16, 0x00000071012131c4,res::clearAllCaches3,16, -0x00000071012131d4,return_0_1,24, +0x00000071012131d4,return_0_1,24,_ZN4ksys3res10isHostPathERKN4sead14SafeStringBaseIcEE 0x00000071012131ec,res::isCompactionStopped,100, 0x0000007101213250,callResourceMgrTaskMethodOO,16, 0x0000007101213260,res::setCompactionStopped,24, @@ -93333,7 +93333,7 @@ 0x00000071012132c0,res::writeResourceListToCsv,4, 0x00000071012132c4,nullsub_4708,4, 0x00000071012132c8,nullsub_4709,4, -0x00000071012132cc,return_0,8, +0x00000071012132cc,return_0,8,_ZN4ksys3res12returnFalse3ERKN4sead14SafeStringBaseIcEE 0x00000071012132d4,return_8,8,_ZN4ksys3res19getDefaultAlignmentEv 0x00000071012132dc,return1,16, 0x00000071012132ec,ArchiveRes::ctor,60,_ZN4ksys3res7ArchiveC1Ev diff --git a/src/KingSystem/ActorSystem/actActorParam.cpp b/src/KingSystem/ActorSystem/actActorParam.cpp index 639f6b3f..dbe2096e 100644 --- a/src/KingSystem/ActorSystem/actActorParam.cpp +++ b/src/KingSystem/ActorSystem/actActorParam.cpp @@ -49,8 +49,8 @@ void ActorParam::deleteResHandles() { handles.freeBuffer(); } -bool ActorParam::isDummyParam(res::ActorLink::Users::User user) const { - return mRes.mActorLink->getUsers().getUserName(user) == "Dummy"; +bool ActorParam::isDummyParam(res::ActorLink::User user) const { + return sead::SafeString(mRes.mActorLink->getUserName(user)) == "Dummy"; } void ActorParam::allocResHandles(sead::Heap* heap, u32 buffer_idx, s32 count) { @@ -154,4 +154,6 @@ void ActorParam::setProfileAndPriority(const char* profile, const char* priority } } +void ActorParam::onLoadFinished(ActorParamMgr*) {} + } // namespace ksys::act diff --git a/src/KingSystem/ActorSystem/actActorParam.h b/src/KingSystem/ActorSystem/actActorParam.h index 88f563ec..fe93b944 100644 --- a/src/KingSystem/ActorSystem/actActorParam.h +++ b/src/KingSystem/ActorSystem/actActorParam.h @@ -40,6 +40,8 @@ class UMii; namespace act { +class ActorParamMgr; + // FIXME: incomplete class ActorParam : public sead::hostio::Node { public: @@ -69,8 +71,15 @@ public: LifeCondition = 22, UMii = 23, AnimationInfo = 24, + AS = 25, + AttClient = 26, + RagdollConfig = 27, }; + static constexpr bool isValidType(ResourceType type) { + return type <= ResourceType::AnimationInfo; + } + union Resources { struct { res::ActorLink* mActorLink; @@ -112,7 +121,7 @@ public: Priority getPriority() const { return mPriority; } const Resources& getRes() const { return mRes; } - bool isDummyParam(res::ActorLink::Users::User user) const; + bool isDummyParam(res::ActorLink::User user) const; static void resetDummyResources(); @@ -141,7 +150,15 @@ private: bool setPriority(const sead::SafeString& priority); void setProfileAndPriority(const char* profile, const char* priority); - u16 _8 = 0; + void setResourceIfValidType(ResourceType type, ParamIO* param_io) { + if (isValidType(type)) + setResource(type, param_io); + } + + void onLoadFinished(ActorParamMgr* mgr); + + u8 _8 = 0; + u8 _9 = 0; u8 _a = 0; sead::FixedSafeString<64> mActorName; sead::SafeString mProfile; diff --git a/src/KingSystem/ActorSystem/actActorParamMgr.cpp b/src/KingSystem/ActorSystem/actActorParamMgr.cpp index 82fa697e..17c6404d 100644 --- a/src/KingSystem/ActorSystem/actActorParamMgr.cpp +++ b/src/KingSystem/ActorSystem/actActorParamMgr.cpp @@ -3,7 +3,36 @@ #include "KingSystem/ActorSystem/actASSetting.h" #include "KingSystem/ActorSystem/actActorParam.h" #include "KingSystem/Resource/resLoadRequest.h" +#include "KingSystem/Resource/resResourceAIProgram.h" +#include "KingSystem/Resource/resResourceAISchedule.h" +#include "KingSystem/Resource/resResourceAS.h" +#include "KingSystem/Resource/resResourceASList.h" +#include "KingSystem/Resource/resResourceActorLink.h" +#include "KingSystem/Resource/resResourceAnimInfo.h" +#include "KingSystem/Resource/resResourceArchive.h" +#include "KingSystem/Resource/resResourceAttClient.h" +#include "KingSystem/Resource/resResourceAttClientList.h" +#include "KingSystem/Resource/resResourceAwareness.h" +#include "KingSystem/Resource/resResourceBoneControl.h" +#include "KingSystem/Resource/resResourceChemical.h" +#include "KingSystem/Resource/resResourceDamageParam.h" +#include "KingSystem/Resource/resResourceDrop.h" #include "KingSystem/Resource/resResourceGParamList.h" +#include "KingSystem/Resource/resResourceLifeCondition.h" +#include "KingSystem/Resource/resResourceLod.h" +#include "KingSystem/Resource/resResourceMgrTask.h" +#include "KingSystem/Resource/resResourceModelList.h" +#include "KingSystem/Resource/resResourcePhysics.h" +#include "KingSystem/Resource/resResourceRagdollBlendWeight.h" +#include "KingSystem/Resource/resResourceRagdollConfig.h" +#include "KingSystem/Resource/resResourceRagdollConfigList.h" +#include "KingSystem/Resource/resResourceRecipe.h" +#include "KingSystem/Resource/resResourceShop.h" +#include "KingSystem/Resource/resResourceUMii.h" +#include "KingSystem/Resource/resSystem.h" +#include "KingSystem/Resource/resTempResourceLoader.h" +#include "KingSystem/Utils/Debug.h" +#include "KingSystem/Utils/ParamIO.h" namespace ksys::act { @@ -15,6 +44,31 @@ ActorParamMgr::~ActorParamMgr() { ASSetting::deleteInstance(); } +bool ActorParamMgr::checkPath(const sead::SafeString& path) const { + return res::returnFalse3(path); +} + +ActorParam* ActorParamMgr::allocParam(const char* actor_name, bool* allocated_new) { + auto lock = sead::makeScopedLock(mCS); + + ActorParam* free_param = nullptr; + auto* param = getParam(actor_name, &free_param); + + if (!param) { + param = free_param; + if (free_param) + free_param->mRes = {}; + else + param = &mParams[NumParams - 1]; + + param->mActorName = actor_name; + *allocated_new = true; + } + + param->incrementRef(); + return param; +} + // NON_MATCHING: addressing mode ActorParam* ActorParamMgr::getParam(const char* actor_name, ActorParam** out_free_param) const { auto lock = sead::makeScopedLock(mCS); @@ -32,30 +86,10 @@ ActorParam* ActorParamMgr::getParam(const char* actor_name, ActorParam** out_fre ActorParam* ActorParamMgr::loadParam(const char* actor_name, res::Handle* handle, void* x, u32 load_req_c) { - ActorParam* param; - bool existing = false; + bool allocated_new = false; + ActorParam* param = allocParam(actor_name, &allocated_new); - { - auto lock = sead::makeScopedLock(mCS); - - ActorParam* free_param = nullptr; - param = getParam(actor_name, &free_param); - - if (param) { - existing = true; - } else { - param = free_param; - if (free_param) - free_param->mRes = {}; - else - param = &mParams[NumParams - 1]; - - param->mActorName = actor_name; - } - param->incrementRef(); - } - - if (!existing) { + if (allocated_new) { loadFiles(param, mTmpActorParamMgrHeap, handle, x, load_req_c); param->setEventSignal(); } else { @@ -65,8 +99,43 @@ ActorParam* ActorParamMgr::loadParam(const char* actor_name, res::Handle* handle return param; } -bool ActorParamMgr::loadActorPack(res::Handle* handle, const sead::SafeString& actor_name, - u32 load_req_c) { +void ActorParamMgr::loadFiles(ActorParam* param, sead::Heap* heap, res::Handle* pack_handle, + void* x, u32 load_req_c) { + param->deleteResHandles(); + param->allocResHandles(heap, 0, 29); + param->mActiveBufferIdx = 0; + + using Type = ActorParam::ResourceType; + using User = res::ActorLink::User; + + const auto* link = + loadFile(param, Type::ActorLink, "Actor/ActorLink", "xml", + param->getActorName().cstr(), pack_handle, x, load_req_c); + + if (link) + param->setProfileAndPriority(link->getUserName(User::Profile), link->getPriority().cstr()); + + const auto* actor_link = param->getRes().mActorLink; + if (!actor_link) + return; + + param->mActiveBufferIdx = 0; + + loadFile(param, Type::ModelList, "Actor/ModelList", "modellist", + actor_link->getUserName(User::Model), pack_handle, x, load_req_c); + + loadFile(param, Type::UMii, "Actor/UMii", "umii", + actor_link->getUserName(User::UMii), pack_handle, x, load_req_c); + + loadFile(param, Type::ASList, "Actor/ASList", "aslist", + actor_link->getUserName(res::ActorLink::User::AS), pack_handle, x, + load_req_c); + + loadFilesStep2(param, heap, pack_handle, x, load_req_c); +} + +bool ActorParamMgr::requestLoadActorPack(res::Handle* handle, const sead::SafeString& actor_name, + u32 load_req_c) { sead::FixedSafeString<128> path; res::LoadRequest req; @@ -81,6 +150,279 @@ bool ActorParamMgr::loadActorPack(res::Handle* handle, const sead::SafeString& a return handle->requestLoad(path, &req); } +void ActorParamMgr::loadFilesStep2(ActorParam* param, sead::Heap* heap, res::Handle* pack_handle, + void* x, u32 load_req_c) { + const auto* link = param->getRes().mActorLink; + param->mActiveBufferIdx = 0; + + using Type = ActorParam::ResourceType; + using User = res::ActorLink::User; + + loadFile(param, Type::AttClientList, "Actor/AttClientList", "atcllist", + link->getUserName(User::Attention), pack_handle, x, load_req_c); + + loadFile(param, Type::RagdollConfigList, "Actor/RagdollConfigList", + "rgconfiglist", link->getUserName(User::RgConfigList), + pack_handle, x, load_req_c); + + { + s32 num_extra_handles = 0; + auto* aslist = param->getRes().mASList; + auto* atcllist = param->getRes().mAttClientList; + auto* rgconfiglist = param->getRes().mRagdollConfigList; + if (aslist) + num_extra_handles += aslist->getBuffers().as_defines.size(); + if (atcllist) + num_extra_handles += atcllist->getClients().size(); + if (rgconfiglist) + num_extra_handles += rgconfiglist->getImpulseParams().size(); + + param->allocResHandles(heap, 1, num_extra_handles); + } + + // Start loading the extra ActorParam files. + param->mActiveBufferIdx = 1; + + if (auto* aslist = param->getRes().mASList) { + for (s32 i = 0; i < aslist->getBuffers().as_defines.size(); ++i) { + auto* as = loadFile(param, Type::AS, "Actor/AS", "as", + aslist->getBuffers().as_defines[i].file_name.ref().cstr(), + pack_handle, x, load_req_c); + if (as) { + as->setIndex(u32(Type::AS)); + aslist->addAS_(i, as); + } + } + } + + if (auto* list = param->getRes().mAttClientList) { + for (s32 i = 0; i < list->getClients().size(); ++i) { + auto* client = loadFile( + param, Type::AttClient, "Actor/AttClient", "atcl", + list->getClients()[i].file_name.ref().cstr(), pack_handle, x, load_req_c); + if (client) { + client->setIndex(u32(Type::AttClient)); + list->addClient_(i, client); + } + } + } + + if (auto* list = param->getRes().mRagdollConfigList) { + for (s32 i = 0; i < list->getImpulseParams().size(); ++i) { + auto* config = loadFile( + param, Type::RagdollConfig, "Actor/RagdollConfig", "rgconfig", + list->getImpulseParams()[i].file_name.ref().cstr(), pack_handle, x, load_req_c); + if (config) { + config->setIndex(u32(Type::RagdollConfig)); + list->addImpulseParamConfig_(i, config); + } + } + } + + // We have now finished loading the extra ActorParam files. + // Go back to using the main resource handle buffer. + param->mActiveBufferIdx = 0; + + loadFile(param, Type::AIProgram, "Actor/AIProgram", "aiprog", + link->getUsers().getAIProgram(), pack_handle, x, load_req_c); + + loadFile(param, Type::GParamList, "Actor/GeneralParamList", "gparamlist", + link->getUsers().getGParam(), pack_handle, x, load_req_c); + + loadFile(param, Type::Physics, "Actor/Physics", "physics", + link->getUsers().getPhysics(), pack_handle, x, load_req_c); + + loadFile(param, Type::Chemical, "Actor/Chemical", "chemical", + link->getUsers().getChemical(), pack_handle, x, load_req_c); + + loadFile(param, Type::DamageParam, "Actor/DamageParam", "dmgparam", + link->getUsers().getDamageParam(), pack_handle, x, load_req_c); + + loadFile(param, Type::RagdollBlendWeight, "Actor/RagdollBlendWeight", + "rgbw", link->getUsers().getRgBlendWeight(), pack_handle, x, + load_req_c); + + loadFile(param, Type::Awareness, "Actor/Awareness", "awareness", + link->getUsers().getAwareness(), pack_handle, x, load_req_c); + + loadFile(param, Type::DropTable, "Actor/DropTable", "drop", + link->getUsers().getDropTable(), pack_handle, x, load_req_c); + + loadFile(param, Type::ShopData, "Actor/ShopData", "shop", + link->getUsers().getShopData(), pack_handle, x, load_req_c); + + loadFile(param, Type::Recipe, "Actor/Recipe", "recipe", + link->getUsers().getRecipe(), pack_handle, x, load_req_c); + + loadFile(param, Type::Lod, "Actor/LOD", "lod", link->getUsers().getLOD(), pack_handle, + x, load_req_c); + + loadFile(param, Type::AISchedule, "Actor/AISchedule", "aischedule", + link->getUsers().getAISchedule(), pack_handle, x, load_req_c); + + loadFile(param, Type::BoneControl, "Actor/BoneControl", "bonectrl", + link->getUsers().getBoneControl(), pack_handle, x, load_req_c); + + loadFile(param, Type::LifeCondition, "Actor/LifeCondition", "lifecondition", + link->getUsers().getLifeCondition(), pack_handle, x, load_req_c); + + loadFile(param, Type::AnimationInfo, "Actor/AnimationInfo", "animinfo", + link->getUsers().getAnimationInfo(), pack_handle, x, load_req_c); + + param->_9 = 0; + param->onLoadFinished(this); +} + +void ActorParamMgr::unloadParam(ActorParam* param) { + auto lock = sead::makeScopedLock(mCS); + param->decrementRef(); +} + +bool ActorParamMgr::prepareLoadFromActorPack(sead::BufferedSafeString* path, res::LoadRequest* req, + void*, const sead::SafeString& dir_name, + const sead::SafeString& extension, + const sead::SafeString& file_name, + res::Handle* pack_handle, u32 load_req_c, + const sead::SafeString& requester) { + path->format("%s/%s.b%s", dir_name.cstr(), file_name.cstr(), extension.cstr()); + + bool in_pack = false; + if (pack_handle && pack_handle->isSuccess()) { + auto* pack = static_cast(pack_handle->getResourceUnchecked()); + in_pack = pack->getFile(*path) != nullptr; + } + + const bool cond1 = res::returnFalse3(*path); + const bool is_host_path = res::isHostPath(*path); + if (!in_pack && !cond1 && !is_host_path && path->include("bxml")) { + sead::FormatFixedSafeString<256> message("↓↓↓\nファイルパス : %s\n↑↑↑\n", path->cstr()); + util::PrintDebug(message); + } + + const bool ret = res::returnFalse3(*path); + if (!ret && pack_handle && pack_handle->isSuccess()) { + req->mPackHandle = pack_handle; + req->_24 = false; + } + + req->_c = load_req_c; + req->mRequester = requester; + req->_8 = true; + return ret; +} + +res::Archive* ActorParamMgr::loadActorPack(res::Handle* handle, const sead::SafeString& actor_name, + u32 load_req_c) { + sead::FixedSafeString<128> path; + res::TempResourceLoader::LoadArg arg; + arg.retry_on_failure = true; + arg.use_handle = true; + + if (mFlags.isOn(Flag::_5)) + return nullptr; + + path.format("Actor/Pack/%s.bactorpack", actor_name.cstr()); + arg.load_req.mRequester = actor_name; + arg.load_req._c = load_req_c; + arg.load_req._8 = true; + arg.load_req._28 = false; + arg.load_req.mPath = path; + + res::TempResourceLoader loader; + { + res::TempResourceLoader::InitArg init_arg{}; + res::ResourceMgrTask::instance()->initTempResourceLoader(&loader, init_arg); + } + loader.load(arg); + + res::SimpleLoadRequest req; + req.mRequester = "tap::ActorParamMgr"; + req.mPath = path; + req._c = 2; + return sead::DynamicCast(handle->load(path, &req)); +} + +template +T* ActorParamMgr::loadFile(ActorParam* param, ActorParam::ResourceType type, const char* dir_name_c, + const char* extension_c, const char* name_c, res::Handle* pack_handle, + void* x, u32 load_req_c) { + const sead::SafeString name = name_c; + const sead::SafeString extension = extension_c; + sead::FixedSafeString<128> path; + + T* res = nullptr; + + if (name != "Dummy" && !name.isEmpty()) { + auto* temp_handle = param->allocHandle(); + const sead::SafeString* actor_name; + path.format("%s/%s.b%s", dir_name_c, name_c, extension_c); + { + res::SimpleLoadRequest req; + req._8 = true; + actor_name = ¶m->getActorName(); + req.mRequester = *actor_name; + req.mPath = path; + req._c = 2; + res = sead::DynamicCast(temp_handle->load(path, &req)); + } + + // If loading the resource from the RomFS has failed, try to load it from the actor pack. + if (!res) { + if (!pack_handle->isSuccess()) + loadActorPack(pack_handle, *actor_name, load_req_c); + + res::LoadRequest req; + prepareLoadFromActorPack(&path, &req, x, dir_name_c, extension_c, name_c, pack_handle, + load_req_c, *actor_name); + res = sead::DynamicCast(temp_handle->load(path, &req)); + + if (!res) { + static_cast(temp_handle->isSuccess()); + // Try again without the pack. + if (req.mPackHandle) { + req.mPackHandle = nullptr; + req._24 = false; + res = sead::DynamicCast(temp_handle->load(path, &req)); + if (!res) + static_cast(temp_handle->isSuccess()); + } + } + } + + if (!res) + param->freeLastHandle(); + else if (type == ActorParam::ResourceType::EventFlow) + temp_handle->requestUnload2(); + + } else { + path.format("%s/%s.b%s", dir_name_c, name_c, extension_c); + res = sead::DynamicCast(mResHandles[s32(type)].getResource()); + } + + if (res) { + if (type == ActorParam::ResourceType::EventFlow) + return res; + + static_cast(res)->getPath().copy(path); + param->setResourceIfValidType(type, res); + return res; + } + + if (extension != "fevfl") + param->_a = 1; + + // Fall back to using the dummy resource. + res = sead::DynamicCast(mResHandles[s32(type)].getResource()); + sead::FixedSafeString<128> dummy_path; + dummy_path.format("%s/Dummy.b%s", dir_name_c, extension_c); + if (res) { + static_cast(res)->getPath().copy(dummy_path); + param->setResourceIfValidType(type, res); + } + + return res; +} + res::GParamList* ActorParamMgr::getDummyGParamList() const { return static_cast( mResHandles[u32(ActorParam::ResourceType::GParamList)].getResourceUnchecked()); diff --git a/src/KingSystem/ActorSystem/actActorParamMgr.h b/src/KingSystem/ActorSystem/actActorParamMgr.h index accb3457..67e60427 100644 --- a/src/KingSystem/ActorSystem/actActorParamMgr.h +++ b/src/KingSystem/ActorSystem/actActorParamMgr.h @@ -6,6 +6,7 @@ #include #include #include +#include "KingSystem/ActorSystem/actActorParam.h" #include "KingSystem/Resource/resHandle.h" #include "KingSystem/System/DebugMessage.h" #include "KingSystem/System/KingEditor.h" @@ -14,13 +15,13 @@ namespace ksys { namespace res { +class Archive; class GParamList; +class LoadRequest; } // namespace res namespace act { -class ActorParam; - // FIXME: incomplete class ActorParamMgr final : public sead::hostio::Node, public KingEditorComponent { SEAD_SINGLETON_DISPOSER(ActorParamMgr) @@ -35,10 +36,14 @@ public: sead::Heap* getDebugHeap() const { return mDebugHeap; } sead::Heap* getTmpActorParamMgrHeap() const { return mTmpActorParamMgrHeap; } + bool checkPath(const sead::SafeString& path) const; + void init(sead::Heap* heap, sead::Heap* debug_heap); + ActorParam* allocParam(const char* actor_name, bool* allocated_new); ActorParam* getParam(const char* actor_name, ActorParam** out_free_param) const; ActorParam* loadParam(const char* actor_name, res::Handle* handle, void* x, u32 load_req_c); + void unloadParam(ActorParam* param); res::GParamList* getDummyGParamList() const; @@ -50,9 +55,25 @@ private: _5 = _1 | _4, }; - void loadFiles(ActorParam* param, sead::Heap* heap, res::Handle* handle, void* x, + void loadFiles(ActorParam* param, sead::Heap* heap, res::Handle* pack_handle, void* x, u32 load_req_c); - bool loadActorPack(res::Handle* handle, const sead::SafeString& actor_name, u32 load_req_c); + bool requestLoadActorPack(res::Handle* handle, const sead::SafeString& actor_name, + u32 load_req_c); + bool prepareLoadFromActorPack(sead::BufferedSafeString* path, res::LoadRequest* req, void* x, + const sead::SafeString& dir_name, + const sead::SafeString& extension, + const sead::SafeString& file_name, res::Handle* pack_handle, + u32 load_req_c, const sead::SafeString& requester); + res::Archive* loadActorPack(res::Handle* handle, const sead::SafeString& actor_name, + u32 load_req_c); + + template + T* loadFile(ActorParam* param, ActorParam::ResourceType type, const char* dir_name_c, + const char* extension_c, const char* name_c, res::Handle* pack_handle, void* x, + u32 load_req_c); + + void loadFilesStep2(ActorParam* param, sead::Heap* heap, res::Handle* pack_handle, void* x, + u32 load_req_c); static constexpr s32 NumParams = 0x400; diff --git a/src/KingSystem/Resource/resResourceASList.h b/src/KingSystem/Resource/resResourceASList.h index b5910910..3f3b5366 100644 --- a/src/KingSystem/Resource/resResourceASList.h +++ b/src/KingSystem/Resource/resResourceASList.h @@ -10,6 +10,8 @@ namespace ksys::res { +class AS; + class ASList : public ParamIO, public Resource { SEAD_RTTI_OVERRIDE(ASList, Resource) public: @@ -17,7 +19,7 @@ public: agl::utl::Parameter name; agl::utl::Parameter file_name; agl::utl::ParameterObj obj; - void* _88; + AS* as; }; KSYS_CHECK_SIZE_NX150(ASDefine, 0x88); @@ -65,6 +67,8 @@ public: const Buffers& getBuffers() const { return mBuffers; } const Common& getCommon() const { return mCommon.ref(); } + void addAS_(s32 index, AS* as); + protected: bool finishParsing_() override; bool m7_() override; diff --git a/src/KingSystem/Resource/resResourceActorLink.h b/src/KingSystem/Resource/resResourceActorLink.h index 7463e1c2..7230d68f 100644 --- a/src/KingSystem/Resource/resResourceActorLink.h +++ b/src/KingSystem/Resource/resResourceActorLink.h @@ -13,41 +13,68 @@ namespace ksys::res { class ActorLink : public ParamIO, public Resource { SEAD_RTTI_OVERRIDE(ActorLink, Resource) public: - struct Users { - enum class User { - Profile = 0, - ActorCapture = 1, - AS = 2, - Model = 3, - Anim = 4, - AIProgram = 5, - GParam = 6, - DamageParam = 7, - RgConfigList = 8, - RgBlendWeight = 9, - Awareness = 10, - Physics = 11, - Chemical = 12, - Attention = 13, - ELink = 14, - SLink = 15, - XLink = 16, - DropTable = 17, - ShopData = 18, - Recipe = 19, - LOD = 20, - BoneControl = 21, - AISchedule = 22, - LifeCondition = 23, - UMii = 24, - AnimationInfo = 25, - }; + enum class User { + Profile = 0, + ActorCapture = 1, + AS = 2, + Model = 3, + Anim = 4, + AIProgram = 5, + GParam = 6, + DamageParam = 7, + RgConfigList = 8, + RgBlendWeight = 9, + Awareness = 10, + Physics = 11, + Chemical = 12, + Attention = 13, + ELink = 14, + SLink = 15, + XLink = 16, + DropTable = 17, + ShopData = 18, + Recipe = 19, + LOD = 20, + BoneControl = 21, + AISchedule = 22, + LifeCondition = 23, + UMii = 24, + AnimationInfo = 25, + }; + struct Users { const agl::utl::Parameter& getUser(User user) const { return *(&profile + u32(user)); } - sead::SafeString getUserName(User user) const { return getUser(user).ref().cstr(); } + const char* getUserName(User user) const { return getUser(user).ref().cstr(); } + + const char* getProfile() const { return profile.ref().cstr(); } + const char* getActorCapture() const { return actor_capture.ref().cstr(); } + const char* getAS() const { return as.ref().cstr(); } + const char* getModel() const { return model.ref().cstr(); } + const char* getAnim() const { return anim.ref().cstr(); } + const char* getAIProgram() const { return ai_program.ref().cstr(); } + const char* getGParam() const { return gparam.ref().cstr(); } + const char* getDamageParam() const { return damage_param.ref().cstr(); } + const char* getRgConfigList() const { return rg_config_list.ref().cstr(); } + const char* getRgBlendWeight() const { return rg_blend_weight.ref().cstr(); } + const char* getAwareness() const { return awareness.ref().cstr(); } + const char* getPhysics() const { return physics.ref().cstr(); } + const char* getChemical() const { return chemical.ref().cstr(); } + const char* getAttention() const { return attention.ref().cstr(); } + const char* getELink() const { return elink.ref().cstr(); } + const char* getSLink() const { return slink.ref().cstr(); } + const char* getXLink() const { return xlink.ref().cstr(); } + const char* getDropTable() const { return drop_table.ref().cstr(); } + const char* getShopData() const { return shop_data.ref().cstr(); } + const char* getRecipe() const { return recipe.ref().cstr(); } + const char* getLOD() const { return lod.ref().cstr(); } + const char* getBoneControl() const { return bone_control.ref().cstr(); } + const char* getAISchedule() const { return ai_schedule.ref().cstr(); } + const char* getLifeCondition() const { return life_condition.ref().cstr(); } + const char* getUMii() const { return umii.ref().cstr(); } + const char* getAnimationInfo() const { return animation_info.ref().cstr(); } agl::utl::Parameter profile; agl::utl::Parameter actor_capture; @@ -84,6 +111,7 @@ public: bool needsParse() const override { return true; } const Users& getUsers() const { return mUsers; } + const char* getUserName(User user) const { return getUsers().getUserName(user); } const sead::SafeString& getActorNameJpn() const { return mActorNameJpn.ref(); } const sead::SafeString& getPriority() const { return mPriority.ref(); } f32 getActorScale() const { return mActorScale.ref(); } diff --git a/src/KingSystem/Resource/resResourceAttClientList.h b/src/KingSystem/Resource/resResourceAttClientList.h index adb38da8..9cb018f4 100644 --- a/src/KingSystem/Resource/resResourceAttClientList.h +++ b/src/KingSystem/Resource/resResourceAttClientList.h @@ -10,6 +10,8 @@ namespace ksys::res { +class AttClient; + class AttClientList : public ParamIO, public Resource { SEAD_RTTI_OVERRIDE(AttClientList, Resource) public: @@ -26,7 +28,7 @@ public: agl::utl::Parameter file_name; agl::utl::Parameter is_valid; agl::utl::ParameterObj obj; - void* _a0; + AttClient* client; }; KSYS_CHECK_SIZE_NX150(Client, 0xa8); @@ -36,6 +38,8 @@ public: bool isForceEdit() const { return mForceEdit.ref(); } const sead::Buffer& getClients() const { return mClients; } + void addClient_(s32 index, AttClient* client) { mClients[index].client = client; } + private: agl::utl::ParameterList mAttClientsList; agl::utl::ParameterObj mAttPosObj; diff --git a/src/KingSystem/Resource/resResourceMgrTask.cpp b/src/KingSystem/Resource/resResourceMgrTask.cpp index 5b5d39ed..b883c84a 100644 --- a/src/KingSystem/Resource/resResourceMgrTask.cpp +++ b/src/KingSystem/Resource/resResourceMgrTask.cpp @@ -373,7 +373,7 @@ bool ResourceMgrTask::canUseSdCard() const { return false; } -bool ResourceMgrTask::returnFalse() const { +bool ResourceMgrTask::isHostPath(const sead::SafeString&) const { return false; } @@ -634,6 +634,12 @@ bool ResourceMgrTask::isCompactionStopped() const { return mCompactionCounter == 0; } +bool ResourceMgrTask::initTempResourceLoader(TempResourceLoader* loader, + TempResourceLoader::InitArg& arg) { + arg.work = mTexHandleMgr->getArchiveWork(); + return loader->init(arg); +} + bool ResourceMgrTask::returnTrue1() { return true; } diff --git a/src/KingSystem/Resource/resResourceMgrTask.h b/src/KingSystem/Resource/resResourceMgrTask.h index df1117e9..d8c1d042 100644 --- a/src/KingSystem/Resource/resResourceMgrTask.h +++ b/src/KingSystem/Resource/resResourceMgrTask.h @@ -21,6 +21,7 @@ #include "KingSystem/Resource/resControlTask.h" #include "KingSystem/Resource/resCounter.h" #include "KingSystem/Resource/resInfoContainer.h" +#include "KingSystem/Resource/resTempResourceLoader.h" #include "KingSystem/Resource/resUnit.h" #include "KingSystem/Resource/resUnitPool.h" #include "KingSystem/System/OverlayArena.h" @@ -162,7 +163,7 @@ public: sead::DirectResource* load(const DirectLoadArg& arg); bool canUseSdCard() const; - bool returnFalse() const; + bool isHostPath(const sead::SafeString& path) const; bool dropSFromExtensionIfNeeded(const sead::SafeString& path, sead::BufferedSafeString& new_path, s32 dot_idx, @@ -213,6 +214,8 @@ public: void setCompactionStopped(bool stopped); bool isCompactionStopped() const; + bool initTempResourceLoader(TempResourceLoader* loader, TempResourceLoader::InitArg& arg); + bool returnTrue1(); void clearCacheWithFileExtension(const sead::SafeString& extension); diff --git a/src/KingSystem/Resource/resResourceRagdollConfigList.h b/src/KingSystem/Resource/resResourceRagdollConfigList.h index 8f203be8..c7787cb2 100644 --- a/src/KingSystem/Resource/resResourceRagdollConfigList.h +++ b/src/KingSystem/Resource/resResourceRagdollConfigList.h @@ -10,13 +10,15 @@ namespace ksys::res { +class RagdollConfig; + class RagdollConfigList : public ParamIO, public Resource { SEAD_RTTI_OVERRIDE(RagdollConfigList, Resource) public: struct ImpulseParam { agl::utl::Parameter file_name; agl::utl::ParameterObj obj; - void* _58; + RagdollConfig* config; }; KSYS_CHECK_SIZE_NX150(ImpulseParam, 0x60); @@ -39,7 +41,11 @@ public: const sead::Buffer& getImpulseParams() const { return mImpulseParams; } f32 getUpperLimitHeight() const { return mUpperLimitHeight.ref(); } f32 getLowerLimitHeight() const { return mLowerLimitHeight.ref(); } - const sead::Buffer& getMBodyParams() const { return mBodyParams; } + const sead::Buffer& getBodyParams() const { return mBodyParams; } + + void addImpulseParamConfig_(s32 index, RagdollConfig* config) { + mImpulseParams[index].config = config; + } private: agl::utl::ParameterList mImpulseParamList; diff --git a/src/KingSystem/Resource/resSystem.cpp b/src/KingSystem/Resource/resSystem.cpp index 71713a1c..f4238ad1 100644 --- a/src/KingSystem/Resource/resSystem.cpp +++ b/src/KingSystem/Resource/resSystem.cpp @@ -1,4 +1,5 @@ #include "KingSystem/Resource/resSystem.h" +#include "KingSystem/Resource/resResourceMgrTask.h" namespace ksys::res { @@ -6,6 +7,10 @@ bool stubbedLogFunction() { return true; } +bool isHostPath(const sead::SafeString& path) { + return ResourceMgrTask::instance()->isHostPath(path); +} + bool returnFalse() { return false; } @@ -14,6 +19,10 @@ bool returnFalse2(const sead::SafeString&) { return false; } +bool returnFalse3(const sead::SafeString&) { + return false; +} + s32 getDefaultAlignment() { return 8; } diff --git a/src/KingSystem/Resource/resSystem.h b/src/KingSystem/Resource/resSystem.h index b617d323..4d44d20f 100644 --- a/src/KingSystem/Resource/resSystem.h +++ b/src/KingSystem/Resource/resSystem.h @@ -9,6 +9,8 @@ class EntryFactoryBase; void registerEntryFactory(EntryFactoryBase* factory, const sead::SafeString& name); void unregisterEntryFactory(EntryFactoryBase* factory); +bool isHostPath(const sead::SafeString& path); + // In release builds, the only thing this function does is return 1. // TODO: figure out what this is used for. Stubbed log function? bool stubbedLogFunction(); @@ -21,6 +23,8 @@ bool returnFalse(); // TODO: figure out what this is used for. Stubbed log function? bool returnFalse2(const sead::SafeString&); +bool returnFalse3(const sead::SafeString& path); + s32 getDefaultAlignment(); } // namespace ksys::res diff --git a/src/KingSystem/Resource/resTextureHandleMgr.h b/src/KingSystem/Resource/resTextureHandleMgr.h index 7e90d537..b9fd7701 100644 --- a/src/KingSystem/Resource/resTextureHandleMgr.h +++ b/src/KingSystem/Resource/resTextureHandleMgr.h @@ -2,11 +2,14 @@ namespace ksys::res { +class ArchiveWork; + // TODO: very incomplete class TextureHandleMgr { public: virtual ~TextureHandleMgr(); + ArchiveWork* getArchiveWork() const; void clearAllCache(); }; diff --git a/src/KingSystem/Utils/ParamIO.h b/src/KingSystem/Utils/ParamIO.h index 58f14e55..820cdc76 100644 --- a/src/KingSystem/Utils/ParamIO.h +++ b/src/KingSystem/Utils/ParamIO.h @@ -16,12 +16,13 @@ public: bool applyResourceUpdate(const char* data, const char* data1); u32 getIdx() const { return mIdx; } - const sead::SafeString& getId() const { return mId; } + sead::BufferedSafeString& getPath() { return mPath; } + const sead::BufferedSafeString& getPath() const { return mPath; } void setIndex(u32 idx) { mIdx = idx; } protected: u32 mIdx = 0x1c; - sead::FixedSafeString<128> mId; + sead::FixedSafeString<128> mPath; }; KSYS_CHECK_SIZE_NX150(ParamIO, 0x278);