Skip to content

Commit c9e7cd1

Browse files
authored
[GEN] Backport loading DDS file if TGA file of the same name was not found (#723)
1 parent 4375493 commit c9e7cd1

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,12 +2201,28 @@ IDirect3DSurface8 * DX8Wrapper::_Create_DX8_Surface(const char *filename_)
22012201
// If file not found, create a surface with missing texture in it
22022202

22032203
if (!myfile->Is_Available()) {
2204-
return MissingTexture::_Create_Missing_Surface();
2204+
// If file not found, try the dds format
2205+
// else create a surface with missing texture in it
2206+
char compressed_name[200];
2207+
strncpy(compressed_name,filename_, 200);
2208+
char *ext = strstr(compressed_name, ".");
2209+
if ( (strlen(ext)==4) &&
2210+
( (ext[1] == 't') || (ext[1] == 'T') ) &&
2211+
( (ext[2] == 'g') || (ext[2] == 'G') ) &&
2212+
( (ext[3] == 'a') || (ext[3] == 'A') ) ) {
2213+
ext[1]='d';
2214+
ext[2]='d';
2215+
ext[3]='s';
2216+
}
2217+
file_auto_ptr myfile2(_TheFileFactory,compressed_name);
2218+
if (!myfile2->Is_Available())
2219+
return MissingTexture::_Create_Missing_Surface();
22052220
}
22062221
}
22072222

2223+
StringClass filename_string(filename_,true);
22082224
surface=TextureLoader::Load_Surface_Immediate(
2209-
filename_,
2225+
filename_string,
22102226
WW3D_FORMAT_UNKNOWN,
22112227
true);
22122228
return surface;

0 commit comments

Comments
 (0)