From 2f3d76852dc9c16af37c2598bcbe5a3c072e105e Mon Sep 17 00:00:00 2001 From: Naomi Ahmed Date: Fri, 10 Jun 2022 09:08:41 +0100 Subject: [PATCH] More logging, try loading all mips for Smite --- Unreal/FileSystem/GameFileSystem.cpp | 5 +++++ Unreal/FileSystem/GameFileSystemSmite.cpp | 15 +++++++++++---- Unreal/FileSystem/GameFileSystemSmite.h | 2 +- Unreal/UnrealMaterial/UnTexture3.cpp | 21 ++++++++++----------- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/Unreal/FileSystem/GameFileSystem.cpp b/Unreal/FileSystem/GameFileSystem.cpp index dcc7f3a4..6152655a 100644 --- a/Unreal/FileSystem/GameFileSystem.cpp +++ b/Unreal/FileSystem/GameFileSystem.cpp @@ -820,8 +820,13 @@ void appSetRootDirectory(const char *dir, bool recurse) #if SMITE if(GForceGame == GAME_Smite) { const CGameFileInfo* manifest = CGameFileInfo::Find("MergedFileIndexCache.bin"); + const CGameFileInfo* modernCheck = CGameFileInfo::Find("assembly.dat"); if (manifest) { + if(!modernCheck) { + appNotify("Smite: old manifest format, might crash."); + } + LoadSmiteManifest(manifest); } else diff --git a/Unreal/FileSystem/GameFileSystemSmite.cpp b/Unreal/FileSystem/GameFileSystemSmite.cpp index d688cb36..184fc86f 100644 --- a/Unreal/FileSystem/GameFileSystemSmite.cpp +++ b/Unreal/FileSystem/GameFileSystemSmite.cpp @@ -2,6 +2,7 @@ #include "UnCore.h" #include "GameFileSystem.h" #include "GameFileSystemSmite.h" +#include #if SMITE static FSmiteManifest* GSmiteManifest = NULL; @@ -21,18 +22,23 @@ void LoadSmiteManifest(const CGameFileInfo* info) { GSmiteManifest->Serialize(*loader); delete loader; - unguard + unguard; } -FArchive* GetSmiteBlob(const FGuid& guid, int level, const char* ext) { +FArchive* GetSmiteBlob(const char* name, int name_len, int level, const char* ext) { guard(GetSmiteBlob); if(GSmiteManifest == nullptr) { return nullptr; } - TArray* item = GSmiteManifest->Files.Find(guid); + MD5Context ctx; + md5Init(&ctx); + md5Update(&ctx, (unsigned char*)name, name_len); + md5Finalize(&ctx); + + TArray* item = GSmiteManifest->Files.Find(*reinterpret_cast(ctx.digest)); if(item == nullptr) { return nullptr; } @@ -46,6 +52,7 @@ FArchive* GetSmiteBlob(const FGuid& guid, int level, const char* ext) { appSprintf(ARRAY_ARG(filename), "%s.%s", bulk->GetDataArray().GetData(), ext); const CGameFileInfo* info = CGameFileInfo::Find(filename); if(info == nullptr) { + appNotify("Smite: can't find tfc %s for %s", filename, name); return nullptr; } @@ -60,7 +67,7 @@ FArchive* GetSmiteBlob(const FGuid& guid, int level, const char* ext) { return Ar; } } - unguard + unguard; return nullptr; } diff --git a/Unreal/FileSystem/GameFileSystemSmite.h b/Unreal/FileSystem/GameFileSystemSmite.h index 0a360837..42560084 100644 --- a/Unreal/FileSystem/GameFileSystemSmite.h +++ b/Unreal/FileSystem/GameFileSystemSmite.h @@ -29,6 +29,6 @@ struct FSmiteManifest void LoadSmiteManifest(const CGameFileInfo* info); -FArchive* GetSmiteBlob(const FGuid& guid, int level, const char* ext); +FArchive* GetSmiteBlob(const char* name, int name_len, int level, const char* ext); #endif // SMITE diff --git a/Unreal/UnrealMaterial/UnTexture3.cpp b/Unreal/UnrealMaterial/UnTexture3.cpp index 520baa07..5d06d957 100644 --- a/Unreal/UnrealMaterial/UnTexture3.cpp +++ b/Unreal/UnrealMaterial/UnTexture3.cpp @@ -644,13 +644,13 @@ static int GetRealTextureOffset_MH(const UTexture2D *Obj, int MipIndex) #endif // MARVEL_HEROES #if SMITE -#include #include "../FileSystem/GameFileSystemSmite.h" #include "../UnrealPackage/UnPackageUE3Reader.h" static bool LoadBulkTextureSMITE(const UTexture2D* texture, const TArray &MipsArray, int MipIndex, bool verbose) { static char buf[2048]; - texture->GetFullName(ARRAY_ARG(buf), true, true, true); char *s = buf; + texture->GetFullName(ARRAY_ARG(buf), true, true, true); + char *s = buf; int len = 0; if(verbose) { appPrintf("Smite: Finding %s (Mip %d) in MergedFileIndexCache\n", buf, MipIndex); @@ -660,13 +660,9 @@ static bool LoadBulkTextureSMITE(const UTexture2D* texture, const TArray(ctx.digest), MipIndex, "tfc"); + FArchive* Ar = GetSmiteBlob(buf, len, MipIndex, "tfc"); if(Ar == NULL) { appPrintf("Smite: unable to find %s (Mip %d) in MergedFileIndexCache\n", buf, MipIndex); return false; @@ -727,10 +723,8 @@ bool UTexture2D::LoadBulkTexture(const TArray &MipsArray, int if (TextureFileCacheName != "None") { #if SMITE - if(GForceGame == GAME_Smite) { - if(LoadBulkTextureSMITE(this, MipsArray, MipIndex, verbose)) { - return true; - } + if(Package && Package->Game == GAME_Smite) { + return LoadBulkTextureSMITE(this, MipsArray, MipIndex, verbose); } #endif // TFC file is assigned @@ -1091,6 +1085,11 @@ bool UTexture2D::GetTextureData(CTextureData &TexData) const //?? Separate this function ? //!! * -notfc cmdline switch //!! * material viewer: support switching mip levels (for xbox decompression testing) + #if SMITE + if(Package && Package->Game == GAME_Smite) { + bulkFailed = false; + } else + #endif if (Bulk.BulkDataFlags & BULKDATA_Unused) continue; // mip level is stripped if (!(Bulk.BulkDataFlags & BULKDATA_StoreInSeparateFile)) continue; // equals to BULKDATA_PayloadAtEndOfFile for UE4 // some optimization in a case of missing bulk file