Fix up some .wal palette issues when running q2 bsps in q1 gamedirs.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6245 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2022-05-28 17:59:08 +00:00
parent 08aedd4b5b
commit f996ff5fc8
2 changed files with 18 additions and 8 deletions

View file

@ -1132,6 +1132,11 @@ static qboolean CL_CheckQ2BspWals(char *file)
if (lump.filelen != count*sizeof(*tinf)) if (lump.filelen != count*sizeof(*tinf))
return false; return false;
//grab the appropriate palette, just in case... but only if this won't confuse anything.
if (CL_CheckDLFile("gfx/palette.lmp"))
if (!CL_CheckOrEnqueDownloadFile("pics/colormap.pcx", NULL, 0))
gotone = true;
tinf = (q2texinfo_t*)(file + lump.fileofs); tinf = (q2texinfo_t*)(file + lump.fileofs);
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
@ -1141,13 +1146,16 @@ static qboolean CL_CheckQ2BspWals(char *file)
break; break;
if (i == j) if (i == j)
{ { //note: we do support formats other than .wal but we still need the .wal to figure out the correct scaling.
//we make a special exception for .tga-without-.wal because other q2 engines already expect that, with pre-scaled textures (and thus lightmaps too).
if (!CL_CheckDLFile(va("textures/%s.wal", tinf[i].texture))) if (!CL_CheckDLFile(va("textures/%s.wal", tinf[i].texture)))
if (!CL_CheckDLFile(va("textures/%s.tga", tinf[i].texture))) if (!CL_CheckDLFile(va("textures/%s.tga", tinf[i].texture)))
if (!CL_CheckOrEnqueDownloadFile(va("textures/%s.wal", tinf[i].texture), NULL, 0)) if (!CL_CheckOrEnqueDownloadFile(va("textures/%s.wal", tinf[i].texture), NULL, 0))
gotone = true; gotone = true;
} }
} }
//FIXME: parse entity lump for sky name.
#endif #endif
return gotone; return gotone;
} }

View file

@ -220,7 +220,9 @@ extern qbyte *mod_base;
dist = plane->dist - dist; \ dist = plane->dist - dist; \
break; break;
unsigned char d_q28to24table[1024]; #ifdef HAVE_CLIENT
static unsigned char q2_palette[256*3];
#endif
/* /*
@ -1359,7 +1361,7 @@ static texture_t *Mod_LoadWall(model_t *loadmodel, char *mapname, char *texname,
tex->srcdata = out = BZ_Malloc(size); tex->srcdata = out = BZ_Malloc(size);
tex->srcfmt = TF_MIP4_8PAL24_T255; tex->srcfmt = TF_MIP4_8PAL24_T255;
tex->palette = host_basepal; tex->palette = q2_palette;
memcpy(out, (qbyte *)wal + wal->offsets[0], (wal->width>>0)*(wal->height>>0)); memcpy(out, (qbyte *)wal + wal->offsets[0], (wal->width>>0)*(wal->height>>0));
out += (wal->width>>0)*(wal->height>>0); out += (wal->width>>0)*(wal->height>>0);
memcpy(out, (qbyte *)wal + wal->offsets[1], (wal->width>>1)*(wal->height>>1)); memcpy(out, (qbyte *)wal + wal->offsets[1], (wal->width>>1)*(wal->height>>1));
@ -4031,7 +4033,7 @@ static int CM_GetQ2Palette (void)
Con_Printf (CON_WARNING "Couldn't find pics/colormap.pcx\n"); Con_Printf (CON_WARNING "Couldn't find pics/colormap.pcx\n");
return -1; return -1;
} }
if (!ReadPCXPalette(f, sz, d_q28to24table)) if (!ReadPCXPalette(f, sz, q2_palette))
{ {
Con_Printf (CON_WARNING "Couldn't read pics/colormap.pcx\n"); Con_Printf (CON_WARNING "Couldn't read pics/colormap.pcx\n");
FS_FreeFile(f); FS_FreeFile(f);
@ -4040,14 +4042,14 @@ static int CM_GetQ2Palette (void)
FS_FreeFile(f); FS_FreeFile(f);
#if 1 #if 0
{ {
float inf; float inf;
qbyte palette[768]; qbyte palette[768];
qbyte *pal; qbyte *pal;
int i; int i;
pal = d_q28to24table; pal = q2_palette;
for (i=0 ; i<768 ; i++) for (i=0 ; i<768 ; i++)
{ {
@ -4059,7 +4061,7 @@ static int CM_GetQ2Palette (void)
palette[i] = inf; palette[i] = inf;
} }
memcpy (d_q28to24table, palette, sizeof(palette)); memcpy (q2_palette, palette, sizeof(palette));
} }
#endif #endif
return 0; return 0;
@ -4818,7 +4820,7 @@ static cmodel_t *CM_LoadMap (model_t *mod, qbyte *filein, size_t filelen, qboole
#ifdef HAVE_CLIENT #ifdef HAVE_CLIENT
if (CM_GetQ2Palette()) if (CM_GetQ2Palette())
memcpy(d_q28to24table, host_basepal, 768); memcpy(q2_palette, host_basepal, 768);
#endif #endif