Skip to content

Commit

Permalink
Fixed: GL_LoadImageFromFile guessing of an image handler
Browse files Browse the repository at this point in the history
When attempting to load a lump as a graphic, GL_LoadImageFromFile
was using the path rather than the name of the lump for basing its
name pattern guess. Presently, this path is always of zero-length
for LumpFiles.

Status message is now verbose2 and wording now better represents
what is happening here. The Patch format handler is not presently
executed from there, it needs to be refactored into place.
  • Loading branch information
danij-deng committed Jan 2, 2012
1 parent b08b7d2 commit e0d97f3
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions doomsday/engine/portable/src/gl_texmanager.c
Expand Up @@ -1451,13 +1451,26 @@ static boolean isColorKeyed(const char* path)
uint8_t* GL_LoadImageFromFile(image_t* img, DFile* file)
{
const imagehandler_t* hdlr;
const char* fileName;
int n = 0;
assert(img && file);

GL_InitImage(img);

// Firstly try the expected format given the file name.
hdlr = findHandlerFromFileName(Str_Text(AbstractFile_Path(DFile_File_Const(file))));
switch(AbstractFile_Type(DFile_File_Const(file)))
{
case FT_LUMPFILE: {
const lumpinfo_t* info = AbstractFile_Info(DFile_File_Const(file));
fileName = (char*)info->name;
break;
}
default:
fileName = Str_Text(AbstractFile_Path(DFile_File_Const(file)));
break;
}

hdlr = findHandlerFromFileName(fileName);
if(hdlr)
{
hdlr->loadFunc(img, file);
Expand All @@ -1476,9 +1489,9 @@ uint8_t* GL_LoadImageFromFile(image_t* img, DFile* file)

if(!img->pixels)
{
Con_Message("GL_LoadImageFromFile: \"%s\" unrecognizable, could not load.\n",
F_PrettyPath(Str_Text(AbstractFile_Path(DFile_File_Const(file)))));
return NULL; // Not a recogniseable format.
VERBOSE2( Con_Message("GL_LoadImageFromFile: \"%s\" unrecognized, trying fallback loader...\n",
F_PrettyPath(fileName)) )
return NULL; // Not a recognised format. It may still be loadable, however.
}

VERBOSE( Con_Message("GL_LoadImageFromFile: \"%s\" (%ix%i)\n",
Expand Down

0 comments on commit e0d97f3

Please sign in to comment.