@@ -643,6 +643,97 @@ static int GetRealTextureOffset_MH(const UTexture2D *Obj, int MipIndex)
643
643
644
644
#endif // MARVEL_HEROES
645
645
646
+ #if SMITE
647
+ #include " ../FileSystem/GameFileSystemSmite.h"
648
+ #include " ../UnrealPackage/UnPackageUE3Reader.h"
649
+
650
+ static bool LoadBulkTextureSMITE (const UTexture2D* texture, const TArray<FTexture2DMipMap> &MipsArray, int MipIndex, bool verbose) {
651
+ FMemReader* MemAr = nullptr ;
652
+ const FTexture2DMipMap &Mip = MipsArray[MipIndex];
653
+
654
+ int i;
655
+ static char buf[2048 ];
656
+ for (i = 0 ; i < 4 ; ++i) {
657
+ static char tmp[2048 ];
658
+ texture->GetFullName (ARRAY_ARG (tmp), true , true , false );
659
+ switch (i) {
660
+ case 0 :
661
+ appSprintf (ARRAY_ARG (buf), " %s" , tmp);
662
+ break ;
663
+ case 1 :
664
+ if (texture->Package == nullptr ) {
665
+ continue ;
666
+ }
667
+ appSprintf (ARRAY_ARG (buf), " %s.%s" , texture->Package ->Name , tmp);
668
+ break ;
669
+ case 2 :
670
+ appSprintf (ARRAY_ARG (buf), " Textures.%s" , tmp);
671
+ break ;
672
+ case 3 :
673
+ if (texture->Package == nullptr ) {
674
+ continue ;
675
+ }
676
+ appSprintf (ARRAY_ARG (buf), " %s.Textures.%s" , texture->Package ->Name , tmp);
677
+ break ;
678
+ }
679
+ char *s = buf;
680
+ int len = 0 ;
681
+ if (verbose) {
682
+ appPrintf (" Smite: Finding %s (Mip %d) in MergedFileIndexCache\n " , buf, MipIndex);
683
+ }
684
+ while (*s) {
685
+ *s = toupper ((unsigned char ) *s);
686
+ len++;
687
+ s++;
688
+ }
689
+
690
+ MemAr = GetSmiteBlob (buf, len, MipIndex, " tfc" );
691
+ if (MemAr != NULL ) {
692
+ break ;
693
+ }
694
+ }
695
+
696
+ if (MemAr == NULL ) {
697
+ appPrintf (" Smite: unable to find %s (Mip %d) in MergedFileIndexCache\n " , texture->Name , MipIndex);
698
+ return false ;
699
+ }
700
+
701
+ FCompressedChunkHeader H;
702
+ *MemAr << H;
703
+ TArray<FCompressedChunk> Chunks;
704
+ FCompressedChunk *Chunk = new (Chunks) FCompressedChunk;
705
+ Chunk->UncompressedOffset = 0 ;
706
+ Chunk->UncompressedSize = H.Sum .UncompressedSize ;
707
+ Chunk->CompressedOffset = 0 ;
708
+ Chunk->CompressedSize = H.Sum .CompressedSize ;
709
+ FByteBulkData *Bulk = const_cast <FByteBulkData*>(&Mip.Data );
710
+ int flags = COMPRESS_LZO;
711
+ if (Bulk->BulkDataFlags & BULKDATA_CompressedOodle_SMITE) flags = COMPRESS_OODLE;
712
+ else if (Bulk->BulkDataFlags & BULKDATA_CompressedZlib) flags = COMPRESS_ZLIB;
713
+ else if (Bulk->BulkDataFlags & BULKDATA_CompressedLzx) flags = COMPRESS_LZX;
714
+
715
+ FUE3ArchiveReader* Ar = new FUE3ArchiveReader (MemAr, flags, Chunks);
716
+ Ar->IsFullyCompressed = true ;
717
+
718
+ if (verbose)
719
+ {
720
+ appPrintf (" Reading %s mip level %d (%dx%d) from TFC\n " , texture->Name , MipIndex, Mip.SizeX , Mip.SizeY );
721
+ }
722
+
723
+ Bulk->BulkDataSizeOnDisk = H.Sum .UncompressedSize ;
724
+ Bulk->ElementCount = H.Sum .UncompressedSize ;
725
+ Bulk->BulkDataOffsetInFile = 0 ;
726
+ int backup = Bulk->BulkDataFlags ;
727
+ Bulk->BulkDataFlags = 0 ; // wipe compression flags temporarily
728
+ Bulk->SerializeData (*Ar);
729
+ Bulk->BulkDataFlags = backup;
730
+
731
+ MemAr->Free ();
732
+ delete Ar;
733
+ return true ;
734
+ }
735
+ #endif // SMITE
736
+
646
737
647
738
bool UTexture2D::LoadBulkTexture (const TArray<FTexture2DMipMap> &MipsArray, int MipIndex, const char * tfcSuffix, bool verbose) const
648
739
{
@@ -656,6 +747,11 @@ bool UTexture2D::LoadBulkTexture(const TArray<FTexture2DMipMap> &MipsArray, int
656
747
FStaticString<MAX_PACKAGE_PATH> bulkFileName;
657
748
if (TextureFileCacheName != " None" )
658
749
{
750
+ #if SMITE
751
+ if (Package && Package->Game == GAME_Smite) {
752
+ return LoadBulkTextureSMITE (this , MipsArray, MipIndex, verbose);
753
+ }
754
+ #endif
659
755
// TFC file is assigned
660
756
bulkFileName = *TextureFileCacheName;
661
757
@@ -1014,6 +1110,11 @@ bool UTexture2D::GetTextureData(CTextureData &TexData) const
1014
1110
// ?? Separate this function ?
1015
1111
// !! * -notfc cmdline switch
1016
1112
// !! * material viewer: support switching mip levels (for xbox decompression testing)
1113
+ #if SMITE
1114
+ if (Package && Package->Game == GAME_Smite) {
1115
+ bulkFailed = false ;
1116
+ } else
1117
+ #endif
1017
1118
if (Bulk.BulkDataFlags & BULKDATA_Unused) continue ; // mip level is stripped
1018
1119
if (!(Bulk.BulkDataFlags & BULKDATA_StoreInSeparateFile)) continue ; // equals to BULKDATA_PayloadAtEndOfFile for UE4
1019
1120
// some optimization in a case of missing bulk file
0 commit comments