Fix model HUD weapons not showing in Polymer, introduced in r3717.

git-svn-id: https://svn.eduke32.com/eduke32@3722 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-05-01 17:42:07 +00:00
parent 198a3a556c
commit 9f313043bf
4 changed files with 33 additions and 36 deletions

View file

@ -5593,19 +5593,13 @@ static void drawsprite_classic(int32_t snum)
if (bad_tspr(tspr)) if (bad_tspr(tspr))
return; return;
// This happens when using steroids.
// XXX: Should we instead run the code but handle stuff indexed by
// tspr->owner specially?
if ((unsigned)tspr->owner >= MAXSPRITES)
return;
DO_TILE_ANIM(tspr->picnum, spritenum+32768); DO_TILE_ANIM(tspr->picnum, spritenum+32768);
#ifdef USE_OPENGL #ifdef USE_OPENGL
{ {
// hack pending proper alpha implentation // hack pending proper alpha implentation
// TODO: a real implementation // TODO: a real implementation
float alpha = spriteext[tspr->owner].alpha; float alpha = spriteext[spritenum].alpha;
if (alpha >= 0.33f) // if alpha is 0 (which is the default) this structure should only necessitate one comparison if (alpha >= 0.33f) // if alpha is 0 (which is the default) this structure should only necessitate one comparison
{ {
@ -5633,7 +5627,7 @@ static void drawsprite_classic(int32_t snum)
vtilenum = tilenum; // if the game wants voxels, it gets voxels vtilenum = tilenum; // if the game wants voxels, it gets voxels
else if (usevoxels && tiletovox[tilenum] != -1 else if (usevoxels && tiletovox[tilenum] != -1
#ifdef USE_OPENGL #ifdef USE_OPENGL
&& (!(spriteext[tspr->owner].flags&SPREXT_NOTMD)) && (!(spriteext[spritenum].flags&SPREXT_NOTMD))
#endif #endif
) )
{ {
@ -6553,7 +6547,7 @@ draw_as_face_sprite:
i = (int32_t)tspr->ang+1536; i = (int32_t)tspr->ang+1536;
#ifdef USE_OPENGL #ifdef USE_OPENGL
i += spriteext[tspr->owner].angoff; i += spriteext[spritenum].angoff;
#endif #endif
drawvox(tspr->x,tspr->y,tspr->z,i,daxrepeat,(int32_t)tspr->yrepeat,vtilenum,tspr->shade,tspr->pal,lwall,swall); drawvox(tspr->x,tspr->y,tspr->z,i,daxrepeat,(int32_t)tspr->yrepeat,vtilenum,tspr->shade,tspr->pal,lwall,swall);
} }

View file

@ -95,7 +95,9 @@ void set_globalang(int16_t ang);
static inline int32_t bad_tspr(const spritetype *tspr) static inline int32_t bad_tspr(const spritetype *tspr)
{ {
return ((unsigned)tspr->owner >= MAXSPRITES || (unsigned)tspr->picnum >= MAXTILES); // NOTE: tspr->owner >= MAXSPRITES (could be model) has to be handled by
// caller.
return (tspr->owner < 0 || (unsigned)tspr->picnum >= MAXTILES);
} }
void dorotspr_handle_bit2(int32_t *sx, int32_t *sy, int32_t *z, int32_t dastat, void dorotspr_handle_bit2(int32_t *sx, int32_t *sy, int32_t *z, int32_t dastat,

View file

@ -1334,13 +1334,12 @@ void polymer_drawmaskwall(int32_t damaskwallcnt)
void polymer_drawsprite(int32_t snum) void polymer_drawsprite(int32_t snum)
{ {
spritetype *tspr;
int32_t i, j, cs; int32_t i, j, cs;
_prsprite *s; _prsprite *s;
if (pr_verbosity >= 3) OSD_Printf("PR : Sprite %i...\n", snum); spritetype *const tspr = tspriteptr[snum];
tspr = tspriteptr[snum]; if (pr_verbosity >= 3) OSD_Printf("PR : Sprite %i...\n", snum);
if (bad_tspr(tspr)) if (bad_tspr(tspr))
return; return;
@ -1387,11 +1386,12 @@ void polymer_drawsprite(int32_t snum)
polymer_updatesprite(snum); polymer_updatesprite(snum);
if (prsprites[tspr->owner] == NULL) Bassert(tspr->owner < MAXSPRITES);
return;
s = prsprites[tspr->owner]; s = prsprites[tspr->owner];
if (s == NULL)
return;
switch ((tspr->cstat>>4) & 3) switch ((tspr->cstat>>4) & 3)
{ {
case 1: case 1:

View file

@ -4818,7 +4818,7 @@ int32_t lastcullcheck = 0;
char cullmodel[MAXSPRITES]; char cullmodel[MAXSPRITES];
int32_t cullcheckcnt = 0; int32_t cullcheckcnt = 0;
static int32_t __fastcall polymost_checkcoordinates(int32_t x, int32_t y, spritetype *tspr) static int32_t polymost_checkcoordinates(int32_t x, int32_t y, const spritetype *tspr)
{ {
int16_t datempsectnum = tspr->sectnum; int16_t datempsectnum = tspr->sectnum;
int32_t oldx = x, i, j = (tilesizy[tspr->picnum]*tspr->yrepeat); int32_t oldx = x, i, j = (tilesizy[tspr->picnum]*tspr->yrepeat);
@ -4869,12 +4869,11 @@ void polymost_drawsprite(int32_t snum)
float f, c, s, fx, fy, sx0, sy0, sx1, xp0, yp0, xp1, yp1, oxp0, oyp0, ryp0, ryp1, ft[4]; float f, c, s, fx, fy, sx0, sy0, sx1, xp0, yp0, xp1, yp1, oxp0, oyp0, ryp0, ryp1, ft[4];
float x0, y0, x1, y1, sc0, sf0, sc1, sf1, px2[6], py2[6], xv, yv, t0, t1; float x0, y0, x1, y1, sc0, sf0, sc1, sf1, px2[6], py2[6], xv, yv, t0, t1;
int32_t i, j, spritenum, xoff=0, yoff=0, method, npoints; int32_t i, j, spritenum, xoff=0, yoff=0, method, npoints;
spritetype *tspr;
int32_t posx,posy; int32_t posx,posy;
int32_t oldsizx, oldsizy; int32_t oldsizx, oldsizy;
int32_t tsizx, tsizy; int32_t tsizx, tsizy;
tspr = tspriteptr[snum]; spritetype *const tspr = tspriteptr[snum];
if (bad_tspr(tspr)) if (bad_tspr(tspr))
return; return;
@ -4900,17 +4899,16 @@ void polymost_drawsprite(int32_t snum)
method = 1+4; method = 1+4;
if (tspr->cstat&2) { if (!(tspr->cstat&512)) method = 2+4; else method = 3+4; } if (tspr->cstat&2) { if (!(tspr->cstat&512)) method = 2+4; else method = 3+4; }
alpha = spriteext[tspr->owner].alpha; alpha = spriteext[spritenum].alpha;
#ifdef USE_OPENGL #ifdef USE_OPENGL
calc_and_apply_fog(globalshade, sector[tspr->sectnum].visibility, sector[tspr->sectnum].floorpal); calc_and_apply_fog(globalshade, sector[tspr->sectnum].visibility, sector[tspr->sectnum].floorpal);
while (rendmode >= 3 && !(spriteext[tspr->owner].flags&SPREXT_NOTMD)) while (rendmode >= 3 && !(spriteext[spritenum].flags&SPREXT_NOTMD))
{ {
if (usemodels && tile2model[Ptile2tile(tspr->picnum,tspr->pal)].modelid >= 0 && tile2model[Ptile2tile(tspr->picnum,tspr->pal)].framenum >= 0) if (usemodels && tile2model[Ptile2tile(tspr->picnum,tspr->pal)].modelid >= 0 && tile2model[Ptile2tile(tspr->picnum,tspr->pal)].framenum >= 0)
{ {
// md2model *modelptr = (md2model *)models[tile2model[Ptile2tile(tspr->picnum,tspr->pal)].modelid]; if (spritenum >= MAXSPRITES || tspr->statnum == TSPR_MIRROR)
if (tspr->owner < 0 || tspr->owner >= MAXSPRITES || tspr->statnum == TSPR_MIRROR)
{ {
if (mddraw(tspr)) return; if (mddraw(tspr)) return;
break; // else, render as flat sprite break; // else, render as flat sprite
@ -4919,7 +4917,10 @@ void polymost_drawsprite(int32_t snum)
# ifdef MODEL_OCCLUSION_CHECKING # ifdef MODEL_OCCLUSION_CHECKING
if (r_modelocclusionchecking) if (r_modelocclusionchecking)
{ {
if (totalclock >= lastcullcheck + CULL_DELAY && cullcheckcnt < MAXCULLCHECKS && (/*modelptr->usesalpha ||*/ tspr->yrepeat*tilesizy[sprite[tspr->owner].picnum] > 1536 || tspr->xrepeat*tilesizx[sprite[tspr->owner].picnum] > 1536)) const int32_t spic = sprite[spritenum].picnum;
if (totalclock >= lastcullcheck + CULL_DELAY && cullcheckcnt < MAXCULLCHECKS &&
(/*modelptr->usesalpha ||*/ tspr->yrepeat*tilesizy[spic] > 1536 || tspr->xrepeat*tilesizx[spic] > 1536))
{ {
do // this is so gay do // this is so gay
{ {
@ -4928,37 +4929,37 @@ void polymost_drawsprite(int32_t snum)
// don't bother with shadows because processing its owner will take care of it // don't bother with shadows because processing its owner will take care of it
if (tspr->statnum == TSPR_TEMP) if (tspr->statnum == TSPR_TEMP)
break; break;
cullmodel[tspr->owner] = 1; cullmodel[spritenum] = 1;
cullcheckcnt++; cullcheckcnt++;
if (cansee(globalposx, globalposy, globalposz, globalcursectnum, if (cansee(globalposx, globalposy, globalposz, globalcursectnum,
tspr->x, tspr->y, tspr->z,tspr->sectnum)) tspr->x, tspr->y, tspr->z,tspr->sectnum))
{ cullmodel[tspr->owner] = 0; break; } { cullmodel[spritenum] = 0; break; }
if (polymost_checkcoordinates(-CULL_OFFSET, 0, tspr) || getticks() > t || cullcheckcnt >= MAXCULLCHECKS) if (polymost_checkcoordinates(-CULL_OFFSET, 0, tspr) || getticks() > t || cullcheckcnt >= MAXCULLCHECKS)
{ cullmodel[tspr->owner] = 0; break; } { cullmodel[spritenum] = 0; break; }
if (polymost_checkcoordinates(-CULL_OFFSET, -CULL_OFFSET, tspr) || getticks() > t || cullcheckcnt >= MAXCULLCHECKS) if (polymost_checkcoordinates(-CULL_OFFSET, -CULL_OFFSET, tspr) || getticks() > t || cullcheckcnt >= MAXCULLCHECKS)
{ cullmodel[tspr->owner] = 0; break; } { cullmodel[spritenum] = 0; break; }
if (polymost_checkcoordinates(CULL_OFFSET, 0, tspr) || getticks() > t || cullcheckcnt >= MAXCULLCHECKS) if (polymost_checkcoordinates(CULL_OFFSET, 0, tspr) || getticks() > t || cullcheckcnt >= MAXCULLCHECKS)
{ cullmodel[tspr->owner] = 0; break; } { cullmodel[spritenum] = 0; break; }
if (polymost_checkcoordinates(CULL_OFFSET, CULL_OFFSET, tspr) || getticks() > t || cullcheckcnt >= MAXCULLCHECKS) if (polymost_checkcoordinates(CULL_OFFSET, CULL_OFFSET, tspr) || getticks() > t || cullcheckcnt >= MAXCULLCHECKS)
{ cullmodel[tspr->owner] = 0; break; } { cullmodel[spritenum] = 0; break; }
if (polymost_checkcoordinates(-CULL_OFFSET, CULL_OFFSET, tspr) || getticks() > t || cullcheckcnt >= MAXCULLCHECKS) if (polymost_checkcoordinates(-CULL_OFFSET, CULL_OFFSET, tspr) || getticks() > t || cullcheckcnt >= MAXCULLCHECKS)
{ cullmodel[tspr->owner] = 0; break; } { cullmodel[spritenum] = 0; break; }
if (polymost_checkcoordinates(0, 0, tspr) || getticks() > t || cullcheckcnt >= MAXCULLCHECKS) if (polymost_checkcoordinates(0, 0, tspr) || getticks() > t || cullcheckcnt >= MAXCULLCHECKS)
{ cullmodel[tspr->owner] = 0; break; } { cullmodel[spritenum] = 0; break; }
break; break;
} }
while (1); while (1);
} }
} }
else cullmodel[tspr->owner] = 0; else cullmodel[spritenum] = 0;
if (cullmodel[tspr->owner]) if (cullmodel[spritenum])
break; break;
# endif # endif
if (mddraw(tspr)) if (mddraw(tspr))
@ -4992,12 +4993,12 @@ void polymost_drawsprite(int32_t snum)
posx=tspr->x; posx=tspr->x;
posy=tspr->y; posy=tspr->y;
if (spriteext[tspr->owner].flags&SPREXT_AWAY1) if (spriteext[spritenum].flags&SPREXT_AWAY1)
{ {
posx+=(sintable[(tspr->ang+512)&2047]>>13); posx+=(sintable[(tspr->ang+512)&2047]>>13);
posy+=(sintable[(tspr->ang)&2047]>>13); posy+=(sintable[(tspr->ang)&2047]>>13);
} }
else if (spriteext[tspr->owner].flags&SPREXT_AWAY2) else if (spriteext[spritenum].flags&SPREXT_AWAY2)
{ {
posx-=(sintable[(tspr->ang+512)&2047]>>13); posx-=(sintable[(tspr->ang+512)&2047]>>13);
posy-=(sintable[(tspr->ang)&2047]>>13); posy-=(sintable[(tspr->ang)&2047]>>13);