diff --git a/data/data_symbols.csv b/data/data_symbols.csv index 9dbc0bee..94e6e41d 100644 --- a/data/data_symbols.csv +++ b/data/data_symbols.csv @@ -1,5 +1,19 @@ 0x00000071023556B0,_ZTVN4sead14SafeStringBaseIcEE +0x0000007102356AF0,_ZTVN4sead22BufferedSafeStringBaseIcEE 0x000000710246F9E0,_ZN4ksys3gdt6detail13sCommonFlags0E 0x00000071024709E0,_ZN4ksys3gdt6detail13sCommonFlags1E 0x00000071024719E0,_ZN4ksys3gdt6detail13sCommonFlags2E 0x00000071024729E0,_ZN4ksys3gdt6detail13sCommonFlags3E +0x00000071024C0F18,_ZTVN3agl3utl13ParameterBaseE +0x00000071024C1060,_ZTVN3agl3utl9ParameterIbEE +0x00000071024C1100,_ZTVN3agl3utl9ParameterIfEE +0x00000071024C11A0,_ZTVN3agl3utl9ParameterIiEE +0x00000071024C1240,_ZTVN3agl3utl9ParameterIjEE +0x00000071024C12E0,_ZTVN3agl3utl9ParameterIN4sead7Vector2IfEEEE +0x00000071024C1380,_ZTVN3agl3utl9ParameterIN4sead7Vector3IfEEEE +0x00000071024C1420,_ZTVN3agl3utl9ParameterIN4sead7Vector4IfEEEE +0x00000071024C14E0,_ZTVN3agl3utl9ParameterIN4sead7Color4fEEE +0x00000071024C1560,_ZTVN3agl3utl9ParameterIN4sead4QuatIfEEEE +0x00000071024C1600,_ZTVN3agl3utl9ParameterIN4sead15FixedSafeStringILi64EEEEE +0x00000071024C16A0,_ZTVN3agl3utl9ParameterIN4sead15FixedSafeStringILi256EEEEE +0x00000071024C1740,_ZTVN3agl3utl9ParameterIN4sead14SafeStringBaseIcEEEE diff --git a/data/uking_functions.csv b/data/uking_functions.csv index a08b08cb..a12cee28 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -5049,7 +5049,7 @@ 0x00000071000e6500,AI_Action_DamageTurnByWeakPoint::loadParams,156, 0x00000071000e659c,AI_Action_DamageTurnByWeakPoint::rtti1,288, 0x00000071000e66bc,AI_Action_DamageTurnByWeakPoint::rtti2,92, -0x00000071000e6718,_ZN4sead21FormatFixedSafeStringILi256EEC2EPKcz,224, +0x00000071000e6718,_ZN4sead21FormatFixedSafeStringILi256EEC2EPKcz,224,_ZN4sead21FormatFixedSafeStringILi256EEC2EPKcz 0x00000071000e67f8,j__ZdlPv_42,4, 0x00000071000e67fc,AI_Action_DefeatedHugeEnemyCount::ctor,56, 0x00000071000e6834,AI_Action_DefeatedHugeEnemyCount::dtor,20, @@ -61780,51 +61780,51 @@ 0x0000007100aab7f8,isCurrentMapTypeMainFieldOrGameTestField,264, 0x0000007100aab900,sub_7100AAB900,84, 0x0000007100aab954,sub_7100AAB954,32, -0x0000007100aab974,_ZN2al9ByamlIterC2Ev,8, -0x0000007100aab97c,_ZN2al9ByamlIterC2EPKh,76, -0x0000007100aab9c8,_ZN2al9ByamlIterC1EPKhS2_,20, -0x0000007100aab9dc,_ZN2al9ByamlIteraSERKS0_,28, -0x0000007100aab9f8,_ZN2al9ByamlIterC1EPKhS2__0,8, -0x0000007100aaba00,_ZNK2al9ByamlIter7isValidEv,16, -0x0000007100aaba10,_ZNK2al9ByamlIter11isTypeArrayEv,32, -0x0000007100aaba30,_ZNK2al9ByamlIter10isExistKeyEPKc,140, -0x0000007100aababc,_ZNK2al9ByamlIter11getKeyIndexEPKc,60, -0x0000007100aabaf8,_ZNK2al9ByamlIter7getSizeEv,56, -0x0000007100aabb30,_ZNK2al9ByamlIter19getByamlDataByIndexEPNS_9ByamlDataEi,212, -0x0000007100aabc04,_ZNK2al9ByamlIter12getIterByKeyEPKc,136, -0x0000007100aabc8c,_ZNK2al9ByamlIter17getByamlDataByKeyEPNS_9ByamlDataEPKc,252, -0x0000007100aabd88,_ZNK2al9ByamlIter10getKeyNameEPPKci,152, -0x0000007100aabe20,_ZNK2al9ByamlIter17tryGetIterByIndexEPS0_i,88, -0x0000007100aabe78,_ZNK2al9ByamlIter27tryGetIterAndKeyNameByIndexEPS0_PPKci,324, -0x0000007100aabfbc,_ZNK2al9ByamlIter15tryGetIterByKeyEPS0_PKc,164, -0x0000007100aac060,_ZNK2al9ByamlIter17tryGetStringByKeyEPPKcS2_,140, -0x0000007100aac0ec,_ZNK2al9ByamlIter16tryConvertStringEPPKcPKNS_9ByamlDataE,100, -0x0000007100aac150,_ZNK2al9ByamlIter14tryGetIntByKeyEPiPKc,104, -0x0000007100aac1b8,_ZNK2al9ByamlIter15tryGetUIntByKeyEPjPKc,136, -0x0000007100aac240,_ZNK2al9ByamlIter14tryConvertUIntEPjPKNS_9ByamlDataE,72, -0x0000007100aac288,_ZNK2al9ByamlIter16tryGetFloatByKeyEPfPKc,104, -0x0000007100aac2f0,_ZNK2al9ByamlIter15tryGetBoolByKeyEPbPKc,112, -0x0000007100aac360,_ZNK2al9ByamlIter19tryGetStringByIndexEPPKci,208, -0x0000007100aac430,_ZNK2al9ByamlIter16tryGetIntByIndexEPii,180, -0x0000007100aac4e4,_ZNK2al9ByamlIter17tryGetUIntByIndexEPji,212, -0x0000007100aac5b8,_ZNK2al9ByamlIter18tryGetFloatByIndexEPfi,180, -0x0000007100aac66c,_ZNK2al9ByamlIter17tryGetBoolByIndexEPbi,188, -0x0000007100aac728,_ZNK2al9ByamlIter11isEqualDataERKS0_,60, -0x0000007100aac764,_ZN2al9ByamlDataC2Ev,12, -0x0000007100aac770,alByamlLocalUtil::getHashKeyTableOrStringTable,8, -0x0000007100aac778,_ZNK2al20ByamlStringTableIter9getStringEi,20, -0x0000007100aac78c,_ZNK2al20ByamlStringTableIter15findStringIndexEPKc,152, -0x0000007100aac824,_ZN2al14ByamlArrayIterC2EPKhb,8, -0x0000007100aac82c,_ZNK2al14ByamlArrayIter12getDataTableEv,32, -0x0000007100aac84c,_ZNK2al14ByamlArrayIter14getDataByIndexEPNS_9ByamlDataEi,96, +0x0000007100aab974,_ZN2al9ByamlIterC2Ev,8,_ZN2al9ByamlIterC1Ev +0x0000007100aab97c,_ZN2al9ByamlIterC2EPKh,76,_ZN2al9ByamlIterC1EPKh +0x0000007100aab9c8,_ZN2al9ByamlIterC1EPKhS2_,20,_ZN2al9ByamlIterC1ERKS0_ +0x0000007100aab9dc,_ZN2al9ByamlIteraSERKS0_,28,_ZN2al9ByamlIteraSERKS0_ +0x0000007100aab9f8,_ZN2al9ByamlIterC1EPKhS2__0,8,_ZN2al9ByamlIterC1EPKhS2_ +0x0000007100aaba00,_ZNK2al9ByamlIter7isValidEv,16,_ZNK2al9ByamlIter7isValidEv +0x0000007100aaba10,_ZNK2al9ByamlIter11isTypeArrayEv,32,_ZNK2al9ByamlIter11isTypeArrayEv +0x0000007100aaba30,_ZNK2al9ByamlIter10isExistKeyEPKc,140,_ZNK2al9ByamlIter10isExistKeyEPKc +0x0000007100aababc,_ZNK2al9ByamlIter11getKeyIndexEPKc,60,_ZNK2al9ByamlIter11getKeyIndexEPKc +0x0000007100aabaf8,_ZNK2al9ByamlIter7getSizeEv,56,_ZNK2al9ByamlIter7getSizeEv +0x0000007100aabb30,_ZNK2al9ByamlIter19getByamlDataByIndexEPNS_9ByamlDataEi,212,_ZNK2al9ByamlIter14getIterByIndexEi +0x0000007100aabc04,_ZNK2al9ByamlIter12getIterByKeyEPKc,136,_ZNK2al9ByamlIter12getIterByKeyEPKc +0x0000007100aabc8c,_ZNK2al9ByamlIter17getByamlDataByKeyEPNS_9ByamlDataEPKc,252,_ZNK2al9ByamlIter17getByamlDataByKeyEPNS_9ByamlDataEPKc +0x0000007100aabd88,_ZNK2al9ByamlIter10getKeyNameEPPKci,152,_ZNK2al9ByamlIter10getKeyNameEPPKci +0x0000007100aabe20,_ZNK2al9ByamlIter17tryGetIterByIndexEPS0_i,88,_ZNK2al9ByamlIter17tryGetIterByIndexEPS0_i +0x0000007100aabe78,_ZNK2al9ByamlIter27tryGetIterAndKeyNameByIndexEPS0_PPKci,324,_ZNK2al9ByamlIter27tryGetIterAndKeyNameByIndexEPS0_PPKci! +0x0000007100aabfbc,_ZNK2al9ByamlIter15tryGetIterByKeyEPS0_PKc,164,_ZNK2al9ByamlIter15tryGetIterByKeyEPS0_PKc +0x0000007100aac060,_ZNK2al9ByamlIter17tryGetStringByKeyEPPKcS2_,140,_ZNK2al9ByamlIter17tryGetStringByKeyEPPKcS2_ +0x0000007100aac0ec,_ZNK2al9ByamlIter16tryConvertStringEPPKcPKNS_9ByamlDataE,100,_ZNK2al9ByamlIter16tryConvertStringEPPKcPKNS_9ByamlDataE +0x0000007100aac150,_ZNK2al9ByamlIter14tryGetIntByKeyEPiPKc,104,_ZNK2al9ByamlIter14tryGetIntByKeyEPiPKc +0x0000007100aac1b8,_ZNK2al9ByamlIter15tryGetUIntByKeyEPjPKc,136,_ZNK2al9ByamlIter15tryGetUIntByKeyEPjPKc! +0x0000007100aac240,_ZNK2al9ByamlIter14tryConvertUIntEPjPKNS_9ByamlDataE,72,_ZNK2al9ByamlIter14tryConvertUIntEPjPKNS_9ByamlDataE +0x0000007100aac288,_ZNK2al9ByamlIter16tryGetFloatByKeyEPfPKc,104,_ZNK2al9ByamlIter16tryGetFloatByKeyEPfPKc +0x0000007100aac2f0,_ZNK2al9ByamlIter15tryGetBoolByKeyEPbPKc,112,_ZNK2al9ByamlIter15tryGetBoolByKeyEPbPKc +0x0000007100aac360,_ZNK2al9ByamlIter19tryGetStringByIndexEPPKci,208,_ZNK2al9ByamlIter19tryGetStringByIndexEPPKci +0x0000007100aac430,_ZNK2al9ByamlIter16tryGetIntByIndexEPii,180,_ZNK2al9ByamlIter16tryGetIntByIndexEPii +0x0000007100aac4e4,_ZNK2al9ByamlIter17tryGetUIntByIndexEPji,212,_ZNK2al9ByamlIter17tryGetUIntByIndexEPji! +0x0000007100aac5b8,_ZNK2al9ByamlIter18tryGetFloatByIndexEPfi,180,_ZNK2al9ByamlIter18tryGetFloatByIndexEPfi +0x0000007100aac66c,_ZNK2al9ByamlIter17tryGetBoolByIndexEPbi,188,_ZNK2al9ByamlIter17tryGetBoolByIndexEPbi +0x0000007100aac728,_ZNK2al9ByamlIter11isEqualDataERKS0_,60,_ZNK2al9ByamlIter11isEqualDataERKS0_ +0x0000007100aac764,_ZN2al9ByamlDataC2Ev,12,_ZN2al9ByamlDataC1Ev +0x0000007100aac770,alByamlLocalUtil::getHashKeyTableOrStringTable,8,_ZN2al20ByamlStringTableIterC1EPKh +0x0000007100aac778,_ZNK2al20ByamlStringTableIter9getStringEi,20,_ZNK2al20ByamlStringTableIter9getStringEi +0x0000007100aac78c,_ZNK2al20ByamlStringTableIter15findStringIndexEPKc,152,_ZNK2al20ByamlStringTableIter15findStringIndexEPKc +0x0000007100aac824,_ZN2al14ByamlArrayIterC2EPKhb,8,_ZN2al14ByamlArrayIterC1EPKh +0x0000007100aac82c,_ZNK2al14ByamlArrayIter12getDataTableEv,32,_ZNK2al14ByamlArrayIter12getDataTableEv +0x0000007100aac84c,_ZNK2al14ByamlArrayIter14getDataByIndexEPNS_9ByamlDataEi,96,_ZN2al14ByamlArrayIter14getDataByIndexEPNS_9ByamlDataEi 0x0000007100aac8ac,_ZN16alByamlLocalUtil11verifiByamlEPKh,640, -0x0000007100aacb2c,_ZN2al13ByamlHashIterC2EPKhb,8, -0x0000007100aacb34,_ZNK2al13ByamlHashIter7getSizeEv,28, -0x0000007100aacb50,_ZNK2al13ByamlHashIter12getPairTableEv,20, -0x0000007100aacb64,_ZNK2al13ByamlHashIter14getDataByIndexEPNS_9ByamlDataEi,88, -0x0000007100aacbbc,_ZNK2al13ByamlHashIter12getDataByKeyEPNS_9ByamlDataEi,168, -0x0000007100aacc64,_ZNK2al13ByamlHashIter8findPairEi,92, -0x0000007100aaccc0,_ZNK2al13ByamlHashIter14getPairByIndexEi,80, +0x0000007100aacb2c,_ZN2al13ByamlHashIterC2EPKhb,8,_ZN2al13ByamlHashIterC1EPKh +0x0000007100aacb34,_ZNK2al13ByamlHashIter7getSizeEv,28,_ZNK2al13ByamlHashIter7getSizeEv +0x0000007100aacb50,_ZNK2al13ByamlHashIter12getPairTableEv,20,_ZNK2al13ByamlHashIter12getPairTableEv +0x0000007100aacb64,_ZNK2al13ByamlHashIter14getDataByIndexEPNS_9ByamlDataEi,88,_ZNK2al13ByamlHashIter14getDataByIndexEPNS_9ByamlDataEi +0x0000007100aacbbc,_ZNK2al13ByamlHashIter12getDataByKeyEPNS_9ByamlDataEi,168,_ZNK2al13ByamlHashIter12getDataByKeyEPNS_9ByamlDataEi +0x0000007100aacc64,_ZNK2al13ByamlHashIter8findPairEi,92,_ZNK2al13ByamlHashIter8findPairEi +0x0000007100aaccc0,_ZNK2al13ByamlHashIter14getPairByIndexEi,80,_ZNK2al13ByamlHashIter14getPairByIndexEi 0x0000007100aacd10,_ZN2al14tryGetByamlS32EPiRKNS_9ByamlIterEPKc,16,_ZN2al14tryGetByamlS32EPiRKNS_9ByamlIterEPKc 0x0000007100aacd20,_ZN2al14tryGetByamlU32EPjRKNS_9ByamlIterEPKc,64,_ZN2al14tryGetByamlU32EPjRKNS_9ByamlIterEPKc 0x0000007100aacd60,_ZN2al14tryGetByamlF32EPfRKNS_9ByamlIterEPKc,72,_ZN2al14tryGetByamlF32EPfRKNS_9ByamlIterEPKc @@ -73354,43 +73354,43 @@ 0x0000007100d2e088,act::getPictureBookSpecialDrop,20, 0x0000007100d2e09c,sub_7100D2E09C,100, 0x0000007100d2e100,sub_7100D2E100,108, -0x0000007100d2e16c,ActorInfoData::createInstance,184, -0x0000007100d2e224,sub_7100D2E224,96, -0x0000007100d2e284,sub_7100D2E284,84, -0x0000007100d2e2d8,ActorInfoData::init,628, +0x0000007100d2e16c,ActorInfoData::createInstance,184,_ZN4ksys3act8InfoData14createInstanceEPN4sead4HeapE +0x0000007100d2e224,sub_7100D2E224,96,_ZN4ksys3act8InfoDataD1Ev +0x0000007100d2e284,sub_7100D2E284,84,_ZN4ksys3act8InfoDataD0Ev +0x0000007100d2e2d8,ActorInfoData::init,628,_ZN4ksys3act8InfoData4initEPhPN4sead4HeapES5_ 0x0000007100d2e54c,ActorInfoData::getActorScaleColorModelBfres,820, -0x0000007100d2e880,ActorInfoData::getActorDataIter,208, +0x0000007100d2e880,ActorInfoData::getActorDataIter,208,_ZNK4ksys3act8InfoData12getActorIterEPN2al9ByamlIterEPKcb 0x0000007100d2e950,ActorInfoData::isNotMergedGrudgeOrArmor50OrWeaponSwordDemoCheck,348, -0x0000007100d2eaac,ActorInfoData::x,1484, -0x0000007100d2f078,act::getActorInfoInt,56, -0x0000007100d2f0b0,bymlGetString,84, -0x0000007100d2f104,sub_7100D2F104,608, -0x0000007100d2f364,sub_7100D2F364,348, +0x0000007100d2eaac,ActorInfoData::x,1484,_ZNK4ksys3act8InfoData13getRecipeInfoEPKcRNS1_10RecipeInfoE +0x0000007100d2f078,act::getActorInfoInt,56,_ZN4ksys3act8InfoData11getIntByKeyERKN2al9ByamlIterEPKci +0x0000007100d2f0b0,bymlGetString,84,_ZN4ksys3act8InfoData14getStringByKeyERKN2al9ByamlIterEPKcRKN4sead14SafeStringBaseIcEE +0x0000007100d2f104,sub_7100D2F104,608,_ZNK4ksys3act8InfoData11getLocatorsEPKcRNS1_8LocatorsE +0x0000007100d2f364,sub_7100D2F364,348,_ZNK4ksys3act8InfoData12getHomeAreasEPKcRNS1_9HomeAreasE 0x0000007100d2f4c0,ActorInfoData::x_1,560, 0x0000007100d2f6f0,ActorInfoData::hasTagByName,232, 0x0000007100d2f7d8,ActorInfoData::hasTagWithIter,296, 0x0000007100d2f900,ActorInfoData::hasTag,224, -0x0000007100d2f9e0,ActorInfoData::getActorSameGroupActorName,256, +0x0000007100d2f9e0,ActorInfoData::getActorSameGroupActorName,256,_ZNK4ksys3act8InfoData21getSameGroupActorNameEPKc 0x0000007100d2fae0,ActorInfoData::__auto1,136, 0x0000007100d2fb68,ActorInfoData::getTerrainTextures,452, 0x0000007100d2fd2c,ActorInfoData::getDrops,228, 0x0000007100d2fe10,sub_7100D2FE10,72, -0x0000007100d2fe58,ActorInfoData::getActorString,288, +0x0000007100d2fe58,ActorInfoData::getActorString,288,_ZNK4ksys3act8InfoData9getStringEPKcS3_RKN4sead14SafeStringBaseIcEEb 0x0000007100d2ff78,sub_7100D2FF78,8, -0x0000007100d2ff80,ActorInfoData::getSlinkUser,236, -0x0000007100d3006c,ActorInfoData::getElinkAndSlink,328, -0x0000007100d301b4,sub_7100D301B4,72, -0x0000007100d301fc,ActorInfoData::getActorProfile,276, +0x0000007100d2ff80,ActorInfoData::getSlinkUser,236,_ZNK4ksys3act8InfoData12getSLinkUserEPKc +0x0000007100d3006c,ActorInfoData::getElinkAndSlink,328,_ZNK4ksys3act8InfoData21getSLinkAndELinkUsersEPKcPS3_S4_ +0x0000007100d301b4,sub_7100D301B4,72,_ZNK4ksys3act8InfoData12getXLinkUserEPKc +0x0000007100d301fc,ActorInfoData::getActorProfile,276,_ZNK4ksys3act8InfoData15getActorProfileEPPKcS3_ 0x0000007100d30310,ActorInfoData::getProfile,132, -0x0000007100d30394,ActorInfoData::getActorInt,252, -0x0000007100d30490,ActorInfoData::getActorFloat,252, -0x0000007100d3058c,ActorInfoData::getBool,260, -0x0000007100d30690,act::getBymlPropertyFloat,56, -0x0000007100d306c8,act::getBymlPropertyBool,68, +0x0000007100d30394,ActorInfoData::getActorInt,252,_ZNK4ksys3act8InfoData6getIntEPKcS3_ib +0x0000007100d30490,ActorInfoData::getActorFloat,252,_ZNK4ksys3act8InfoData8getFloatEPKcS3_fb +0x0000007100d3058c,ActorInfoData::getBool,260,_ZNK4ksys3act8InfoData7getBoolEPKcS3_bb +0x0000007100d30690,act::getBymlPropertyFloat,56,_ZN4ksys3act8InfoData13getFloatByKeyERKN2al9ByamlIterEPKcf +0x0000007100d306c8,act::getBymlPropertyBool,68,_ZN4ksys3act8InfoData12getBoolByKeyERKN2al9ByamlIterEPKcb 0x0000007100d3070c,ActorInfoData::getActorIterByHash,168, 0x0000007100d307b4,sub_7100D307B4,104, 0x0000007100d3081c,sub_7100D3081C,252, -0x0000007100d30918,ActorInfoData::getActorScale,20, +0x0000007100d30918,ActorInfoData::getActorScale,20,_ZNK4ksys3act8InfoData8getScaleEPKc 0x0000007100d3092c,ActorInfoData::getLookAtOffsetY,272, 0x0000007100d30a3c,ActorInfoData::getCursorOffsetY,20, 0x0000007100d30a50,ActorInfoData::getTraverseDist,20, @@ -84589,20 +84589,20 @@ 0x0000007100fdf538,sub_7100FDF538,52, 0x0000007100fdf56c,sub_7100FDF56C,92, 0x0000007100fdf5c8,sub_7100FDF5C8,44, -0x0000007100fdf5f4,TempResourceLoader::ctor,148, -0x0000007100fdf688,TempResourceLoader::dtor,44, -0x0000007100fdf6b4,TempResourceLoader::unload,212, -0x0000007100fdf788,TempResourceLoader::setStruct10,16, -0x0000007100fdf798,TempResourceLoader::isStatus1,12, -0x0000007100fdf7a4,TempResourceLoader::hasResourceAndIsParseOk,24, -0x0000007100fdf7bc,TempResourceLoader::callRes2I,24, -0x0000007100fdf7d4,TempResourceLoader::submitLoadReq,412, -0x0000007100fdf970,TempResourceLoader::load,504, -0x0000007100fdfb68,TempResourceLoader::loadSync,844, -0x0000007100fdfeb4,TempResourceLoader::getResource,64, -0x0000007100fdfef4,TempResourceLoader::getResError,8, -0x0000007100fdfefc,TempResourceLoader::getFileDeviceIfHasResource,56, -0x0000007100fdff34,TempResourceLoader::getHeapSize,16, +0x0000007100fdf5f4,TempResourceLoader::ctor,148,_ZN4ksys3res18TempResourceLoaderC1Ev +0x0000007100fdf688,TempResourceLoader::dtor,44,_ZN4ksys3res18TempResourceLoaderD1Ev +0x0000007100fdf6b4,TempResourceLoader::unload,212,_ZN4ksys3res18TempResourceLoader6unloadEv +0x0000007100fdf788,TempResourceLoader::setStruct10,16,_ZN4ksys3res18TempResourceLoader4initERKNS1_7InitArgE +0x0000007100fdf798,TempResourceLoader::isStatus1,12,_ZNK4ksys3res18TempResourceLoader9isLoadingEv +0x0000007100fdf7a4,TempResourceLoader::hasResourceAndIsParseOk,24,_ZNK4ksys3res18TempResourceLoader9isSuccessEv +0x0000007100fdf7bc,TempResourceLoader::callRes2I,24,_ZNK4ksys3res18TempResourceLoader15checkLoadStatusEv +0x0000007100fdf7d4,TempResourceLoader::submitLoadReq,412,_ZN4ksys3res18TempResourceLoader11requestLoadERNS1_7LoadArgE +0x0000007100fdf970,TempResourceLoader::load,504,_ZN4ksys3res18TempResourceLoader25getResourceForLoadRequestEPNS0_7ContextE +0x0000007100fdfb68,TempResourceLoader::loadSync,844,_ZN4ksys3res18TempResourceLoader4loadERNS1_7LoadArgE +0x0000007100fdfeb4,TempResourceLoader::getResource,64,_ZNK4ksys3res18TempResourceLoader11getResourceEv +0x0000007100fdfef4,TempResourceLoader::getResError,8,_ZNK4ksys3res18TempResourceLoader15getHandleStatusEv +0x0000007100fdfefc,TempResourceLoader::getFileDeviceIfHasResource,56,_ZNK4ksys3res18TempResourceLoader19getHandleFileDeviceEv +0x0000007100fdff34,TempResourceLoader::getHeapSize,16,_ZNK4ksys3res18TempResourceLoader15getWorkHeapSizeEv 0x0000007100fdff44,Struct10::ctor,8,_ZN4ksys3res11ArchiveWorkC1Ev 0x0000007100fdff4c,sub_7100FDFF4C,88,_ZN4ksys3res11ArchiveWorkD1Ev 0x0000007100fdffa4,Struct10::initEventAndOverlayArenaS1,260,_ZN4ksys3res11ArchiveWork4initERKNS1_7InitArgE @@ -87926,7 +87926,7 @@ 0x0000007101098234,j__ZdlPv_1174,4,_ZN4sead19FixedSafeStringBaseIcLi75EED0Ev 0x0000007101098238,_ZN4sead15FixedSafeStringILi165EEaSERKNS_14SafeStringBaseIcEE,240,_ZN4sead19FixedSafeStringBaseIcLi75EEaSERKNS_14SafeStringBaseIcEE 0x0000007101098328,getDamageReactionTypes,428,_ZN4ksys3res11DamageParam10DamageSize5text_Ei? -0x00000071010984d4,sub_71010984D4,372, +0x00000071010984d4,sub_71010984D4,372,_ZN4ksys3res11DamageParam33checkDerivedRuntimeTypeInfoStaticEPKN4sead15RuntimeTypeInfo9InterfaceE 0x0000007101098648,nullsub_4469,4,_ZN4ksys3res4Drop9doCreate_EPhjPN4sead4HeapE 0x000000710109864c,nullsub_4470,4,_ZThn632_N4ksys3res4Drop9doCreate_EPhjPN4sead4HeapE 0x0000007101098650,Bdrop::parse,1684,_ZN4ksys3res4Drop6parse_EPhmPN4sead4HeapE @@ -90950,94 +90950,94 @@ 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 -0x000000710116a560,sub_710116A560,224, -0x000000710116a640,sub_710116A640,548, -0x000000710116a864,ActorParam::__auto0,144, -0x000000710116a8f4,ActorParam::x,828, -0x000000710116ac30,sub_710116AC30,1852, -0x000000710116b36c,sub_710116B36C,548, -0x000000710116b590,sub_710116B590,548, -0x000000710116b7b4,sub_710116B7B4,548, -0x000000710116b9d8,sub_710116B9D8,548, -0x000000710116bbfc,sub_710116BBFC,548, -0x000000710116be20,sub_710116BE20,548, -0x000000710116c044,sub_710116C044,548, -0x000000710116c268,sub_710116C268,548, -0x000000710116c48c,sub_710116C48C,548, -0x000000710116c6b0,sub_710116C6B0,548, -0x000000710116c8d4,sub_710116C8D4,548, -0x000000710116caf8,sub_710116CAF8,548, -0x000000710116cd1c,sub_710116CD1C,548, -0x000000710116cf40,sub_710116CF40,548, -0x000000710116d164,sub_710116D164,548, -0x000000710116d388,sub_710116D388,548, -0x000000710116d5ac,sub_710116D5AC,548, -0x000000710116d7d0,sub_710116D7D0,548, -0x000000710116d9f4,sub_710116D9F4,548, -0x000000710116dc18,sub_710116DC18,548, -0x000000710116de3c,ActorParam::__auto1,608, -0x000000710116e09c,sub_710116E09C,828, -0x000000710116e3d8,sub_710116E3D8,828, -0x000000710116e714,sub_710116E714,828, -0x000000710116ea50,sub_710116EA50,828, -0x000000710116ed8c,sub_710116ED8C,828, -0x000000710116f0c8,sub_710116F0C8,828, -0x000000710116f404,sub_710116F404,828, -0x000000710116f740,sub_710116F740,828, -0x000000710116fa7c,sub_710116FA7C,828, -0x000000710116fdb8,sub_710116FDB8,828, -0x00000071011700f4,sub_71011700F4,828, -0x0000007101170430,sub_7101170430,828, -0x000000710117076c,sub_710117076C,828, -0x0000007101170aa8,sub_7101170AA8,828, -0x0000007101170de4,sub_7101170DE4,828, -0x0000007101171120,sub_7101171120,828, -0x000000710117145c,sub_710117145C,828, -0x0000007101171798,sub_7101171798,828, -0x0000007101171ad4,sub_7101171AD4,828, -0x0000007101171e10,sub_7101171E10,828, -0x000000710117214c,sub_710117214C,732, -0x0000007101172428,sub_7101172428,548, -0x000000710117264c,sub_710117264C,548, -0x0000007101172870,sub_7101172870,548, -0x0000007101172a94,ActorParam::__auto2,1664, -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, +0x000000710116a258,ActorParam::loadActorFiles,492,_ZN4ksys3act13ActorParamMgr9loadFilesEPNS0_10ActorParamEPN4sead4HeapEPNS_3res6HandleEPvj +0x000000710116a444,ActorParam::loadActorPack,284,_ZN4ksys3act13ActorParamMgr20requestLoadActorPackEPNS_3res6HandleERKN4sead14SafeStringBaseIcEEj +0x000000710116a560,sub_710116A560,224,_ZN4ksys3act13ActorParamMgr14loadParamAsyncEPKcPNS_3res6HandleEPbPvj +0x000000710116a640,sub_710116A640,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res9ActorLinkEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116a864,ActorParam::__auto0,144,_ZN4ksys3act13ActorParamMgr22finishLoadingActorLinkEPNS0_10ActorParamEPv +0x000000710116a8f4,ActorParam::x,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res9ActorLinkEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x000000710116ac30,sub_710116AC30,1852,_ZN4ksys3act13ActorParamMgr19loadParamAsyncStep2EPNS0_10ActorParamEPNS_3res6HandleEPvj +0x000000710116b36c,sub_710116B36C,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res9ModelListEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116b590,sub_710116B590,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res4UMiiEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116b7b4,sub_710116B7B4,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res6ASListEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116b9d8,sub_710116B9D8,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res13AttClientListEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116bbfc,sub_710116BBFC,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res17RagdollConfigListEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116be20,sub_710116BE20,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res9AIProgramEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116c044,sub_710116C044,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res10GParamListEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116c268,sub_710116C268,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res7PhysicsEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116c48c,sub_710116C48C,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res8ChemicalEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116c6b0,sub_710116C6B0,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res11DamageParamEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116c8d4,sub_710116C8D4,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res18RagdollBlendWeightEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116caf8,sub_710116CAF8,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res9AwarenessEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116cd1c,sub_710116CD1C,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res4DropEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116cf40,sub_710116CF40,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res4ShopEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116d164,sub_710116D164,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res6RecipeEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116d388,sub_710116D388,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res3LodEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116d5ac,sub_710116D5AC,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res10AIScheduleEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116d7d0,sub_710116D7D0,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res11BoneControlEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116d9f4,sub_710116D9F4,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res13LifeConditionEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116dc18,sub_710116DC18,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res8AnimInfoEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710116de3c,ActorParam::__auto1,608,_ZN4ksys3act13ActorParamMgr18finishLoadingStep2EPNS0_10ActorParamEPv +0x000000710116e09c,sub_710116E09C,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res9ModelListEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x000000710116e3d8,sub_710116E3D8,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res4UMiiEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x000000710116e714,sub_710116E714,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res6ASListEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x000000710116ea50,sub_710116EA50,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res13AttClientListEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x000000710116ed8c,sub_710116ED8C,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res17RagdollConfigListEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x000000710116f0c8,sub_710116F0C8,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res9AIProgramEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x000000710116f404,sub_710116F404,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res10GParamListEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x000000710116f740,sub_710116F740,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res7PhysicsEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x000000710116fa7c,sub_710116FA7C,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res8ChemicalEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x000000710116fdb8,sub_710116FDB8,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res11DamageParamEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x00000071011700f4,sub_71011700F4,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res18RagdollBlendWeightEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x0000007101170430,sub_7101170430,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res9AwarenessEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x000000710117076c,sub_710117076C,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res4DropEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x0000007101170aa8,sub_7101170AA8,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res4ShopEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x0000007101170de4,sub_7101170DE4,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res6RecipeEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x0000007101171120,sub_7101171120,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res3LodEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x000000710117145c,sub_710117145C,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res10AIScheduleEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x0000007101171798,sub_7101171798,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res11BoneControlEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x0000007101171ad4,sub_7101171AD4,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res13LifeConditionEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x0000007101171e10,sub_7101171E10,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res8AnimInfoEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x000000710117214c,sub_710117214C,732,_ZN4ksys3act13ActorParamMgr17loadExtraResAsyncEPNS0_10ActorParamEPNS_3res6HandleEPvj +0x0000007101172428,sub_7101172428,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res2ASEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x000000710117264c,sub_710117264C,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res9AttClientEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x0000007101172870,sub_7101172870,548,_ZN4ksys3act13ActorParamMgr13loadFileAsyncINS_3res13RagdollConfigEEEbPNS0_10ActorParamENS5_12ResourceTypeERKN4sead14SafeStringBaseIcEESC_SC_PNS3_6HandleEPvj +0x0000007101172a94,ActorParam::__auto2,1664,_ZN4ksys3act13ActorParamMgr21finishLoadingExtraResEPNS0_10ActorParamEPv +0x0000007101173114,sub_7101173114,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res2ASEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x0000007101173450,sub_7101173450,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res9AttClientEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +0x000000710117378c,sub_710117378C,828,_ZN4ksys3act13ActorParamMgr19handleAsyncFileLoadINS_3res13RagdollConfigEEEPT_PNS0_10ActorParamEPiNS7_12ResourceTypeEPv? +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 @@ -91108,7 +91108,7 @@ 0x00000071011810a4,EntryFactoryBatcllist::newResource_,456, 0x000000710118126c,sub_710118126C,8, 0x0000007101181274,sub_7101181274,8, -0x000000710118127c,sub_710118127C,500, +0x000000710118127c,sub_710118127C,500,_ZN4ksys3res9AttClientC1Ev 0x0000007101181470,sub_7101181470,68, 0x00000071011814b4,sub_71011814B4,76, 0x0000007101181500,sub_7101181500,132, @@ -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 @@ -91495,7 +91495,7 @@ 0x00000071011abc7c,sub_71011ABC7C,8, 0x00000071011abc84,sub_71011ABC84,372, 0x00000071011abdf8,nullsub_4622,4, -0x00000071011abdfc,sub_71011ABDFC,372, +0x00000071011abdfc,sub_71011ABDFC,372,_ZN4ksys3res6ASListC1Ev 0x00000071011abf70,sub_71011ABF70,668, 0x00000071011ac20c,sub_71011AC20C,8, 0x00000071011ac214,sub_71011AC214,8, @@ -91525,8 +91525,8 @@ 0x00000071011ae2bc,sub_71011AE2BC,8, 0x00000071011ae2c4,sub_71011AE2C4,372, 0x00000071011ae438,sub_71011AE438,212, -0x00000071011ae50c,Bmodellist::ctor,596, -0x00000071011ae760,BmodellistSub::ctor,404, +0x00000071011ae50c,Bmodellist::ctor,596,_ZN4ksys3res9ModelListC1Ev +0x00000071011ae760,BmodellistSub::ctor,404,_ZN4ksys3res9ModelList9AttentionC2Ev 0x00000071011ae8f4,sub_71011AE8F4,972, 0x00000071011aecc0,sub_71011AECC0,8, 0x00000071011aecc8,sub_71011AECC8,8, @@ -91544,7 +91544,7 @@ 0x00000071011b0c0c,Bmodellist::x,8, 0x00000071011b0c14,modellist::x,376, 0x00000071011b0d8c,sub_71011B0D8C,688, -0x00000071011b103c,sub_71011B103C,296, +0x00000071011b103c,sub_71011B103C,296,_ZN4ksys3actL21getLocatorTypeFromStrERKN4sead14SafeStringBaseIcEE 0x00000071011b1164,sub_71011B1164,544, 0x00000071011b1384,sub_71011B1384,32, 0x00000071011b13a4,sub_71011B13A4,32, @@ -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 @@ -96810,26 +96810,26 @@ 0x00000071012fce98,sub_71012FCE98,128,_ZThn664_N4ksys3res6RecipeD1Ev 0x00000071012fcf18,sub_71012FCF18,116,_ZThn664_N4ksys3res6RecipeD0Ev 0x00000071012fcf8c,sub_71012FCF8C,372,_ZN4ksys3res6Recipe33checkDerivedRuntimeTypeInfoStaticEPKN4sead15RuntimeTypeInfo9InterfaceE -0x00000071012fd100,sub_71012FD100,232, -0x00000071012fd1e8,sub_71012FD1E8,52, -0x00000071012fd21c,sub_71012FD21C,48, -0x00000071012fd24c,sub_71012FD24C,52, -0x00000071012fd280,sub_71012FD280,40, -0x00000071012fd2a8,sub_71012FD2A8,36, -0x00000071012fd2cc,sub_71012FD2CC,40, -0x00000071012fd2f4,sub_71012FD2F4,16, -0x00000071012fd304,sub_71012FD304,16, -0x00000071012fd314,nullsub_4847,4, -0x00000071012fd318,nullsub_4848,4, -0x00000071012fd31c,sub_71012FD31C,56, -0x00000071012fd354,sub_71012FD354,56, -0x00000071012fd38c,sub_71012FD38C,8, -0x00000071012fd394,sub_71012FD394,92, -0x00000071012fd3f0,sub_71012FD3F0,8, -0x00000071012fd3f8,sub_71012FD3F8,8, -0x00000071012fd400,sub_71012FD400,92, -0x00000071012fd45c,sub_71012FD45C,8, -0x00000071012fd464,sub_71012FD464,372, +0x00000071012fd100,sub_71012FD100,232,_ZN4ksys3res4UMiiC1Ev +0x00000071012fd1e8,sub_71012FD1E8,52,_ZN4ksys3res4UMiiD1Ev +0x00000071012fd21c,sub_71012FD21C,48,_ZThn632_N4ksys3res4UMiiD1Ev +0x00000071012fd24c,sub_71012FD24C,52,_ZThn664_N4ksys3res4UMiiD1Ev +0x00000071012fd280,sub_71012FD280,40,_ZN4ksys3res4UMiiD0Ev +0x00000071012fd2a8,sub_71012FD2A8,36,_ZThn632_N4ksys3res4UMiiD0Ev +0x00000071012fd2cc,sub_71012FD2CC,40,_ZThn664_N4ksys3res4UMiiD0Ev +0x00000071012fd2f4,sub_71012FD2F4,16,_ZN4ksys3res4UMii3m2_Ev +0x00000071012fd304,sub_71012FD304,16,_ZThn632_N4ksys3res4UMii3m2_Ev +0x00000071012fd314,nullsub_4847,4,_ZN4ksys3res4UMii9doCreate_EPhjPN4sead4HeapE +0x00000071012fd318,nullsub_4848,4,_ZThn632_N4ksys3res4UMii9doCreate_EPhjPN4sead4HeapE +0x00000071012fd31c,sub_71012FD31C,56,_ZN4ksys3res4UMii6parse_EPhmPN4sead4HeapE +0x00000071012fd354,sub_71012FD354,56,_ZThn632_N4ksys3res4UMii6parse_EPhmPN4sead4HeapE +0x00000071012fd38c,sub_71012FD38C,8,_ZNK4ksys3res4UMii27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE +0x00000071012fd394,sub_71012FD394,92,_ZNK4ksys3res4UMii18getRuntimeTypeInfoEv +0x00000071012fd3f0,sub_71012FD3F0,8,_ZNK4ksys3res4UMii10needsParseEv +0x00000071012fd3f8,sub_71012FD3F8,8,_ZThn632_NK4ksys3res4UMii27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE +0x00000071012fd400,sub_71012FD400,92,_ZThn632_NK4ksys3res4UMii18getRuntimeTypeInfoEv +0x00000071012fd45c,sub_71012FD45C,8,_ZThn632_NK4ksys3res4UMii10needsParseEv +0x00000071012fd464,sub_71012FD464,372,_ZN4ksys3res4UMii33checkDerivedRuntimeTypeInfoStaticEPKN4sead15RuntimeTypeInfo9InterfaceE 0x00000071012fd5d8,sub_71012FD5D8,24, 0x00000071012fd5f0,nullsub_4849,4, 0x00000071012fd5f4,j__ZdlPv_1323,4, diff --git a/lib/sead b/lib/sead index 2c55e2f0..6d0d19ac 160000 --- a/lib/sead +++ b/lib/sead @@ -1 +1 @@ -Subproject commit 2c55e2f00fd10d58739c3a6efa57cf93c7195995 +Subproject commit 6d0d19ac628c26622c75c38dde8e1cbd93f3a854 diff --git a/src/KingSystem/ActorSystem/CMakeLists.txt b/src/KingSystem/ActorSystem/CMakeLists.txt index d80bb38d..05aff8cd 100644 --- a/src/KingSystem/ActorSystem/CMakeLists.txt +++ b/src/KingSystem/ActorSystem/CMakeLists.txt @@ -22,6 +22,8 @@ target_sources(uking PRIVATE actAiClass.h actAiParam.cpp actAiParam.h + actAttention.cpp + actAttention.h actBaseProc.cpp actBaseProc.h actBaseProcHandle.cpp @@ -40,7 +42,10 @@ target_sources(uking PRIVATE actBaseProcUnit.h actDebug.cpp actDebug.h + actInfoData.cpp + actInfoData.h actInstParamPack.cpp actInstParamPack.h + actLifeRecoveryInfo.h actTag.h ) diff --git a/src/KingSystem/ActorSystem/actActorParam.cpp b/src/KingSystem/ActorSystem/actActorParam.cpp index b358375a..dbe2096e 100644 --- a/src/KingSystem/ActorSystem/actActorParam.cpp +++ b/src/KingSystem/ActorSystem/actActorParam.cpp @@ -3,7 +3,7 @@ #include #include "KingSystem/ActorSystem/actActorParamMgr.h" #include "KingSystem/ActorSystem/actActorTemplate.h" -#include "KingSystem/Utils/Byaml.h" +#include "KingSystem/Utils/Byaml/Byaml.h" namespace ksys::act { @@ -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..1186e244 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,7 +71,15 @@ public: LifeCondition = 22, UMii = 23, AnimationInfo = 24, + AS = 25, + AttClient = 26, + RagdollConfig = 27, }; + static constexpr s32 NumResourceTypes = 28; + + static constexpr bool isValidType(ResourceType type) { + return type <= ResourceType::AnimationInfo; + } union Resources { struct { @@ -112,7 +122,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 +151,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..e75eb43f 100644 --- a/src/KingSystem/ActorSystem/actActorParamMgr.cpp +++ b/src/KingSystem/ActorSystem/actActorParamMgr.cpp @@ -3,18 +3,75 @@ #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 { SEAD_SINGLETON_DISPOSER_IMPL(ActorParamMgr) +using Type = ActorParam::ResourceType; +using User = res::ActorLink::User; + ActorParamMgr::ActorParamMgr() = default; 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); @@ -30,33 +87,13 @@ ActorParam* ActorParamMgr::getParam(const char* actor_name, ActorParam** out_fre return nullptr; } -ActorParam* ActorParamMgr::loadParam(const char* actor_name, res::Handle* handle, void* x, +ActorParam* ActorParamMgr::loadParam(const char* actor_name, res::Handle* pack_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) { - loadFiles(param, mTmpActorParamMgrHeap, handle, x, load_req_c); + if (allocated_new) { + loadFiles(param, mTmpActorParamMgrHeap, pack_handle, x, load_req_c); param->setEventSignal(); } else { param->waitForEvent(); @@ -65,8 +102,40 @@ 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, ActorParam::NumResourceTypes + 1); + param->mActiveBufferIdx = 0; + + 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,9 +150,638 @@ bool ActorParamMgr::loadActorPack(res::Handle* handle, const sead::SafeString& a return handle->requestLoad(path, &req); } +ActorParam* ActorParamMgr::loadParamAsync(const char* actor_name, res::Handle* pack_handle, + bool* allocated_new, void* x, u32 load_req_c) { + auto* param = allocParam(actor_name, allocated_new); + if (!*allocated_new) + return param; + + param->deleteResHandles(); + param->allocResHandles(mTmpActorParamMgrHeap, 0, ActorParam::NumResourceTypes + 1); + param->mActiveBufferIdx = 0; + + loadFileAsync(param, Type::ActorLink, "Actor/ActorLink", "xml", + param->getActorName().cstr(), pack_handle, x, load_req_c); + return param; +} + +template +bool ActorParamMgr::loadFileAsync(ActorParam* param, ActorParam::ResourceType type, + const sead::SafeString& dir_name, + const sead::SafeString& extension, const sead::SafeString& name, + res::Handle* pack_handle, void* x, u32 load_req_c) { + auto* handle = param->allocHandle(); + + if (name != "Dummy" && !name.isEmpty()) { + sead::FixedSafeString<128> path; + res::LoadRequest req; + prepareLoadFromActorPack(&path, &req, x, dir_name, extension, name, pack_handle, load_req_c, + param->getActorName()); + return handle->requestLoad(path, &req); + } + + if (ActorParam::isValidType(type)) { + auto* res = sead::DynamicCast(mDummyResources[u32(type)].getResource()); + param->setResource(type, res); + } + + return true; +} + +// NON_MATCHING: different address calculation for static_cast(res)->getPath() +template +T* ActorParamMgr::handleAsyncFileLoad(ActorParam* param, s32* idx, ActorParam::ResourceType type, + void*) { + const s32 current_idx = *idx; + auto& handle = param->mHandles[param->mActiveBufferIdx][current_idx]; + *idx = current_idx + 1; + + if (ActorParam::isValidType(type)) { + if (auto* res = static_cast(param->getRes().mArray[u32(type)])) + return res; + } + + if (handle.isFlag8Set()) + return sead::DynamicCast(handle.getResource()); + + if (!handle.isReadyOrNeedsParse()) + return nullptr; + + handle.parseResource(nullptr); + + if (handle.checkLoadStatus() && type != Type::EventFlow) + param->_a = 1; + + auto* res = sead::DynamicCast(handle.getResource()); + if (res) { + auto* unit = handle.getUnit(); + if (unit) + static_cast(res)->getPath().copy(unit->getPath()); + } else { + res = sead::DynamicCast(mDummyResources[s32(type)].getResource()); + } + + if (ActorParam::isValidType(type) && res) + param->setResource(type, res); + + return res; +} + +bool ActorParamMgr::finishLoadingActorLink(ActorParam* param, void* x) { + s32 idx = 0; + if (!handleAsyncFileLoad(param, &idx, Type::ActorLink, x)) + return param->_a != 0; + + const auto* link = param->getRes().mActorLink; + if (!link) + return true; + + param->setProfileAndPriority(link->getUsers().getProfile(), link->getPriority().cstr()); + return true; +} + +void ActorParamMgr::loadParamAsyncStep2(ActorParam* param, res::Handle* pack_handle, void* x, + u32 load_req_c) { + const auto* link = param->getRes().mActorLink; + + loadFileAsync(param, Type::ModelList, "Actor/ModelList", "modellist", + link->getUsers().getModel(), pack_handle, x, load_req_c); + + loadFileAsync(param, Type::UMii, "Actor/UMii", "umii", link->getUsers().getUMii(), + pack_handle, x, load_req_c); + + loadFileAsync(param, Type::ASList, "Actor/ASList", "aslist", + link->getUsers().getAS(), pack_handle, x, load_req_c); + + loadFileAsync(param, Type::AttClientList, "Actor/AttClientList", "atcllist", + link->getUserName(User::Attention), pack_handle, x, + load_req_c); + + loadFileAsync(param, Type::RagdollConfigList, "Actor/RagdollConfigList", + "rgconfiglist", link->getUserName(User::RgConfigList), + pack_handle, x, load_req_c); + + loadFileAsync(param, Type::AIProgram, "Actor/AIProgram", "aiprog", + link->getUsers().getAIProgram(), pack_handle, x, load_req_c); + + loadFileAsync(param, Type::GParamList, "Actor/GeneralParamList", "gparamlist", + link->getUsers().getGParam(), pack_handle, x, load_req_c); + + loadFileAsync(param, Type::Physics, "Actor/Physics", "physics", + link->getUsers().getPhysics(), pack_handle, x, load_req_c); + + loadFileAsync(param, Type::Chemical, "Actor/Chemical", "chemical", + link->getUsers().getChemical(), pack_handle, x, load_req_c); + + loadFileAsync(param, Type::DamageParam, "Actor/DamageParam", "dmgparam", + link->getUsers().getDamageParam(), pack_handle, x, load_req_c); + + loadFileAsync( + param, Type::RagdollBlendWeight, "Actor/RagdollBlendWeight", "rgbw", + link->getUsers().getRgBlendWeight(), pack_handle, x, load_req_c); + + loadFileAsync(param, Type::Awareness, "Actor/Awareness", "awareness", + link->getUsers().getAwareness(), pack_handle, x, load_req_c); + + loadFileAsync(param, Type::DropTable, "Actor/DropTable", "drop", + link->getUsers().getDropTable(), pack_handle, x, load_req_c); + + loadFileAsync(param, Type::ShopData, "Actor/ShopData", "shop", + link->getUsers().getShopData(), pack_handle, x, load_req_c); + + loadFileAsync(param, Type::Recipe, "Actor/Recipe", "recipe", + link->getUsers().getRecipe(), pack_handle, x, load_req_c); + + loadFileAsync(param, Type::Lod, "Actor/LOD", "lod", link->getUsers().getLOD(), + pack_handle, x, load_req_c); + + loadFileAsync(param, Type::AISchedule, "Actor/AISchedule", "aischedule", + link->getUsers().getAISchedule(), pack_handle, x, load_req_c); + + loadFileAsync(param, Type::BoneControl, "Actor/BoneControl", "bonectrl", + link->getUsers().getBoneControl(), pack_handle, x, load_req_c); + + loadFileAsync(param, Type::LifeCondition, "Actor/LifeCondition", + "lifecondition", link->getUsers().getLifeCondition(), + pack_handle, x, load_req_c); + + loadFileAsync(param, Type::AnimationInfo, "Actor/AnimationInfo", "animinfo", + link->getUsers().getAnimationInfo(), pack_handle, x, load_req_c); +} + +bool ActorParamMgr::finishLoadingStep2(ActorParam* param, void* x) { + s32 idx = 1; + + if (!handleAsyncFileLoad(param, &idx, Type::ModelList, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::UMii, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::ASList, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::AttClientList, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::RagdollConfigList, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::AIProgram, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::GParamList, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::Physics, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::Chemical, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::DamageParam, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::RagdollBlendWeight, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::Awareness, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::DropTable, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::ShopData, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::Recipe, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::Lod, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::AISchedule, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::BoneControl, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::LifeCondition, x)) + return false; + + if (!handleAsyncFileLoad(param, &idx, Type::AnimationInfo, x)) + return false; + + return true; +} + +void ActorParamMgr::loadExtraResAsync(ActorParam* param, res::Handle* pack_handle, void* x, + u32 load_req_c) { + const auto* aslist = param->getRes().mASList; + const auto* atcllist = param->getRes().mAttClientList; + const auto* rgconfiglist = param->getRes().mRagdollConfigList; + + const auto num_as = aslist ? aslist->getASDefines().size() : 0; + const auto num_att = atcllist ? atcllist->getClients().size() : 0; + const auto num_rg = rgconfiglist ? rgconfiglist->getImpulseParams().size() : 0; + + param->allocResHandles(mTmpActorParamMgrHeap, 1, num_as + num_att + num_rg); + param->mActiveBufferIdx = 1; + + if (aslist) { + for (s32 i = 0; i < num_as; ++i) { + loadFileAsync(param, Type::AS, "Actor/AS", "as", + aslist->getASDefines()[i].getFileName(), pack_handle, x, + load_req_c); + } + } + + if (atcllist) { + for (s32 i = 0; i < num_att; ++i) { + loadFileAsync(param, Type::AttClient, "Actor/AttClient", "atcl", + atcllist->getClients()[i].getFileName(), pack_handle, x, + load_req_c); + } + } + + if (rgconfiglist) { + for (s32 i = 0; i < num_rg; ++i) { + loadFileAsync( + param, Type::RagdollConfig, "Actor/RagdollConfig", "rgconfig", + rgconfiglist->getImpulseParams()[i].getFileName(), pack_handle, x, load_req_c); + } + } +} + +bool ActorParamMgr::finishLoadingExtraRes(ActorParam* param, void* x) { + s32 idx = 0; + + auto* aslist = param->getRes().mASList; + if (aslist) { + for (s32 i = 0, n = aslist->getASDefines().size(); i < n; ++i) { + const sead::SafeString file_name = aslist->getASDefines()[i].getFileName(); + if (file_name == "Dummy" || file_name.isEmpty()) { + auto* as = sead::DynamicCast(mDummyResources[u32(Type::AS)].getResource()); + as->setIndex(u32(Type::AS)); + aslist->addAS_(i, as); + ++idx; + } else { + const res::Handle& handle = param->mHandles[1][idx]; + if (handle.isFlag8Set()) { + ++idx; + continue; + } + + auto* as = handleAsyncFileLoad(param, &idx, Type::AS, x); + if (!as) + return false; + + as->setIndex(u32(Type::AS)); + aslist->addAS_(i, as); + } + } + } + + auto* atcllist = param->getRes().mAttClientList; + if (atcllist) { + for (s32 i = 0, n = atcllist->getClients().size(); i < n; ++i) { + const sead::SafeString file_name = atcllist->getClients()[i].getFileName(); + if (file_name == "Dummy" || file_name.isEmpty()) { + auto* res = sead::DynamicCast( + mDummyResources[u32(Type::AttClient)].getResource()); + /// @bug This should be Type::AttClient. Copy paste error? + res->setIndex(u32(Type::AS)); + atcllist->addClient_(i, res); + ++idx; + } else { + const res::Handle& handle = param->mHandles[1][idx]; + if (handle.isFlag8Set()) { + ++idx; + continue; + } + + auto* res = handleAsyncFileLoad(param, &idx, Type::AttClient, x); + if (!res) + return false; + + res->setIndex(u32(Type::AttClient)); + atcllist->addClient_(i, res); + } + } + } + + auto* rgconfiglist = param->getRes().mRagdollConfigList; + if (rgconfiglist) { + for (s32 i = 0, n = rgconfiglist->getImpulseParams().size(); i < n; ++i) { + const sead::SafeString file_name = rgconfiglist->getImpulseParams()[i].getFileName(); + if (file_name == "Dummy" || file_name.isEmpty()) { + auto* res = sead::DynamicCast( + mDummyResources[u32(Type::RagdollConfig)].getResource()); + res->setIndex(u32(Type::RagdollConfig)); + rgconfiglist->addImpulseParamConfig_(i, res); + ++idx; + } else { + const res::Handle& handle = param->mHandles[1][idx]; + if (handle.isFlag8Set()) { + ++idx; + continue; + } + + auto* res = + handleAsyncFileLoad(param, &idx, Type::RagdollConfig, x); + if (!res) + return false; + + res->setIndex(u32(Type::RagdollConfig)); + rgconfiglist->addImpulseParamConfig_(i, res); + } + } + } + + param->_9 = 0; + param->onLoadFinished(this); + param->setEventSignal(); + return true; +} + +void ActorParamMgr::allocExtraResHandles(ActorParam* param, sead::Heap* heap) const { + 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->getASDefines().size(); + + if (atcllist) + num_extra_handles += atcllist->getClients().size(); + + if (rgconfiglist) + num_extra_handles += rgconfiglist->getImpulseParams().size(); + + param->allocResHandles(heap, 1, num_extra_handles); +} + +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; + + 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); + + // Start loading the extra ActorParam files. + allocExtraResHandles(param, heap); + param->mActiveBufferIdx = 1; + + if (auto* aslist = param->getRes().mASList) { + for (s32 i = 0; i < aslist->getASDefines().size(); ++i) { + auto* as = loadFile(param, Type::AS, "Actor/AS", "as", + aslist->getASDefines()[i].getFileName(), 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].getFileName(), + 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].getFileName(), 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(mDummyResources[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(mDummyResources[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()); + mDummyResources[u32(ActorParam::ResourceType::GParamList)].getResourceUnchecked()); } } // namespace ksys::act diff --git a/src/KingSystem/ActorSystem/actActorParamMgr.h b/src/KingSystem/ActorSystem/actActorParamMgr.h index accb3457..461ca4a6 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,11 +36,23 @@ 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); + ActorParam* loadParam(const char* actor_name, res::Handle* pack_handle, void* x, + u32 load_req_c); + void unloadParam(ActorParam* param); + ActorParam* loadParamAsync(const char* actor_name, res::Handle* pack_handle, + bool* allocated_new, void* x, u32 load_req_c); + bool finishLoadingActorLink(ActorParam* param, void* x); + void loadParamAsyncStep2(ActorParam* param, res::Handle* pack_handle, void* x, u32 load_req_c); + bool finishLoadingStep2(ActorParam* param, void* x); + void loadExtraResAsync(ActorParam* param, res::Handle* pack_handle, void* x, u32 load_req_c); + bool finishLoadingExtraRes(ActorParam* param, void* x); res::GParamList* getDummyGParamList() const; private: @@ -50,9 +63,36 @@ 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); + + template + bool loadFileAsync(ActorParam* param, ActorParam::ResourceType type, + const sead::SafeString& dir_name, const sead::SafeString& extension, + const sead::SafeString& name, res::Handle* pack_handle, void* x, + u32 load_req_c); + + template + T* handleAsyncFileLoad(ActorParam* param, s32* idx, ActorParam::ResourceType type, void* x); + + void loadFilesStep2(ActorParam* param, sead::Heap* heap, res::Handle* pack_handle, void* x, + u32 load_req_c); + + void allocExtraResHandles(ActorParam* param, sead::Heap* heap) const; static constexpr s32 NumParams = 0x400; @@ -63,7 +103,7 @@ private: void* _e8 = nullptr; sead::Heap* mDebugHeap = nullptr; sead::Heap* mTmpActorParamMgrHeap = nullptr; - sead::SafeArray mResHandles; + sead::SafeArray mDummyResources; mutable sead::CriticalSection mCS; }; KSYS_CHECK_SIZE_NX150(ActorParamMgr, 0xa00); diff --git a/src/KingSystem/ActorSystem/actActorTemplate.cpp b/src/KingSystem/ActorSystem/actActorTemplate.cpp index 0daf5dae..f4b16526 100644 --- a/src/KingSystem/ActorSystem/actActorTemplate.cpp +++ b/src/KingSystem/ActorSystem/actActorTemplate.cpp @@ -1,6 +1,6 @@ #include "KingSystem/ActorSystem/actActorTemplate.h" #include "KingSystem/ActorSystem/actActorParamMgr.h" -#include "KingSystem/Utils/Byaml.h" +#include "KingSystem/Utils/Byaml/Byaml.h" #include "KingSystem/Utils/SafeDelete.h" namespace ksys::act { diff --git a/src/KingSystem/ActorSystem/actAttention.cpp b/src/KingSystem/ActorSystem/actAttention.cpp new file mode 100644 index 00000000..001c72f2 --- /dev/null +++ b/src/KingSystem/ActorSystem/actAttention.cpp @@ -0,0 +1,9 @@ +#include "KingSystem/ActorSystem/actAttention.h" + +namespace ksys::act { + +SEAD_ENUM_IMPL(AttActionType) + +SEAD_ENUM_IMPL(AttPriorityType) + +} // namespace ksys::act diff --git a/src/KingSystem/ActorSystem/actAttention.h b/src/KingSystem/ActorSystem/actAttention.h new file mode 100644 index 00000000..bf7ed816 --- /dev/null +++ b/src/KingSystem/ActorSystem/actAttention.h @@ -0,0 +1,70 @@ +#pragma once + +#include + +namespace ksys::act { + +enum class AttType { + Action = 0, + Lock = 1, + SwordSearch = 2, + Attack = 3, + Appeal = 4, + JumpRide = 5, + NameBalloon = 6, + LookOnly = 7, + Invalid = 8, +}; + +// Make sure to update AttActionType if this is changed +enum class AttActionCode { + None = 0x1800000, + Talk, + Listen, + Awake, + Grab, + Open, + Pick, + Catch, + CheckCatch, + CatchWeapon, + Skin, + Sleep, + Sit, + Lumber, + Pushpull, + Read, + Check, + Boot, + BootPStop, + Leave, + Remind, + Buy, + Ride, + Wakeboard, + WakeboardRide, + RideRito, + RideZora, + Cook, + KillTime, + Display, + DisplayBow, + DisplayShield, + PickUp, + Pray, + PullOut, + Waterfall, + CommandWait, + CommandCome, + Thrust, + Put, + PickToEvent, + Dummy, +}; + +// clang-format off +SEAD_ENUM(AttActionType, None,Talk,Listen,Awake,Grab,Open,Pick,Catch,CheckCatch,CatchWeapon,Skin,Sleep,Sit,Lumber,Pushpull,Read,Check,Boot,BootPStop,Leave,Remind,Buy,Ride,Wakeboard,WakeboardRide,RideRito,RideZora,Cook,KillTime,Display,DisplayBow,DisplayShield,PickUp,Pray,PullOut,Waterfall,CommandWait,CommandCome,Thrust,Put,PickToEvent,Dummy) +SEAD_ENUM(AttPriorityType, Default,Enemy,Npc,Obj,ObjLow,ObjMiddle,ObjHigh,Bullet) +// clang-format on + +} // namespace ksys::act diff --git a/src/KingSystem/ActorSystem/actInfoData.cpp b/src/KingSystem/ActorSystem/actInfoData.cpp new file mode 100644 index 00000000..54499e40 --- /dev/null +++ b/src/KingSystem/ActorSystem/actInfoData.cpp @@ -0,0 +1,296 @@ +#include "KingSystem/ActorSystem/actInfoData.h" +#include +#include +#include "KingSystem/Utils/Byaml/Byaml.h" +#include "KingSystem/Utils/Byaml/ByamlArrayIter.h" +#include "KingSystem/Utils/Byaml/ByamlData.h" +#include "KingSystem/Utils/Byaml/ByamlHashIter.h" + +namespace ksys::act { + +SEAD_SINGLETON_DISPOSER_IMPL(InfoData) + +InfoData::~InfoData() { + if (mHashesIter) + delete mHashesIter; + + if (mActorsIter) + delete mActorsIter; + + if (mRootIter) + delete mRootIter; + + mRootIter = nullptr; + mHashesIter = nullptr; + mActorsIter = nullptr; + mHashesBytes = nullptr; + mHashes = nullptr; + mActorsBytes = nullptr; + mActorOffsets = nullptr; +} + +void InfoData::init(u8* data, sead::Heap* heap, sead::Heap* debug_heap) { + mRootIter = new (heap) al::ByamlIter(data); + mHashesIter = new (heap) al::ByamlIter(); + mActorsIter = new (heap) al::ByamlIter(); + + if (debug_heap) { + mDebugEntries = new (debug_heap) DebugEntry[NumDebugEntries]; + for (s32 i = 0; i != NumDebugEntries; ++i) + mDebugEntries[i].used = false; + } else { + mDebugEntries = nullptr; + } + + if (mRootIter->tryGetIterByKey(mHashesIter, "Hashes")) { + mHashesBytes = mHashesIter->getData(); + mHashes = al::ByamlArrayIter(mHashesIter->getRootNode()).getDataTable(); + } + + if (mRootIter->tryGetIterByKey(mActorsIter, "Actors")) { + mActorsBytes = mActorsIter->getData(); + mActorOffsets = al::ByamlArrayIter(mActorsIter->getRootNode()).getDataTable(); + } + + mNumActors = mActorsIter->getSize(); + _88 = 0; + mDebugHeap = debug_heap; + mTagsIdx = mRootIter->getKeyIndex("tags"); + mProfileIdx = mRootIter->getKeyIndex("profile"); + mInvalidWeathersIdx = mRootIter->getKeyIndex("invalidWeathers"); + mInvalidTimesIdx = mRootIter->getKeyIndex("invalidTimes"); + mNameIdx = mRootIter->getKeyIndex("name"); + mSystemSameGroupActorNameIdx = mRootIter->getKeyIndex("systemSameGroupActorName"); +} + +bool InfoData::getActorIter(al::ByamlIter* iter, const char* actor, bool x) const { + const u32 hash = sead::HashCRC32::calcStringHash(actor); + + // Perform a binary search. + s32 a = 0; + s32 b = mNumActors; + while (a < b) { + const s32 idx = (a + b) / 2; + const u32 hash_i = mHashes[idx]; + + if (hash_i == hash) { + *iter = al::ByamlIter(mActorsBytes, mActorsBytes + mActorOffsets[idx]); + return true; + } + + if (hash_i >= hash) + b = idx; + else + a = idx + 1; + } + + if (x) + static_cast(logFailure(actor)); + + return false; +} + +void InfoData::getRecipeInfo(const char* actor, InfoData::RecipeInfo& info) const { + al::ByamlIter iter; + if (getActorIter(&iter, actor)) { + info.num_items = iter.getIntByKey("normal0StuffNum"); + + info.items[0].name = iter.getStringByKey("normal0ItemName01"); + info.items[0].num = iter.getIntByKey("normal0ItemNum01"); + + info.items[1].name = iter.getStringByKey("normal0ItemName02"); + info.items[1].num = iter.getIntByKey("normal0ItemNum02"); + + info.items[2].name = iter.getStringByKey("normal0ItemName03"); + info.items[2].num = iter.getIntByKey("normal0ItemNum03"); + + } else { + info.num_items = 0; + + info.items[0].name = sead::SafeString::cEmptyString; + info.items[0].num = 0; + + info.items[1].name = sead::SafeString::cEmptyString; + info.items[1].num = 0; + + info.items[2].name = sead::SafeString::cEmptyString; + info.items[2].num = 0; + } +} + +s32 InfoData::getIntByKey(const al::ByamlIter& iter, const char* key, s32 default_) { + s32 value; + return iter.tryGetIntByKey(&value, key) ? value : default_; +} + +const char* InfoData::getStringByKey(const al::ByamlIter& iter, const char* key, + const sead::SafeString& default_) { + const char* value; + return iter.tryGetStringByKey(&value, key) ? value : default_.cstr(); +} + +[[gnu::noinline]] static InfoData::Locator::Type +getLocatorTypeFromStr(const sead::SafeString& type) { + static constexpr const char* types[] = {"Trunk", "Branch", "GlowStone", + "OnTree", "MagnePos", "StopTimerPos"}; + for (s32 i = 0; i < s32(std::size(types)); ++i) { + if (type == types[i]) + return InfoData::Locator::Type(i); + } + return InfoData::Locator::Type::Invalid; +} + +void InfoData::getLocators(const char* actor, Locators& info) const { + info.num = 0; + + al::ByamlIter iter; + if (!getActorIter(&iter, actor)) + return; + + al::ByamlIter iter_locators; + if (!iter.tryGetIterByKey(&iter_locators, "locators")) + return; + + info.num = iter_locators.getSize(); + for (s32 i = 0; i < info.num; ++i) { + al::ByamlIter it; + if (!iter_locators.tryGetIterByIndex(&it, i)) + continue; + + const char* type_str{}; + auto& locator = info.locators[i]; + + it.tryGetFloatByKey(&locator.pos.x, "pos_x"); + it.tryGetFloatByKey(&locator.pos.y, "pos_y"); + it.tryGetFloatByKey(&locator.pos.z, "pos_z"); + + it.tryGetFloatByKey(&locator.rot.x, "rot_x"); + it.tryGetFloatByKey(&locator.rot.y, "rot_y"); + it.tryGetFloatByKey(&locator.rot.z, "rot_z"); + + it.tryGetStringByKey(&type_str, "type"); + locator.type = type_str ? getLocatorTypeFromStr(type_str) : Locator::Type::Invalid; + + locator.rot *= 2 * sead::numbers::pi / 360.0; + } +} + +void InfoData::getHomeAreas(const char* actor, HomeAreas& info) const { + info.names.fill(""); + + al::ByamlIter iter; + if (!getActorIter(&iter, actor)) + return; + + al::ByamlIter home_area; + if (!iter.tryGetIterByKey(&home_area, "homeArea")) + return; + + for (s32 i = 0, n = home_area.getSize(); i < info.names.size() && i < n; ++i) { + al::ByamlIter it; + if (home_area.tryGetIterByIndex(&it, i)) + it.tryGetStringByKey(&info.names[i], "name"); + } +} + +const char* InfoData::getSameGroupActorName(const char* actor) const { + al::ByamlIter iter; + return [&] { + if (getActorIter(&iter, actor, false)) { + al::ByamlHashIter hash_iter{iter.getRootNode()}; + al::ByamlData data; + if (hash_iter.getDataByKey(&data, mSystemSameGroupActorNameIdx)) { + const char* name; + if (iter.tryConvertString(&name, &data)) + return name; + } + } + return sead::SafeString::cEmptyString.cstr(); + }(); +} + +const char* InfoData::getString(const char* actor, const char* key, + const sead::SafeString& default_, bool x) const { + al::ByamlIter iter; + if (!getActorIter(&iter, actor, x)) + return default_.cstr(); + + return getStringByKey(iter, key, default_); +} + +const char* InfoData::getSLinkUser(const char* actor) const { + al::ByamlIter iter; + if (!getActorIter(&iter, actor)) + return "Dummy"; + + return getStringByKey(iter, "slink", "Dummy"); +} + +bool InfoData::getSLinkAndELinkUsers(const char* actor, const char** elink, + const char** slink) const { + al::ByamlIter iter; + if (getActorIter(&iter, actor)) { + *elink = getStringByKey(iter, "elink", "Dummy"); + *slink = getStringByKey(iter, "slink", "Dummy"); + return true; + } + *elink = "Dummy"; + *slink = "Dummy"; + return false; +} + +const char* InfoData::getXLinkUser(const char* actor) const { + return getString(actor, "xlink", "Dummy"); +} + +bool InfoData::getActorProfile(const char** profile, const char* actor) const { + al::ByamlIter iter; + if (getActorIter(&iter, actor)) { + al::ByamlHashIter hash_iter{iter.getRootNode()}; + al::ByamlData data; + if (hash_iter.getDataByKey(&data, mProfileIdx)) + return iter.tryConvertString(profile, &data); + } + *profile = "Dummy"; + return false; +} + +s32 InfoData::getInt(const char* actor, const char* key, s32 default_, bool x) const { + al::ByamlIter iter; + if (!getActorIter(&iter, actor, x)) + return default_; + + return getIntByKey(iter, key, default_); +} + +f32 InfoData::getFloat(const char* actor, const char* key, f32 default_, bool x) const { + al::ByamlIter iter; + if (!getActorIter(&iter, actor, x)) + return default_; + + return getFloatByKey(iter, key, default_); +} + +bool InfoData::getBool(const char* actor, const char* key, bool default_, bool x) const { + al::ByamlIter iter; + if (!getActorIter(&iter, actor, x)) + return default_; + + return getBoolByKey(iter, key, default_); +} + +f32 InfoData::getFloatByKey(const al::ByamlIter& iter, const char* key, f32 default_) { + f32 value; + return iter.tryGetFloatByKey(&value, key) ? value : default_; +} + +bool InfoData::getBoolByKey(const al::ByamlIter& iter, const char* key, bool default_) { + bool value; + return iter.tryGetBoolByKey(&value, key) ? value != 0 : default_; +} + +f32 InfoData::getScale(const char* actor) const { + return getFloat(actor, "actorScale", 1.0); +} + +} // namespace ksys::act diff --git a/src/KingSystem/ActorSystem/actInfoData.h b/src/KingSystem/ActorSystem/actInfoData.h new file mode 100644 index 00000000..56a84e6f --- /dev/null +++ b/src/KingSystem/ActorSystem/actInfoData.h @@ -0,0 +1,135 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include "KingSystem/Utils/Types.h" + +namespace al { +class ByamlIter; +} + +namespace ksys::act { + +class InfoData { + SEAD_SINGLETON_DISPOSER(InfoData) + InfoData() = default; + virtual ~InfoData(); + +public: + struct ModelInfo { + sead::Vector3f baseScale; + sead::Color4f addColor; + sead::Color4f mulColor; + const char* bfres; + const char* mainModel; + }; + KSYS_CHECK_SIZE_NX150(ModelInfo, 0x40); + + struct RecipeInfo { + struct Item { + sead::FixedSafeString<64> name; + s32 num; + }; + + s32 num_items; + Item items[3]; + }; + KSYS_CHECK_SIZE_NX150(RecipeInfo, 0x128); + + struct Locator { + enum class Type { + Invalid = -1, + Trunk = 0, + Branch = 1, + GlowStone = 2, + OnTree = 3, + MagnePos = 4, + StopTimerPos = 5, + }; + + Type type; + sead::Vector3f pos; + sead::Vector3f rot; + }; + KSYS_CHECK_SIZE_NX150(Locator, 0x1c); + + struct Locators { + s32 num; + sead::SafeArray locators; + }; + KSYS_CHECK_SIZE_NX150(Locators, 0xe4); + + struct HomeAreas { + sead::SafeArray names; + }; + KSYS_CHECK_SIZE_NX150(HomeAreas, 0x18); + + void init(u8* data, sead::Heap* heap, sead::Heap* debug_heap); + + void getModelInfo(const char* actor, ModelInfo& info) const; + bool getActorIter(al::ByamlIter* iter, const char* actor, bool x = true) const; + bool logFailure(const sead::SafeString& actor_name) const; + void getRecipeInfo(const char* actor, RecipeInfo& info) const; + void getLocators(const char* actor, Locators& info) const; + void getHomeAreas(const char* actor, HomeAreas& info) const; + // TODO: invalid time function + // TODO: tag functions + const char* getSameGroupActorName(const char* actor) const; + // TODO: more functions + const char* getSLinkUser(const char* actor) const; + bool getSLinkAndELinkUsers(const char* actor, const char** elink, const char** slink) const; + const char* getXLinkUser(const char* actor) const; + bool getActorProfile(const char** profile, const char* actor) const; + // TODO: more functions + f32 getScale(const char* actor) const; + + const char* getString(const char* actor, const char* key, const sead::SafeString& default_, + bool x = true) const; + s32 getInt(const char* actor, const char* key, s32 default_ = 0, bool x = true) const; + f32 getFloat(const char* actor, const char* key, f32 default_ = 0, bool x = true) const; + bool getBool(const char* actor, const char* key, bool default_ = false, bool x = true) const; + + static s32 getIntByKey(const al::ByamlIter& iter, const char* key, s32 default_ = 0); + static f32 getFloatByKey(const al::ByamlIter& iter, const char* key, f32 default_ = 0); + static bool getBoolByKey(const al::ByamlIter& iter, const char* key, bool default_ = false); + static const char* getStringByKey(const al::ByamlIter& iter, const char* key, + const sead::SafeString& default_); + +private: + struct DebugEntry { + sead::FixedSafeString<64> str; + bool used; + }; + KSYS_CHECK_SIZE_NX150(DebugEntry, 0x60); + + al::ByamlIter* mRootIter{}; + al::ByamlIter* mHashesIter{}; + al::ByamlIter* mActorsIter{}; + + const u8* mHashesBytes{}; + const u32* mHashes{}; + + const u8* mActorsBytes{}; + const u32* mActorOffsets{}; + + s32 mTagsIdx = -1; + s32 mInvalidWeathersIdx = -1; + s32 mInvalidTimesIdx = -1; + s32 mSystemSameGroupActorNameIdx = -1; + s32 mNameIdx = -1; + s32 mProfileIdx = -1; + + s32 mNumActors = 0; + DebugEntry* mDebugEntries{}; + u32 _88 = 0; + sead::Heap* mDebugHeap{}; + + static constexpr s32 NumDebugEntries = 512; +}; +KSYS_CHECK_SIZE_NX150(InfoData, 0x98); + +} // namespace ksys::act diff --git a/src/KingSystem/Ecosystem/ecoLevelSensor.cpp b/src/KingSystem/Ecosystem/ecoLevelSensor.cpp index 42676953..f7db37fd 100644 --- a/src/KingSystem/Ecosystem/ecoLevelSensor.cpp +++ b/src/KingSystem/Ecosystem/ecoLevelSensor.cpp @@ -1,5 +1,5 @@ #include "KingSystem/Ecosystem/ecoLevelSensor.h" -#include "KingSystem/Utils/Byaml.h" +#include "KingSystem/Utils/Byaml/Byaml.h" namespace ksys::eco { diff --git a/src/KingSystem/GameData/gdtManager.h b/src/KingSystem/GameData/gdtManager.h index 8208414b..7dca62ce 100644 --- a/src/KingSystem/GameData/gdtManager.h +++ b/src/KingSystem/GameData/gdtManager.h @@ -12,7 +12,7 @@ #include "KingSystem/GameData/gdtTriggerParam.h" #include "KingSystem/Resource/resHandle.h" #include "KingSystem/System/KingEditor.h" -#include "KingSystem/Utils/Byaml.h" +#include "KingSystem/Utils/Byaml/Byaml.h" #include "KingSystem/Utils/Types.h" namespace sead { diff --git a/src/KingSystem/Map/mapMubinIter.h b/src/KingSystem/Map/mapMubinIter.h index cf9f7243..fc7c8606 100644 --- a/src/KingSystem/Map/mapMubinIter.h +++ b/src/KingSystem/Map/mapMubinIter.h @@ -2,7 +2,7 @@ #include #include "KingSystem/Map/mapTypes.h" -#include "KingSystem/Utils/Byaml.h" +#include "KingSystem/Utils/Byaml/Byaml.h" namespace ksys::map { diff --git a/src/KingSystem/Resource/CMakeLists.txt b/src/KingSystem/Resource/CMakeLists.txt index 715888cf..e2e23994 100644 --- a/src/KingSystem/Resource/CMakeLists.txt +++ b/src/KingSystem/Resource/CMakeLists.txt @@ -105,12 +105,16 @@ target_sources(uking PRIVATE resLoadRequest.h resMemoryTask.cpp resMemoryTask.h + resModelResourceDivide.cpp + resModelResourceDivide.h resOffsetReadFileDevice.cpp resOffsetReadFileDevice.h resResourceMgrTask.cpp resResourceMgrTask.h resSystem.cpp resSystem.h + resTempResourceLoader.cpp + resTempResourceLoader.h resTextureHandleList.cpp resTextureHandleList.h resTextureHandleMgr.cpp @@ -128,10 +132,26 @@ target_sources(uking PRIVATE resResourceActorLink.h resResourceAIProgram.cpp resResourceAIProgram.h + resResourceAISchedule.cpp + resResourceAISchedule.h + resResourceAnimInfo.cpp + resResourceAnimInfo.h + resResourceAS.cpp + resResourceAS.h + resResourceASList.cpp + resResourceASList.h + resResourceAttClient.cpp + resResourceAttClient.h + resResourceAttClientList.cpp + resResourceAttClientList.h resResourceArchive.cpp resResourceArchive.h resResourceAwareness.cpp resResourceAwareness.h + resResourceBoneControl.cpp + resResourceBoneControl.h + resResourceChemical.cpp + resResourceChemical.h resResourceDamageParam.cpp resResourceDamageParam.h resResourceDemo.cpp @@ -148,8 +168,20 @@ target_sources(uking PRIVATE resResourceLifeCondition.h resResourceLod.cpp resResourceLod.h + resResourceModelList.cpp + resResourceModelList.h + resResourcePhysics.cpp + resResourcePhysics.h + resResourceRagdollBlendWeight.cpp + resResourceRagdollBlendWeight.h + resResourceRagdollConfig.cpp + resResourceRagdollConfig.h + resResourceRagdollConfigList.cpp + resResourceRagdollConfigList.h resResourceRecipe.cpp resResourceRecipe.h resResourceShop.cpp resResourceShop.h + resResourceUMii.cpp + resResourceUMii.h ) diff --git a/src/KingSystem/Resource/resHandle.h b/src/KingSystem/Resource/resHandle.h index 32993f0d..e97ff259 100644 --- a/src/KingSystem/Resource/resHandle.h +++ b/src/KingSystem/Resource/resHandle.h @@ -73,6 +73,7 @@ public: sead::SafeString makeEmptyString(); + ResourceUnit* getUnit() const { return mUnit; } void setUnit(ResourceUnit* unit) { mUnit = unit; } bool isLinked() const { return mListNode.isLinked(); } diff --git a/src/KingSystem/Resource/resModelResourceDivide.cpp b/src/KingSystem/Resource/resModelResourceDivide.cpp new file mode 100644 index 00000000..772fac7f --- /dev/null +++ b/src/KingSystem/Resource/resModelResourceDivide.cpp @@ -0,0 +1,7 @@ +#include "KingSystem/Resource/resModelResourceDivide.h" + +namespace ksys::res { + +SEAD_SINGLETON_DISPOSER_IMPL(ModelResourceDivide) + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resModelResourceDivide.h b/src/KingSystem/Resource/resModelResourceDivide.h new file mode 100644 index 00000000..1e7b9576 --- /dev/null +++ b/src/KingSystem/Resource/resModelResourceDivide.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include +#include "KingSystem/Resource/resHandle.h" + +namespace al { +class ByamlIter; +} + +namespace ksys::res { + +class ModelResourceDivide { + SEAD_SINGLETON_DISPOSER(ModelResourceDivide) + ModelResourceDivide() = default; + virtual ~ModelResourceDivide(); + +public: + void init(sead::Heap* heap); + + const char* getModelResource(const sead::SafeString& model_name, + const sead::SafeString& fmdb_name) const; + +private: + al::ByamlIter* mIter{}; + Handle mHandle; +}; +KSYS_CHECK_SIZE_NX150(ModelResourceDivide, 0x80); + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resResource.h b/src/KingSystem/Resource/resResource.h index d8613219..675fe739 100644 --- a/src/KingSystem/Resource/resResource.h +++ b/src/KingSystem/Resource/resResource.h @@ -21,7 +21,7 @@ public: Resource(); ~Resource() override; - void doCreate_(u8* buffer, u32 bufferSize, sead::Heap* heap) override; + void doCreate_(u8* buffer, u32 buffer_size, sead::Heap* heap) override; virtual bool needsParse() const { return false; } virtual bool m2_() { return true; } diff --git a/src/KingSystem/Resource/resResourceAISchedule.cpp b/src/KingSystem/Resource/resResourceAISchedule.cpp new file mode 100644 index 00000000..99e09384 --- /dev/null +++ b/src/KingSystem/Resource/resResourceAISchedule.cpp @@ -0,0 +1 @@ +#include "KingSystem/Resource/resResourceAISchedule.h" diff --git a/src/KingSystem/Resource/resResourceAISchedule.h b/src/KingSystem/Resource/resResourceAISchedule.h new file mode 100644 index 00000000..2d1ceb29 --- /dev/null +++ b/src/KingSystem/Resource/resResourceAISchedule.h @@ -0,0 +1,13 @@ +#pragma once + +#include "KingSystem/Resource/resResource.h" +#include "KingSystem/Utils/ParamIO.h" + +namespace ksys::res { + +// TODO +class AISchedule : public ParamIO, public Resource { + SEAD_RTTI_OVERRIDE(AISchedule, Resource) +}; + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resResourceAS.cpp b/src/KingSystem/Resource/resResourceAS.cpp new file mode 100644 index 00000000..e4d0dbdc --- /dev/null +++ b/src/KingSystem/Resource/resResourceAS.cpp @@ -0,0 +1 @@ +#include "KingSystem/Resource/resResourceAS.h" diff --git a/src/KingSystem/Resource/resResourceAS.h b/src/KingSystem/Resource/resResourceAS.h new file mode 100644 index 00000000..76f2af2d --- /dev/null +++ b/src/KingSystem/Resource/resResourceAS.h @@ -0,0 +1,42 @@ +#pragma once + +#include +#include +#include +#include +#include "KingSystem/Resource/resResource.h" +#include "KingSystem/Utils/ParamIO.h" +#include "KingSystem/Utils/Types.h" + +namespace ksys::res { + +class AS : public ParamIO, public Resource { + SEAD_RTTI_OVERRIDE(AS, Resource) +public: + struct Element {}; + + AS(); + + void doCreate_(u8*, u32, sead::Heap*) override {} + bool needsParse() const override { return true; } + bool parse_(u8* data, size_t size, sead::Heap* heap) override; + void finalize_() override; + +private: + sead::Buffer mElements; + agl::utl::ParameterList mElementsList; + + agl::utl::ParameterObj mCommonParams; + agl::utl::Parameter mRandomRateMin; + agl::utl::Parameter mRandomRateMax; + agl::utl::Parameter mForbidPartialDemoAS; + agl::utl::Parameter mUseIK; + u8 _3b8{}; + u8 _3b9{}; + u8 _3ba{}; + u8 _3bb{}; + sead::Heap* mHeap{}; +}; +KSYS_CHECK_SIZE_NX150(AS, 0x3c8); + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resResourceASList.cpp b/src/KingSystem/Resource/resResourceASList.cpp new file mode 100644 index 00000000..31880bbf --- /dev/null +++ b/src/KingSystem/Resource/resResourceASList.cpp @@ -0,0 +1,7 @@ +#include "KingSystem/Resource/resResourceASList.h" + +namespace ksys::res { + +ASList::ASList() : ParamIO("aslist", 0) {} + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resResourceASList.h b/src/KingSystem/Resource/resResourceASList.h new file mode 100644 index 00000000..34795aa4 --- /dev/null +++ b/src/KingSystem/Resource/resResourceASList.h @@ -0,0 +1,89 @@ +#pragma once + +#include +#include +#include +#include +#include +#include "KingSystem/Resource/resResource.h" +#include "KingSystem/Utils/ParamIO.h" + +namespace ksys::res { + +class AS; + +class ASList : public ParamIO, public Resource { + SEAD_RTTI_OVERRIDE(ASList, Resource) +public: + struct ASDefine { + const char* getFileName() const { return file_name.ref().cstr(); } + + agl::utl::Parameter name; + agl::utl::Parameter file_name; + agl::utl::ParameterObj obj; + AS* as; + }; + KSYS_CHECK_SIZE_NX150(ASDefine, 0x88); + + struct CFDefine { + agl::utl::Parameter name; + agl::utl::ParameterObj pre_obj; + sead::Buffer posts; + agl::utl::ParameterList posts_list; + sead::Buffer excepts; + agl::utl::ParameterObj obj; + agl::utl::ParameterList excepts_list; + }; + KSYS_CHECK_SIZE_NX150(CFDefine, 0x138); + + struct AddRes { + agl::utl::Parameter _0; + agl::utl::Parameter _28; + agl::utl::Parameter _50; + agl::utl::ParameterObj obj; + }; + KSYS_CHECK_SIZE_NX150(AddRes, 0xa0); + + struct Common { + agl::utl::Parameter rate_all; + agl::utl::ParameterObj obj; + }; + KSYS_CHECK_SIZE_NX150(Common, 0x50); + + struct Buffers { + Buffers() { _0 = 0; } + + s32 _0; + sead::Buffer as_defines; + sead::Buffer cf_defines; + sead::Buffer add_reses; + }; + + ASList(); + ~ASList() override; + + void doCreate_(u8* buffer, u32 buffer_size, sead::Heap* heap) override; + bool needsParse() const override { return true; } + bool parse_(u8* data, size_t size, sead::Heap* heap) override; + + const sead::Buffer& getASDefines() const { return mBuffers.as_defines; } + const sead::Buffer& getCFDefines() const { return mBuffers.cf_defines; } + const sead::Buffer& getAddReses() const { return mBuffers.add_reses; } + const Common& getCommon() const { return mCommon.ref(); } + + void addAS_(s32 index, AS* as); + +protected: + bool finishParsing_() override; + bool m7_() override; + +private: + Buffers mBuffers; + agl::utl::ParameterList mCFDefinesList; + agl::utl::ParameterList mASDefinesList; + agl::utl::ParameterList mAddResesList; + sead::StorageFor mCommon{sead::ZeroInitializeTag{}}; +}; +KSYS_CHECK_SIZE_NX150(ASList, 0x410); + +} // namespace ksys::res 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/resResourceAnimInfo.cpp b/src/KingSystem/Resource/resResourceAnimInfo.cpp new file mode 100644 index 00000000..b70e4e2d --- /dev/null +++ b/src/KingSystem/Resource/resResourceAnimInfo.cpp @@ -0,0 +1 @@ +#include "KingSystem/Resource/resResourceAnimInfo.h" diff --git a/src/KingSystem/Resource/resResourceAnimInfo.h b/src/KingSystem/Resource/resResourceAnimInfo.h new file mode 100644 index 00000000..d25f9203 --- /dev/null +++ b/src/KingSystem/Resource/resResourceAnimInfo.h @@ -0,0 +1,13 @@ +#pragma once + +#include "KingSystem/Resource/resResource.h" +#include "KingSystem/Utils/ParamIO.h" + +namespace ksys::res { + +// TODO +class AnimInfo : public ParamIO, public Resource { + SEAD_RTTI_OVERRIDE(AnimInfo, Resource) +}; + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resResourceAttClient.cpp b/src/KingSystem/Resource/resResourceAttClient.cpp new file mode 100644 index 00000000..2bbe4f26 --- /dev/null +++ b/src/KingSystem/Resource/resResourceAttClient.cpp @@ -0,0 +1,7 @@ +#include "KingSystem/Resource/resResourceAttClient.h" + +namespace ksys::res { + +AttClient::AttClient() : ParamIO("atcl", 0) {} + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resResourceAttClient.h b/src/KingSystem/Resource/resResourceAttClient.h new file mode 100644 index 00000000..808b8c81 --- /dev/null +++ b/src/KingSystem/Resource/resResourceAttClient.h @@ -0,0 +1,45 @@ +#pragma once + +#include +#include +#include +#include +#include "KingSystem/ActorSystem/actAttention.h" +#include "KingSystem/Resource/resResource.h" +#include "KingSystem/Utils/ParamIO.h" +#include "KingSystem/Utils/Types.h" + +namespace ksys::res { + +class AttClient : public ParamIO, public Resource { + SEAD_RTTI_OVERRIDE(AttClient, Resource) +public: + struct Check {}; + + AttClient(); + ~AttClient() override; + + act::AttType getAttType() const { return mAttType; } + act::AttActionCode getActionCode() const { return mActionCode; } + act::AttPriorityType getPriorityType() const { return mPriorityType; } + const sead::SafeString& getPriorityTypeStr() const { return mPriorityTypeStr; } + const sead::Buffer& getChecks() const { return mChecks; } + + void doCreate_(u8*, u32, sead::Heap*) override {} + bool needsParse() const override { return true; } + bool parse_(u8* data, size_t size, sead::Heap* heap) override; + +private: + act::AttType mAttType = act::AttType::Action; + act::AttActionCode mActionCode = act::AttActionCode::None; + act::AttPriorityType mPriorityType = act::AttPriorityType::Default; + sead::FixedSafeString<32> mPriorityTypeStr; + agl::utl::ParameterObj mAttClientParamsObj; + agl::utl::Parameter> mAttTypeParam; + agl::utl::Parameter> mActionTypeParam; + agl::utl::Parameter> mPriorityTypeParam; + sead::Buffer mChecks; +}; +KSYS_CHECK_SIZE_NX150(AttClient, 0x428); + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resResourceAttClientList.cpp b/src/KingSystem/Resource/resResourceAttClientList.cpp new file mode 100644 index 00000000..c764ef74 --- /dev/null +++ b/src/KingSystem/Resource/resResourceAttClientList.cpp @@ -0,0 +1 @@ +#include "KingSystem/Resource/resResourceAttClientList.h" diff --git a/src/KingSystem/Resource/resResourceAttClientList.h b/src/KingSystem/Resource/resResourceAttClientList.h new file mode 100644 index 00000000..aaf85966 --- /dev/null +++ b/src/KingSystem/Resource/resResourceAttClientList.h @@ -0,0 +1,54 @@ +#pragma once + +#include +#include +#include +#include +#include "KingSystem/Resource/resResource.h" +#include "KingSystem/Utils/ParamIO.h" +#include "KingSystem/Utils/Types.h" + +namespace ksys::res { + +class AttClient; + +class AttClientList : public ParamIO, public Resource { + SEAD_RTTI_OVERRIDE(AttClientList, Resource) +public: + struct AttPos { + agl::utl::Parameter _0; + agl::utl::Parameter _28; + agl::utl::Parameter _50; + agl::utl::Parameter _78; + }; + KSYS_CHECK_SIZE_NX150(AttPos, 0x98); + + struct Client { + const char* getFileName() const { return file_name.ref().cstr(); } + + agl::utl::Parameter name; + agl::utl::Parameter file_name; + agl::utl::Parameter is_valid; + agl::utl::ParameterObj obj; + AttClient* client; + }; + KSYS_CHECK_SIZE_NX150(Client, 0xa8); + + AttClientList() : ParamIO("atcllist", 0) {} + + const AttPos& getAttPos() const { return mAttPos; } + 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; + AttPos mAttPos; + agl::utl::Parameter mForceEdit; + sead::Buffer mClients; +}; +KSYS_CHECK_SIZE_NX150(AttClientList, 0x3f0); + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resResourceBoneControl.cpp b/src/KingSystem/Resource/resResourceBoneControl.cpp new file mode 100644 index 00000000..b8d7521d --- /dev/null +++ b/src/KingSystem/Resource/resResourceBoneControl.cpp @@ -0,0 +1 @@ +#include "KingSystem/Resource/resResourceBoneControl.h" diff --git a/src/KingSystem/Resource/resResourceBoneControl.h b/src/KingSystem/Resource/resResourceBoneControl.h new file mode 100644 index 00000000..9adedd57 --- /dev/null +++ b/src/KingSystem/Resource/resResourceBoneControl.h @@ -0,0 +1,13 @@ +#pragma once + +#include "KingSystem/Resource/resResource.h" +#include "KingSystem/Utils/ParamIO.h" + +namespace ksys::res { + +// TODO +class BoneControl : public ParamIO, public Resource { + SEAD_RTTI_OVERRIDE(BoneControl, Resource) +}; + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resResourceChemical.cpp b/src/KingSystem/Resource/resResourceChemical.cpp new file mode 100644 index 00000000..fa7bd256 --- /dev/null +++ b/src/KingSystem/Resource/resResourceChemical.cpp @@ -0,0 +1 @@ +#include "KingSystem/Resource/resResourceChemical.h" diff --git a/src/KingSystem/Resource/resResourceChemical.h b/src/KingSystem/Resource/resResourceChemical.h new file mode 100644 index 00000000..bb9ffe9b --- /dev/null +++ b/src/KingSystem/Resource/resResourceChemical.h @@ -0,0 +1,13 @@ +#pragma once + +#include "KingSystem/Resource/resResource.h" +#include "KingSystem/Utils/ParamIO.h" + +namespace ksys::res { + +// TODO +class Chemical : public ParamIO, public Resource { + SEAD_RTTI_OVERRIDE(Chemical, Resource) +}; + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resResourceGameData.cpp b/src/KingSystem/Resource/resResourceGameData.cpp index 7020a57d..cc315128 100644 --- a/src/KingSystem/Resource/resResourceGameData.cpp +++ b/src/KingSystem/Resource/resResourceGameData.cpp @@ -1,7 +1,7 @@ #include "KingSystem/Resource/resResourceGameData.h" #include #include "KingSystem/GameData/gdtManager.h" -#include "KingSystem/Utils/Byaml.h" +#include "KingSystem/Utils/Byaml/Byaml.h" #include "KingSystem/Utils/HeapUtil.h" namespace ksys::res { diff --git a/src/KingSystem/Resource/resResourceGameSaveData.cpp b/src/KingSystem/Resource/resResourceGameSaveData.cpp index 108239f2..b832fb27 100644 --- a/src/KingSystem/Resource/resResourceGameSaveData.cpp +++ b/src/KingSystem/Resource/resResourceGameSaveData.cpp @@ -3,7 +3,7 @@ #include #include #include "KingSystem/GameData/gdtManager.h" -#include "KingSystem/Utils/Byaml.h" +#include "KingSystem/Utils/Byaml/Byaml.h" namespace ksys::res { 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/resResourceModelList.cpp b/src/KingSystem/Resource/resResourceModelList.cpp new file mode 100644 index 00000000..b5d6ed03 --- /dev/null +++ b/src/KingSystem/Resource/resResourceModelList.cpp @@ -0,0 +1,7 @@ +#include "KingSystem/Resource/resResourceModelList.h" + +namespace ksys::res { + +ModelList::ModelList() : ParamIO("modellist", 0) {} + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resResourceModelList.h b/src/KingSystem/Resource/resResourceModelList.h new file mode 100644 index 00000000..58038559 --- /dev/null +++ b/src/KingSystem/Resource/resResourceModelList.h @@ -0,0 +1,114 @@ +#pragma once + +#include +#include +#include +#include +#include "KingSystem/Resource/resResource.h" +#include "KingSystem/Utils/ParamIO.h" + +namespace ksys::res { + +// FIXME: incomplete +class ModelList : public ParamIO, public Resource { + SEAD_RTTI_OVERRIDE(ModelList, Resource) +public: + struct ControllerInfo { + agl::utl::Parameter _2b0; + agl::utl::Parameter _2d8; + agl::utl::ParameterObj mControllerInfo; + agl::utl::Parameter mBaseScale; + agl::utl::Parameter _358; + agl::utl::Parameter _380; + agl::utl::Parameter _3a0; + agl::utl::Parameter _3c8; + agl::utl::Parameter _3e8; + }; + KSYS_CHECK_SIZE_NX150(ControllerInfo, 0x160); + + struct Attention { + agl::utl::Parameter _0; + agl::utl::Parameter _20; + agl::utl::Parameter _48; + agl::utl::Parameter _70; + agl::utl::Parameter _90; + agl::utl::Parameter _b0; + agl::utl::Parameter _d8; + agl::utl::Parameter _100; + agl::utl::Parameter _128; + agl::utl::Parameter _150; + agl::utl::Parameter _178; + agl::utl::Parameter _1a0; + agl::utl::Parameter _1c8; + agl::utl::Parameter _1f0; + agl::utl::Parameter _210; + agl::utl::Parameter _238; + agl::utl::Parameter _260; + agl::utl::Parameter _280; + agl::utl::Parameter _2a8; + agl::utl::ParameterObj _2d0; + }; + KSYS_CHECK_SIZE_NX150(Attention, 0x300); + + struct Unit { + agl::utl::Parameter unit_name; + agl::utl::Parameter bind_bone; + agl::utl::ParameterObj obj; + }; + KSYS_CHECK_SIZE_NX150(Unit, 0x80); + + struct ModelData { + agl::utl::Parameter folder; + agl::utl::ParameterObj base_obj; + sead::Buffer units; + agl::utl::ParameterList unit_list; + agl::utl::ParameterList list; + }; + KSYS_CHECK_SIZE_NX150(ModelData, 0xf8); + + // Misspelling of "partical", which is a misspelling of "particle"? + struct Partial { + agl::utl::Parameter bone; + agl::utl::Parameter bind_flag; + agl::utl::Parameter recursible; + agl::utl::ParameterObj obj; + }; + KSYS_CHECK_SIZE_NX150(Partial, 0x98); + + struct AnmTarget { + agl::utl::Parameter num_as_slot; + agl::utl::Parameter is_partical_enable; + agl::utl::Parameter target_type; + agl::utl::ParameterObj base_obj; + sead::Buffer partials; + agl::utl::ParameterList partial_list; + agl::utl::ParameterList list; + }; + KSYS_CHECK_SIZE_NX150(AnmTarget, 0x130); + + ModelList(); + ~ModelList() override; + + void doCreate_(u8* buffer, u32 buffer_size, sead::Heap* heap) override; + bool needsParse() const override { return true; } + bool parse_(u8* data, size_t size, sead::Heap* heap) override; + + const ControllerInfo& getControllerInfo() const { return mControllerInfo.ref(); } + const Attention& getAttention() const { return mAttention.ref(); } + const sead::Buffer& getModelData() const { return mModelData; } + const sead::Buffer& getAnmTargets() const { return mAnmTargets; } + bool is7C8() const { return _7c8; } + +private: + sead::StorageFor mControllerInfo{sead::ZeroInitializeTag{}}; + sead::StorageFor mAttention{sead::ZeroInitializeTag{}}; + u8* mRawData{}; + sead::Buffer mModelData; + agl::utl::ParameterList mModelDataList; + sead::Buffer mAnmTargets; + agl::utl::ParameterList mAnmTargetList; + bool _7c8 = false; +}; +KSYS_CHECK_SIZE_NX150(ModelList, 0x7d0); + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resResourcePhysics.cpp b/src/KingSystem/Resource/resResourcePhysics.cpp new file mode 100644 index 00000000..89054e81 --- /dev/null +++ b/src/KingSystem/Resource/resResourcePhysics.cpp @@ -0,0 +1 @@ +#include "KingSystem/Resource/resResourcePhysics.h" diff --git a/src/KingSystem/Resource/resResourcePhysics.h b/src/KingSystem/Resource/resResourcePhysics.h new file mode 100644 index 00000000..fb95e0c1 --- /dev/null +++ b/src/KingSystem/Resource/resResourcePhysics.h @@ -0,0 +1,13 @@ +#pragma once + +#include "KingSystem/Resource/resResource.h" +#include "KingSystem/Utils/ParamIO.h" + +namespace ksys::res { + +// TODO +class Physics : public ParamIO, public Resource { + SEAD_RTTI_OVERRIDE(Physics, Resource) +}; + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resResourceRagdollBlendWeight.cpp b/src/KingSystem/Resource/resResourceRagdollBlendWeight.cpp new file mode 100644 index 00000000..f0b511a8 --- /dev/null +++ b/src/KingSystem/Resource/resResourceRagdollBlendWeight.cpp @@ -0,0 +1 @@ +#include "KingSystem/Resource/resResourceRagdollBlendWeight.h" diff --git a/src/KingSystem/Resource/resResourceRagdollBlendWeight.h b/src/KingSystem/Resource/resResourceRagdollBlendWeight.h new file mode 100644 index 00000000..fbc76b92 --- /dev/null +++ b/src/KingSystem/Resource/resResourceRagdollBlendWeight.h @@ -0,0 +1,13 @@ +#pragma once + +#include "KingSystem/Resource/resResource.h" +#include "KingSystem/Utils/ParamIO.h" + +namespace ksys::res { + +// TODO +class RagdollBlendWeight : public ParamIO, public Resource { + SEAD_RTTI_OVERRIDE(RagdollBlendWeight, Resource) +}; + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resResourceRagdollConfig.cpp b/src/KingSystem/Resource/resResourceRagdollConfig.cpp new file mode 100644 index 00000000..e5c27c33 --- /dev/null +++ b/src/KingSystem/Resource/resResourceRagdollConfig.cpp @@ -0,0 +1 @@ +#include "KingSystem/Resource/resResourceRagdollConfig.h" diff --git a/src/KingSystem/Resource/resResourceRagdollConfig.h b/src/KingSystem/Resource/resResourceRagdollConfig.h new file mode 100644 index 00000000..d9768b22 --- /dev/null +++ b/src/KingSystem/Resource/resResourceRagdollConfig.h @@ -0,0 +1,13 @@ +#pragma once + +#include "KingSystem/Resource/resResource.h" +#include "KingSystem/Utils/ParamIO.h" + +namespace ksys::res { + +// TODO +class RagdollConfig : public ParamIO, public Resource { + SEAD_RTTI_OVERRIDE(RagdollConfig, Resource) +}; + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resResourceRagdollConfigList.cpp b/src/KingSystem/Resource/resResourceRagdollConfigList.cpp new file mode 100644 index 00000000..218c20b8 --- /dev/null +++ b/src/KingSystem/Resource/resResourceRagdollConfigList.cpp @@ -0,0 +1 @@ +#include "KingSystem/Resource/resResourceRagdollConfigList.h" diff --git a/src/KingSystem/Resource/resResourceRagdollConfigList.h b/src/KingSystem/Resource/resResourceRagdollConfigList.h new file mode 100644 index 00000000..f5975628 --- /dev/null +++ b/src/KingSystem/Resource/resResourceRagdollConfigList.h @@ -0,0 +1,65 @@ +#pragma once + +#include +#include +#include +#include +#include "KingSystem/Resource/resResource.h" +#include "KingSystem/Utils/ParamIO.h" +#include "KingSystem/Utils/Types.h" + +namespace ksys::res { + +class RagdollConfig; + +class RagdollConfigList : public ParamIO, public Resource { + SEAD_RTTI_OVERRIDE(RagdollConfigList, Resource) +public: + struct ImpulseParam { + const char* getFileName() const { return file_name.ref().cstr(); } + + agl::utl::Parameter file_name; + agl::utl::ParameterObj obj; + RagdollConfig* config; + }; + KSYS_CHECK_SIZE_NX150(ImpulseParam, 0x60); + + struct BodyParam : agl::utl::ParameterObj { + agl::utl::Parameter rigid_name; + agl::utl::Parameter friction_scale; + agl::utl::Parameter buoyancy_scale; + }; + KSYS_CHECK_SIZE_NX150(BodyParam, 0x98); + + RagdollConfigList(); + ~RagdollConfigList() override; + + void doCreate_(u8*, u32, sead::Heap*) override {} + bool needsParse() const override { return true; } + bool parse_(u8* data, size_t size, sead::Heap* heap) override; + bool finishParsing_() override; + bool m7_() override; + + const sead::Buffer& getImpulseParams() const { return mImpulseParams; } + f32 getUpperLimitHeight() const { return mUpperLimitHeight.ref(); } + f32 getLowerLimitHeight() const { return mLowerLimitHeight.ref(); } + const sead::Buffer& getBodyParams() const { return mBodyParams; } + + void addImpulseParamConfig_(s32 index, RagdollConfig* config) { + mImpulseParams[index].config = config; + } + +private: + agl::utl::ParameterList mImpulseParamList; + sead::Buffer mImpulseParams; + + agl::utl::ParameterObj mCommonData; + agl::utl::Parameter mUpperLimitHeight; + agl::utl::Parameter mLowerLimitHeight; + + agl::utl::ParameterList mBodyParamList; + sead::Buffer mBodyParams; +}; +KSYS_CHECK_SIZE_NX150(RagdollConfigList, 0x3d0); + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resResourceUMii.cpp b/src/KingSystem/Resource/resResourceUMii.cpp new file mode 100644 index 00000000..cefadea6 --- /dev/null +++ b/src/KingSystem/Resource/resResourceUMii.cpp @@ -0,0 +1,15 @@ +#include "KingSystem/Resource/resResourceUMii.h" + +namespace ksys::res { + +UMii::UMii() : ParamIO("umii", 0) {} + +UMii::~UMii() = default; + +bool UMii::parse_(u8* data, size_t, sead::Heap*) { + agl::utl::ResParameterArchive archive{data + mAllocSize}; + mData = archive.ptr(); + return true; +} + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resResourceUMii.h b/src/KingSystem/Resource/resResourceUMii.h new file mode 100644 index 00000000..1191c76e --- /dev/null +++ b/src/KingSystem/Resource/resResourceUMii.h @@ -0,0 +1,27 @@ +#pragma once + +#include "KingSystem/Resource/resResource.h" +#include "KingSystem/Utils/ParamIO.h" +#include "KingSystem/Utils/Types.h" + +namespace ksys::res { + +class UMii : public ParamIO, public Resource { + SEAD_RTTI_OVERRIDE(UMii, Resource) +public: + UMii(); + ~UMii() override; + + agl::utl::ResParameterArchiveData* getData() const { return mData; } + + bool needsParse() const override { return true; } + bool m2_() override { return mData != nullptr; } + void doCreate_(u8*, u32, sead::Heap*) override {} + bool parse_(u8* data, size_t size, sead::Heap* heap) override; + +private: + agl::utl::ResParameterArchiveData* mData{}; +}; +KSYS_CHECK_SIZE_NX150(UMii, 0x2b8); + +} // namespace ksys::res 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/resTempResourceLoader.cpp b/src/KingSystem/Resource/resTempResourceLoader.cpp new file mode 100644 index 00000000..704c7e30 --- /dev/null +++ b/src/KingSystem/Resource/resTempResourceLoader.cpp @@ -0,0 +1,220 @@ +#include "KingSystem/Resource/resTempResourceLoader.h" +#include +#include +#include "KingSystem/Resource/resArchiveWork.h" +#include "KingSystem/Resource/resResourceMgrTask.h" +#include "KingSystem/Resource/resSystem.h" +#include "KingSystem/Resource/resUnit.h" +#include "KingSystem/Utils/Debug.h" +#include "KingSystem/Utils/Thread/TaskThread.h" + +namespace ksys::res { + +TempResourceLoader::TempResourceLoader() = default; + +TempResourceLoader::~TempResourceLoader() { + unload(); +} + +void TempResourceLoader::unload() { + const auto* unit = mHandle.getUnit(); + const auto& path = unit ? unit->getPath() : sead::SafeString::cEmptyString; + sead::FormatFixedSafeString<256> message("(TempResourceLoader) アンロードします。: %s\n", + path.cstr()); + util::PrintDebug(message); + + if (mFlags.isOn(Flag::IsRetryingLoad)) { + stubbedLogFunction(); + mFlags.reset(Flag::IsRetryingLoad); + } else if (returnFalse()) { + stubbedLogFunction(); + } + + mFlags.reset(Flag::Loading); + mHandle.requestUnload(); + + if (mResource) { + ResourceMgrTask::instance()->unloadSeadResource(mResource); + mResource = nullptr; + } + + if (mWork) + mWork->setEvent(); +} + +bool TempResourceLoader::init(const InitArg& arg) { + mWork = arg.work; + return true; +} + +bool TempResourceLoader::isLoading() const { + return mFlags.isOn(Flag::Loading); +} + +bool TempResourceLoader::isSuccess() const { + return !isLoading() && mHandle.isSuccess(); +} + +bool TempResourceLoader::checkLoadStatus() const { + return !isLoading() && mHandle.checkLoadStatus(); +} + +void TempResourceLoader::requestLoad(LoadArg& arg) { + if (!arg.use_handle) + return; + + updateFlagsBeforeLoadingStarts(); + mPath = arg.load_req.mPath; + mLoadArg = arg; + mLoadArg.load_req.mPath = mPath; + arg.load_req.mArena = mWork->getArena(); + mHandle.requestLoad(arg.load_req.mPath, &arg.load_req); + if (returnFalse()) + stubbedLogFunction(); +} + +sead::DirectResource* TempResourceLoader::getResourceForLoadRequest(Context* context) { + if (!mLoadArg.use_handle || !mHandle.isFlag2Set() || mHandle.isFlag8Set() || + !mHandle.isReadyOrNeedsParse()) { + return nullptr; + } + + mHandle.parseResource(context); + + if (!mHandle.isSuccess()) { + if (mHandle.getStatus() != Handle::Status::_3) { + mFlags.reset(Flag::Loading); + sead::FormatFixedSafeString<256> message( + "(TempResourceLoader) メモリ不足以外のエラーでした。: %s(%d)\n", + mLoadArg.load_req.mPath.cstr(), s32(mHandle.getStatus())); + util::PrintDebug(message); + resetRetryFlag(); + return nullptr; + } + + if (!mLoadArg.retry_on_failure) { + mFlags.reset(Flag::Loading); + sead::FormatFixedSafeString<256> message( + "(TempResourceLoader) ロード失敗しました。: %s\n", mLoadArg.load_req.mPath.cstr()); + util::PrintDebug(message); + resetRetryFlag(); + return nullptr; + } + + setRetryFlag(); + mLoadArg.load_req.mArena = mWork->getArena(); + mHandle.requestLoad(mLoadArg.load_req.mPath, &mLoadArg.load_req); + return nullptr; + } + + mFlags.reset(Flag::Loading); + sead::FormatFixedSafeString<256> message("(TempResourceLoader) ロードに成功しました。: %s\n", + mLoadArg.load_req.mPath.cstr()); + util::PrintDebug(message); + resetRetryFlag(); + return mHandle.getResource(); +} + +sead::DirectResource* TempResourceLoader::load(TempResourceLoader::LoadArg& arg) { + updateFlagsBeforeLoadingStarts(); + + const auto* current_thread = sead::ThreadMgr::instance()->getCurrentThread(); + bool is_on_res_thread = false; + is_on_res_thread |= current_thread == ResourceMgrTask::instance()->getResourceMemoryThread(); + is_on_res_thread |= current_thread == ResourceMgrTask::instance()->getResourceLoadingThread(); + if (is_on_res_thread) + arg.use_handle = false; + + while (true) { + if (returnFalse()) + stubbedLogFunction(); + + bool use_handle = arg.use_handle; + auto* arena = mWork->getArena(); + if (use_handle) { + arg.load_req.mArena = arena; + mHandle.load(arg.load_req.mPath, &arg.load_req); + + if (mHandle.isSuccess()) + break; + + if (mHandle.getStatus() != Handle::Status::_3) { + mFlags.reset(Flag::Loading); + sead::FormatFixedSafeString<256> message( + "(TempResourceLoader) メモリ不足以外のエラーでした。: %s(%d)\n", + arg.load_req.mPath.cstr(), s32(mHandle.getStatus())); + util::PrintDebug(message); + resetRetryFlag(); + return nullptr; + } + } else { + ResourceMgrTask::DirectLoadArg load_arg{}; + load_arg.heap = arena->getHeap(); + load_arg.req._21 = false; + load_arg.req._22 = true; + load_arg.req.mPath = arg.load_req.mPath; + load_arg.req.mAocFileDevice = arg.load_req.mAocFileDevice; + load_arg.req.mLoadDataAlignment = arg.load_req.mLoadDataAlignment; + load_arg.req.mEntryFactory = arg.load_req.mEntryFactory; + load_arg.req._20 = false; + load_arg.req.mRequester = "TempResourceLoader"; + + if (arena->getHeap()->isLockEnabled()) + arena->getHeap()->getCriticalSection().lock(); + + mResource = ResourceMgrTask::instance()->load(load_arg); + + if (arena->getHeap()->isLockEnabled()) + arena->getHeap()->getCriticalSection().unlock(); + + if (mResource) { + mFlags.reset(Flag::Loading); + return mResource; + } + } + + if (!arg.retry_on_failure) { + mFlags.reset(Flag::Loading); + sead::FormatFixedSafeString<256> message( + "(TempResourceLoader) ロード失敗しました。: %s\n", arg.load_req.mPath.cstr()); + util::PrintDebug(message); + resetRetryFlag(); + return nullptr; + } + + setRetryFlag(); + if (!mWork->waitForEvent(arg.ms_between_attempts)) { + mFlags.reset(Flag::Loading); + return nullptr; + } + } + + mFlags.reset(Flag::Loading); + sead::FormatFixedSafeString<256> message("(TempResourceLoader) ロードに成功しました。: %s\n", + arg.load_req.mPath.cstr()); + util::PrintDebug(message); + resetRetryFlag(); + return mHandle.getResource(); +} + +sead::DirectResource* TempResourceLoader::getResource() const { + if (mHandle.getResource()) + return mHandle.getResource(); + return mResource; +} + +Handle::Status TempResourceLoader::getHandleStatus() const { + return mHandle.getStatus(); +} + +sead::FileDevice* TempResourceLoader::getHandleFileDevice() const { + if (mHandle.isSuccess()) + return mHandle.getUnit()->getLoadArg().device; + return nullptr; +} + +u32 TempResourceLoader::getWorkHeapSize() const { + return mWork ? mWork->getHeapSize() : 0; +} + +} // namespace ksys::res diff --git a/src/KingSystem/Resource/resTempResourceLoader.h b/src/KingSystem/Resource/resTempResourceLoader.h new file mode 100644 index 00000000..69e42ce1 --- /dev/null +++ b/src/KingSystem/Resource/resTempResourceLoader.h @@ -0,0 +1,87 @@ +#pragma once + +#include +#include +#include +#include "KingSystem/Resource/resHandle.h" +#include "KingSystem/Resource/resLoadRequest.h" +#include "KingSystem/Resource/resSystem.h" +#include "KingSystem/Utils/Types.h" + +namespace sead { +class DirectResource; +} + +namespace ksys::res { + +class ArchiveWork; + +class TempResourceLoader { +public: + struct InitArg { + ArchiveWork* work; + }; + + struct LoadArg { + bool retry_on_failure = true; + bool use_handle = true; + u32 ms_between_attempts = 0; + LoadRequest load_req; + }; + + TempResourceLoader(); + ~TempResourceLoader(); + + void unload(); + bool init(const InitArg& arg); + bool isLoading() const; + bool isSuccess() const; + bool checkLoadStatus() const; + void requestLoad(LoadArg& arg); + sead::DirectResource* getResourceForLoadRequest(Context* context); + sead::DirectResource* load(LoadArg& arg); + sead::DirectResource* getResource() const; + Handle::Status getHandleStatus() const; + sead::FileDevice* getHandleFileDevice() const; + u32 getWorkHeapSize() const; + +private: + enum class Flag : u8 { + Loading = 1, + IsRetryingLoad = 2, + }; + + void setRetryFlag() { + if (mFlags.isOff(Flag::IsRetryingLoad)) { + stubbedLogFunction(); + mFlags.set(Flag::IsRetryingLoad); + } else if (returnFalse()) { + stubbedLogFunction(); + } + } + + void resetRetryFlag() { + if (mFlags.isOn(Flag::IsRetryingLoad)) { + stubbedLogFunction(); + mFlags.reset(Flag::IsRetryingLoad); + } else if (returnFalse()) { + stubbedLogFunction(); + } + } + + void updateFlagsBeforeLoadingStarts() { + mFlags.reset(Flag::Loading); + mFlags.reset(Flag::IsRetryingLoad); + mFlags.set(Flag::Loading); + } + + sead::TypedBitFlag mFlags; + sead::DirectResource* mResource{}; + ArchiveWork* mWork{}; + Handle mHandle; + LoadArg mLoadArg; + sead::FixedSafeString<128> mPath; +}; +KSYS_CHECK_SIZE_NX150(TempResourceLoader, 0x188); + +} // 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/Resource/resUnit.h b/src/KingSystem/Resource/resUnit.h index 8cbfa907..61a5b544 100644 --- a/src/KingSystem/Resource/resUnit.h +++ b/src/KingSystem/Resource/resUnit.h @@ -94,6 +94,8 @@ public: void attachHandle(Handle* handle); + const sead::SafeString& getPath() const { return mPath; } + const sead::ResourceMgr::LoadArg& getLoadArg() const { return mLoadArg; } s32 getRefCount() const; Status getStatus() const; diff --git a/src/KingSystem/Utils/Byaml.cpp b/src/KingSystem/Utils/Byaml.cpp deleted file mode 100644 index 23d82bb9..00000000 --- a/src/KingSystem/Utils/Byaml.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "KingSystem/Utils/Byaml.h" diff --git a/src/KingSystem/Utils/Byaml/Byaml.cpp b/src/KingSystem/Utils/Byaml/Byaml.cpp new file mode 100644 index 00000000..2fe0dac1 --- /dev/null +++ b/src/KingSystem/Utils/Byaml/Byaml.cpp @@ -0,0 +1,402 @@ +#include "KingSystem/Utils/Byaml/Byaml.h" +#include +#include +#include "KingSystem/Utils/Byaml/ByamlArrayIter.h" +#include "KingSystem/Utils/Byaml/ByamlData.h" +#include "KingSystem/Utils/Byaml/ByamlHashIter.h" +#include "KingSystem/Utils/Byaml/ByamlLocal.h" +#include "KingSystem/Utils/Byaml/ByamlStringTableIter.h" + +namespace al { + +ByamlIter::ByamlIter() : mData(nullptr), mRootNode(nullptr) {} + +ByamlIter::ByamlIter(const u8* data) { + mData = data; + mRootNode = nullptr; + if (mData) { + if (ByamlLocalUtil::verifiByaml(mData)) { + const ByamlHeader* header = reinterpret_cast(mData); + u32 data_root_offset = header->getDataOffset(); + if (data_root_offset) { + mRootNode = &mData[data_root_offset]; + } + } else { + mData = nullptr; + mRootNode = nullptr; + } + } +} + +ByamlIter::ByamlIter(const u8* data, const u8* root_node) : mData(data), mRootNode(root_node) {} + +ByamlIter::ByamlIter(const ByamlIter& other) : mData(other.mData), mRootNode(other.mRootNode) {} + +ByamlIter& ByamlIter::operator=(const ByamlIter& rhs) { + if (this != &rhs) { + // This is formally undefined behavior because ByamlIter is not trivially copyable + // (since it has non-trivial copy constructors and copy assignment operators) + // but those are effectively trivial so this will work in practice. + // This is what Nintendo did and it is required for matching. + sead::MemUtil::copy(this, &rhs, sizeof(*this)); + } + return *this; +} + +bool ByamlIter::isValid() const { + return mData != nullptr; +} + +bool ByamlIter::isTypeHash() const { + const ByamlContainerHeader* node = reinterpret_cast(mRootNode); + return node && node->getType() == ByamlType::Hash; +} + +bool ByamlIter::isTypeArray() const { + const ByamlContainerHeader* node = reinterpret_cast(mRootNode); + return node && node->getType() == ByamlType::Array; +} + +bool ByamlIter::isTypeContainer() const { + return isTypeArray() || isTypeHash(); +} + +bool ByamlIter::isExistKey(const char* key) const { + if (!mRootNode) { + return false; + } + + if (!isTypeHash()) { + return false; + } + + const s32 index = getKeyIndex(key); + if (index < 0) { + return 0; + } + + ByamlHashIter node_hash(mRootNode); + return node_hash.findPair(index); +} + +s32 ByamlIter::getKeyIndex(const char* key) const { + const ByamlStringTableIter table = ByamlLocalUtil::getHashKeyTableIter(mData); + return table.findStringIndex(key); +} + +s32 ByamlIter::getSize() const { + if (!mRootNode) { + return 0; + } + + if (isTypeContainer()) { + return ByamlLocalUtil::getContainerSize(mRootNode); + } + + return 0; +} + +ByamlIter ByamlIter::getIterByIndex(s32 index) const { + ByamlData data; + if (!getByamlDataByIndex(&data, index)) { + return ByamlIter(); + } + + return getIterFromData(data); +} + +ByamlIter ByamlIter::getIterByKey(const char* key) const { + ByamlData data; + if (!getByamlDataByKey(&data, key)) { + return ByamlIter(); + } + + return getIterFromData(data); +} + +ByamlIter ByamlIter::getIterFromData(const ByamlData& data) const { + if (data.getType() == ByamlType::Hash || data.getType() == ByamlType::Array) { + return ByamlIter(mData, &mData[data.getValue()]); + } + + if (data.getType() == ByamlType::Null) { + return ByamlIter(mData, nullptr); + } + + return ByamlIter(); +} + +bool ByamlIter::getByamlDataByIndex(ByamlData* data, s32 index) const { + if (isTypeArray()) { + ByamlArrayIter array_node(mRootNode); + return array_node.getDataByIndex(data, index); + } else if (isTypeHash()) { + ByamlHashIter hash_node(mRootNode); + return hash_node.getDataByIndex(data, index); + } + + return false; +} + +bool ByamlIter::getByamlDataByKey(ByamlData* data, const char* key) const { + if (!isTypeHash()) { + return false; + } + + auto* header = reinterpret_cast(mData); + const s32 offset = header->getHashKeyTableOffset(); + if (!offset) { + return false; + } + const ByamlStringTableIter table = ByamlStringTableIter(&mData[offset]); + + ByamlHashIter hash_node(mRootNode); + const s32 size = hash_node.getSize(); + if (size < 1) { + return false; + } + + // Binary Search + const ByamlHashPair* pair; + s32 start = 0; + s32 end = size; + s32 index; + while (true) { + if (start >= end) { + return false; + } + + index = (start + end) / 2; + pair = hash_node.getPairByIndex(index); + const char* str = table.getString(pair->getKey()); + s32 result = std::strcmp(key, str); + if (result == 0) + break; + if (result > 0) + start = index + 1; + else if (result < 0) + end = index; + } + + data->set(pair); + + return true; +} + +bool ByamlIter::getByamlDataAndKeyNameByIndex(ByamlData* data, const char** key, s32 index) const { + if (!isTypeHash()) { + return false; + } + + const ByamlHashIter hash_iter(mRootNode); + const ByamlHashPair* pair = hash_iter.getPairByIndex(index); + if (!pair) { + return false; + } + + if (data) { + data->set(pair); + } + + ByamlStringTableIter table_iter = ByamlLocalUtil::getHashKeyTableIter(mData); + *key = table_iter.getString(pair->getKey()); + return true; +} + +bool ByamlIter::getKeyName(const char** key, s32 index) const { + if (!mRootNode) { + return false; + } + + if (!isTypeHash()) { + return false; + } + + ByamlHashIter hash_node(mRootNode); + const ByamlHashPair* pair = hash_node.getPairByIndex(index); + if (!pair) { + return false; + } + + const ByamlStringTableIter hash_table = ByamlLocalUtil::getHashKeyTableIter(mData); + *key = hash_table.getString(pair->getKey()); + + return true; +} + +bool ByamlIter::tryGetIterByIndex(ByamlIter* iter, s32 index) const { + *iter = getIterByIndex(index); + return iter->isValid(); +} + +bool ByamlIter::tryGetIterByKey(ByamlIter* iter, const char* key) const { + *iter = getIterByKey(key); + return iter->isValid(); +} + +bool ByamlIter::tryGetIterAndKeyNameByIndex(ByamlIter* iter, const char** key, s32 index) const { + ByamlData data; + if (!getByamlDataAndKeyNameByIndex(&data, key, index)) { + *key = nullptr; + return tryGetIterByIndex(iter, index); + } + + *iter = getIterFromData(data); + return true; +} + +bool ByamlIter::tryGetStringByIndex(const char** value, s32 index) const { + ByamlData data; + if (!getByamlDataByIndex(&data, index)) { + return false; + } + + return tryConvertString(value, &data); +} + +bool ByamlIter::tryGetStringByKey(const char** value, const char* key) const { + ByamlData data; + if (!getByamlDataByKey(&data, key)) { + return false; + } + + return tryConvertString(value, &data); +} + +bool ByamlIter::tryConvertString(const char** value, const ByamlData* data) const { + if (data->getType() != ByamlType::String) { + return false; + } + + const auto string_table = ByamlLocalUtil::getStringTableIter(mData); + *value = string_table.getString(data->getValue()); + + return true; +} + +bool ByamlIter::tryGetIntByIndex(s32* value, s32 index) const { + ByamlData data; + if (!getByamlDataByIndex(&data, index)) { + return false; + } + + return tryConvertInt(value, &data); +} + +bool ByamlIter::tryGetIntByKey(s32* value, const char* key) const { + ByamlData data; + if (!getByamlDataByKey(&data, key)) { + return false; + } + + return tryConvertInt(value, &data); +} + +bool ByamlIter::tryConvertInt(s32* value, const ByamlData* data) const { + if (data->getType() != ByamlType::Int) { + return false; + } + + *value = data->getValue(); + return true; +} + +bool ByamlIter::tryGetUIntByIndex(u32* value, s32 index) const { + ByamlData data; + if (!getByamlDataByIndex(&data, index)) { + return false; + } + + return tryConvertUInt(value, &data); +} + +bool ByamlIter::tryGetUIntByKey(u32* value, const char* key) const { + ByamlData data; + if (!getByamlDataByKey(&data, key)) { + return false; + } + + return tryConvertUInt(value, &data); +} + +bool ByamlIter::tryConvertUInt(u32* value, const ByamlData* data) const { + if (data->getType() == ByamlType::Int) { + s32 signed_value = data->getValue(); + if (signed_value < 0) { + *value = 0; + return false; + } else { + *value = signed_value; + return true; + } + } else if (data->getType() == ByamlType::UInt) { + *value = data->getValue(); + return true; + } + + return false; +} + +bool ByamlIter::tryGetFloatByIndex(f32* value, s32 index) const { + ByamlData data; + if (!getByamlDataByIndex(&data, index)) { + return false; + } + + return tryConvertFloat(value, &data); +} + +bool ByamlIter::tryGetFloatByKey(f32* value, const char* key) const { + ByamlData data; + if (!getByamlDataByKey(&data, key)) { + return false; + } + + return tryConvertFloat(value, &data); +} + +bool ByamlIter::tryConvertFloat(f32* value, const ByamlData* data) const { + if (data->getType() != ByamlType::Float) { + return false; + } + + *value = data->getValue(); + return true; +} + +bool ByamlIter::tryGetBoolByIndex(bool* value, s32 index) const { + ByamlData data; + if (!getByamlDataByIndex(&data, index)) { + return false; + } + + return tryConvertBool(value, &data); +} + +bool ByamlIter::tryGetBoolByKey(bool* value, const char* key) const { + ByamlData data; + if (!getByamlDataByKey(&data, key)) { + return false; + } + + return tryConvertBool(value, &data); +} + +bool ByamlIter::tryConvertBool(bool* value, const ByamlData* data) const { + if (data->getType() != ByamlType::Bool) { + return false; + } + + *value = data->getValue() != 0; + return true; +} + +bool ByamlIter::isEqualData(const ByamlIter& other) const { + if (!mData || !other.mData) { + return false; + } + + return mData == other.mData && mRootNode == other.mRootNode; +} + +} // namespace al diff --git a/src/KingSystem/Utils/Byaml.h b/src/KingSystem/Utils/Byaml/Byaml.h similarity index 52% rename from src/KingSystem/Utils/Byaml.h rename to src/KingSystem/Utils/Byaml/Byaml.h index 5c600627..c13500d7 100644 --- a/src/KingSystem/Utils/Byaml.h +++ b/src/KingSystem/Utils/Byaml/Byaml.h @@ -4,12 +4,14 @@ #include #include +#include #include #include "KingSystem/Utils/Types.h" namespace al { struct ByamlData; +struct ByamlHashPair; enum class ByamlType { Invalid = 0, @@ -41,6 +43,9 @@ public: ByamlIter& operator=(const ByamlIter& rhs); + const u8* getData() const { return mData; } + const u8* getRootNode() const { return mRootNode; } + bool isValid() const; bool isTypeHash() const; bool isTypeArray() const; @@ -51,11 +56,13 @@ public: s32 getSize() const; - void getByamlDataByIndex(ByamlData* data, s32 index) const; - bool getByamlDataByKey(ByamlData* data, const char* key) const; - bool getByamlDataByKeyIndex(ByamlData* data, s32 index) const; ByamlIter getIterByIndex(s32 index) const; ByamlIter getIterByKey(const char* key) const; + ByamlIter getIterFromData(const ByamlData& data) const; + bool getByamlDataByIndex(ByamlData* data, s32 index) const; + bool getByamlDataByKey(ByamlData* data, const char* key) const; + bool getByamlDataAndKeyNameByIndex(ByamlData* data, const char** key, s32 index) const; + bool getKeyName(const char** key, s32 index) const; bool tryGetIterByIndex(ByamlIter* iter, s32 index) const; @@ -68,6 +75,7 @@ public: bool tryGetIntByIndex(s32* value, s32 index) const; bool tryGetIntByKey(s32* value, const char* key) const; + bool tryConvertInt(s32* value, const ByamlData* data) const; bool tryGetUIntByIndex(u32* value, s32 index) const; bool tryGetUIntByKey(u32* value, const char* key) const; @@ -75,61 +83,96 @@ public: bool tryGetFloatByIndex(f32* value, s32 index) const; bool tryGetFloatByKey(f32* value, const char* key) const; + bool tryConvertFloat(f32* value, const ByamlData* data) const; bool tryGetBoolByIndex(bool* value, s32 index) const; bool tryGetBoolByKey(bool* value, const char* key) const; + bool tryConvertBool(bool* value, const ByamlData* data) const; bool isEqualData(const ByamlIter& other) const; + const char* getStringByIndex(s32 index) const { + const char* value; + if (!tryGetStringByIndex(&value, index)) + return ""; + return value; + } + + const char* getStringByKey(const char* key) const { + const char* value; + if (!tryGetStringByKey(&value, key)) + return ""; + return value; + } + + s32 getIntByIndex(s32 index) const { + s32 value; + if (!tryGetIntByIndex(&value, index)) + return {}; + return value; + } + + s32 getIntByKey(const char* key) const { + s32 value; + if (!tryGetIntByKey(&value, key)) + return {}; + return value; + } + + u32 getUIntByIndex(s32 index) const { + u32 value; + if (!tryGetUIntByIndex(&value, index)) + return {}; + return value; + } + + u32 getUIntByKey(const char* key) const { + u32 value; + if (!tryGetUIntByKey(&value, key)) + return {}; + return value; + } + + f32 getFloatByIndex(s32 index) const { + f32 value; + if (!tryGetFloatByIndex(&value, index)) + return {}; + return value; + } + + f32 getFloatByKey(const char* key) const { + f32 value; + if (!tryGetFloatByKey(&value, key)) + return {}; + return value; + } + + bool getBoolByIndex(s32 index) const { + bool value; + if (!tryGetBoolByIndex(&value, index)) + return {}; + return value; + } + + bool getBoolByKey(const char* key) const { + bool value; + if (!tryGetBoolByKey(&value, key)) + return {}; + return value; + } + private: const u8* mData = nullptr; const u8* mRootNode = nullptr; }; -class ByamlStringTableIter { -public: - explicit ByamlStringTableIter(const u8* data) : mData(data) {} - - const char* getString(s32 index) const; - s32 findStringIndex(const char* string) const; - -private: - const u8* mData; -}; - -class ByamlArrayIter { -public: - explicit ByamlArrayIter(const u8* data); - - const u8* getDataTable() const; - bool getDataByIndex(ByamlData* data, s32 index); - -private: - const u8* mData; -}; - -class ByamlHashIter { -public: - explicit ByamlHashIter(const u8* data); - - s32 getSize() const; - const u8* getPairTable() const; - bool getDataByIndex(ByamlData* data, s32 index) const; - bool getDataByKey(ByamlData* data, s32 key_index) const; - const u8* findPair(s32 key_index) const; - const u8* getPairByIndex(s32 index) const; - -private: - const u8* mData; -}; - struct ByamlHeader { u16 getTag() const; bool isInvertHeader() const; - u16 getVersion() const; - u16 getHashKeyTableOffset() const; - u16 getStringTableOffset() const; - u16 getDataOffset() const; + u16 getVersion() const { return version; }; + u32 getHashKeyTableOffset() const { return hash_key_table_offset; }; + u32 getStringTableOffset() const { return string_table_offset; }; + u32 getDataOffset() const { return data_offset; }; u16 magic; u16 version; @@ -140,32 +183,15 @@ struct ByamlHeader { KSYS_CHECK_SIZE_NX150(ByamlHeader, 0x10); struct ByamlContainerHeader { - ByamlType getType() const; - u32 getCount(bool byteswap) const; + ByamlType getType() const { + // Type is only the first byte + return ByamlType(*reinterpret_cast(&type_and_size)); + } + u32 getCount() const { return type_and_size >> 8; }; u32 type_and_size; }; -struct ByamlHashPair { - u32 getKey(bool byteswap) const; - ByamlType getType() const; - u32 getValue(bool byteswap) const; - - u32 name_and_type; - u32 value; -}; - -struct ByamlData { - u32 getValue() const { return value; } - ByamlType getType() const { return type; } - - void set(const ByamlHashPair* pair, bool byteswap); - void set(u8, u32, bool byteswap); - - u32 value = 0; - sead::SizedEnum type = ByamlType::Invalid; -}; - bool tryGetByamlS32(s32* value, const ByamlIter& iter, const char* key); bool tryGetByamlU32(u32* value, const ByamlIter& iter, const char* key); bool tryGetByamlF32(f32* value, const ByamlIter& iter, const char* key); diff --git a/src/KingSystem/Utils/Byaml/ByamlArrayIter.cpp b/src/KingSystem/Utils/Byaml/ByamlArrayIter.cpp new file mode 100644 index 00000000..fe5db205 --- /dev/null +++ b/src/KingSystem/Utils/Byaml/ByamlArrayIter.cpp @@ -0,0 +1,29 @@ +#include "KingSystem/Utils/Byaml/ByamlArrayIter.h" +#include "KingSystem/Utils/Byaml/Byaml.h" +#include "KingSystem/Utils/Byaml/ByamlData.h" +#include "KingSystem/Utils/Byaml/ByamlLocal.h" + +namespace al { +ByamlArrayIter::ByamlArrayIter(const u8* data) { + mData = data; +} + +const u32* ByamlArrayIter::getDataTable() const { + return reinterpret_cast(&mData[TypeTableOffset + getDataOffset()]); +} + +bool ByamlArrayIter::getDataByIndex(ByamlData* data, s32 index) { + if (index < 0) { + return false; + } + + if (index >= ByamlLocalUtil::getContainerSize(mData)) { + return false; + } + + data->setType(ByamlType(mData[TypeTableOffset + index])); + data->setValue(getDataTable()[index]); + + return true; +} +} // namespace al \ No newline at end of file diff --git a/src/KingSystem/Utils/Byaml/ByamlArrayIter.h b/src/KingSystem/Utils/Byaml/ByamlArrayIter.h new file mode 100644 index 00000000..a29cefc1 --- /dev/null +++ b/src/KingSystem/Utils/Byaml/ByamlArrayIter.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include +#include "KingSystem/Utils/Byaml/Byaml.h" +#include "KingSystem/Utils/Byaml/ByamlLocal.h" + +namespace al { + +class ByamlArrayIter { +public: + explicit ByamlArrayIter(const u8* data); + + const u32* getDataTable() const; + bool getDataByIndex(ByamlData* data, s32 index); + +private: + s32 getDataOffset() const { + const s32 size = ByamlLocalUtil::getContainerSize(mData); + return sead::Mathu::roundUp(size, 4); + } + + static constexpr s32 TypeTableOffset = 4; + + const u8* mData; +}; + +} // namespace al diff --git a/src/KingSystem/Utils/Byaml/ByamlData.cpp b/src/KingSystem/Utils/Byaml/ByamlData.cpp new file mode 100644 index 00000000..2aff5f96 --- /dev/null +++ b/src/KingSystem/Utils/Byaml/ByamlData.cpp @@ -0,0 +1,7 @@ +#include "KingSystem/Utils/Byaml/ByamlData.h" +#include "KingSystem/Utils/Byaml/Byaml.h" + +namespace al { +ByamlData::ByamlData() = default; + +} // namespace al \ No newline at end of file diff --git a/src/KingSystem/Utils/Byaml/ByamlData.h b/src/KingSystem/Utils/Byaml/ByamlData.h new file mode 100644 index 00000000..ed41dc82 --- /dev/null +++ b/src/KingSystem/Utils/Byaml/ByamlData.h @@ -0,0 +1,45 @@ +#pragma once + +#include +#include "KingSystem/Utils/Byaml/Byaml.h" +#include "KingSystem/Utils/Byaml/ByamlHashIter.h" + +namespace al { + +struct ByamlData { + ByamlData(); + + template + T getValue() const { + return *reinterpret_cast(&mValue); + } + ByamlType getType() const { return mType; } + + void set(const ByamlHashPair* pair) { + mType = pair->getType(); + mValue = pair->getValue(); + } + template + void set(const ByamlType& type, const T& value) { + mType = type; + mValue = *reinterpret_cast(&value); + } + + void setType(const ByamlType& type) { mType = type; } + + template + void setValue(const T& value) { + mValue = *reinterpret_cast(&value); + } + + void clear() { + mValue = 0; + mType = ByamlType::Invalid; + } + +private: + u32 mValue = 0; + sead::SizedEnum mType = ByamlType::Invalid; +}; + +} // namespace al diff --git a/src/KingSystem/Utils/Byaml/ByamlHashIter.cpp b/src/KingSystem/Utils/Byaml/ByamlHashIter.cpp new file mode 100644 index 00000000..edce10ee --- /dev/null +++ b/src/KingSystem/Utils/Byaml/ByamlHashIter.cpp @@ -0,0 +1,110 @@ +#include "KingSystem/Utils/Byaml/ByamlHashIter.h" +#include "KingSystem/Utils/Byaml/Byaml.h" +#include "KingSystem/Utils/Byaml/ByamlData.h" +#include "KingSystem/Utils/Byaml/ByamlLocal.h" + +namespace al { + +ByamlHashIter::ByamlHashIter(const u8* data) { + mData = data; +} + +s32 ByamlHashIter::getSize() const { + if (!mData) { + return 0; + } + + return ByamlLocalUtil::getContainerSize(mData); +} + +const ByamlHashPair* ByamlHashIter::getPairTable() const { + if (!mData) { + return nullptr; + } + + return reinterpret_cast(&mData[mTableOffset]); +} + +bool ByamlHashIter::getDataByIndex(ByamlData* data, s32 index) const { + if (!mData) { + return false; + } + + if (ByamlLocalUtil::getContainerSize(mData) == 0) { + return false; + } + + const ByamlHashPair* pair_table = getPairTable(); + const ByamlHashPair* pair = &pair_table[index]; + if (!pair) // This seems wrong, this can never be null? + { + return false; + } + + data->set(pair); + + return true; +} + +bool ByamlHashIter::getDataByKey(ByamlData* data, s32 key_index) const { + if (getSize() == 0) { + return false; + } + + const ByamlHashPair* pair = findPair(key_index); + if (!pair) { + return false; + } + + data->set(pair); + return true; +} + +const ByamlHashPair* ByamlHashIter::findPair(s32 key_index) const { + const ByamlHashPair* pair_table = getPairTable(); + if (!pair_table) { + return nullptr; + } + + if (ByamlLocalUtil::getContainerSize(mData) == 0) { + return nullptr; + } + + // Binary Search + s32 start = 0; + s32 end = getSize(); + s32 index; + const ByamlHashPair* pair; + while (true) { + if (start >= end) { + return nullptr; + } + + index = (start + end) / 2; + pair = &pair_table[index]; + s32 result = key_index - pair->getKey(); + if (result == 0) + break; + if (result > 0) + start = index + 1; + else if (result < 0) + end = index; + } + + return pair; +} + +const ByamlHashPair* ByamlHashIter::getPairByIndex(s32 index) const { + if (index < 0) { + return nullptr; + } + + if (getSize() <= index) { + return nullptr; + } + + const ByamlHashPair* pair_table = getPairTable(); + return pair_table + index; +} + +} // namespace al diff --git a/src/KingSystem/Utils/Byaml/ByamlHashIter.h b/src/KingSystem/Utils/Byaml/ByamlHashIter.h new file mode 100644 index 00000000..2ad55877 --- /dev/null +++ b/src/KingSystem/Utils/Byaml/ByamlHashIter.h @@ -0,0 +1,38 @@ +#pragma once + +#include +#include "KingSystem/Utils/Byaml/Byaml.h" +#include "prim/seadEndian.h" + +namespace al { + +struct ByamlData; +struct ByamlHashPair; + +class ByamlHashIter { +public: + explicit ByamlHashIter(const u8* data); + + s32 getSize() const; + const ByamlHashPair* getPairTable() const; + bool getDataByIndex(ByamlData* data, s32 index) const; + bool getDataByKey(ByamlData* data, s32 key_index) const; + const ByamlHashPair* findPair(s32 key_index) const; + const ByamlHashPair* getPairByIndex(s32 index) const; + +private: + const u8* mData; + + static constexpr s32 mTableOffset = 4; +}; + +struct ByamlHashPair { + u32 getKey() const { return mKeyAndType & 0xFFFFFF; } + ByamlType getType() const { return ByamlType(mKeyAndType >> 24); } + u32 getValue() const { return mValue; } + + u32 mKeyAndType; + u32 mValue; +}; + +} // namespace al diff --git a/src/KingSystem/Utils/Byaml/ByamlLocal.cpp b/src/KingSystem/Utils/Byaml/ByamlLocal.cpp new file mode 100644 index 00000000..321fc879 --- /dev/null +++ b/src/KingSystem/Utils/Byaml/ByamlLocal.cpp @@ -0,0 +1,3 @@ +#include "KingSystem/Utils/Byaml/ByamlLocal.h" + +namespace al::ByamlLocalUtil {} // namespace al::ByamlLocalUtil \ No newline at end of file diff --git a/src/KingSystem/Utils/Byaml/ByamlLocal.h b/src/KingSystem/Utils/Byaml/ByamlLocal.h new file mode 100644 index 00000000..faf51cac --- /dev/null +++ b/src/KingSystem/Utils/Byaml/ByamlLocal.h @@ -0,0 +1,38 @@ +#pragma once + +#include "KingSystem/Utils/Byaml/Byaml.h" +#include "KingSystem/Utils/Byaml/ByamlStringTableIter.h" + +#include + +namespace al::ByamlLocalUtil { + +inline ByamlStringTableIter getHashKeyTableIter(const u8* data) { + auto* header = reinterpret_cast(data); + const u8* ptr = &data[header->getHashKeyTableOffset()]; + return ByamlStringTableIter(ptr); +} + +inline ByamlStringTableIter getStringTableIter(const u8* data) { + auto* header = reinterpret_cast(data); + const u8* ptr = &data[header->getStringTableOffset()]; + return ByamlStringTableIter(ptr); +} + +inline s32 getContainerSize(const u8* data) { + auto* node = reinterpret_cast(data); + return node->getCount(); +} + +inline al::ByamlType getType(const u8* data) { + auto* node = reinterpret_cast(data); + return node->getType(); +} + +const char* getDataTypeString(s32 type); + +bool verifiByaml(const u8* data); +bool verifiByamlHeader(const u8* data); +bool verifiByamlStringTable(const u8* data); + +} // namespace al::ByamlLocalUtil diff --git a/src/KingSystem/Utils/Byaml/ByamlStringTableIter.cpp b/src/KingSystem/Utils/Byaml/ByamlStringTableIter.cpp new file mode 100644 index 00000000..f55e69c8 --- /dev/null +++ b/src/KingSystem/Utils/Byaml/ByamlStringTableIter.cpp @@ -0,0 +1,50 @@ +#include "KingSystem/Utils/Byaml/ByamlStringTableIter.h" +#include "KingSystem/Utils/Byaml/Byaml.h" +#include "KingSystem/Utils/Byaml/ByamlLocal.h" + +namespace al { + +ByamlStringTableIter::ByamlStringTableIter(const u8* data) { + mData = data; +} + +ByamlStringTableIter::ByamlStringTableIter(const ByamlStringTableIter& other) { + mData = other.mData; +} + +const char* ByamlStringTableIter::getString(s32 index) const { + const u32* string_offset_array = getStringOffsetArray(); + return reinterpret_cast(&mData[string_offset_array[index]]); +} + +s32 ByamlStringTableIter::findStringIndex(const char* string) const { + const u32* string_offset_array = getStringOffsetArray(); + u32 table_size = ByamlLocalUtil::getContainerSize(mData); + if (table_size == 0) { + return -1; + } + + // Binary Search + s32 start = 0; + s32 end = table_size; + s32 index; + while (true) { + if (start >= end) { + return -1; + } + + index = (start + end) / 2; + const char* str = reinterpret_cast(&mData[string_offset_array[index]]); + s32 result = std::strcmp(string, str); + if (result == 0) + break; + if (result > 0) + start = index + 1; + else if (result < 0) + end = index; + } + + return index; +} + +} // namespace al diff --git a/src/KingSystem/Utils/Byaml/ByamlStringTableIter.h b/src/KingSystem/Utils/Byaml/ByamlStringTableIter.h new file mode 100644 index 00000000..5e397ab4 --- /dev/null +++ b/src/KingSystem/Utils/Byaml/ByamlStringTableIter.h @@ -0,0 +1,27 @@ +#pragma once + +#include + +namespace al { + +class ByamlStringTableIter { +public: + explicit ByamlStringTableIter(const u8* data); + ByamlStringTableIter(const ByamlStringTableIter& other); + + const char* getString(s32 index) const; + s32 findStringIndex(const char* string) const; + + bool isValid() const { return mData != nullptr; } + + const u32* getStringOffsetArray() const { + return reinterpret_cast(&mData[TableOffset]); + } + +private: + const u8* mData; + + static constexpr u32 TableOffset = 4u; +}; + +} // namespace al \ No newline at end of file diff --git a/src/KingSystem/Utils/ByamlUtil.cpp b/src/KingSystem/Utils/Byaml/ByamlUtil.cpp similarity index 95% rename from src/KingSystem/Utils/ByamlUtil.cpp rename to src/KingSystem/Utils/Byaml/ByamlUtil.cpp index 6c46fff5..ef0df072 100644 --- a/src/KingSystem/Utils/ByamlUtil.cpp +++ b/src/KingSystem/Utils/Byaml/ByamlUtil.cpp @@ -1,4 +1,4 @@ -#include "KingSystem/Utils/Byaml.h" +#include "KingSystem/Utils/Byaml/Byaml.h" namespace al { diff --git a/src/KingSystem/Utils/ByamlLocal.cpp b/src/KingSystem/Utils/ByamlLocal.cpp deleted file mode 100644 index e981e804..00000000 --- a/src/KingSystem/Utils/ByamlLocal.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "KingSystem/Utils/ByamlLocal.h" diff --git a/src/KingSystem/Utils/ByamlLocal.h b/src/KingSystem/Utils/ByamlLocal.h deleted file mode 100644 index f10c68b8..00000000 --- a/src/KingSystem/Utils/ByamlLocal.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include - -namespace alByamlLocalUtil { - -const char* getDataTypeString(s32 type); - -const u8* getHashKeyTable(const u8* data); -const u8* getStringTable(const u8* data); - -bool verifiByaml(const u8* data); -bool verifiByamlHeader(const u8* data); -bool verifiByamlStringTable(const u8* data); - -} // namespace alByamlLocalUtil diff --git a/src/KingSystem/Utils/CMakeLists.txt b/src/KingSystem/Utils/CMakeLists.txt index 1fa59cff..45b8ecdd 100644 --- a/src/KingSystem/Utils/CMakeLists.txt +++ b/src/KingSystem/Utils/CMakeLists.txt @@ -21,11 +21,20 @@ target_sources(uking PRIVATE Thread/TaskThread.cpp Thread/TaskThread.h - Byaml.cpp - Byaml.h - ByamlLocal.cpp - ByamlLocal.h - ByamlUtil.cpp + Byaml/Byaml.cpp + Byaml/Byaml.h + Byaml/ByamlArrayIter.cpp + Byaml/ByamlArrayIter.h + Byaml/ByamlData.cpp + Byaml/ByamlData.h + Byaml/ByamlStringTableIter.cpp + Byaml/ByamlStringTableIter.h + Byaml/ByamlHashIter.cpp + Byaml/ByamlHashIter.h + Byaml/ByamlLocal.cpp + Byaml/ByamlLocal.h + Byaml/ByamlUtil.cpp + Debug.h FixedString.h HashUtil.h 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);