return image_rgba;
}
+void Image_StripImageExtension (char *in, char *out)
+{
+ byte *end;
+ end = in + strlen(in);
+ if ((end - in) >= 4)
+ {
+ if (strcmp(end - 4, ".tga") == 0 || strcmp(end - 4, ".pcx") == 0 || strcmp(end - 4, ".lmp") == 0)
+ end -= 4;
+ while (in < end)
+ *out++ = *in++;
+ *out++ = 0;
+ }
+ else
+ strcpy(out, in);
+}
+
byte* loadimagepixels (char* filename, qboolean complain, int matchwidth, int matchheight)
{
FILE *f;
- char basename[128], name[128];
+ char basename[256], name[256];
byte *image_rgba, *c;
- COM_StripExtension(filename, basename); // strip the extension to allow TGA skins on Q2 models despite the .pcx in the skin name
+ Image_StripImageExtension(filename, basename); // strip .tga, .pcx and .lmp extensions to allow replacement by other types
// replace *'s with #, so commandline utils don't get confused when dealing with the external files
for (c = basename;*c;c++)
if (*c == '*')
if (f)
return LoadPCX (f, matchwidth, matchheight);
sprintf (name, "%s.tga", basename);
+ Con_Printf("name = %s : ", name);
COM_FOpenFile (name, &f, true);
if (f)
+ {
+ Con_Printf("succeeded\n");
return LoadTGA (f, matchwidth, matchheight);
+ }
+ else
+ Con_Printf("failed\n");
sprintf (name, "%s.pcx", basename);
COM_FOpenFile (name, &f, true);
if (f)
{
}
+void Mod_Sprite_StripExtension(char *in, char *out)
+{
+ byte *end;
+ end = in + strlen(in);
+ if ((end - in) >= 6)
+ if (strcmp(end - 6, ".spr32") == 0)
+ end -= 6;
+ if ((end - in) >= 4)
+ if (strcmp(end - 4, ".spr") == 0)
+ end -= 4;
+ while (in < end)
+ *out++ = *in++;
+ *out++ = 0;
+}
+
/*
=================
Mod_LoadSpriteFrame
dspriteframe_t *pinframe;
mspriteframe_t *pspriteframe;
int i, width, height, size, origin[2];
- char name[64];
+ char name[256], tempname[256];
byte *pixbuf, *pixel, *inpixel;
pinframe = (dspriteframe_t *)pin;
pspriteframe->left = origin[0];
pspriteframe->right = width + origin[0];
- sprintf (name, "%s_%i", loadmodel->name, framenum);
- pspriteframe->gl_texturenum = loadtextureimagewithmask(name, 0, 0, false, true);
+ Mod_Sprite_StripExtension(loadmodel->name, tempname);
+ sprintf (name, "%s_%i", tempname, framenum);
+ pspriteframe->gl_texturenum = loadtextureimagewithmask(name, 0, 0, true, true);
pspriteframe->gl_fogtexturenum = image_masktexnum;
if (pspriteframe->gl_texturenum == 0)
{
ptemp = (void *)pin_intervals;
for (i=0 ; i<numframes ; i++)
- {
ptemp = Mod_LoadSpriteFrame (ptemp, &pspritegroup->frames[i], framenum * 100 + i, bytesperpixel);
- }
return ptemp;
}