diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index 1977df690..529e8c412 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -1344,7 +1344,7 @@ void polymer_inb4rotatesprite(int16_t tilenum, char pal, int8_t s { _prmaterial rotatespritematerial; - polymer_getbuildmaterial(&rotatespritematerial, tilenum, pal, shade, 0, 4); + polymer_getbuildmaterial(&rotatespritematerial, tilenum, pal, shade, 0, DAMETH_CLAMPED); rotatespritematerialbits = polymer_bindmaterial(rotatespritematerial, NULL, 0); } @@ -3621,7 +3621,7 @@ void polymer_updatesprite(int32_t snum) } polymer_getbuildmaterial(&s->plane.material, curpicnum, tspr->pal, tspr->shade, - sector[tspr->sectnum].visibility, 4); + sector[tspr->sectnum].visibility, DAMETH_CLAMPED); if (tspr->cstat & 2) { @@ -4001,7 +4001,7 @@ static void polymer_drawskybox(int16_t tilenum, char palnum, int8_t shad while (i < 6) { drawingskybox = i + 1; - pth = texcache_fetch(tilenum, palnum, 0, 4); + pth = texcache_fetch(tilenum, palnum, 0, DAMETH_CLAMPED); color[0] = color[1] = color[2] = getshadefactor(shade); diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 8dba21e83..81cad41f9 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -1433,7 +1433,7 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method) pthtyp *pth, *detailpth, *glowpth; int32_t texunits = GL_TEXTURE0_ARB; - if (skyclamphack) method |= 4; + if (skyclamphack) method |= DAMETH_CLAMPED; pth = our_texcache_fetch(method&(~3)); if (!pth) @@ -4843,7 +4843,7 @@ int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, i { int32_t ousehightile = usehightile; usehightile = usehitile && usehightile; - pth = texcache_fetch(wallnum,0,0,4); + pth = texcache_fetch(wallnum, 0, 0, DAMETH_CLAMPED); if (usehightile) loadedhitile[wallnum>>3] |= (1<<(wallnum&7)); usehightile = ousehightile; @@ -5292,7 +5292,7 @@ void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype) hicprecaching = 1; - texcache_fetch(dapicnum, dapalnum, 0, (datype & 1) << 2); + texcache_fetch(dapicnum, dapalnum, 0, (datype & 1)*DAMETH_CLAMPED); hicprecaching = 0; if (datype == 0 || !usemodels) return; diff --git a/polymer/eduke32/build/src/texcache.c b/polymer/eduke32/build/src/texcache.c index 775bee718..ad06c4f2d 100644 --- a/polymer/eduke32/build/src/texcache.c +++ b/polymer/eduke32/build/src/texcache.c @@ -30,17 +30,15 @@ static const char *texcache_errorstr[TEXCACHEERRORS] = { // : ignored if not in Polymost+r_usetileshades pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int32_t dameth) { - int32_t i, j; - hicreplctyp *si; - pthtyp *pth, *pth2; + int32_t i; + pthtyp *pth; + + const int32_t j = dapicnum&(GLTEXCACHEADSIZ-1); + hicreplctyp *const si = usehightile ? hicfindsubst(dapicnum,dapalnum,drawingskybox) : NULL; - j = (dapicnum&(GLTEXCACHEADSIZ-1)); - if (getrendermode() != REND_POLYMOST || !r_usetileshades) dashade = 0; - si = usehightile ? hicfindsubst(dapicnum,dapalnum,drawingskybox) : NULL; - if (!si) { if (drawingskybox || dapalnum >= (MAXPALOOKUPS - RESERVEDPALS)) return NULL; @@ -86,6 +84,9 @@ pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int3 // possibly fetch an already loaded multitexture :_) if (dapalnum >= (MAXPALOOKUPS - RESERVEDPALS)) for (i = (GLTEXCACHEADSIZ - 1); i >= 0; i--) + { + const pthtyp *pth2; + for (pth2=texcache.list[i]; pth2; pth2=pth2->next) { if (pth2->hicr && pth2->hicr->filename && Bstrcasecmp(pth2->hicr->filename, si->filename) == 0) @@ -96,12 +97,14 @@ pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int3 if (pth2->flags & PTH_HASALPHA) pth->flags |= PTH_HASALPHA; pth->hicr = si; - pth->next = texcache.list[j]; + pth->next = texcache.list[j]; texcache.list[j] = pth; + return(pth); } } + } if (gloadtile_hi(dapicnum,dapalnum,drawingskybox,si,dameth,pth,1, (si->palnum>0) ? 0 : hictinting[dapalnum].f)) {