Skip to content

Commit

Permalink
More logging, try loading all mips for Smite
Browse files Browse the repository at this point in the history
  • Loading branch information
yretenai committed Jun 10, 2022
1 parent fc617e5 commit 2f3d768
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
5 changes: 5 additions & 0 deletions Unreal/FileSystem/GameFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions Unreal/FileSystem/GameFileSystemSmite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "UnCore.h"
#include "GameFileSystem.h"
#include "GameFileSystemSmite.h"
#include <md5/md5.h>

#if SMITE
static FSmiteManifest* GSmiteManifest = NULL;
Expand All @@ -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<FSmiteFile>* item = GSmiteManifest->Files.Find(guid);
MD5Context ctx;
md5Init(&ctx);
md5Update(&ctx, (unsigned char*)name, name_len);
md5Finalize(&ctx);

TArray<FSmiteFile>* item = GSmiteManifest->Files.Find(*reinterpret_cast<FGuid*>(ctx.digest));
if(item == nullptr) {
return nullptr;
}
Expand All @@ -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;
}

Expand All @@ -60,7 +67,7 @@ FArchive* GetSmiteBlob(const FGuid& guid, int level, const char* ext) {
return Ar;
}
}
unguard
unguard;

return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion Unreal/FileSystem/GameFileSystemSmite.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 10 additions & 11 deletions Unreal/UnrealMaterial/UnTexture3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,13 +644,13 @@ static int GetRealTextureOffset_MH(const UTexture2D *Obj, int MipIndex)
#endif // MARVEL_HEROES

#if SMITE
#include <md5/md5.h>
#include "../FileSystem/GameFileSystemSmite.h"
#include "../UnrealPackage/UnPackageUE3Reader.h"

static bool LoadBulkTextureSMITE(const UTexture2D* texture, const TArray<FTexture2DMipMap> &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);
Expand All @@ -660,13 +660,9 @@ static bool LoadBulkTextureSMITE(const UTexture2D* texture, const TArray<FTextur
len++;
s++;
}
MD5Context ctx;
md5Init(&ctx);
md5Update(&ctx, (unsigned char*)buf, len);
md5Finalize(&ctx);

const FTexture2DMipMap &Mip = MipsArray[MipIndex];
FArchive* Ar = GetSmiteBlob(*reinterpret_cast<FGuid*>(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;
Expand Down Expand Up @@ -727,10 +723,8 @@ bool UTexture2D::LoadBulkTexture(const TArray<FTexture2DMipMap> &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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2f3d768

Please sign in to comment.