@@ -680,6 +680,15 @@ VTF::VTF(std::vector<std::byte>&& vtfData, bool parseHeaderOnly)
680680 if (resource.type == Resource::TYPE_THUMBNAIL_DATA) {
681681 ::swapImageDataEndianForConsole<true >(resource.data , this ->thumbnailFormat , 1 , 1 , 1 , this ->thumbnailWidth , this ->thumbnailHeight , 1 , this ->platform );
682682 } else if (resource.type == Resource::TYPE_IMAGE_DATA) {
683+ if (this ->platform == PLATFORM_PS3_ORANGEBOX) {
684+ bool ok;
685+ const auto reorderedFallbackData = ::convertBetweenDDSAndVTFMipOrderForXBOX<true >(false , resource.data , this ->format , this ->mipCount , this ->frameCount , this ->getFaceCount (), this ->width , this ->height , this ->depth , ok);
686+ if (!ok || reorderedFallbackData.size () != resource.data .size ()) {
687+ this ->opened = false ;
688+ return ;
689+ }
690+ std::memcpy (resource.data .data (), reorderedFallbackData.data (), resource.data .size ());
691+ }
683692 ::swapImageDataEndianForConsole<true >(resource.data , this ->format , this ->mipCount , this ->frameCount , this ->getFaceCount (), this ->width , this ->height , this ->depth , this ->platform );
684693 } else if (!(resource.flags & Resource::FLAG_LOCAL_DATA) && resource.data .size () >= sizeof (uint32_t )) {
685694 BufferStream::swap_endian (reinterpret_cast <uint32_t *>(resource.data .data ()));
@@ -2384,7 +2393,15 @@ std::vector<std::byte> VTF::bake() const {
23842393 ::swapImageDataEndianForConsole<false >(thumbnailResourceData, this ->thumbnailFormat , 1 , 1 , 1 , this ->thumbnailWidth , this ->thumbnailHeight , 1 , this ->platform );
23852394 resource.data = thumbnailResourceData;
23862395 } else if (resource.type == Resource::TYPE_IMAGE_DATA) {
2387- imageResourceData = {resource.data .begin (), resource.data .end ()};
2396+ if (this ->platform == PLATFORM_PS3_ORANGEBOX) {
2397+ bool ok;
2398+ imageResourceData = ::convertBetweenDDSAndVTFMipOrderForXBOX<false >(false , resource.data , this ->format , this ->mipCount , this ->frameCount , this ->getFaceCount (), this ->width , this ->height , this ->depth , ok);
2399+ if (!ok || imageResourceData.size () != resource.data .size ()) {
2400+ return {};
2401+ }
2402+ } else {
2403+ imageResourceData = {resource.data .begin (), resource.data .end ()};
2404+ }
23882405 ::swapImageDataEndianForConsole<false >(imageResourceData, this ->format , this ->mipCount , this ->frameCount , this ->getFaceCount (), this ->width , this ->height , this ->depth , this ->platform );
23892406
23902407 // LZMA compression has not been observed on the PS3 copy of The Orange Box
0 commit comments