Polymodes: Explicitly opt out of hicfindsubst falling back to pal 0 instead of checking against the reserved palnum range.

git-svn-id: https://svn.eduke32.com/eduke32@6217 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-06-21 13:46:54 +00:00
parent a032b829bf
commit 986a545ff5
4 changed files with 12 additions and 12 deletions

View file

@ -43,8 +43,8 @@ typedef struct texcachepic_t
int border, depth; int border, depth;
} texcachepicture; } texcachepicture;
hicreplctyp * hicfindsubst(int picnum, int palnum); hicreplctyp * hicfindsubst(int picnum, int palnum, int nozero = 0);
hicreplctyp * hicfindskybox(int picnum, int palnum); hicreplctyp * hicfindskybox(int picnum, int palnum, int nozero = 0);
static inline int have_basepal_tint(void) static inline int have_basepal_tint(void)
{ {

View file

@ -21,7 +21,7 @@ int32_t hicinitcounter = 0;
// //
// find the index into hicreplc[] which contains the replacement tile particulars // find the index into hicreplc[] which contains the replacement tile particulars
// //
hicreplctyp *hicfindsubst(int32_t picnum, int32_t palnum) hicreplctyp *hicfindsubst(int picnum, int palnum, int nozero)
{ {
if (!hicreplc[picnum] || !hicinitcounter) return NULL; if (!hicreplc[picnum] || !hicinitcounter) return NULL;
@ -32,7 +32,7 @@ hicreplctyp *hicfindsubst(int32_t picnum, int32_t palnum)
if (hr->palnum == palnum) if (hr->palnum == palnum)
return hr; return hr;
if (!palnum || palnum >= (MAXPALOOKUPS - RESERVEDPALS)) if (!palnum || nozero)
return NULL; return NULL;
palnum = 0; palnum = 0;
@ -45,7 +45,7 @@ hicreplctyp *hicfindsubst(int32_t picnum, int32_t palnum)
// this is separate because it's not worth passing an extra parameter which is "0" in 99.9999% of cases // this is separate because it's not worth passing an extra parameter which is "0" in 99.9999% of cases
// to the regular hicfindsubst() function // to the regular hicfindsubst() function
// //
hicreplctyp *hicfindskybox(int32_t picnum, int32_t palnum) hicreplctyp *hicfindskybox(int picnum, int palnum, int nozero)
{ {
if (!hicreplc[picnum] || !hicinitcounter) return NULL; if (!hicreplc[picnum] || !hicinitcounter) return NULL;
@ -56,7 +56,7 @@ hicreplctyp *hicfindskybox(int32_t picnum, int32_t palnum)
if (hr->skybox && hr->palnum == palnum) if (hr->skybox && hr->palnum == palnum)
return hr; return hr;
if (!palnum || palnum >= (MAXPALOOKUPS - RESERVEDPALS)) if (!palnum || nozero)
return NULL; return NULL;
palnum = 0; palnum = 0;

View file

@ -5015,7 +5015,7 @@ static _prbucket* polymer_getbuildmaterial(_prmaterial* material, int16_t tile
} }
// PR_BIT_DIFFUSE_DETAIL_MAP // PR_BIT_DIFFUSE_DETAIL_MAP
if (hicfindsubst(tilenum, DETAILPAL) && (pth = texcache_fetch(tilenum, DETAILPAL, 0, DAMETH_NOMASK)) && if (hicfindsubst(tilenum, DETAILPAL, 1) && (pth = texcache_fetch(tilenum, DETAILPAL, 0, DAMETH_NOMASK)) &&
pth->hicr && (pth->hicr->palnum == DETAILPAL)) pth->hicr && (pth->hicr->palnum == DETAILPAL))
{ {
material->detailmap = pth->glpic; material->detailmap = pth->glpic;
@ -5024,17 +5024,17 @@ static _prbucket* polymer_getbuildmaterial(_prmaterial* material, int16_t tile
} }
// PR_BIT_GLOW_MAP // PR_BIT_GLOW_MAP
if (hicfindsubst(tilenum, GLOWPAL) && (pth = texcache_fetch(tilenum, GLOWPAL, 0, DAMETH_MASK)) && if (hicfindsubst(tilenum, GLOWPAL, 1) && (pth = texcache_fetch(tilenum, GLOWPAL, 0, DAMETH_MASK)) &&
pth->hicr && (pth->hicr->palnum == GLOWPAL)) pth->hicr && (pth->hicr->palnum == GLOWPAL))
material->glowmap = pth->glpic; material->glowmap = pth->glpic;
// PR_BIT_SPECULAR_MAP // PR_BIT_SPECULAR_MAP
if (hicfindsubst(tilenum, SPECULARPAL) && (pth = texcache_fetch(tilenum, SPECULARPAL, 0, DAMETH_NOMASK)) && if (hicfindsubst(tilenum, SPECULARPAL, 1) && (pth = texcache_fetch(tilenum, SPECULARPAL, 0, DAMETH_NOMASK)) &&
pth->hicr && (pth->hicr->palnum == SPECULARPAL)) pth->hicr && (pth->hicr->palnum == SPECULARPAL))
material->specmap = pth->glpic; material->specmap = pth->glpic;
// PR_BIT_NORMAL_MAP // PR_BIT_NORMAL_MAP
if (hicfindsubst(tilenum, NORMALPAL) && (pth = texcache_fetch(tilenum, NORMALPAL, 0, DAMETH_NOMASK)) && if (hicfindsubst(tilenum, NORMALPAL, 1) && (pth = texcache_fetch(tilenum, NORMALPAL, 0, DAMETH_NOMASK)) &&
pth->hicr && (pth->hicr->palnum == NORMALPAL)) pth->hicr && (pth->hicr->palnum == NORMALPAL))
{ {
material->normalmap = pth->glpic; material->normalmap = pth->glpic;

View file

@ -1755,7 +1755,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
{ {
pthtyp *detailpth = NULL; pthtyp *detailpth = NULL;
if (usehightile && !drawingskybox && hicfindsubst(globalpicnum, DETAILPAL) && if (usehightile && !drawingskybox && hicfindsubst(globalpicnum, DETAILPAL, 1) &&
(detailpth = texcache_fetch(globalpicnum, DETAILPAL, 0, method & ~DAMETH_MASKPROPS)) && (detailpth = texcache_fetch(globalpicnum, DETAILPAL, 0, method & ~DAMETH_MASKPROPS)) &&
detailpth->hicr && detailpth->hicr->palnum == DETAILPAL) detailpth->hicr && detailpth->hicr->palnum == DETAILPAL)
{ {
@ -1779,7 +1779,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
{ {
pthtyp *glowpth = NULL; pthtyp *glowpth = NULL;
if (usehightile && !drawingskybox && hicfindsubst(globalpicnum, GLOWPAL) && if (usehightile && !drawingskybox && hicfindsubst(globalpicnum, GLOWPAL, 1) &&
(glowpth = texcache_fetch(globalpicnum, GLOWPAL, 0, (method & ~DAMETH_MASKPROPS) | DAMETH_MASK)) && (glowpth = texcache_fetch(globalpicnum, GLOWPAL, 0, (method & ~DAMETH_MASKPROPS) | DAMETH_MASK)) &&
glowpth->hicr && (glowpth->hicr->palnum == GLOWPAL)) glowpth->hicr && (glowpth->hicr->palnum == GLOWPAL))
polymost_setupglowtexture(++texunits, glowpth ? glowpth->glpic : 0); polymost_setupglowtexture(++texunits, glowpth ? glowpth->glpic : 0);