From e363cd53a587994b8a36422bdf7947db08f677fd Mon Sep 17 00:00:00 2001 From: Evan Ramos Date: Thu, 2 Jan 2020 22:20:56 -0600 Subject: [PATCH] tspritetype cleanup # Conflicts: # source/blood/src/m32common.cpp # source/blood/src/m32exec.cpp # source/blood/src/m32structures.cpp # source/blood/src/mapedit.cpp # source/rr/src/astub.cpp # source/rr/src/m32common.cpp # source/rr/src/m32exec.cpp # source/rr/src/m32structures.cpp --- source/blood/src/mirrors.cpp | 2 +- source/blood/src/view.cpp | 2 +- source/exhumed/src/sequence.cpp | 94 +++++++++++++++++---------------- source/rr/src/game.cpp | 6 +-- 4 files changed, 53 insertions(+), 51 deletions(-) diff --git a/source/blood/src/mirrors.cpp b/source/blood/src/mirrors.cpp index ed68b4964..e5012614d 100644 --- a/source/blood/src/mirrors.cpp +++ b/source/blood/src/mirrors.cpp @@ -269,7 +269,7 @@ void sub_557C4(int x, int y, int interpolation) int dy = mirror[j].atc; int dz = mirror[j].at10; tspritetype *pTSprite = &tsprite[spritesortcnt]; - memset(pTSprite, 0, sizeof(uspritetype)); + memset(pTSprite, 0, sizeof(tspritetype)); pTSprite->type = pSprite->type; pTSprite->index = pSprite->index; pTSprite->sectnum = nSector2; diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 946337bdc..2bf7b3f21 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -1914,7 +1914,7 @@ template tspritetype* viewInsertTSprite(int nSector, int nStatnum, T pTSprite->x += Cos(gCameraAng)>>25; pTSprite->y += Sin(gCameraAng)>>25; } - return &tsprite[nTSprite]; + return pTSprite; } int effectDetail[] = { diff --git a/source/exhumed/src/sequence.cpp b/source/exhumed/src/sequence.cpp index b86f88934..fe2affee0 100644 --- a/source/exhumed/src/sequence.cpp +++ b/source/exhumed/src/sequence.cpp @@ -500,17 +500,18 @@ int seq_GetSeqPicnum(short nSeq, short edx, short ebx) int seq_PlotArrowSequence(short nSprite, short nSeq, int nVal) { - int nAngle = GetMyAngle(nCamerax - tsprite[nSprite].x, nCameray - tsprite[nSprite].y); + tspriteptr_t pTSprite = &tsprite[nSprite]; + int nAngle = GetMyAngle(nCamerax - pTSprite->x, nCameray - pTSprite->y); - int nSeqOffset = ((((tsprite[nSprite].ang + 512) - nAngle) + 128) & kAngleMask) >> 8; + int nSeqOffset = ((((pTSprite->ang + 512) - nAngle) + 128) & kAngleMask) >> 8; short nFrame = SeqBase[nSeqOffset + nSeq] + nVal; short nFrameBase = FrameBase[nFrame]; short nFrameSize = FrameSize[nFrame]; - uint8_t nShade = tsprite[nSprite].shade; - short nStat = tsprite[nSprite].cstat; + uint8_t nShade = pTSprite->shade; + short nStat = pTSprite->cstat; nStat |= 0x80; @@ -525,29 +526,30 @@ int seq_PlotArrowSequence(short nSprite, short nSeq, int nVal) nShade -= 100; } - tsprite[nSprite].cstat = nStat; - tsprite[nSprite].shade = nShade; - tsprite[nSprite].statnum = nFrameSize; + pTSprite->cstat = nStat; + pTSprite->shade = nShade; + pTSprite->statnum = nFrameSize; if (ChunkFlag[nFrameBase] & 1) { - tsprite[nSprite].xoffset = ChunkXpos[nFrameBase]; - tsprite[nSprite].cstat |= 4; + pTSprite->xoffset = ChunkXpos[nFrameBase]; + pTSprite->cstat |= 4; } else { - tsprite[nSprite].xoffset = -ChunkXpos[nFrameBase]; + pTSprite->xoffset = -ChunkXpos[nFrameBase]; } - tsprite[nSprite].yoffset = -ChunkYpos[nFrameBase]; - tsprite[nSprite].picnum = ChunkPict[nFrameBase]; + pTSprite->yoffset = -ChunkYpos[nFrameBase]; + pTSprite->picnum = ChunkPict[nFrameBase]; return ChunkPict[nFrameBase]; } int seq_PlotSequence(short nSprite, short edx, short nFrame, short ecx) { - int nAngle = GetMyAngle(nCamerax - tsprite[nSprite].x, nCameray - tsprite[nSprite].y); + tspriteptr_t pTSprite = &tsprite[nSprite]; + int nAngle = GetMyAngle(nCamerax - pTSprite->x, nCameray - pTSprite->y); int val; @@ -557,7 +559,7 @@ int seq_PlotSequence(short nSprite, short edx, short nFrame, short ecx) } else { - val = (((tsprite[nSprite].ang - nAngle) + 128) & kAngleMask) >> 8; + val = (((pTSprite->ang - nAngle) + 128) & kAngleMask) >> 8; } int eax = SeqBase[edx] + nFrame; @@ -566,7 +568,7 @@ int seq_PlotSequence(short nSprite, short edx, short nFrame, short ecx) short nBase = FrameBase[edi]; short nSize = FrameSize[edi]; - int8_t shade = tsprite[nSprite].shade; + int8_t shade = pTSprite->shade; if (FrameFlag[eax] & 4) { @@ -588,7 +590,7 @@ int seq_PlotSequence(short nSprite, short edx, short nFrame, short ecx) esi += edx; int var_14 = edx + 1; - short nOwner = tsprite[nSprite].owner; + short nOwner = pTSprite->owner; while (1) { @@ -599,63 +601,63 @@ int seq_PlotSequence(short nSprite, short edx, short nFrame, short ecx) break; } - tsprite[spritesortcnt].x = tsprite[nSprite].x; - tsprite[spritesortcnt].y = tsprite[nSprite].y; - tsprite[spritesortcnt].z = tsprite[nSprite].z; - tsprite[spritesortcnt].shade = shade; - tsprite[spritesortcnt].pal = tsprite[nSprite].pal; - tsprite[spritesortcnt].xrepeat = tsprite[nSprite].xrepeat; - tsprite[spritesortcnt].yrepeat = tsprite[nSprite].yrepeat; - tsprite[spritesortcnt].ang = tsprite[nSprite].ang; - tsprite[spritesortcnt].owner = tsprite[nSprite].owner; - tsprite[spritesortcnt].sectnum = tsprite[nSprite].sectnum; - tsprite[spritesortcnt].cstat = tsprite[nSprite].cstat |= 0x80; - tsprite[spritesortcnt].statnum = esi; + tspriteptr_t tsp = &tsprite[spritesortcnt++]; + tsp->x = pTSprite->x; + tsp->y = pTSprite->y; + tsp->z = pTSprite->z; + tsp->shade = shade; + tsp->pal = pTSprite->pal; + tsp->xrepeat = pTSprite->xrepeat; + tsp->yrepeat = pTSprite->yrepeat; + tsp->ang = pTSprite->ang; + tsp->owner = pTSprite->owner; + tsp->sectnum = pTSprite->sectnum; + tsp->cstat = pTSprite->cstat |= 0x80; + tsp->statnum = esi; if (ChunkFlag[nBase] & 1) { - tsprite[spritesortcnt].xoffset = ChunkXpos[nBase]; - tsprite[spritesortcnt].cstat |= 4; // x-flipped + tsp->xoffset = ChunkXpos[nBase]; + tsp->cstat |= 4; // x-flipped } else { - tsprite[spritesortcnt].xoffset = -ChunkXpos[nBase]; + tsp->xoffset = -ChunkXpos[nBase]; } - tsprite[spritesortcnt].yoffset = -ChunkYpos[nBase]; - tsprite[spritesortcnt].picnum = ChunkPict[nBase]; + tsp->yoffset = -ChunkYpos[nBase]; + tsp->picnum = ChunkPict[nBase]; - spritesortcnt++; nBase++; } - if (!(tsprite[nSprite].cstat & 0x101) || (sprite[nOwner].statnum == 100 && nNetPlayerCount)) + if (!(pTSprite->cstat & 0x101) || (sprite[nOwner].statnum == 100 && nNetPlayerCount)) { - tsprite[nSprite].owner = -1; + pTSprite->owner = -1; } else { - short nSector = tsprite[nSprite].sectnum; + short nSector = pTSprite->sectnum; int nFloorZ = sector[nSector].floorz; if (nFloorZ <= eyelevel[nLocalPlayer] + initz) { - tsprite[nSprite].owner = -1; + pTSprite->owner = -1; } else { - tsprite[nSprite].picnum = nShadowPic; + pTSprite->picnum = nShadowPic; - int edx = ((tilesiz[nPict].x << 5) / nShadowWidth) - ((nFloorZ - tsprite[nSprite].z) >> 10); + int edx = ((tilesiz[nPict].x << 5) / nShadowWidth) - ((nFloorZ - pTSprite->z) >> 10); if (edx < 1) { edx = 1; } - tsprite[nSprite].cstat = 0x22; // transluscence, floor sprite - tsprite[nSprite].z = videoGetRenderMode() >= REND_POLYMOST ? nFloorZ : nFloorZ + 1; - tsprite[nSprite].yrepeat = (uint8_t)edx; - tsprite[nSprite].xrepeat = (uint8_t)edx; - tsprite[nSprite].statnum = -3; - tsprite[nSprite].pal = 0; + pTSprite->cstat = 0x22; // transluscence, floor sprite + pTSprite->z = videoGetRenderMode() >= REND_POLYMOST ? nFloorZ : nFloorZ + 1; + pTSprite->yrepeat = (uint8_t)edx; + pTSprite->xrepeat = (uint8_t)edx; + pTSprite->statnum = -3; + pTSprite->pal = 0; } } diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index 863af19ed..4ed3b19a2 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -615,7 +615,7 @@ static void G_OROR_DupeSprites(const spritetype *sp) if (sprite[k].picnum != SECTOREFFECTOR && sprite[k].z >= sp->z) { - Bmemcpy(&tsprite[spritesortcnt], &sprite[k], sizeof(spritetype)); + Bmemcpy(&tsprite[spritesortcnt], &sprite[k], sizeof(tspritetype)); tsprite[spritesortcnt].x += (refsp->x - sp->x); tsprite[spritesortcnt].y += (refsp->y - sp->y); @@ -4988,9 +4988,9 @@ default_case1: #if 0 if (spritesortcnt < maxspritesonscreen) { - spritetype *const newt = &tsprite[spritesortcnt++]; + auto const newt = &tsprite[spritesortcnt++]; - Bmemcpy(newt, t, sizeof(spritetype)); + *newt = *t; newt->cstat |= 2|512; newt->x += (sintable[(newt->ang+512)&2047]>>12);