Refactor tsprite creation into renderAddTSpriteFromSprite

git-svn-id: https://svn.eduke32.com/eduke32@8521 1a8010ca-5511-0410-912e-c29ae57300e0

# Conflicts:
#	source/build/src/polymer.cpp
#	source/duke3d/src/m32exec.cpp
This commit is contained in:
hendricks266 2019-12-26 06:27:58 +00:00 committed by Christoph Oelckers
parent 422601bc82
commit 6465feb438
4 changed files with 45 additions and 27 deletions

View file

@ -449,6 +449,39 @@ static FORCE_INLINE void sprite_tracker_hook__(intptr_t const address)
} }
#endif #endif
static inline tspriteptr_t renderMakeTSpriteFromSprite(tspriteptr_t const tspr, uint16_t const spritenum)
{
auto const spr = (uspriteptr_t)&sprite[spritenum];
tspr->pos = spr->pos;
tspr->cstat = spr->cstat;
tspr->picnum = spr->picnum;
tspr->shade = spr->shade;
tspr->pal = spr->pal;
tspr->blend = spr->blend;
tspr->xrepeat = spr->xrepeat;
tspr->yrepeat = spr->yrepeat;
tspr->xoffset = spr->xoffset;
tspr->yoffset = spr->yoffset;
tspr->sectnum = spr->sectnum;
tspr->statnum = spr->statnum;
tspr->ang = spr->ang;
tspr->vel = spr->vel;
tspr->lotag = spr->lotag;
tspr->hitag = spr->hitag;
tspr->clipdist = 0;
tspr->owner = spritenum;
tspr->extra = 0;
return tspr;
}
static inline tspriteptr_t renderAddTSpriteFromSprite(uint16_t const spritenum)
{
return renderMakeTSpriteFromSprite(&tsprite[spritesortcnt++], spritenum);
}
EXTERN int16_t maskwall[MAXWALLSB], maskwallcnt; EXTERN int16_t maskwall[MAXWALLSB], maskwallcnt;
EXTERN int16_t thewall[MAXWALLSB]; EXTERN int16_t thewall[MAXWALLSB];

View file

@ -824,11 +824,8 @@ static void yax_copytsprites()
if (spritesortcnt >= maxspritesonscreen) if (spritesortcnt >= maxspritesonscreen)
break; break;
Bmemcpy(&tsprite[spritesortcnt], spr, sizeof(tspritetype)); tspriteptr_t tsp = renderAddTSpriteFromSprite(spritenum);
tsprite[spritesortcnt].owner = spritenum; tsp->sectnum = sectnum; // potentially tweak sectnum!
tsprite[spritesortcnt].extra = 0;
tsprite[spritesortcnt].sectnum = sectnum; // potentially tweak sectnum!
spritesortcnt++;
} }
} }
@ -1465,9 +1462,7 @@ int32_t renderAddTsprite(int16_t z, int16_t sectnum)
if (spritesortcnt >= maxspritesonscreen) if (spritesortcnt >= maxspritesonscreen)
return 1; return 1;
Bmemcpy(&tsprite[spritesortcnt], spr, sizeof(tspritetype)); renderAddTSpriteFromSprite(z);
tsprite[spritesortcnt].extra = 0;
tsprite[spritesortcnt++].owner = z;
#ifdef YAX_ENABLE #ifdef YAX_ENABLE
} }

View file

@ -362,17 +362,14 @@ static void G_OROR_DupeSprites(spritetype const *sp)
if (sprite[k].picnum != SECTOREFFECTOR && sprite[k].z >= sp->z) if (sprite[k].picnum != SECTOREFFECTOR && sprite[k].z >= sp->z)
{ {
Bmemcpy(&tsprite[spritesortcnt], &sprite[k], sizeof(tspritetype)); tspriteptr_t tsp = renderAddTSpriteFromSprite(k);
tsprite[spritesortcnt].x += (refsp->x - sp->x); tsp->x += (refsp->x - sp->x);
tsprite[spritesortcnt].y += (refsp->y - sp->y); tsp->y += (refsp->y - sp->y);
tsprite[spritesortcnt].z = tsprite[spritesortcnt].z - sp->z + actor[sp->yvel].ceilingz; tsp->z += -sp->z + actor[sp->yvel].ceilingz;
tsprite[spritesortcnt].sectnum = refsp->sectnum; tsp->sectnum = refsp->sectnum;
tsprite[spritesortcnt].owner = k;
tsprite[spritesortcnt].extra = 0;
// OSD_Printf("duped sprite of pic %d at %d %d %d\n",tsprite[spritesortcnt].picnum,tsprite[spritesortcnt].x,tsprite[spritesortcnt].y,tsprite[spritesortcnt].z); // OSD_Printf("duped sprite of pic %d at %d %d %d\n",tsp->picnum,tsp->x,tsp->y,tsp->z);
spritesortcnt++;
} }
} }
} }

View file

@ -600,10 +600,7 @@ void WarpCopySprite(void)
if (sprite[spnum].picnum == ST1) if (sprite[spnum].picnum == ST1)
continue; continue;
tspriteptr_t New = &tsprite[spritesortcnt]; tspriteptr_t New = renderAddTSpriteFromSprite(spnum);
memcpy(New, &sprite[spnum], sizeof(tspritetype));
spritesortcnt++;
New->owner = spnum;
New->statnum = 0; New->statnum = 0;
xoff = sp1->x - New->x; xoff = sp1->x - New->x;
@ -624,10 +621,7 @@ void WarpCopySprite(void)
if (sprite[spnum].picnum == ST1) if (sprite[spnum].picnum == ST1)
continue; continue;
tspriteptr_t New = &tsprite[spritesortcnt]; tspriteptr_t New = renderAddTSpriteFromSprite(spnum);
memcpy(New, &sprite[spnum], sizeof(tspritetype));
spritesortcnt++;
New->owner = spnum;
New->statnum = 0; New->statnum = 0;
xoff = sp2->x - New->x; xoff = sp2->x - New->x;
@ -1492,8 +1486,7 @@ void SpriteSortList2D(int tx, int ty)
if (dist < 22000) if (dist < 22000)
{ {
memcpy(&tsprite[spritesortcnt], sp, sizeof(tspritetype)); renderAddTSpriteFromSprite(i);
tsprite[spritesortcnt++].owner = i;
} }
} }
} }