diff --git a/src/Core/Resource/Animation/CAnimEventData.h b/src/Core/Resource/Animation/CAnimEventData.h index 6dd889ed..ffdce5f3 100644 --- a/src/Core/Resource/Animation/CAnimEventData.h +++ b/src/Core/Resource/Animation/CAnimEventData.h @@ -5,6 +5,8 @@ class CAnimEventData : public CResource { + DECLARE_RESOURCE_TYPE(eAnimEventData) + struct SEvent { u32 mCharacterIndex; diff --git a/src/Core/Resource/CStringTable.h b/src/Core/Resource/CStringTable.h index 7540a5b3..a00fd538 100644 --- a/src/Core/Resource/CStringTable.h +++ b/src/Core/Resource/CStringTable.h @@ -72,6 +72,7 @@ public: TString TagName = rkStr.SubString(TagIdx + 1, NameEnd - TagIdx - 1); TString ParamString = rkStr.SubString(NameEnd + 1, TagEnd - NameEnd - 1); + if (ParamString.IsEmpty()) continue; // Font if (TagName == "font") @@ -103,6 +104,9 @@ public: else if (ImageType == "SA") TexturesStart = 4; + else if (ImageType == "B") + TexturesStart = 2; + else if (ImageType.IsHexString(false, IDLength * 2)) TexturesStart = 0; diff --git a/src/Core/Resource/Factory/CMaterialLoader.cpp b/src/Core/Resource/Factory/CMaterialLoader.cpp index 012d7464..bf5fe2aa 100644 --- a/src/Core/Resource/Factory/CMaterialLoader.cpp +++ b/src/Core/Resource/Factory/CMaterialLoader.cpp @@ -397,7 +397,10 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial() case 6: // Model Matrix case 10: // Yet-to-be-named break; - case 8: // Unknown/unsupported animation type + + // Unknown/unsupported animation type + case 8: + case 11: break; default: Log::FileError(mpFile->GetSourceString(), mpFile->Tell() - 8, "Unsupported animation mode encountered: " + TString::HexString((u32) pPass->mAnimMode)); diff --git a/src/Core/Resource/Factory/CUnsupportedFormatLoader.cpp b/src/Core/Resource/Factory/CUnsupportedFormatLoader.cpp index ee1cb6ab..4305db2a 100644 --- a/src/Core/Resource/Factory/CUnsupportedFormatLoader.cpp +++ b/src/Core/Resource/Factory/CUnsupportedFormatLoader.cpp @@ -3,6 +3,41 @@ #include "Core/GameProject/CResourceIterator.h" #include "Core/Resource/CWorld.h" +void CUnsupportedFormatLoader::PerformCheating(IInputStream& rFile, EGame Game, std::list& rAssetList) +{ + // Analyze file contents and check every sequence of 4/8 bytes for asset IDs + std::vector Data(rFile.Size() - rFile.Tell()); + rFile.ReadBytes(Data.data(), Data.size()); + + u32 MaxIndex = (Game <= eEchoes ? Data.size() - 3 : Data.size() - 7); + CAssetID ID; + + for (u32 iByte = 0; iByte < MaxIndex; iByte++) + { + if (Game <= eEchoes) + { + ID = ( (Data[iByte+0] << 24) | + (Data[iByte+1] << 16) | + (Data[iByte+2] << 8) | + (Data[iByte+3] << 0) ); + } + else + { + ID = ( ((u64) Data[iByte+0] << 56) | + ((u64) Data[iByte+1] << 48) | + ((u64) Data[iByte+2] << 40) | + ((u64) Data[iByte+3] << 32) | + ((u64) Data[iByte+4] << 24) | + ((u64) Data[iByte+5] << 16) | + ((u64) Data[iByte+6] << 8) | + ((u64) Data[iByte+7] << 0) ); + } + + if (gpResourceStore->IsResourceRegistered(ID)) + rAssetList.push_back(ID); + } +} + CAudioMacro* CUnsupportedFormatLoader::LoadCAUD(IInputStream& rCAUD, CResourceEntry *pEntry) { u32 Magic = rCAUD.ReadLong(); @@ -18,10 +53,15 @@ CAudioMacro* CUnsupportedFormatLoader::LoadCAUD(IInputStream& rCAUD, CResourceEn CAudioMacro *pMacro = new CAudioMacro(pEntry); pMacro->mMacroName = rCAUD.ReadString(); - // DKCR needs some reverse engineering work still in order to parse the file correctly, unfortunately + // DKCR is missing the sample data size value, and the bulk of the format isn't well understood, unfortunately if (Game == eReturns) { - Log::Warning("DKCR CAUD dependencies not being handled!"); + std::list AssetList; + PerformCheating(rCAUD, pEntry->Game(), AssetList); + + for (auto Iter = AssetList.begin(); Iter != AssetList.end(); Iter++) + pMacro->mSamples.push_back(*Iter); + return pMacro; } @@ -68,37 +108,13 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadDUMB(IInputStream& rDUMB, CResou return LoadHIER(rDUMB, pEntry); // Load other DUMB file. DUMB files don't have a set format - they're different between different files - std::vector Data(rDUMB.Size()); - rDUMB.ReadBytes(Data.data(), Data.size()); - CDependencyGroup *pGroup = new CDependencyGroup(pEntry); - u32 MaxIndex = (pEntry->Game() <= eEchoes ? Data.size() - 3 : Data.size() - 7); - CAssetID ID; - for (u32 iByte = 0; iByte < MaxIndex; iByte++) - { - if (pEntry->Game() <= eEchoes) - { - ID = ( (Data[iByte+0] << 24) | - (Data[iByte+1] << 16) | - (Data[iByte+2] << 8) | - (Data[iByte+3] << 0) ); - } - else - { - ID = ( ((u64) Data[iByte+0] << 56) | - ((u64) Data[iByte+1] << 48) | - ((u64) Data[iByte+2] << 40) | - ((u64) Data[iByte+3] << 32) | - ((u64) Data[iByte+4] << 24) | - ((u64) Data[iByte+5] << 16) | - ((u64) Data[iByte+6] << 8) | - ((u64) Data[iByte+7] << 0) ); - } + std::list DepList; + PerformCheating(rDUMB, pEntry->Game(), DepList); - if (gpResourceStore->IsResourceRegistered(ID)) - pGroup->AddDependency(ID); - } + for (auto Iter = DepList.begin(); Iter != DepList.end(); Iter++) + pGroup->AddDependency(*Iter); return pGroup; } diff --git a/src/Core/Resource/Factory/CUnsupportedFormatLoader.h b/src/Core/Resource/Factory/CUnsupportedFormatLoader.h index a5845ded..63870b4f 100644 --- a/src/Core/Resource/Factory/CUnsupportedFormatLoader.h +++ b/src/Core/Resource/Factory/CUnsupportedFormatLoader.h @@ -12,6 +12,8 @@ class CUnsupportedFormatLoader CDependencyGroup *mpGroup; CUnsupportedFormatLoader() {} + static void PerformCheating(IInputStream& rFile, EGame Game, std::list& rAssetList); + public: static CAudioMacro* LoadCAUD(IInputStream& rCAUD, CResourceEntry *pEntry); static CDependencyGroup* LoadCSNG(IInputStream& rCSNG, CResourceEntry *pEntry); diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index 71f7e437..670f9431 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -37,7 +37,7 @@ int main(int argc, char *argv[]) qInstallMessageHandler(QtLogRedirect); // Create editor resource store - gpEditorStore = new CResourceStore(L"../resources/EditorResourceDB.rdb"); + gpEditorStore = new CResourceStore("../resources/EditorResourceDB.rdb"); gpEditorStore->LoadResourceDatabase(); // Load templates diff --git a/templates/dkcr/MasterTemplate.xml b/templates/dkcr/MasterTemplate.xml index 9604456e..41bafcb4 100644 --- a/templates/dkcr/MasterTemplate.xml +++ b/templates/dkcr/MasterTemplate.xml @@ -102,7 +102,7 @@ - +