Skip to content

DDS texture fallback lookup code in DX8Wrapper::_Create_DX8_Surface will not always work #725

Open
@xezon

Description

@xezon

The DDS texture fallback lookup code in DX8Wrapper::_Create_DX8_Surface will fail if the texture name contains a dot in its name when not before the file extension.

"texture.dds" will load when referenced as "texture.tga"
"texture.file.dds" will not load when referenced as "texture.file.tga"

IDirect3DSurface8 * DX8Wrapper::_Create_DX8_Surface(const char *filename_)
{
...
		if (!myfile->Is_Available()) {
			// If file not found, try the dds format
			// else create a surface with missing texture in it
			char compressed_name[200];
			strncpy(compressed_name,filename_, 200);
			char *ext = strstr(compressed_name, "."); // <--- naive search
			if ( (strlen(ext)==4) && 
				  ( (ext[1] == 't') || (ext[1] == 'T') ) && 
				  ( (ext[2] == 'g') || (ext[2] == 'G') ) && 
				  ( (ext[3] == 'a') || (ext[3] == 'A') ) ) {
				ext[1]='d';
				ext[2]='d';
				ext[3]='s';
			}
...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething is not working rightInvestigateMinorSeverity: Minor < Major < Critical < Blocker

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions