Skip to content

Commit

Permalink
Warn when loading png/jpg images (not supported by QS)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-drexler committed Oct 19, 2024
1 parent cb59430 commit 40ae636
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Quake/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,22 @@ byte *Image_LoadImage (const char *name, int *width, int *height, enum srcformat

for (i = 0; stbi_formats[i]; i++)
{
q_snprintf (loadfilename, sizeof(loadfilename), "%s.%s", name, stbi_formats[i]);
const char *ext = stbi_formats[i];
q_snprintf (loadfilename, sizeof(loadfilename), "%s.%s", name, ext);
COM_FOpenFile (loadfilename, &f, NULL);
if (f)
{
byte *data = stbi_load_from_file (f, width, height, NULL, 4);
if (data)
{
int numbytes = (*width) * (*height) * 4;
byte *hunkdata = (byte *) Hunk_AllocName (numbytes, stbi_formats[i]);
byte *hunkdata = (byte *) Hunk_AllocName (numbytes, ext);
memcpy (hunkdata, data, numbytes);
free (data);
data = hunkdata;
*fmt = SRC_RGBA;
if ((developer.value || map_checks.value) && strcmp (ext, "tga") != 0)
Con_Warning ("%s not supported by QS, consider tga\n", loadfilename);
}
else
Con_Warning ("couldn't load %s (%s)\n", loadfilename, stbi_failure_reason ());
Expand Down

0 comments on commit 40ae636

Please sign in to comment.