- use a pointer to access sprites in movesprite.

This commit is contained in:
Christoph Oelckers 2020-10-12 20:59:08 +02:00
parent 8ece66e55c
commit 5bcaaf45e7

View file

@ -145,7 +145,8 @@ bool floorspace_d(int sectnum)
void check_fta_sounds_d(int i) void check_fta_sounds_d(int i)
{ {
if (sprite[i].extra > 0) switch (sprite[i].picnum) auto spri = &sprite[i];
if (spri->extra > 0) switch (spri->picnum)
{ {
case LIZTROOPONTOILET: case LIZTROOPONTOILET:
case LIZTROOPJUSTSIT: case LIZTROOPJUSTSIT:
@ -187,18 +188,18 @@ void check_fta_sounds_d(int i)
S_PlaySound(BOS1_RECOG); S_PlaySound(BOS1_RECOG);
break; break;
case BOSS2: case BOSS2:
if (sprite[i].pal == 1) if (spri->pal == 1)
S_PlaySound(BOS2_RECOG); S_PlaySound(BOS2_RECOG);
else S_PlaySound(WHIPYOURASS); else S_PlaySound(WHIPYOURASS);
break; break;
case BOSS3: case BOSS3:
if (sprite[i].pal == 1) if (spri->pal == 1)
S_PlaySound(BOS3_RECOG); S_PlaySound(BOS3_RECOG);
else S_PlaySound(RIPHEADNECK); else S_PlaySound(RIPHEADNECK);
break; break;
case BOSS4: case BOSS4:
case BOSS4STAYPUT: case BOSS4STAYPUT:
if (sprite[i].pal == 1) if (spri->pal == 1)
S_PlaySound(BOS4_RECOG); S_PlaySound(BOS4_RECOG);
S_PlaySound(BOSS4_FIRSTSEE); S_PlaySound(BOSS4_FIRSTSEE);
break; break;
@ -294,16 +295,17 @@ bool ifsquished(int i, int p)
{ {
if (isRR()) return false; // this function is a no-op in RR's source. if (isRR()) return false; // this function is a no-op in RR's source.
auto spri = &sprite[i];
bool squishme = false; bool squishme = false;
if (sprite[i].picnum == APLAYER && ud.clipping) if (spri->picnum == APLAYER && ud.clipping)
return false; return false;
auto& sc = sector[sprite[i].sectnum]; auto& sc = sector[spri->sectnum];
int floorceildist = sc.floorz - sc.ceilingz; int floorceildist = sc.floorz - sc.ceilingz;
if (sc.lotag != ST_23_SWINGING_DOOR) if (sc.lotag != ST_23_SWINGING_DOOR)
{ {
if (sprite[i].pal == 1) if (spri->pal == 1)
squishme = floorceildist < (32 << 8) && (sc.lotag & 32768) == 0; squishme = floorceildist < (32 << 8) && (sc.lotag & 32768) == 0;
else else
squishme = floorceildist < (12 << 8); squishme = floorceildist < (12 << 8);
@ -314,9 +316,9 @@ bool ifsquished(int i, int p)
FTA(QUOTE_SQUISHED, &ps[p]); FTA(QUOTE_SQUISHED, &ps[p]);
if (badguy(&sprite[i])) if (badguy(&sprite[i]))
sprite[i].xvel = 0; spri->xvel = 0;
if (sprite[i].pal == 1) if (spri->pal == 1)
{ {
hittype[i].picnum = SHOTSPARK1; hittype[i].picnum = SHOTSPARK1;
hittype[i].extra = 1; hittype[i].extra = 1;
@ -545,82 +547,82 @@ int movesprite_d(short spritenum, int xchange, int ychange, int zchange, unsigne
{ {
int daz, h, oldx, oldy; int daz, h, oldx, oldy;
short retval, dasectnum, cd; short retval, dasectnum, cd;
char bg;
bg = badguy(&sprite[spritenum]); auto spri = &sprite[spritenum];
int bg = badguy(spri);
if (sprite[spritenum].statnum == 5 || (bg && sprite[spritenum].xrepeat < 4)) if (spri->statnum == 5 || (bg && spri->xrepeat < 4))
{ {
sprite[spritenum].x += (xchange * TICSPERFRAME) >> 2; spri->x += (xchange * TICSPERFRAME) >> 2;
sprite[spritenum].y += (ychange * TICSPERFRAME) >> 2; spri->y += (ychange * TICSPERFRAME) >> 2;
sprite[spritenum].z += (zchange * TICSPERFRAME) >> 2; spri->z += (zchange * TICSPERFRAME) >> 2;
if (bg) if (bg)
setsprite(spritenum, sprite[spritenum].x, sprite[spritenum].y, sprite[spritenum].z); setsprite(spritenum, spri->x, spri->y, spri->z);
return 0; return 0;
} }
dasectnum = sprite[spritenum].sectnum; dasectnum = spri->sectnum;
daz = sprite[spritenum].z; daz = spri->z;
h = ((tilesiz[sprite[spritenum].picnum].y * sprite[spritenum].yrepeat) << 1); h = ((tilesiz[spri->picnum].y * spri->yrepeat) << 1);
daz -= h; daz -= h;
if (bg) if (bg)
{ {
oldx = sprite[spritenum].x; oldx = spri->x;
oldy = sprite[spritenum].y; oldy = spri->y;
if (sprite[spritenum].xrepeat > 60) if (spri->xrepeat > 60)
retval = clipmove(&sprite[spritenum].x, &sprite[spritenum].y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 1024L, (4 << 8), (4 << 8), cliptype); retval = clipmove(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 1024L, (4 << 8), (4 << 8), cliptype);
else else
{ {
if (sprite[spritenum].picnum == LIZMAN) if (spri->picnum == LIZMAN)
cd = 292; cd = 292;
else if (actorflag(spritenum, SFLAG_BADGUY)) else if (actorflag(spritenum, SFLAG_BADGUY))
cd = sprite[spritenum].clipdist << 2; cd = spri->clipdist << 2;
else else
cd = 192; cd = 192;
retval = clipmove(&sprite[spritenum].x, &sprite[spritenum].y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), cd, (4 << 8), (4 << 8), cliptype); retval = clipmove(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), cd, (4 << 8), (4 << 8), cliptype);
} }
// conditional code from hell... // conditional code from hell...
if (dasectnum < 0 || (dasectnum >= 0 && if (dasectnum < 0 || (dasectnum >= 0 &&
((hittype[spritenum].actorstayput >= 0 && hittype[spritenum].actorstayput != dasectnum) || ((hittype[spritenum].actorstayput >= 0 && hittype[spritenum].actorstayput != dasectnum) ||
((sprite[spritenum].picnum == BOSS2) && sprite[spritenum].pal == 0 && sector[dasectnum].lotag != 3) || ((spri->picnum == BOSS2) && spri->pal == 0 && sector[dasectnum].lotag != 3) ||
((sprite[spritenum].picnum == BOSS1 || sprite[spritenum].picnum == BOSS2) && sector[dasectnum].lotag == ST_1_ABOVE_WATER) || ((spri->picnum == BOSS1 || spri->picnum == BOSS2) && sector[dasectnum].lotag == ST_1_ABOVE_WATER) ||
(sector[dasectnum].lotag == ST_1_ABOVE_WATER && (sprite[spritenum].picnum == LIZMAN || (sprite[spritenum].picnum == LIZTROOP && sprite[spritenum].zvel == 0))) (sector[dasectnum].lotag == ST_1_ABOVE_WATER && (spri->picnum == LIZMAN || (spri->picnum == LIZTROOP && spri->zvel == 0)))
)) ))
) )
{ {
sprite[spritenum].x = oldx; spri->x = oldx;
sprite[spritenum].y = oldy; spri->y = oldy;
if (sector[dasectnum].lotag == ST_1_ABOVE_WATER && sprite[spritenum].picnum == LIZMAN) if (sector[dasectnum].lotag == ST_1_ABOVE_WATER && spri->picnum == LIZMAN)
sprite[spritenum].ang = (krand()&2047); spri->ang = (krand()&2047);
else if ((hittype[spritenum].temp_data[0]&3) == 1 && sprite[spritenum].picnum != COMMANDER) else if ((hittype[spritenum].temp_data[0]&3) == 1 && spri->picnum != COMMANDER)
sprite[spritenum].ang = (krand()&2047); spri->ang = (krand()&2047);
setsprite(spritenum,oldx,oldy,sprite[spritenum].z); setsprite(spritenum,oldx,oldy,spri->z);
if (dasectnum < 0) dasectnum = 0; if (dasectnum < 0) dasectnum = 0;
return (16384+dasectnum); return (16384+dasectnum);
} }
if ((retval&49152) >= 32768 && (hittype[spritenum].cgg==0)) sprite[spritenum].ang += 768; if ((retval&49152) >= 32768 && (hittype[spritenum].cgg==0)) spri->ang += 768;
} }
else else
{ {
if (sprite[spritenum].statnum == 4) if (spri->statnum == 4)
retval = retval =
clipmove(&sprite[spritenum].x, &sprite[spritenum].y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 8L, (4 << 8), (4 << 8), cliptype); clipmove(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 8L, (4 << 8), (4 << 8), cliptype);
else else
retval = retval =
clipmove(&sprite[spritenum].x, &sprite[spritenum].y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), (int)(sprite[spritenum].clipdist << 2), (4 << 8), (4 << 8), cliptype); clipmove(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), (int)(spri->clipdist << 2), (4 << 8), (4 << 8), cliptype);
} }
if (dasectnum >= 0) if (dasectnum >= 0)
if ((dasectnum != sprite[spritenum].sectnum)) if ((dasectnum != spri->sectnum))
changespritesect(spritenum, dasectnum); changespritesect(spritenum, dasectnum);
daz = sprite[spritenum].z + ((zchange * TICSPERFRAME) >> 3); daz = spri->z + ((zchange * TICSPERFRAME) >> 3);
if ((daz > hittype[spritenum].ceilingz) && (daz <= hittype[spritenum].floorz)) if ((daz > hittype[spritenum].ceilingz) && (daz <= hittype[spritenum].floorz))
sprite[spritenum].z = daz; spri->z = daz;
else else
if (retval == 0) if (retval == 0)
return(16384 + dasectnum); return(16384 + dasectnum);
@ -747,15 +749,15 @@ void gutsdir_d(spritetype* s, short gtype, short n, short p)
void movefta_d(void) void movefta_d(void)
{ {
int x, px, py, sx, sy; int x, px, py, sx, sy;
short i, j, p, psect, ssect, nexti; short p, psect, ssect, nexti;
spritetype* s; int i, j;
i = headspritestat[STAT_ZOMBIEACTOR]; i = headspritestat[STAT_ZOMBIEACTOR];
while (i >= 0) while (i >= 0)
{ {
nexti = nextspritestat[i]; nexti = nextspritestat[i];
s = &sprite[i]; auto s = &sprite[i];
p = findplayer(s, &x); p = findplayer(s, &x);
ssect = psect = s->sectnum; ssect = psect = s->sectnum;