Palette texture hack for palremap

This commit is contained in:
GenericHeroGuy 2025-02-18 21:19:22 +01:00
parent d3d67d1d0e
commit bfe1a253da
2 changed files with 27 additions and 2 deletions

View file

@ -2030,6 +2030,20 @@ void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *texindex)
Z_Free((void *)texturesText);
}
static void PaletteTextureHack(const char **name)
{
static char uberhack[5];
if (!udmf)
{
unsigned num;
if (sscanf(*name, "~%03u", &num) && num < 256)
{
snprintf(uberhack, 5, "~%03u", R_GetPaletteRemap(num));
*name = uberhack;
}
}
}
// Search for flat name.
lumpnum_t R_GetFlatNumForName(const char *name)
{
@ -2038,6 +2052,8 @@ lumpnum_t R_GetFlatNumForName(const char *name)
lumpnum_t start;
lumpnum_t end;
PaletteTextureHack(&name);
// Scan wad files backwards so patched flats take preference.
for (i = numwadfiles - 1; i >= 0; i--)
{
@ -2102,6 +2118,8 @@ INT32 R_CheckTextureNumForName(const char *name)
if (name[0] == '-')
return 0;
PaletteTextureHack(&name);
hash = quickncasehash(name, 8);
for (i = 0; i < tidcachelen; i++)

View file

@ -1681,12 +1681,19 @@ void zerr(int ret)
}
#endif
// returns true if the given lump is not cached, AND comes from a compatmode file
// returns true if the given lump is not cached, AND comes from a compatmode file (AND isn't special-cased)
boolean W_NeedPaletteRemapPwad(UINT16 wad, UINT16 lump, boolean ignorecache)
{
if (!wadfiles[wad]->lumpcache[lump] || ignorecache)
{
return wadfiles[wad]->compatmode;
// ugh, palette textures...
// never do remapping on them; PaletteTextureHack handles that
unsigned num;
const char *name = (wadfiles[wad]->lumpinfo + lump)->longname;
if (sscanf(name, "~%03u", &num) && num < 256)
return false;
else
return wadfiles[wad]->compatmode;
}
return false;
}