- Exhumed: replaced a large amount of sprite array accesses with pointers.

No logic changes, this is mainly search & replace.
This commit is contained in:
Christoph Oelckers 2021-09-06 08:33:02 +02:00
parent c485fce958
commit 6f8a5ee2d2
29 changed files with 1851 additions and 1667 deletions

View file

@ -72,10 +72,11 @@ void DestroyAnim(int nAnim)
if (nSprite >= 0) if (nSprite >= 0)
{ {
auto pSprite = &sprite[nSprite];
StopSpriteSound(nSprite); StopSpriteSound(nSprite);
runlist_SubRunRec(AnimList[nAnim].AnimRunRec); runlist_SubRunRec(AnimList[nAnim].AnimRunRec);
runlist_DoSubRunRec(sprite[nSprite].extra); runlist_DoSubRunRec(pSprite->extra);
runlist_FreeRun(sprite[nSprite].lotag - 1); runlist_FreeRun(pSprite->lotag - 1);
} }
AnimList.Release(nAnim); AnimList.Release(nAnim);
@ -91,43 +92,44 @@ int BuildAnim(int nSprite, int val, int val2, int x, int y, int z, int nSector,
if (nSprite == -1) { if (nSprite == -1) {
nSprite = insertsprite(nSector, 500); nSprite = insertsprite(nSector, 500);
} }
auto pSprite = &sprite[nSprite];
sprite[nSprite].x = x; pSprite->x = x;
sprite[nSprite].y = y; pSprite->y = y;
sprite[nSprite].z = z; pSprite->z = z;
sprite[nSprite].cstat = 0; pSprite->cstat = 0;
if (nFlag & 4) if (nFlag & 4)
{ {
sprite[nSprite].pal = 4; pSprite->pal = 4;
sprite[nSprite].shade = -64; pSprite->shade = -64;
} }
else else
{ {
sprite[nSprite].pal = 0; pSprite->pal = 0;
sprite[nSprite].shade = -12; pSprite->shade = -12;
} }
sprite[nSprite].clipdist = 10; pSprite->clipdist = 10;
sprite[nSprite].xrepeat = nRepeat; pSprite->xrepeat = nRepeat;
sprite[nSprite].yrepeat = nRepeat; pSprite->yrepeat = nRepeat;
sprite[nSprite].picnum = 1; pSprite->picnum = 1;
sprite[nSprite].ang = 0; pSprite->ang = 0;
sprite[nSprite].xoffset = 0; pSprite->xoffset = 0;
sprite[nSprite].yoffset = 0; pSprite->yoffset = 0;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].backuppos(); pSprite->backuppos();
// CHECKME - where is hitag set otherwise? // CHECKME - where is hitag set otherwise?
if (sprite[nSprite].statnum < 900) { if (pSprite->statnum < 900) {
sprite[nSprite].hitag = -1; pSprite->hitag = -1;
} }
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].owner = -1; pSprite->owner = -1;
sprite[nSprite].extra = runlist_AddRunRec(sprite[nSprite].lotag - 1, nAnim | 0x100000); pSprite->extra = runlist_AddRunRec(pSprite->lotag - 1, nAnim | 0x100000);
AnimList[nAnim].AnimRunRec = runlist_AddRunRec(NewRun, nAnim | 0x100000); AnimList[nAnim].AnimRunRec = runlist_AddRunRec(NewRun, nAnim | 0x100000);
AnimList[nAnim].nSprite = nSprite; AnimList[nAnim].nSprite = nSprite;
@ -137,7 +139,7 @@ int BuildAnim(int nSprite, int val, int val2, int x, int y, int z, int nSector,
AnimList[nAnim].field_4 = 256; AnimList[nAnim].field_4 = 256;
if (nFlag & 0x80) { if (nFlag & 0x80) {
sprite[nSprite].cstat |= 0x2; // set transluscence pSprite->cstat |= 0x2; // set transluscence
} }
return nAnim; return nAnim;
@ -155,6 +157,7 @@ void FuncAnim(int a, int, int nRun)
short nSprite = AnimList[nAnim].nSprite; short nSprite = AnimList[nAnim].nSprite;
short nSeq = AnimList[nAnim].nSeq; short nSeq = AnimList[nAnim].nSeq;
auto pSprite = &sprite[nSprite];
assert(nSprite != -1); assert(nSprite != -1);
@ -166,23 +169,24 @@ void FuncAnim(int a, int, int nRun)
{ {
short var_1C = AnimList[nAnim].field_2; short var_1C = AnimList[nAnim].field_2;
if (!(sprite[nSprite].cstat & 0x8000)) if (!(pSprite->cstat & 0x8000))
{ {
seq_MoveSequence(nSprite, nSeq, var_1C); seq_MoveSequence(nSprite, nSeq, var_1C);
} }
if (sprite[nSprite].statnum == kStatIgnited) if (pSprite->statnum == kStatIgnited)
{ {
short nSpriteB = sprite[nSprite].hitag; short nSpriteB = pSprite->hitag;
if (nSpriteB > -1) if (nSpriteB > -1)
{ {
sprite[nSprite].x = sprite[nSpriteB].x; auto pSpriteB = &sprite[nSpriteB];
sprite[nSprite].y = sprite[nSpriteB].y; pSprite->x = pSpriteB->x;
sprite[nSprite].z = sprite[nSpriteB].z; pSprite->y = pSpriteB->y;
pSprite->z = pSpriteB->z;
if (sprite[nSpriteB].sectnum != sprite[nSprite].sectnum) if (pSpriteB->sectnum != pSprite->sectnum)
{ {
if (sprite[nSpriteB].sectnum < 0 || sprite[nSpriteB].sectnum >= kMaxSectors) if (pSpriteB->sectnum < 0 || pSpriteB->sectnum >= kMaxSectors)
{ {
DestroyAnim(nAnim); DestroyAnim(nAnim);
mydeletesprite(nSprite); mydeletesprite(nSprite);
@ -190,28 +194,28 @@ void FuncAnim(int a, int, int nRun)
} }
else else
{ {
mychangespritesect(nSprite, sprite[nSpriteB].sectnum); mychangespritesect(nSprite, pSpriteB->sectnum);
} }
} }
if (!var_1C) if (!var_1C)
{ {
if (sprite[nSpriteB].cstat != 0x8000) if (pSpriteB->cstat != 0x8000)
{ {
short hitag2 = sprite[nSpriteB].hitag; short hitag2 = pSpriteB->hitag;
sprite[nSpriteB].hitag--; pSpriteB->hitag--;
if (hitag2 >= 15) if (hitag2 >= 15)
{ {
runlist_DamageEnemy(nSpriteB, -1, (sprite[nSpriteB].hitag - 14) * 2); runlist_DamageEnemy(nSpriteB, -1, (pSpriteB->hitag - 14) * 2);
if (sprite[nSpriteB].shade < 100) if (pSpriteB->shade < 100)
{ {
sprite[nSpriteB].pal = 0; pSpriteB->pal = 0;
sprite[nSpriteB].shade++; pSpriteB->shade++;
} }
if (!(sprite[nSpriteB].cstat & 101)) if (!(pSpriteB->cstat & 101))
{ {
DestroyAnim(nAnim); DestroyAnim(nAnim);
mydeletesprite(nSprite); mydeletesprite(nSprite);
@ -220,14 +224,14 @@ void FuncAnim(int a, int, int nRun)
} }
else else
{ {
sprite[nSpriteB].hitag = 1; pSpriteB->hitag = 1;
DestroyAnim(nAnim); DestroyAnim(nAnim);
mydeletesprite(nSprite); mydeletesprite(nSprite);
} }
} }
else else
{ {
sprite[nSpriteB].hitag = 1; pSpriteB->hitag = 1;
DestroyAnim(nAnim); DestroyAnim(nAnim);
mydeletesprite(nSprite); mydeletesprite(nSprite);
} }
@ -289,7 +293,9 @@ void FuncAnim(int a, int, int nRun)
void BuildExplosion(short nSprite) void BuildExplosion(short nSprite)
{ {
short nSector = sprite[nSprite].sectnum; auto pSprite = &sprite[nSprite];
short nSector = pSprite->sectnum;
int edx = 36; int edx = 36;
@ -297,21 +303,22 @@ void BuildExplosion(short nSprite)
{ {
edx = 75; edx = 75;
} }
else if (sprite[nSprite].z == sector[nSector].floorz) else if (pSprite->z == sector[nSector].floorz)
{ {
edx = 34; edx = 34;
} }
BuildAnim(-1, edx, 0, sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, sprite[nSprite].sectnum, sprite[nSprite].xrepeat, 4); BuildAnim(-1, edx, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, pSprite->xrepeat, 4);
} }
int BuildSplash(int nSprite, int nSector) int BuildSplash(int nSprite, int nSector)
{ {
auto pSprite = &sprite[nSprite];
int nRepeat, nSound; int nRepeat, nSound;
if (sprite[nSprite].statnum != 200) if (pSprite->statnum != 200)
{ {
nRepeat = sprite[nSprite].xrepeat + (RandomWord() % sprite[nSprite].xrepeat); nRepeat = pSprite->xrepeat + (RandomWord() % pSprite->xrepeat);
nSound = kSound0; nSound = kSound0;
} }
else else
@ -335,7 +342,7 @@ int BuildSplash(int nSprite, int nSector)
nFlag = 0; nFlag = 0;
} }
int nAnim = BuildAnim(-1, edx, 0, sprite[nSprite].x, sprite[nSprite].y, sector[nSector].floorz, nSector, nRepeat, nFlag); int nAnim = BuildAnim(-1, edx, 0, pSprite->x, pSprite->y, sector[nSector].floorz, nSector, nRepeat, nFlag);
if (!bIsLava) if (!bIsLava)
{ {

View file

@ -199,6 +199,7 @@ void FuncAnubis(int a, int nDamage, int nRun)
} }
short nTarget = ap->nTarget; short nTarget = ap->nTarget;
auto pTarget = nTarget < 0? nullptr : &sprite[nTarget];
short nFrame = SeqBase[nSeq] + ap->nFrame; short nFrame = SeqBase[nSeq] + ap->nFrame;
short nFlag = FrameFlag[nFrame]; short nFlag = FrameFlag[nFrame];
@ -249,7 +250,7 @@ void FuncAnubis(int a, int nDamage, int nRun)
{ {
if ((nMov & 0x3FFF) == nTarget) if ((nMov & 0x3FFF) == nTarget)
{ {
int nAng = getangle(sprite[nTarget].x - sp->x, sprite[nTarget].y - sp->y); int nAng = getangle(pTarget->x - sp->x, pTarget->y - sp->y);
int nAngDiff = AngleDiff(sp->ang, nAng); int nAngDiff = AngleDiff(sp->ang, nAng);
if (nAngDiff < 64) if (nAngDiff < 64)
@ -283,11 +284,11 @@ void FuncAnubis(int a, int nDamage, int nRun)
if (nTarget > -1) // NOTE: nTarget can be -1. this check wasn't in original code. TODO: demo compatiblity? if (nTarget > -1) // NOTE: nTarget can be -1. this check wasn't in original code. TODO: demo compatiblity?
{ {
if (cansee(sp->x, sp->y, sp->z - GetSpriteHeight(nSprite), sp->sectnum, if (cansee(sp->x, sp->y, sp->z - GetSpriteHeight(nSprite), sp->sectnum,
sprite[nTarget].x, sprite[nTarget].y, sprite[nTarget].z - GetSpriteHeight(nTarget), sprite[nTarget].sectnum)) pTarget->x, pTarget->y, pTarget->z - GetSpriteHeight(nTarget), pTarget->sectnum))
{ {
sp->xvel = 0; sp->xvel = 0;
sp->yvel = 0; sp->yvel = 0;
sp->ang = GetMyAngle(sprite[nTarget].x - sp->x, sprite[nTarget].y - sp->y); sp->ang = GetMyAngle(pTarget->x - sp->x, pTarget->y - sp->y);
ap->nAction = 3; ap->nAction = 3;
ap->nFrame = 0; ap->nFrame = 0;
@ -397,7 +398,7 @@ void FuncAnubis(int a, int nDamage, int nRun)
// loc_2564C: // loc_2564C:
if (nAction && nTarget != -1) if (nAction && nTarget != -1)
{ {
if (!(sprite[nTarget].cstat & 0x101)) if (!(pTarget->cstat & 0x101))
{ {
ap->nAction = 0; ap->nAction = 0;
ap->nFrame = 0; ap->nFrame = 0;
@ -444,8 +445,9 @@ void FuncAnubis(int a, int nDamage, int nRun)
if (nTarget < 0) { if (nTarget < 0) {
return; return;
} }
auto pTarget = &sprite[nTarget];
if (sprite[nTarget].statnum == 100 || sprite[nTarget].statnum < 199) if (pTarget->statnum == 100 || pTarget->statnum < 199)
{ {
if (!RandomSize(5)) { if (!RandomSize(5)) {
ap->nTarget = nTarget; ap->nTarget = nTarget;
@ -457,13 +459,14 @@ void FuncAnubis(int a, int nDamage, int nRun)
if (nAction >= 6 && nAction <= 10) if (nAction >= 6 && nAction <= 10)
{ {
int nDrumSprite = insertsprite(sp->sectnum, kStatAnubisDrum); int nDrumSprite = insertsprite(sp->sectnum, kStatAnubisDrum);
auto pDrumSprite = &sprite[nDrumSprite];
sprite[nDrumSprite].x = sp->x; pDrumSprite->x = sp->x;
sprite[nDrumSprite].y = sp->y; pDrumSprite->y = sp->y;
sprite[nDrumSprite].z = sector[sprite[nDrumSprite].sectnum].floorz; pDrumSprite->z = sector[pDrumSprite->sectnum].floorz;
sprite[nDrumSprite].xrepeat = 40; pDrumSprite->xrepeat = 40;
sprite[nDrumSprite].yrepeat = 40; pDrumSprite->yrepeat = 40;
sprite[nDrumSprite].shade = -64; pDrumSprite->shade = -64;
BuildObject(nDrumSprite, 2, 0); BuildObject(nDrumSprite, 2, 0);
} }

View file

@ -97,9 +97,10 @@ void InitBubbles()
void DestroyBubble(short nBubble) void DestroyBubble(short nBubble)
{ {
short nSprite = BubbleList[nBubble].nSprite; short nSprite = BubbleList[nBubble].nSprite;
auto pSprite = &sprite[nSprite];
runlist_DoSubRunRec(sprite[nSprite].lotag - 1); runlist_DoSubRunRec(pSprite->lotag - 1);
runlist_DoSubRunRec(sprite[nSprite].owner); runlist_DoSubRunRec(pSprite->owner);
runlist_SubRunRec(BubbleList[nBubble].nRun); runlist_SubRunRec(BubbleList[nBubble].nRun);
mydeletesprite(nSprite); mydeletesprite(nSprite);
@ -126,27 +127,28 @@ int BuildBubble(int x, int y, int z, short nSector)
int nSprite = insertsprite(nSector, 402); int nSprite = insertsprite(nSector, 402);
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
auto pSprite = &sprite[nSprite];
sprite[nSprite].x = x; pSprite->x = x;
sprite[nSprite].y = y; pSprite->y = y;
sprite[nSprite].z = z; pSprite->z = z;
sprite[nSprite].cstat = 0; pSprite->cstat = 0;
sprite[nSprite].shade = -32; pSprite->shade = -32;
sprite[nSprite].pal = 0; pSprite->pal = 0;
sprite[nSprite].clipdist = 5; pSprite->clipdist = 5;
sprite[nSprite].xrepeat = 40; pSprite->xrepeat = 40;
sprite[nSprite].yrepeat = 40; pSprite->yrepeat = 40;
sprite[nSprite].xoffset = 0; pSprite->xoffset = 0;
sprite[nSprite].yoffset = 0; pSprite->yoffset = 0;
sprite[nSprite].picnum = 1; pSprite->picnum = 1;
sprite[nSprite].ang = inita; pSprite->ang = inita;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = -1200; pSprite->zvel = -1200;
sprite[nSprite].hitag = -1; pSprite->hitag = -1;
sprite[nSprite].extra = -1; pSprite->extra = -1;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].backuppos(); pSprite->backuppos();
// GrabTimeSlot(3); // GrabTimeSlot(3);
@ -154,7 +156,7 @@ int BuildBubble(int x, int y, int z, short nSector)
BubbleList[nBubble].nFrame = 0; BubbleList[nBubble].nFrame = 0;
BubbleList[nBubble].nSeq = SeqOffsets[kSeqBubble] + nSize; BubbleList[nBubble].nSeq = SeqOffsets[kSeqBubble] + nSize;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nBubble | 0x140000); pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nBubble | 0x140000);
BubbleList[nBubble].nRun = runlist_AddRunRec(NewRun, nBubble | 0x140000); BubbleList[nBubble].nRun = runlist_AddRunRec(NewRun, nBubble | 0x140000);
return nBubble | 0x140000; return nBubble | 0x140000;
@ -167,6 +169,7 @@ void FuncBubble(int a, int, int nRun)
short nSprite = BubbleList[nBubble].nSprite; short nSprite = BubbleList[nBubble].nSprite;
short nSeq = BubbleList[nBubble].nSeq; short nSeq = BubbleList[nBubble].nSeq;
auto pSprite = &sprite[nSprite];
int nMessage = a & kMessageMask; int nMessage = a & kMessageMask;
@ -182,16 +185,16 @@ void FuncBubble(int a, int, int nRun)
BubbleList[nBubble].nFrame = 0; BubbleList[nBubble].nFrame = 0;
} }
sprite[nSprite].z += sprite[nSprite].zvel; pSprite->z += pSprite->zvel;
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
if (sprite[nSprite].z <= sector[nSector].ceilingz) if (pSprite->z <= sector[nSector].ceilingz)
{ {
short nSectAbove = SectAbove[nSector]; short nSectAbove = SectAbove[nSector];
if (sprite[nSprite].hitag > -1 && nSectAbove != -1) { if (pSprite->hitag > -1 && nSectAbove != -1) {
BuildAnim(-1, 70, 0, sprite[nSprite].x, sprite[nSprite].y, sector[nSectAbove].floorz, nSectAbove, 64, 0); BuildAnim(-1, 70, 0, pSprite->x, pSprite->y, sector[nSectAbove].floorz, nSectAbove, 64, 0);
} }
DestroyBubble(nBubble); DestroyBubble(nBubble);
@ -228,7 +231,8 @@ void DoBubbleMachines()
Machine[i]._0 = (RandomWord() % Machine[i]._4) + 30; Machine[i]._0 = (RandomWord() % Machine[i]._4) + 30;
int nSprite = Machine[i].nSprite; int nSprite = Machine[i].nSprite;
BuildBubble(sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, sprite[nSprite].sectnum); auto pSprite = &sprite[nSprite];
BuildBubble(pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum);
} }
} }
} }
@ -245,7 +249,8 @@ void BuildBubbleMachine(int nSprite)
Machine[nMachineCount]._0 = Machine[nMachineCount]._4; Machine[nMachineCount]._0 = Machine[nMachineCount]._4;
nMachineCount++; nMachineCount++;
sprite[nSprite].cstat = 0x8000; auto pSprite = &sprite[nSprite];
pSprite->cstat = 0x8000;
} }
void DoBubbles(int nPlayer) void DoBubbles(int nPlayer)
@ -257,7 +262,8 @@ void DoBubbles(int nPlayer)
int nBubble = BuildBubble(x, y, z, nSector); int nBubble = BuildBubble(x, y, z, nSector);
int nSprite = GetBubbleSprite(nBubble); int nSprite = GetBubbleSprite(nBubble);
auto pSprite = &sprite[nSprite];
sprite[nSprite].hitag = nPlayer; pSprite->hitag = nPlayer;
} }
END_PS_NS END_PS_NS

View file

@ -146,9 +146,10 @@ int GrabBullet()
void DestroyBullet(short nBullet) void DestroyBullet(short nBullet)
{ {
short nSprite = BulletList[nBullet].nSprite; short nSprite = BulletList[nBullet].nSprite;
auto pSprite = &sprite[nSprite];
runlist_DoSubRunRec(BulletList[nBullet].field_6); runlist_DoSubRunRec(BulletList[nBullet].field_6);
runlist_DoSubRunRec(sprite[nSprite].lotag - 1); runlist_DoSubRunRec(pSprite->lotag - 1);
runlist_SubRunRec(BulletList[nBullet].field_8); runlist_SubRunRec(BulletList[nBullet].field_8);
StopSpriteSound(nSprite); StopSpriteSound(nSprite);
@ -159,9 +160,11 @@ void DestroyBullet(short nBullet)
void IgniteSprite(int nSprite) void IgniteSprite(int nSprite)
{ {
sprite[nSprite].hitag += 2; auto pSprite = &sprite[nSprite];
int nAnim = BuildAnim(-1, 38, 0, sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, sprite[nSprite].sectnum, 40, 20); pSprite->hitag += 2;
int nAnim = BuildAnim(-1, 38, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 40, 20);
short nAnimSprite = GetAnimSprite(nAnim); short nAnimSprite = GetAnimSprite(nAnim);
sprite[nAnimSprite].hitag = nSprite; sprite[nAnimSprite].hitag = nSprite;
@ -393,7 +396,7 @@ MOVEEND:
} }
} }
// sprite[nSprite].sectnum may have changed since we set nSectFlag ? // pSprite->sectnum may have changed since we set nSectFlag ?
short nFlagVal = nSectFlag ^ SectFlag[pSprite->sectnum]; short nFlagVal = nSectFlag ^ SectFlag[pSprite->sectnum];
if (nFlagVal & kSectUnderwater) if (nFlagVal & kSectUnderwater)
{ {
@ -403,10 +406,10 @@ MOVEEND:
if (nVal == 0 && nType != 15 && nType != 3) if (nVal == 0 && nType != 15 && nType != 3)
{ {
AddFlash(sprite[nSprite].sectnum, sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, 0); AddFlash(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 0);
if (sprite[nSprite].pal != 5) { if (pSprite->pal != 5) {
sprite[nSprite].pal = 1; pSprite->pal = 1;
} }
} }
} }
@ -555,6 +558,7 @@ void SetBulletEnemy(short nBullet, short nEnemy)
int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int val2, int val3) int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int val2, int val3)
{ {
auto pSprite = &sprite[nSprite];
Bullet sBullet; Bullet sBullet;
bulletInfo *pBulletInfo = &BulletInfo[nType]; bulletInfo *pBulletInfo = &BulletInfo[nType];
@ -567,19 +571,19 @@ int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int va
short nTargetSprite = val2; short nTargetSprite = val2;
spritetype *pTargetSprite = &sprite[nTargetSprite]; spritetype *pTargetSprite = &sprite[nTargetSprite];
// assert(sprite[nTargetSprite].sectnum <= kMaxSectors); // assert(pTargetSprite->sectnum <= kMaxSectors);
if (pTargetSprite->cstat & 0x101) if (pTargetSprite->cstat & 0x101)
{ {
sBullet.nType = nType; sBullet.nType = nType;
sBullet.field_13 = val3; sBullet.field_13 = val3;
sBullet.nSprite = insertsprite(sprite[nSprite].sectnum, 200); sBullet.nSprite = insertsprite(pSprite->sectnum, 200);
sprite[sBullet.nSprite].ang = nAngle; sprite[sBullet.nSprite].ang = nAngle;
int nHeight = GetSpriteHeight(nTargetSprite); int nHeight = GetSpriteHeight(nTargetSprite);
assert(sprite[nTargetSprite].sectnum >= 0 && sprite[nTargetSprite].sectnum < kMaxSectors); assert(pTargetSprite->sectnum >= 0 && pTargetSprite->sectnum < kMaxSectors);
BulletHitsSprite(&sBullet, nSprite, nTargetSprite, pTargetSprite->x, pTargetSprite->y, pTargetSprite->z - (nHeight >> 1), pTargetSprite->sectnum); BulletHitsSprite(&sBullet, nSprite, nTargetSprite, pTargetSprite->x, pTargetSprite->y, pTargetSprite->z - (nHeight >> 1), pTargetSprite->sectnum);
mydeletesprite(sBullet.nSprite); mydeletesprite(sBullet.nSprite);
@ -599,16 +603,17 @@ int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int va
short nSector; short nSector;
if (sprite[nSprite].statnum == 100) if (pSprite->statnum == 100)
{ {
nSector = nPlayerViewSect[GetPlayerFromSprite(nSprite)]; nSector = nPlayerViewSect[GetPlayerFromSprite(nSprite)];
} }
else else
{ {
nSector = sprite[nSprite].sectnum; nSector = pSprite->sectnum;
} }
short nBulletSprite = insertsprite(nSector, 200); short nBulletSprite = insertsprite(nSector, 200);
auto pBulletSprite = &sprite[nBulletSprite];
int nHeight = GetSpriteHeight(nSprite); int nHeight = GetSpriteHeight(nSprite);
nHeight = nHeight - (nHeight >> 2); nHeight = nHeight - (nHeight >> 2);
@ -616,9 +621,9 @@ int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int va
val1 = -nHeight; val1 = -nHeight;
} }
sprite[nBulletSprite].x = sprite[nSprite].x; pBulletSprite->x = pSprite->x;
sprite[nBulletSprite].y = sprite[nSprite].y; pBulletSprite->y = pSprite->y;
sprite[nBulletSprite].z = sprite[nSprite].z; pBulletSprite->z = pSprite->z;
// why is this done here??? // why is this done here???
assert(nBulletSprite >= 0 && nBulletSprite < kMaxSprites); assert(nBulletSprite >= 0 && nBulletSprite < kMaxSprites);
@ -627,35 +632,35 @@ int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int va
pBullet->enemy = -1; pBullet->enemy = -1;
sprite[nBulletSprite].cstat = 0; pBulletSprite->cstat = 0;
sprite[nBulletSprite].shade = -64; pBulletSprite->shade = -64;
if (pBulletInfo->nFlags & 4) { if (pBulletInfo->nFlags & 4) {
sprite[nBulletSprite].pal = 4; pBulletSprite->pal = 4;
} }
else { else {
sprite[nBulletSprite].pal = 0; pBulletSprite->pal = 0;
} }
sprite[nBulletSprite].clipdist = 25; pBulletSprite->clipdist = 25;
short nRepeat = pBulletInfo->xyRepeat; short nRepeat = pBulletInfo->xyRepeat;
if (nRepeat < 0) { if (nRepeat < 0) {
nRepeat = 30; nRepeat = 30;
} }
sprite[nBulletSprite].xrepeat = (uint8_t)nRepeat; pBulletSprite->xrepeat = (uint8_t)nRepeat;
sprite[nBulletSprite].yrepeat = (uint8_t)nRepeat; pBulletSprite->yrepeat = (uint8_t)nRepeat;
sprite[nBulletSprite].xoffset = 0; pBulletSprite->xoffset = 0;
sprite[nBulletSprite].yoffset = 0; pBulletSprite->yoffset = 0;
sprite[nBulletSprite].ang = nAngle; pBulletSprite->ang = nAngle;
sprite[nBulletSprite].xvel = 0; pBulletSprite->xvel = 0;
sprite[nBulletSprite].yvel = 0; pBulletSprite->yvel = 0;
sprite[nBulletSprite].zvel = 0; pBulletSprite->zvel = 0;
sprite[nBulletSprite].owner = nSprite; pBulletSprite->owner = nSprite;
sprite[nBulletSprite].lotag = runlist_HeadRun() + 1; pBulletSprite->lotag = runlist_HeadRun() + 1;
sprite[nBulletSprite].extra = -1; pBulletSprite->extra = -1;
sprite[nBulletSprite].hitag = 0; pBulletSprite->hitag = 0;
// GrabTimeSlot(3); // GrabTimeSlot(3);
@ -678,30 +683,30 @@ int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int va
pBullet->nSeq = nSeq; pBullet->nSeq = nSeq;
sprite[nBulletSprite].picnum = seq_GetSeqPicnum(nSeq, 0, 0); pBulletSprite->picnum = seq_GetSeqPicnum(nSeq, 0, 0);
if (nSeq == kSeqBullet) { if (nSeq == kSeqBullet) {
sprite[nBulletSprite].cstat |= 0x8000; pBulletSprite->cstat |= 0x8000;
} }
pBullet->field_C = val2; pBullet->field_C = val2;
pBullet->nType = nType; pBullet->nType = nType;
pBullet->nSprite = nBulletSprite; pBullet->nSprite = nBulletSprite;
pBullet->field_6 = runlist_AddRunRec(sprite[nBulletSprite].lotag - 1, nBullet | 0xB0000); pBullet->field_6 = runlist_AddRunRec(pBulletSprite->lotag - 1, nBullet | 0xB0000);
pBullet->field_8 = runlist_AddRunRec(NewRun, nBullet | 0xB0000); pBullet->field_8 = runlist_AddRunRec(NewRun, nBullet | 0xB0000);
pBullet->field_13 = val3; pBullet->field_13 = val3;
sprite[nBulletSprite].z += val1; pBulletSprite->z += val1;
sprite[nBulletSprite].backuppos(); pBulletSprite->backuppos();
int var_18; int var_18;
nSector = sprite[nBulletSprite].sectnum; nSector = pBulletSprite->sectnum;
while (sprite[nBulletSprite].z < sector[nSector].ceilingz) while (pBulletSprite->z < sector[nSector].ceilingz)
{ {
if (SectAbove[nSector] == -1) if (SectAbove[nSector] == -1)
{ {
sprite[nBulletSprite].z = sector[nSector].ceilingz; pBulletSprite->z = sector[nSector].ceilingz;
break; break;
} }
@ -718,6 +723,7 @@ int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int va
val2 -= 10000; val2 -= 10000;
short nTargetSprite = val2; short nTargetSprite = val2;
auto pTargetSprite = &sprite[nTargetSprite];
if ((unsigned int)pBulletInfo->field_4 > 30000) if ((unsigned int)pBulletInfo->field_4 > 30000)
{ {
@ -727,7 +733,7 @@ int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int va
{ {
nHeight = GetSpriteHeight(nTargetSprite); nHeight = GetSpriteHeight(nTargetSprite);
if (sprite[nTargetSprite].statnum == 100) if (pTargetSprite->statnum == 100)
{ {
nHeight -= nHeight >> 2; nHeight -= nHeight >> 2;
} }
@ -736,19 +742,19 @@ int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int va
nHeight -= nHeight >> 1; nHeight -= nHeight >> 1;
} }
int var_20 = sprite[nTargetSprite].z - nHeight; int var_20 = pTargetSprite->z - nHeight;
int x, y; int x, y;
if (nSprite != -1 && sprite[nSprite].statnum != 100) if (nSprite != -1 && pSprite->statnum != 100)
{ {
x = sprite[nTargetSprite].x; x = pTargetSprite->x;
y = sprite[nTargetSprite].y; y = pTargetSprite->y;
if (sprite[nTargetSprite].statnum != 100) if (pTargetSprite->statnum != 100)
{ {
x += (sprite[nTargetSprite].xvel * 20) >> 6; x += (pTargetSprite->xvel * 20) >> 6;
y += (sprite[nTargetSprite].yvel * 20) >> 6; y += (pTargetSprite->yvel * 20) >> 6;
} }
else else
{ {
@ -760,23 +766,23 @@ int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int va
} }
} }
x -= sprite[nBulletSprite].x; x -= pBulletSprite->x;
y -= sprite[nBulletSprite].y; y -= pBulletSprite->y;
nAngle = GetMyAngle(x, y); nAngle = GetMyAngle(x, y);
sprite[nSprite].ang = nAngle; pSprite->ang = nAngle;
} }
else else
{ {
// loc_2ABA3: // loc_2ABA3:
x = sprite[nTargetSprite].x - sprite[nBulletSprite].x; x = pTargetSprite->x - pBulletSprite->x;
y = sprite[nTargetSprite].y - sprite[nBulletSprite].y; y = pTargetSprite->y - pBulletSprite->y;
} }
int nSqrt = lsqrt(y*y + x*x); int nSqrt = lsqrt(y*y + x*x);
if ((unsigned int)nSqrt > 0) if ((unsigned int)nSqrt > 0)
{ {
var_18 = ((var_20 - sprite[nBulletSprite].z) * pBulletInfo->field_4) / nSqrt; var_18 = ((var_20 - pBulletSprite->z) * pBulletInfo->field_4) / nSqrt;
} }
else else
{ {
@ -786,8 +792,8 @@ int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int va
} }
pBullet->z = 0; pBullet->z = 0;
pBullet->x = (sprite[nSprite].clipdist << 2) * bcos(nAngle); pBullet->x = (pSprite->clipdist << 2) * bcos(nAngle);
pBullet->y = (sprite[nSprite].clipdist << 2) * bsin(nAngle); pBullet->y = (pSprite->clipdist << 2) * bsin(nAngle);
BulletList[nBullet].enemy = -1; BulletList[nBullet].enemy = -1;
if (MoveBullet(nBullet)) if (MoveBullet(nBullet))
@ -812,6 +818,7 @@ void FuncBullet(int a, int, int nRun)
short nSeq = SeqOffsets[BulletList[nBullet].nSeq]; short nSeq = SeqOffsets[BulletList[nBullet].nSeq];
short nSprite = BulletList[nBullet].nSprite; short nSprite = BulletList[nBullet].nSprite;
auto pSprite = &sprite[nSprite];
int nMessage = a & kMessageMask; int nMessage = a & kMessageMask;
@ -825,7 +832,7 @@ void FuncBullet(int a, int, int nRun)
if (nFlag & 0x80) if (nFlag & 0x80)
{ {
BuildAnim(-1, 45, 0, sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, sprite[nSprite].sectnum, sprite[nSprite].xrepeat, 0); BuildAnim(-1, 45, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, pSprite->xrepeat, 0);
} }
BulletList[nBullet].nFrame++; BulletList[nBullet].nFrame++;

View file

@ -193,8 +193,9 @@ void DoRedAlert(int nVal)
{ {
if (nVal) if (nVal)
{ {
PlayFXAtXYZ(StaticSound[kSoundAlarm], sprite[i].x, sprite[i].y, sprite[i].z, sprite[i].sectnum); auto spri = &sprite[i];
AddFlash(sprite[i].sectnum, sprite[i].x, sprite[i].y, sprite[i].z, 192); PlayFXAtXYZ(StaticSound[kSoundAlarm], spri->x, spri->y, spri->z, spri->sectnum);
AddFlash(spri->sectnum, spri->x, spri->y, spri->z, 192);
} }
} }
} }
@ -253,7 +254,7 @@ void GameMove(void)
for (int i = 0; i < MAXSPRITES; i++) for (int i = 0; i < MAXSPRITES; i++)
{ {
sprite[i].backuploc(); sprite[i].backuploc();
} }
if (currentLevel->gameflags & LEVEL_EX_COUNTDOWN) if (currentLevel->gameflags & LEVEL_EX_COUNTDOWN)

View file

@ -103,41 +103,43 @@ void InitFishes()
int BuildFishLimb(short nFish, short edx) int BuildFishLimb(short nFish, short edx)
{ {
short nSprite = FishList[nFish].nSprite; short nSprite = FishList[nFish].nSprite;
auto pSprite = &sprite[nSprite];
int nFree = FishChunk.Reserve(1); int nFree = FishChunk.Reserve(1);
int nSprite2 = insertsprite(sprite[nSprite].sectnum, 99); int nSprite2 = insertsprite(pSprite->sectnum, 99);
assert(nSprite2 >= 0 && nSprite2 < kMaxSprites); assert(nSprite2 >= 0 && nSprite2 < kMaxSprites);
auto pSprite2 = &sprite[nSprite2];
FishChunk[nFree].nSprite = nSprite2; FishChunk[nFree].nSprite = nSprite2;
FishChunk[nFree].nSeqIndex = edx + 40; FishChunk[nFree].nSeqIndex = edx + 40;
FishChunk[nFree].nIndex = RandomSize(3) % SeqSize[SeqOffsets[kSeqFish] + edx + 40]; FishChunk[nFree].nIndex = RandomSize(3) % SeqSize[SeqOffsets[kSeqFish] + edx + 40];
sprite[nSprite2].x = sprite[nSprite].x; pSprite2->x = pSprite->x;
sprite[nSprite2].y = sprite[nSprite].y; pSprite2->y = pSprite->y;
sprite[nSprite2].z = sprite[nSprite].z; pSprite2->z = pSprite->z;
sprite[nSprite2].cstat = 0; pSprite2->cstat = 0;
sprite[nSprite2].shade = -12; pSprite2->shade = -12;
sprite[nSprite2].pal = 0; pSprite2->pal = 0;
sprite[nSprite2].xvel = (RandomSize(5) - 16) << 8; pSprite2->xvel = (RandomSize(5) - 16) << 8;
sprite[nSprite2].yvel = (RandomSize(5) - 16) << 8; pSprite2->yvel = (RandomSize(5) - 16) << 8;
sprite[nSprite2].xrepeat = 64; pSprite2->xrepeat = 64;
sprite[nSprite2].yrepeat = 64; pSprite2->yrepeat = 64;
sprite[nSprite2].xoffset = 0; pSprite2->xoffset = 0;
sprite[nSprite2].yoffset = 0; pSprite2->yoffset = 0;
sprite[nSprite2].zvel = (-(RandomByte() + 512)) * 2; pSprite2->zvel = (-(RandomByte() + 512)) * 2;
seq_GetSeqPicnum(kSeqFish, FishChunk[nFree].nSeqIndex, 0); seq_GetSeqPicnum(kSeqFish, FishChunk[nFree].nSeqIndex, 0);
sprite[nSprite2].picnum = edx; pSprite2->picnum = edx;
sprite[nSprite2].lotag = runlist_HeadRun() + 1; pSprite2->lotag = runlist_HeadRun() + 1;
sprite[nSprite2].clipdist = 0; pSprite2->clipdist = 0;
// GrabTimeSlot(3); // GrabTimeSlot(3);
sprite[nSprite2].extra = -1; pSprite2->extra = -1;
sprite[nSprite2].owner = runlist_AddRunRec(sprite[nSprite2].lotag - 1, nFree | 0x200000); pSprite2->owner = runlist_AddRunRec(pSprite2->lotag - 1, nFree | 0x200000);
sprite[nSprite2].hitag = runlist_AddRunRec(NewRun, nFree | 0x200000); pSprite2->hitag = runlist_AddRunRec(NewRun, nFree | 0x200000);
return nFree | 0x200000; return nFree | 0x200000;
} }
@ -152,6 +154,7 @@ void FuncFishLimb(int a, int, int nRun)
short nFish = RunData[nRun].nVal; short nFish = RunData[nRun].nVal;
short nSprite = FishChunk[nFish].nSprite; short nSprite = FishChunk[nFish].nSprite;
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
auto pSprite = &sprite[nSprite];
int nSeq = SeqOffsets[kSeqFish] + FishChunk[nFish].nSeqIndex; int nSeq = SeqOffsets[kSeqFish] + FishChunk[nFish].nSeqIndex;
@ -161,7 +164,7 @@ void FuncFishLimb(int a, int, int nRun)
{ {
case 0x20000: case 0x20000:
{ {
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, FishChunk[nFish].nIndex); pSprite->picnum = seq_GetSeqPicnum2(nSeq, FishChunk[nFish].nIndex);
Gravity(nSprite); Gravity(nSprite);
@ -171,37 +174,37 @@ void FuncFishLimb(int a, int, int nRun)
{ {
FishChunk[nFish].nIndex = 0; FishChunk[nFish].nIndex = 0;
if (RandomBit()) { if (RandomBit()) {
BuildBlood(sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, sprite[nSprite].sectnum); BuildBlood(pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum);
} }
} }
int FloorZ = sector[sprite[nSprite].sectnum].floorz; int FloorZ = sector[pSprite->sectnum].floorz;
if (FloorZ <= sprite[nSprite].z) if (FloorZ <= pSprite->z)
{ {
sprite[nSprite].z += 256; pSprite->z += 256;
if ((sprite[nSprite].z - FloorZ) > 25600) if ((pSprite->z - FloorZ) > 25600)
{ {
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
runlist_DoSubRunRec(sprite[nSprite].owner); runlist_DoSubRunRec(pSprite->owner);
runlist_FreeRun(sprite[nSprite].lotag - 1); runlist_FreeRun(pSprite->lotag - 1);
runlist_SubRunRec(sprite[nSprite].hitag); runlist_SubRunRec(pSprite->hitag);
mydeletesprite(nSprite); mydeletesprite(nSprite);
} }
else if ((sprite[nSprite].z - FloorZ) > 0) else if ((pSprite->z - FloorZ) > 0)
{ {
sprite[nSprite].zvel = 1024; pSprite->zvel = 1024;
} }
return; return;
} }
else else
{ {
if (movesprite(nSprite, sprite[nSprite].xvel << 8, sprite[nSprite].yvel << 8, sprite[nSprite].zvel, 2560, -2560, CLIPMASK1)) if (movesprite(nSprite, pSprite->xvel << 8, pSprite->yvel << 8, pSprite->zvel, 2560, -2560, CLIPMASK1))
{ {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
} }
@ -219,41 +222,43 @@ void FuncFishLimb(int a, int, int nRun)
int BuildFish(int nSprite, int x, int y, int z, int nSector, int nAngle) int BuildFish(int nSprite, int x, int y, int z, int nSector, int nAngle)
{ {
int nFish = FishList.Reserve(1); int nFish = FishList.Reserve(1);
auto pSprite = &sprite[nSprite];
if (nSprite == -1) if (nSprite == -1)
{ {
nSprite = insertsprite(nSector, 103); nSprite = insertsprite(nSector, 103);
pSprite = &sprite[nSprite];
} }
else else
{ {
x = sprite[nSprite].x; x = pSprite->x;
y = sprite[nSprite].y; y = pSprite->y;
z = sprite[nSprite].z; z = pSprite->z;
nAngle = sprite[nSprite].ang; nAngle = pSprite->ang;
changespritestat(nSprite, 103); changespritestat(nSprite, 103);
} }
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
sprite[nSprite].x = x; pSprite->x = x;
sprite[nSprite].y = y; pSprite->y = y;
sprite[nSprite].z = z; pSprite->z = z;
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
sprite[nSprite].shade = -12; pSprite->shade = -12;
sprite[nSprite].clipdist = 80; pSprite->clipdist = 80;
sprite[nSprite].xrepeat = 40; pSprite->xrepeat = 40;
sprite[nSprite].yrepeat = 40; pSprite->yrepeat = 40;
sprite[nSprite].pal = sector[sprite[nSprite].sectnum].ceilingpal; pSprite->pal = sector[pSprite->sectnum].ceilingpal;
sprite[nSprite].xoffset = 0; pSprite->xoffset = 0;
sprite[nSprite].yoffset = 0; pSprite->yoffset = 0;
sprite[nSprite].picnum = seq_GetSeqPicnum(kSeqFish, FishSeq[0].a, 0); pSprite->picnum = seq_GetSeqPicnum(kSeqFish, FishSeq[0].a, 0);
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].ang = nAngle; pSprite->ang = nAngle;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].hitag = 0; pSprite->hitag = 0;
sprite[nSprite].extra = -1; pSprite->extra = -1;
// GrabTimeSlot(3); // GrabTimeSlot(3);
@ -264,7 +269,7 @@ int BuildFish(int nSprite, int x, int y, int z, int nSector, int nAngle)
FishList[nFish].nCount = 60; FishList[nFish].nCount = 60;
FishList[nFish].nFrame = 0; FishList[nFish].nFrame = 0;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nFish | 0x120000); pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nFish | 0x120000);
FishList[nFish].nRun = runlist_AddRunRec(NewRun, nFish | 0x120000); FishList[nFish].nRun = runlist_AddRunRec(NewRun, nFish | 0x120000);
nCreaturesTotal++; nCreaturesTotal++;
@ -275,36 +280,38 @@ int BuildFish(int nSprite, int x, int y, int z, int nSector, int nAngle)
void IdleFish(short nFish, short edx) void IdleFish(short nFish, short edx)
{ {
short nSprite = FishList[nFish].nSprite; short nSprite = FishList[nFish].nSprite;
auto pSprite = &sprite[nSprite];
sprite[nSprite].ang += (256 - RandomSize(9)) + 1024; pSprite->ang += (256 - RandomSize(9)) + 1024;
sprite[nSprite].ang &= kAngleMask; pSprite->ang &= kAngleMask;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -8); pSprite->xvel = bcos(pSprite->ang, -8);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -8); pSprite->yvel = bsin(pSprite->ang, -8);
FishList[nFish].nAction = 0; FishList[nFish].nAction = 0;
FishList[nFish].nFrame = 0; FishList[nFish].nFrame = 0;
sprite[nSprite].zvel = RandomSize(9); pSprite->zvel = RandomSize(9);
if (!edx) if (!edx)
{ {
if (RandomBit()) { if (RandomBit()) {
sprite[nSprite].zvel = -sprite[nSprite].zvel; pSprite->zvel = -pSprite->zvel;
} }
} }
else if (edx < 0) else if (edx < 0)
{ {
sprite[nSprite].zvel = -sprite[nSprite].zvel; pSprite->zvel = -pSprite->zvel;
} }
} }
void DestroyFish(short nFish) void DestroyFish(short nFish)
{ {
short nSprite = FishList[nFish].nSprite; short nSprite = FishList[nFish].nSprite;
auto pSprite = &sprite[nSprite];
runlist_DoSubRunRec(sprite[nSprite].owner); runlist_DoSubRunRec(pSprite->owner);
runlist_FreeRun(sprite[nSprite].lotag - 1); runlist_FreeRun(pSprite->lotag - 1);
runlist_SubRunRec(FishList[nFish].nRun); runlist_SubRunRec(FishList[nFish].nRun);
mydeletesprite(nSprite); mydeletesprite(nSprite);
} }
@ -316,6 +323,7 @@ void FuncFish(int a, int nDamage, int nRun)
short nSprite = FishList[nFish].nSprite; short nSprite = FishList[nFish].nSprite;
short nAction = FishList[nFish].nAction; short nAction = FishList[nFish].nAction;
auto pSprite = &sprite[nSprite];
int nMessage = a & kMessageMask; int nMessage = a & kMessageMask;
@ -363,7 +371,7 @@ void FuncFish(int a, int nDamage, int nRun)
FishList[nFish].nHealth = 0; FishList[nFish].nHealth = 0;
nCreaturesKilled++; nCreaturesKilled++;
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
if (nMessage == 0x80000) if (nMessage == 0x80000)
{ {
@ -372,7 +380,7 @@ void FuncFish(int a, int nDamage, int nRun)
BuildFishLimb(nFish, i); BuildFishLimb(nFish, i);
} }
PlayFXAtXYZ(StaticSound[kSound40], sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, sprite[nSprite].sectnum); PlayFXAtXYZ(StaticSound[kSound40], pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum);
DestroyFish(nFish); DestroyFish(nFish);
} }
else else
@ -401,14 +409,14 @@ void FuncFish(int a, int nDamage, int nRun)
case 0x20000: case 0x20000:
{ {
if (!(SectFlag[sprite[nSprite].sectnum] & kSectUnderwater)) if (!(SectFlag[pSprite->sectnum] & kSectUnderwater))
{ {
Gravity(nSprite); Gravity(nSprite);
} }
short nSeq = SeqOffsets[kSeqFish] + FishSeq[nAction].a; short nSeq = SeqOffsets[kSeqFish] + FishSeq[nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, FishList[nFish].nFrame); pSprite->picnum = seq_GetSeqPicnum2(nSeq, FishList[nFish].nFrame);
seq_MoveSequence(nSprite, nSeq, FishList[nFish].nFrame); seq_MoveSequence(nSprite, nSeq, FishList[nFish].nFrame);
@ -436,8 +444,8 @@ void FuncFish(int a, int nDamage, int nRun)
FishList[nFish].nAction = 2; FishList[nFish].nAction = 2;
FishList[nFish].nFrame = 0; FishList[nFish].nFrame = 0;
int nAngle = GetMyAngle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].z - sprite[nSprite].z); int nAngle = GetMyAngle(sprite[nTarget].x - pSprite->x, sprite[nTarget].z - pSprite->z);
sprite[nSprite].zvel = bsin(nAngle, -5); pSprite->zvel = bsin(nAngle, -5);
FishList[nFish].nCount = RandomSize(6) + 90; FishList[nFish].nCount = RandomSize(6) + 90;
} }
@ -467,20 +475,20 @@ void FuncFish(int a, int nDamage, int nRun)
PlotCourseToSprite(nSprite, nTarget); PlotCourseToSprite(nSprite, nTarget);
int nHeight = GetSpriteHeight(nSprite) >> 1; int nHeight = GetSpriteHeight(nSprite) >> 1;
int z = abs(sprite[nTarget].z - sprite[nSprite].z); int z = abs(sprite[nTarget].z - pSprite->z);
if (z <= nHeight) if (z <= nHeight)
{ {
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -5) - bcos(sprite[nSprite].ang, -7); pSprite->xvel = bcos(pSprite->ang, -5) - bcos(pSprite->ang, -7);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -5) - bsin(sprite[nSprite].ang, -7); pSprite->yvel = bsin(pSprite->ang, -5) - bsin(pSprite->ang, -7);
} }
else else
{ {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
sprite[nSprite].zvel = (sprite[nTarget].z - sprite[nSprite].z) >> 3; pSprite->zvel = (sprite[nTarget].z - pSprite->z) >> 3;
} }
break; break;
} }
@ -509,20 +517,20 @@ void FuncFish(int a, int nDamage, int nRun)
} }
} }
int x = sprite[nSprite].x; int x = pSprite->x;
int y = sprite[nSprite].y; int y = pSprite->y;
int z = sprite[nSprite].z; int z = pSprite->z;
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
// loc_2EF54 // loc_2EF54
int nMov = movesprite(nSprite, sprite[nSprite].xvel << 13, sprite[nSprite].yvel << 13, sprite[nSprite].zvel << 2, 0, 0, CLIPMASK0); int nMov = movesprite(nSprite, pSprite->xvel << 13, pSprite->yvel << 13, pSprite->zvel << 2, 0, 0, CLIPMASK0);
if (!(SectFlag[sprite[nSprite].sectnum] & kSectUnderwater)) if (!(SectFlag[pSprite->sectnum] & kSectUnderwater))
{ {
mychangespritesect(nSprite, nSector); mychangespritesect(nSprite, nSector);
sprite[nSprite].x = x; pSprite->x = x;
sprite[nSprite].y = y; pSprite->y = y;
sprite[nSprite].z = z; pSprite->z = z;
IdleFish(nFish, 0); IdleFish(nFish, 0);
return; return;
@ -554,7 +562,7 @@ void FuncFish(int a, int nDamage, int nRun)
if (sprite[nMov & 0x3FFF].statnum == 100) if (sprite[nMov & 0x3FFF].statnum == 100)
{ {
FishList[nFish].nTarget = nMov & 0x3FFF; FishList[nFish].nTarget = nMov & 0x3FFF;
sprite[nSprite].ang = GetMyAngle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y); pSprite->ang = GetMyAngle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
if (nAction != 3) if (nAction != 3)
{ {

View file

@ -114,30 +114,32 @@ int ThrowGrenade(short nPlayer, int, int, int ecx, int push1)
short nGrenadeSprite = GrenadeList[nGrenade].nSprite; short nGrenadeSprite = GrenadeList[nGrenade].nSprite;
short nPlayerSprite = PlayerList[nPlayer].nSprite; short nPlayerSprite = PlayerList[nPlayer].nSprite;
auto pGrenadeSprite = &sprite[nGrenadeSprite];
auto pPlayerSprite = &sprite[nPlayerSprite];
short nAngle = sprite[nPlayerSprite].ang; short nAngle = pPlayerSprite->ang;
mychangespritesect(nGrenadeSprite, nPlayerViewSect[nPlayer]); mychangespritesect(nGrenadeSprite, nPlayerViewSect[nPlayer]);
sprite[nGrenadeSprite].x = sprite[nPlayerSprite].x; pGrenadeSprite->x = pPlayerSprite->x;
sprite[nGrenadeSprite].y = sprite[nPlayerSprite].y; pGrenadeSprite->y = pPlayerSprite->y;
sprite[nGrenadeSprite].z = sprite[nPlayerSprite].z; pGrenadeSprite->z = pPlayerSprite->z;
if (nAngle < 0) { if (nAngle < 0) {
nAngle = sprite[nPlayerSprite].ang; nAngle = pPlayerSprite->ang;
} }
sprite[nGrenadeSprite].cstat &= 0x7FFF; pGrenadeSprite->cstat &= 0x7FFF;
sprite[nGrenadeSprite].ang = nAngle; pGrenadeSprite->ang = nAngle;
if (push1 >= -3000) if (push1 >= -3000)
{ {
int nVel = totalvel[nPlayer] << 5; int nVel = totalvel[nPlayer] << 5;
GrenadeList[nGrenade].field_10 = ((90 - GrenadeList[nGrenade].field_E) * (90 - GrenadeList[nGrenade].field_E)) + nVel; GrenadeList[nGrenade].field_10 = ((90 - GrenadeList[nGrenade].field_E) * (90 - GrenadeList[nGrenade].field_E)) + nVel;
sprite[nGrenadeSprite].zvel = (-64 * push1) - 4352; pGrenadeSprite->zvel = (-64 * push1) - 4352;
int nMov = movesprite(nGrenadeSprite, bcos(nAngle) * (sprite[nPlayerSprite].clipdist << 3), bsin(nAngle) * (sprite[nPlayerSprite].clipdist << 3), ecx, 0, 0, CLIPMASK1); int nMov = movesprite(nGrenadeSprite, bcos(nAngle) * (pPlayerSprite->clipdist << 3), bsin(nAngle) * (pPlayerSprite->clipdist << 3), ecx, 0, 0, CLIPMASK1);
if (nMov & 0x8000) if (nMov & 0x8000)
{ {
nAngle = GetWallNormal(nMov & 0x3FFF); nAngle = GetWallNormal(nMov & 0x3FFF);
@ -147,7 +149,7 @@ int ThrowGrenade(short nPlayer, int, int, int ecx, int push1)
else else
{ {
GrenadeList[nGrenade].field_10 = 0; GrenadeList[nGrenade].field_10 = 0;
sprite[nGrenadeSprite].zvel = sprite[nPlayerSprite].zvel; pGrenadeSprite->zvel = pPlayerSprite->zvel;
} }
GrenadeList[nGrenade].x = bcos(nAngle, -4) * GrenadeList[nGrenade].field_10; GrenadeList[nGrenade].x = bcos(nAngle, -4) * GrenadeList[nGrenade].field_10;
@ -165,30 +167,32 @@ int BuildGrenade(int nPlayer)
int nSprite = insertsprite(nPlayerViewSect[nPlayer], 201); int nSprite = insertsprite(nPlayerViewSect[nPlayer], 201);
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
auto pSprite = &sprite[nSprite];
int nPlayerSprite = PlayerList[nPlayer].nSprite; int nPlayerSprite = PlayerList[nPlayer].nSprite;
auto pPlayerSprite = &sprite[nPlayerSprite];
sprite[nSprite].x = sprite[nPlayerSprite].x; pSprite->x = pPlayerSprite->x;
sprite[nSprite].y = sprite[nPlayerSprite].y; pSprite->y = pPlayerSprite->y;
sprite[nSprite].z = sprite[nPlayerSprite].z - 3840; pSprite->z = pPlayerSprite->z - 3840;
sprite[nSprite].shade = -64; pSprite->shade = -64;
sprite[nSprite].xrepeat = 20; pSprite->xrepeat = 20;
sprite[nSprite].yrepeat = 20; pSprite->yrepeat = 20;
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
sprite[nSprite].picnum = 1; pSprite->picnum = 1;
sprite[nSprite].pal = 0; pSprite->pal = 0;
sprite[nSprite].clipdist = 30; pSprite->clipdist = 30;
sprite[nSprite].xoffset = 0; pSprite->xoffset = 0;
sprite[nSprite].yoffset = 0; pSprite->yoffset = 0;
sprite[nSprite].ang = sprite[nPlayerSprite].ang; pSprite->ang = pPlayerSprite->ang;
sprite[nSprite].owner = nPlayerSprite; pSprite->owner = nPlayerSprite;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].hitag = 0; pSprite->hitag = 0;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].extra = -1; pSprite->extra = -1;
sprite[nSprite].backuppos(); pSprite->backuppos();
// GrabTimeSlot(3); // GrabTimeSlot(3);
@ -199,7 +203,7 @@ int BuildGrenade(int nPlayer)
GrenadeList[nGrenade].nSprite = nSprite; GrenadeList[nGrenade].nSprite = nSprite;
GrenadeList[nGrenade].field_A = 0; GrenadeList[nGrenade].field_A = 0;
GrenadeList[nGrenade].field_C = 0; GrenadeList[nGrenade].field_C = 0;
GrenadeList[nGrenade].field_6 = runlist_AddRunRec(sprite[nSprite].lotag - 1, nGrenade | 0x0F0000); GrenadeList[nGrenade].field_6 = runlist_AddRunRec(pSprite->lotag - 1, nGrenade | 0x0F0000);
GrenadeList[nGrenade].field_8 = runlist_AddRunRec(NewRun, nGrenade | 0x0F0000); GrenadeList[nGrenade].field_8 = runlist_AddRunRec(NewRun, nGrenade | 0x0F0000);
nGrenadePlayer[nGrenade] = nPlayer; nGrenadePlayer[nGrenade] = nPlayer;
@ -214,7 +218,8 @@ void ExplodeGrenade(short nGrenade)
short nPlayer = nGrenadePlayer[nGrenade]; short nPlayer = nGrenadePlayer[nGrenade];
int nGrenadeSprite = GrenadeList[nGrenade].nSprite; int nGrenadeSprite = GrenadeList[nGrenade].nSprite;
short nGrenadeSect = sprite[nGrenadeSprite].sectnum; auto pGrenadeSprite = &sprite[nGrenadeSprite];
short nGrenadeSect = pGrenadeSprite->sectnum;
GrenadeList[nGrenade].field_C = 1; GrenadeList[nGrenade].field_C = 1;
@ -225,7 +230,7 @@ void ExplodeGrenade(short nGrenade)
} }
else else
{ {
if (sprite[nGrenadeSprite].z < sector[nGrenadeSect].floorz) if (pGrenadeSprite->z < sector[nGrenadeSect].floorz)
{ {
var_20 = 200; var_20 = 200;
var_28 = 36; var_28 = 36;
@ -244,13 +249,14 @@ void ExplodeGrenade(short nGrenade)
if (GrenadeList[nGrenade].field_10 < 0) if (GrenadeList[nGrenade].field_10 < 0)
{ {
short nPlayerSprite = PlayerList[nPlayer].nSprite; short nPlayerSprite = PlayerList[nPlayer].nSprite;
short nAngle = sprite[nPlayerSprite].ang; auto pPlayerSprite = &sprite[nPlayerSprite];
short nAngle = pPlayerSprite->ang;
sprite[nGrenadeSprite].z = sprite[nPlayerSprite].z; pGrenadeSprite->z = pPlayerSprite->z;
sprite[nGrenadeSprite].x = bcos(nAngle, -5) + sprite[nPlayerSprite].x; pGrenadeSprite->x = bcos(nAngle, -5) + pPlayerSprite->x;
sprite[nGrenadeSprite].y = bsin(nAngle, -5) + sprite[nPlayerSprite].y; pGrenadeSprite->y = bsin(nAngle, -5) + pPlayerSprite->y;
changespritesect(nGrenadeSprite, sprite[nPlayerSprite].sectnum); changespritesect(nGrenadeSprite, pPlayerSprite->sectnum);
if (!PlayerList[nPlayer].invincibility) { if (!PlayerList[nPlayer].invincibility) {
PlayerList[nPlayer].nHealth = 1; PlayerList[nPlayer].nHealth = 1;
@ -265,8 +271,8 @@ void ExplodeGrenade(short nGrenade)
runlist_RadialDamageEnemy(nGrenadeSprite, nDamage, BulletInfo[kWeaponGrenade].nRadius); runlist_RadialDamageEnemy(nGrenadeSprite, nDamage, BulletInfo[kWeaponGrenade].nRadius);
BuildAnim(-1, var_28, 0, sprite[nGrenadeSprite].x, sprite[nGrenadeSprite].y, sprite[nGrenadeSprite].z, sprite[nGrenadeSprite].sectnum, var_20, 4); BuildAnim(-1, var_28, 0, pGrenadeSprite->x, pGrenadeSprite->y, pGrenadeSprite->z, pGrenadeSprite->sectnum, var_20, 4);
AddFlash(sprite[nGrenadeSprite].sectnum, sprite[nGrenadeSprite].x, sprite[nGrenadeSprite].y, sprite[nGrenadeSprite].z, 128); AddFlash(pGrenadeSprite->sectnum, pGrenadeSprite->x, pGrenadeSprite->y, pGrenadeSprite->z, 128);
nGrenadePlayer[nGrenade] = -1; nGrenadePlayer[nGrenade] = -1;
DestroyGrenade(nGrenade); DestroyGrenade(nGrenade);
@ -278,6 +284,7 @@ void FuncGrenade(int a, int, int nRun)
assert(nGrenade >= 0 && nGrenade < kMaxGrenades); assert(nGrenade >= 0 && nGrenade < kMaxGrenades);
short nGrenadeSprite = GrenadeList[nGrenade].nSprite; short nGrenadeSprite = GrenadeList[nGrenade].nSprite;
auto pGrenadeSprite = &sprite[nGrenadeSprite];
short nSeq; short nSeq;
if (GrenadeList[nGrenade].field_C) if (GrenadeList[nGrenade].field_C)
@ -308,7 +315,7 @@ void FuncGrenade(int a, int, int nRun)
case 0x20000: case 0x20000:
{ {
seq_MoveSequence(nGrenadeSprite, nSeq, GrenadeList[nGrenade].field_2 >> 8); seq_MoveSequence(nGrenadeSprite, nSeq, GrenadeList[nGrenade].field_2 >> 8);
sprite[nGrenadeSprite].picnum = seq_GetSeqPicnum2(nSeq, GrenadeList[nGrenade].field_2 >> 8); pGrenadeSprite->picnum = seq_GetSeqPicnum2(nSeq, GrenadeList[nGrenade].field_2 >> 8);
GrenadeList[nGrenade].field_E--; GrenadeList[nGrenade].field_E--;
if (!GrenadeList[nGrenade].field_E) if (!GrenadeList[nGrenade].field_E)
@ -370,10 +377,10 @@ void FuncGrenade(int a, int, int nRun)
return; return;
} }
int zVel = sprite[nGrenadeSprite].zvel; int zVel = pGrenadeSprite->zvel;
Gravity(nGrenadeSprite); Gravity(nGrenadeSprite);
int nMov = movesprite(nGrenadeSprite, GrenadeList[nGrenade].x, GrenadeList[nGrenade].y, sprite[nGrenadeSprite].zvel, sprite[nGrenadeSprite].clipdist >> 1, sprite[nGrenadeSprite].clipdist >> 1, CLIPMASK1); int nMov = movesprite(nGrenadeSprite, GrenadeList[nGrenade].x, GrenadeList[nGrenade].y, pGrenadeSprite->zvel, pGrenadeSprite->clipdist >> 1, pGrenadeSprite->clipdist >> 1, CLIPMASK1);
if (!nMov) if (!nMov)
return; return;
@ -382,7 +389,7 @@ void FuncGrenade(int a, int, int nRun)
{ {
if (zVel) if (zVel)
{ {
if (SectDamage[sprite[nGrenadeSprite].sectnum] > 0) if (SectDamage[pGrenadeSprite->sectnum] > 0)
{ {
ExplodeGrenade(nGrenade); ExplodeGrenade(nGrenade);
return; return;
@ -392,14 +399,14 @@ void FuncGrenade(int a, int, int nRun)
D3PlayFX(StaticSound[kSound3], nGrenadeSprite); D3PlayFX(StaticSound[kSound3], nGrenadeSprite);
sprite[nGrenadeSprite].zvel = -(zVel >> 1); pGrenadeSprite->zvel = -(zVel >> 1);
if (sprite[nGrenadeSprite].zvel > -1280) if (pGrenadeSprite->zvel > -1280)
{ {
D3PlayFX(StaticSound[kSound5], nGrenadeSprite); D3PlayFX(StaticSound[kSound5], nGrenadeSprite);
GrenadeList[nGrenade].field_0 = 0; GrenadeList[nGrenade].field_0 = 0;
GrenadeList[nGrenade].field_2 = 0; GrenadeList[nGrenade].field_2 = 0;
sprite[nGrenadeSprite].zvel = 0; pGrenadeSprite->zvel = 0;
GrenadeList[nGrenade].field_A = 1; GrenadeList[nGrenade].field_A = 1;
} }
} }

View file

@ -338,6 +338,7 @@ void MoveWeapons(short nPlayer)
nTemperature[nPlayer] = 0; nTemperature[nPlayer] = 0;
short nPlayerSprite = PlayerList[nPlayer].nSprite; short nPlayerSprite = PlayerList[nPlayer].nSprite;
auto pPlayerSprite = &sprite[nPlayerSprite];
short nWeapon = PlayerList[nPlayer].nCurrentWeapon; short nWeapon = PlayerList[nPlayer].nCurrentWeapon;
if (nWeapon < -1) if (nWeapon < -1)
@ -630,12 +631,12 @@ loc_flag:
if (((!(nSectFlag & kSectUnderwater)) || nWeapon == kWeaponRing) && (nFrameFlag & 4)) if (((!(nSectFlag & kSectUnderwater)) || nWeapon == kWeaponRing) && (nFrameFlag & 4))
{ {
BuildFlash(nPlayer, sprite[nPlayerSprite].sectnum, 512); BuildFlash(nPlayer, pPlayerSprite->sectnum, 512);
AddFlash( AddFlash(
sprite[nPlayerSprite].sectnum, pPlayerSprite->sectnum,
sprite[nPlayerSprite].x, pPlayerSprite->x,
sprite[nPlayerSprite].y, pPlayerSprite->y,
sprite[nPlayerSprite].z, pPlayerSprite->z,
0); 0);
} }
@ -666,13 +667,13 @@ loc_flag:
} }
short nAmmoType = WeaponInfo[nWeapon].nAmmoType; short nAmmoType = WeaponInfo[nWeapon].nAmmoType;
short nAngle = sprite[nPlayerSprite].ang; short nAngle = pPlayerSprite->ang;
int theX = sprite[nPlayerSprite].x; int theX = pPlayerSprite->x;
int theY = sprite[nPlayerSprite].y; int theY = pPlayerSprite->y;
int theZ = sprite[nPlayerSprite].z; int theZ = pPlayerSprite->z;
int ebp = bcos(nAngle) * (sprite[nPlayerSprite].clipdist << 3); int ebp = bcos(nAngle) * (pPlayerSprite->clipdist << 3);
int ebx = bsin(nAngle) * (sprite[nPlayerSprite].clipdist << 3); int ebx = bsin(nAngle) * (pPlayerSprite->clipdist << 3);
if (WeaponInfo[nWeapon].c) if (WeaponInfo[nWeapon].c)
{ {
@ -706,7 +707,7 @@ loc_flag:
} }
} }
short nSectorB = sprite[nPlayerSprite].sectnum; short nSectorB = pPlayerSprite->sectnum;
switch (nWeapon) switch (nWeapon)
{ {
@ -830,8 +831,8 @@ loc_flag:
{ {
// only autoaim if target is in front of the player. // only autoaim if target is in front of the player.
auto pTargetSprite = &sprite[t]; auto pTargetSprite = &sprite[t];
int angletotarget = bvectangbam(pTargetSprite->x - sprite[nPlayerSprite].x, pTargetSprite->y - sprite[nPlayerSprite].y).asbuild(); int angletotarget = bvectangbam(pTargetSprite->x - pPlayerSprite->x, pTargetSprite->y - pPlayerSprite->y).asbuild();
int anglediff = (sprite[nPlayerSprite].ang - angletotarget) & 2047; int anglediff = (pPlayerSprite->ang - angletotarget) & 2047;
if (anglediff < 512 || anglediff > 1536) target = t + 10000; if (anglediff < 512 || anglediff > 1536) target = t + 10000;
} }
} }
@ -850,8 +851,8 @@ loc_flag:
BuildSnake(nPlayer, nHeight); BuildSnake(nPlayer, nHeight);
nQuake[nPlayer] = 512; nQuake[nPlayer] = 512;
nXDamage[nPlayer] -= bcos(sprite[nPlayerSprite].ang, 9); nXDamage[nPlayer] -= bcos(pPlayerSprite->ang, 9);
nYDamage[nPlayer] -= bsin(sprite[nPlayerSprite].ang, 9); nYDamage[nPlayer] -= bsin(pPlayerSprite->ang, 9);
break; break;
} }
case kWeaponRing: case kWeaponRing:

View file

@ -331,6 +331,7 @@ void InitSectFlag()
void ProcessSpriteTag(short nSprite, short nLotag, short nHitag) void ProcessSpriteTag(short nSprite, short nLotag, short nHitag)
{ {
auto pSprite = &sprite[nSprite];
int nChannel = runlist_AllocChannel(nHitag % 1000); int nChannel = runlist_AllocChannel(nHitag % 1000);
int nSpeed = nLotag / 1000; int nSpeed = nLotag / 1000;
@ -402,33 +403,33 @@ void ProcessSpriteTag(short nSprite, short nLotag, short nHitag)
case 58: case 58:
case 60: case 60:
{ {
sprite[nSprite].hitag = nVal; pSprite->hitag = nVal;
changespritestat(nSprite, nLotag + 900); changespritestat(nSprite, nLotag + 900);
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
BuildItemAnim(nSprite); BuildItemAnim(nSprite);
return; return;
} }
case 12: // berry twig case 12: // berry twig
{ {
sprite[nSprite].hitag = 40; pSprite->hitag = 40;
changespritestat(nSprite, nLotag + 900); changespritestat(nSprite, nLotag + 900);
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
BuildItemAnim(nSprite); BuildItemAnim(nSprite);
return; return;
} }
case 13: // blood bowl case 13: // blood bowl
{ {
sprite[nSprite].hitag = 160; pSprite->hitag = 160;
changespritestat(nSprite, nLotag + 900); changespritestat(nSprite, nLotag + 900);
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
BuildItemAnim(nSprite); BuildItemAnim(nSprite);
return; return;
} }
case 14: // venom bowl case 14: // venom bowl
{ {
sprite[nSprite].hitag = -200; pSprite->hitag = -200;
changespritestat(nSprite, nLotag + 900); changespritestat(nSprite, nLotag + 900);
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
BuildItemAnim(nSprite); BuildItemAnim(nSprite);
return; return;
} }
@ -449,18 +450,18 @@ void ProcessSpriteTag(short nSprite, short nLotag, short nHitag)
} }
else else
{ {
sprite[nSprite].hitag = nVal; pSprite->hitag = nVal;
changespritestat(nSprite, nLotag + 900); changespritestat(nSprite, nLotag + 900);
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
BuildItemAnim(nSprite); BuildItemAnim(nSprite);
return; return;
} }
} }
case 27: case 27:
{ {
sprite[nSprite].hitag = 1; pSprite->hitag = 1;
changespritestat(nSprite, 9 + 900); changespritestat(nSprite, 9 + 900);
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
BuildItemAnim(nSprite); BuildItemAnim(nSprite);
return; return;
} }
@ -469,9 +470,9 @@ void ProcessSpriteTag(short nSprite, short nLotag, short nHitag)
{ {
nVal++; nVal++;
nVal--; // CHECKME ?? nVal--; // CHECKME ??
sprite[nSprite].hitag = nVal; pSprite->hitag = nVal;
changespritestat(nSprite, nLotag + 900); changespritestat(nSprite, nLotag + 900);
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
BuildItemAnim(nSprite); BuildItemAnim(nSprite);
return; return;
} }
@ -490,12 +491,12 @@ void ProcessSpriteTag(short nSprite, short nLotag, short nHitag)
{ {
case 999: case 999:
{ {
AddFlicker(sprite[nSprite].sectnum, nSpeed); AddFlicker(pSprite->sectnum, nSpeed);
break; break;
} }
case 998: case 998:
{ {
AddGlow(sprite[nSprite].sectnum, nSpeed); AddGlow(pSprite->sectnum, nSpeed);
break; break;
} }
case 118: // Anubis with drum case 118: // Anubis with drum
@ -640,7 +641,7 @@ void ProcessSpriteTag(short nSprite, short nLotag, short nHitag)
} }
case 99: // underwater type 2 case 99: // underwater type 2
{ {
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
SetAbove(nSector, nHitag); SetAbove(nSector, nHitag);
SectFlag[nSector] |= kSectUnderwater; SectFlag[nSector] |= kSectUnderwater;
@ -649,7 +650,7 @@ void ProcessSpriteTag(short nSprite, short nLotag, short nHitag)
} }
case 98: case 98:
{ {
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
SetBelow(nSector, nHitag); SetBelow(nSector, nHitag);
SnapSectors(nSector, nHitag, 1); SnapSectors(nSector, nHitag, 1);
@ -658,7 +659,7 @@ void ProcessSpriteTag(short nSprite, short nLotag, short nHitag)
} }
case 97: case 97:
{ {
AddSectorBob(sprite[nSprite].sectnum, nHitag, 1); AddSectorBob(pSprite->sectnum, nHitag, 1);
mydeletesprite(nSprite); mydeletesprite(nSprite);
return; return;
@ -670,7 +671,7 @@ void ProcessSpriteTag(short nSprite, short nLotag, short nHitag)
nDamage = 1; nDamage = 1;
} }
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
SectDamage[nSector] = nDamage; SectDamage[nSector] = nDamage;
SectFlag[nSector] |= kSectLava; SectFlag[nSector] |= kSectLava;
@ -680,14 +681,14 @@ void ProcessSpriteTag(short nSprite, short nLotag, short nHitag)
} }
case 95: case 95:
{ {
AddSectorBob(sprite[nSprite].sectnum, nHitag, 0); AddSectorBob(pSprite->sectnum, nHitag, 0);
mydeletesprite(nSprite); mydeletesprite(nSprite);
return; return;
} }
case 94: // water case 94: // water
{ {
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
SectDepth[nSector] = nHitag << 8; SectDepth[nSector] = nHitag << 8;
mydeletesprite(nSprite); mydeletesprite(nSprite);
@ -706,10 +707,10 @@ void ProcessSpriteTag(short nSprite, short nLotag, short nHitag)
case 79: case 79:
case 89: case 89:
{ {
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
SectSpeed[nSector] = nSpeed; SectSpeed[nSector] = nSpeed;
SectFlag[nSector] |= sprite[nSprite].ang; SectFlag[nSector] |= pSprite->ang;
mydeletesprite(nSprite); mydeletesprite(nSprite);
return; return;
@ -723,7 +724,7 @@ void ProcessSpriteTag(short nSprite, short nLotag, short nHitag)
} }
case 80: // underwater case 80: // underwater
{ {
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
SectFlag[nSector] |= kSectUnderwater; SectFlag[nSector] |= kSectUnderwater;
mydeletesprite(nSprite); mydeletesprite(nSprite);
@ -733,7 +734,7 @@ void ProcessSpriteTag(short nSprite, short nLotag, short nHitag)
{ {
AddFlow(nSprite, nSpeed, 1); AddFlow(nSprite, nSpeed, 1);
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
SectFlag[nSector] |= 0x8000; SectFlag[nSector] |= 0x8000;
mydeletesprite(nSprite); mydeletesprite(nSprite);
@ -771,13 +772,13 @@ void ProcessSpriteTag(short nSprite, short nLotag, short nHitag)
case 63: case 63:
{ {
changespritestat(nSprite, 405); changespritestat(nSprite, 405);
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
return; return;
} }
case 62: case 62:
{ {
nNetStartSprite[nNetStartSprites] = nSprite; nNetStartSprite[nNetStartSprites] = nSprite;
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
nNetStartSprites++; nNetStartSprites++;
return; return;
@ -785,7 +786,7 @@ void ProcessSpriteTag(short nSprite, short nLotag, short nHitag)
case kTagRamses: // Ramses head case kTagRamses: // Ramses head
{ {
nSpiritSprite = nSprite; nSpiritSprite = nSprite;
sprite[nSprite].cstat |= 0x8000; pSprite->cstat |= 0x8000;
return; return;
} }
default: // TODO - checkme! default: // TODO - checkme!
@ -806,16 +807,18 @@ void ExamineSprites()
for (int nSprite = 0; nSprite < kMaxSprites; nSprite++) for (int nSprite = 0; nSprite < kMaxSprites; nSprite++)
{ {
int nStatus = sprite[nSprite].statnum; auto pSprite = &sprite[nSprite];
int nStatus = pSprite->statnum;
if (!nStatus) if (!nStatus)
{ {
short lotag = sprite[nSprite].lotag; short lotag = pSprite->lotag;
short hitag = sprite[nSprite].hitag; short hitag = pSprite->hitag;
if ((nStatus < kMaxStatus) && lotag) if ((nStatus < kMaxStatus) && lotag)
{ {
sprite[nSprite].lotag = 0; pSprite->lotag = 0;
sprite[nSprite].hitag = 0; pSprite->hitag = 0;
ProcessSpriteTag(nSprite, lotag, hitag); ProcessSpriteTag(nSprite, lotag, hitag);
} }
@ -829,10 +832,12 @@ void ExamineSprites()
if (nNetPlayerCount) if (nNetPlayerCount)
{ {
int nSprite = insertsprite(initsect, 0); int nSprite = insertsprite(initsect, 0);
sprite[nSprite].x = initx; auto pSprite = &sprite[nSprite];
sprite[nSprite].y = inity;
sprite[nSprite].z = initz; pSprite->x = initx;
sprite[nSprite].cstat = 0x8000; pSprite->y = inity;
pSprite->z = initz;
pSprite->cstat = 0x8000;
nNetStartSprite[nNetStartSprites] = nSprite; nNetStartSprite[nNetStartSprites] = nSprite;
nNetStartSprites++; nNetStartSprites++;
} }

View file

@ -122,33 +122,37 @@ void SerializeItems(FSerializer& arc)
void BuildItemAnim(short nSprite) void BuildItemAnim(short nSprite)
{ {
int nItem = sprite[nSprite].statnum - 906; auto pSprite = &sprite[nSprite];
int nItem = pSprite->statnum - 906;
if (nItemAnimInfo[nItem].a >= 0) if (nItemAnimInfo[nItem].a >= 0)
{ {
int nAnim = BuildAnim(nSprite, 41, nItemAnimInfo[nItem].a, sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, sprite[nSprite].sectnum, nItemAnimInfo[nItem].repeat, 20); int nAnim = BuildAnim(nSprite, 41, nItemAnimInfo[nItem].a, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, nItemAnimInfo[nItem].repeat, 20);
int nAnimSprite = GetAnimSprite(nAnim); int nAnimSprite = GetAnimSprite(nAnim);
if (nItem == 44) { if (nItem == 44) {
sprite[nAnimSprite].cstat |= 2; sprite[nAnimSprite].cstat |= 2;
} }
changespritestat(nAnimSprite, sprite[nSprite].statnum); changespritestat(nAnimSprite, pSprite->statnum);
sprite[nAnimSprite].owner = nAnim; sprite[nAnimSprite].owner = nAnim;
sprite[nAnimSprite].hitag = sprite[nSprite].hitag; sprite[nAnimSprite].hitag = pSprite->hitag;
} }
else else
{ {
sprite[nSprite].owner = -1; pSprite->owner = -1;
sprite[nSprite].yrepeat = (uint8_t)nItemAnimInfo[nItem].repeat; pSprite->yrepeat = (uint8_t)nItemAnimInfo[nItem].repeat;
sprite[nSprite].xrepeat = (uint8_t)nItemAnimInfo[nItem].repeat; pSprite->xrepeat = (uint8_t)nItemAnimInfo[nItem].repeat;
} }
} }
void DestroyItemAnim(short nSprite) void DestroyItemAnim(short nSprite)
{ {
short nAnim = sprite[nSprite].owner; auto pSprite = &sprite[nSprite];
short nAnim = pSprite->owner;
if (nAnim >= 0) { if (nAnim >= 0) {
DestroyAnim(nAnim); DestroyAnim(nAnim);
@ -185,11 +189,12 @@ static bool UseEye(short nPlayer)
PlayerList[nPlayer].nInvisible = 900; PlayerList[nPlayer].nInvisible = 900;
int nSprite = PlayerList[nPlayer].nSprite; int nSprite = PlayerList[nPlayer].nSprite;
auto pSprite = &sprite[nSprite];
sprite[nSprite].cstat |= 0x8000; pSprite->cstat |= 0x8000;
if (nPlayerFloorSprite[nPlayer] >= 0) { if (nPlayerFloorSprite[nPlayer] >= 0) {
sprite[nSprite].cstat |= 0x8000; pSprite->cstat |= 0x8000;
} }
if (nPlayer == nLocalPlayer) if (nPlayer == nLocalPlayer)
@ -334,6 +339,8 @@ int GrabItem(short nPlayer, short nItem)
void DropMagic(short nSprite) void DropMagic(short nSprite)
{ {
auto pSprite = &sprite[nSprite];
if (lFinaleStart) { if (lFinaleStart) {
return; return;
} }
@ -346,10 +353,10 @@ void DropMagic(short nSprite)
-1, -1,
64, 64,
0, 0,
sprite[nSprite].x, pSprite->x,
sprite[nSprite].y, pSprite->y,
sprite[nSprite].z, pSprite->z,
sprite[nSprite].sectnum, pSprite->sectnum,
48, 48,
4); 4);
@ -409,7 +416,7 @@ void StartRegenerate(short nSprite)
} }
else else
{ {
sprite[edi].ang = sprite[nSprite].ang; sprite[edi].ang = pSprite->ang;
} }
nRegenerates--; nRegenerates--;
@ -437,16 +444,17 @@ void StartRegenerate(short nSprite)
void DoRegenerates() void DoRegenerates()
{ {
int nSprite = nFirstRegenerate; int nSprite = nFirstRegenerate;
auto pSprite = &sprite[nSprite];
for (int i = nRegenerates; i > 0; i--, nSprite = sprite[nSprite].ang) for (int i = nRegenerates; i > 0; i--, nSprite = pSprite->ang)
{ {
if (sprite[nSprite].extra > 0) if (pSprite->extra > 0)
{ {
sprite[nSprite].extra--; pSprite->extra--;
if (sprite[nSprite].extra <= 0) if (pSprite->extra <= 0)
{ {
BuildAnim(-1, 38, 0, sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, sprite[nSprite].sectnum, 64, 4); BuildAnim(-1, 38, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 64, 4);
D3PlayFX(StaticSound[kSoundTorchOn], nSprite); D3PlayFX(StaticSound[kSoundTorchOn], nSprite);
} }
else { else {
@ -455,27 +463,27 @@ void DoRegenerates()
} }
else else
{ {
if (sprite[nSprite].xrepeat < sprite[nSprite].xvel) if (pSprite->xrepeat < pSprite->xvel)
{ {
sprite[nSprite].xrepeat += 2; pSprite->xrepeat += 2;
sprite[nSprite].yrepeat += 2; pSprite->yrepeat += 2;
continue; continue;
} }
} }
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].yrepeat = (uint8_t)sprite[nSprite].xvel; pSprite->yrepeat = (uint8_t)pSprite->xvel;
sprite[nSprite].xrepeat = (uint8_t)sprite[nSprite].xvel; pSprite->xrepeat = (uint8_t)pSprite->xvel;
sprite[nSprite].pal = (uint8_t)sprite[nSprite].yvel; pSprite->pal = (uint8_t)pSprite->yvel;
sprite[nSprite].yvel = sprite[nSprite].zvel; // setting to 0 pSprite->yvel = pSprite->zvel; // setting to 0
sprite[nSprite].xvel = sprite[nSprite].zvel; // setting to 0 pSprite->xvel = pSprite->zvel; // setting to 0
nRegenerates--; nRegenerates--;
if (sprite[nSprite].statnum == kStatExplodeTrigger) { if (pSprite->statnum == kStatExplodeTrigger) {
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
} }
else { else {
sprite[nSprite].cstat = 0; pSprite->cstat = 0;
} }
if (nRegenerates == 0) { if (nRegenerates == 0) {

View file

@ -79,34 +79,36 @@ void InitLava()
int BuildLavaLimb(int nSprite, int edx, int ebx) int BuildLavaLimb(int nSprite, int edx, int ebx)
{ {
short nSector = sprite[nSprite].sectnum; auto pSprite = &sprite[nSprite];
short nSector = pSprite->sectnum;
int nLimbSprite = insertsprite(nSector, 118); int nLimbSprite = insertsprite(nSector, 118);
assert(nLimbSprite >= 0 && nLimbSprite < kMaxSprites); assert(nLimbSprite >= 0 && nLimbSprite < kMaxSprites);
auto pLimbSprite = &sprite[nLimbSprite];
sprite[nLimbSprite].x = sprite[nSprite].x; pLimbSprite->x = pSprite->x;
sprite[nLimbSprite].y = sprite[nSprite].y; pLimbSprite->y = pSprite->y;
sprite[nLimbSprite].z = sprite[nSprite].z - RandomLong() % ebx; pLimbSprite->z = pSprite->z - RandomLong() % ebx;
sprite[nLimbSprite].cstat = 0; pLimbSprite->cstat = 0;
sprite[nLimbSprite].shade = -127; pLimbSprite->shade = -127;
sprite[nLimbSprite].pal = 1; pLimbSprite->pal = 1;
sprite[nLimbSprite].xvel = (RandomSize(5) - 16) << 8; pLimbSprite->xvel = (RandomSize(5) - 16) << 8;
sprite[nLimbSprite].yvel = (RandomSize(5) - 16) << 8; pLimbSprite->yvel = (RandomSize(5) - 16) << 8;
sprite[nLimbSprite].zvel = 2560 - (RandomSize(5) << 8); pLimbSprite->zvel = 2560 - (RandomSize(5) << 8);
sprite[nLimbSprite].xoffset = 0; pLimbSprite->xoffset = 0;
sprite[nLimbSprite].yoffset = 0; pLimbSprite->yoffset = 0;
sprite[nLimbSprite].xrepeat = 90; pLimbSprite->xrepeat = 90;
sprite[nLimbSprite].yrepeat = 90; pLimbSprite->yrepeat = 90;
sprite[nLimbSprite].picnum = (edx & 3) % 3; pLimbSprite->picnum = (edx & 3) % 3;
sprite[nLimbSprite].hitag = 0; pLimbSprite->hitag = 0;
sprite[nLimbSprite].lotag = runlist_HeadRun() + 1; pLimbSprite->lotag = runlist_HeadRun() + 1;
sprite[nLimbSprite].clipdist = 0; pLimbSprite->clipdist = 0;
// GrabTimeSlot(3); // GrabTimeSlot(3);
sprite[nLimbSprite].extra = -1; pLimbSprite->extra = -1;
sprite[nLimbSprite].owner = runlist_AddRunRec(sprite[nLimbSprite].lotag - 1, nLimbSprite | 0x160000); pLimbSprite->owner = runlist_AddRunRec(pLimbSprite->lotag - 1, nLimbSprite | 0x160000);
sprite[nLimbSprite].hitag = runlist_AddRunRec(NewRun, nLimbSprite | 0x160000); pLimbSprite->hitag = runlist_AddRunRec(NewRun, nLimbSprite | 0x160000);
return nLimbSprite; return nLimbSprite;
} }
@ -115,6 +117,7 @@ void FuncLavaLimb(int a, int, int nRun)
{ {
short nSprite = RunData[nRun].nVal; short nSprite = RunData[nRun].nVal;
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
auto pSprite = &sprite[nSprite];
int nMessage = a & kMessageMask; int nMessage = a & kMessageMask;
@ -122,19 +125,19 @@ void FuncLavaLimb(int a, int, int nRun)
{ {
case 0x20000: case 0x20000:
{ {
sprite[nSprite].shade += 3; pSprite->shade += 3;
int nRet = movesprite(nSprite, sprite[nSprite].xvel << 12, sprite[nSprite].yvel << 12, sprite[nSprite].zvel, 2560, -2560, CLIPMASK1); int nRet = movesprite(nSprite, pSprite->xvel << 12, pSprite->yvel << 12, pSprite->zvel, 2560, -2560, CLIPMASK1);
if (nRet || sprite[nSprite].shade > 100) if (nRet || pSprite->shade > 100)
{ {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
runlist_DoSubRunRec(sprite[nSprite].owner); runlist_DoSubRunRec(pSprite->owner);
runlist_FreeRun(sprite[nSprite].lotag - 1); runlist_FreeRun(pSprite->lotag - 1);
runlist_SubRunRec(sprite[nSprite].hitag); runlist_SubRunRec(pSprite->hitag);
mydeletesprite(nSprite); mydeletesprite(nSprite);
} }
@ -143,7 +146,7 @@ void FuncLavaLimb(int a, int, int nRun)
case 0x90000: case 0x90000:
{ {
seq_PlotSequence(a & 0xFFFF, (SeqOffsets[kSeqLavag] + 30) + sprite[nSprite].picnum, 0, 1); seq_PlotSequence(a & 0xFFFF, (SeqOffsets[kSeqLavag] + 30) + pSprite->picnum, 0, 1);
break; break;
} }
@ -156,44 +159,46 @@ int BuildLava(short nSprite, int x, int y, int, short nSector, short nAngle, int
{ {
auto nLava = LavaList.Reserve(1); auto nLava = LavaList.Reserve(1);
auto pSprite = &sprite[nSprite];
if (nSprite == -1) if (nSprite == -1)
{ {
nSprite = insertsprite(nSector, 118); nSprite = insertsprite(nSector, 118);
pSprite = &sprite[nSprite];
} }
else else
{ {
nSector = sprite[nSprite].sectnum; nSector = pSprite->sectnum;
nAngle = sprite[nSprite].ang; nAngle = pSprite->ang;
x = sprite[nSprite].x; x = pSprite->x;
y = sprite[nSprite].y; y = pSprite->y;
changespritestat(nSprite, 118); changespritestat(nSprite, 118);
} }
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
sprite[nSprite].x = x; pSprite->x = x;
sprite[nSprite].y = y; pSprite->y = y;
sprite[nSprite].z = sector[nSector].floorz; pSprite->z = sector[nSector].floorz;
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
sprite[nSprite].xrepeat = 200; pSprite->xrepeat = 200;
sprite[nSprite].yrepeat = 200; pSprite->yrepeat = 200;
sprite[nSprite].shade = -12; pSprite->shade = -12;
sprite[nSprite].pal = 0; pSprite->pal = 0;
sprite[nSprite].clipdist = 127; pSprite->clipdist = 127;
sprite[nSprite].xoffset = 0; pSprite->xoffset = 0;
sprite[nSprite].yoffset = 0; pSprite->yoffset = 0;
sprite[nSprite].picnum = seq_GetSeqPicnum(kSeqLavag, LavadudeSeq[3].a, 0); pSprite->picnum = seq_GetSeqPicnum(kSeqLavag, LavadudeSeq[3].a, 0);
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].ang = nAngle; pSprite->ang = nAngle;
sprite[nSprite].hitag = 0; pSprite->hitag = 0;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
// GrabTimeSlot(3); // GrabTimeSlot(3);
sprite[nSprite].extra = -1; pSprite->extra = -1;
LavaList[nLava].nAction = 0; LavaList[nLava].nAction = 0;
LavaList[nLava].nHealth = 4000; LavaList[nLava].nHealth = 4000;
@ -202,7 +207,7 @@ int BuildLava(short nSprite, int x, int y, int, short nSector, short nAngle, int
LavaList[nLava].nIndex = nChannel; LavaList[nLava].nIndex = nChannel;
LavaList[nLava].nFrame = 0; LavaList[nLava].nFrame = 0;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nLava | 0x150000); pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nLava | 0x150000);
LavaList[nLava].nRun = runlist_AddRunRec(NewRun, nLava | 0x150000); LavaList[nLava].nRun = runlist_AddRunRec(NewRun, nLava | 0x150000);
nCreaturesTotal++; nCreaturesTotal++;
@ -218,6 +223,7 @@ void FuncLava(int a, int nDamage, int nRun)
short nAction = LavaList[nLava].nAction; short nAction = LavaList[nLava].nAction;
short nSeq = LavadudeSeq[nAction].a + SeqOffsets[kSeqLavag]; short nSeq = LavadudeSeq[nAction].a + SeqOffsets[kSeqLavag];
short nSprite = LavaList[nLava].nSprite; short nSprite = LavaList[nLava].nSprite;
auto pSprite = &sprite[nSprite];
int nMessage = a & kMessageMask; int nMessage = a & kMessageMask;
@ -257,7 +263,7 @@ void FuncLava(int a, int nDamage, int nRun)
nCreaturesKilled++; nCreaturesKilled++;
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
} }
else else
{ {
@ -277,7 +283,7 @@ void FuncLava(int a, int nDamage, int nRun)
{ {
LavaList[nLava].nAction = 4; LavaList[nLava].nAction = 4;
LavaList[nLava].nFrame = 0; LavaList[nLava].nFrame = 0;
sprite[nSprite].cstat = 0; pSprite->cstat = 0;
} }
} }
@ -289,7 +295,7 @@ void FuncLava(int a, int nDamage, int nRun)
case 0x20000: case 0x20000:
{ {
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, LavaList[nLava].nFrame); pSprite->picnum = seq_GetSeqPicnum2(nSeq, LavaList[nLava].nFrame);
int var_38 = LavaList[nLava].nFrame; int var_38 = LavaList[nLava].nFrame;
short nFlag = FrameFlag[SeqBase[nSeq] + var_38]; short nFlag = FrameFlag[SeqBase[nSeq] + var_38];
@ -336,36 +342,36 @@ void FuncLava(int a, int nDamage, int nRun)
PlotCourseToSprite(nSprite, nTarget); PlotCourseToSprite(nSprite, nTarget);
sprite[nSprite].xvel = bcos(sprite[nSprite].ang); pSprite->xvel = bcos(pSprite->ang);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang); pSprite->yvel = bsin(pSprite->ang);
if (nTarget >= 0 && !RandomSize(1)) if (nTarget >= 0 && !RandomSize(1))
{ {
LavaList[nLava].nTarget = nTarget; LavaList[nLava].nTarget = nTarget;
LavaList[nLava].nAction = 2; LavaList[nLava].nAction = 2;
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
LavaList[nLava].nFrame = 0; LavaList[nLava].nFrame = 0;
break; break;
} }
} }
int x = sprite[nSprite].x; int x = pSprite->x;
int y = sprite[nSprite].y; int y = pSprite->y;
int z = sprite[nSprite].z; int z = pSprite->z;
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
int nVal = movesprite(nSprite, sprite[nSprite].xvel << 8, sprite[nSprite].yvel << 8, 0, 0, 0, CLIPMASK0); int nVal = movesprite(nSprite, pSprite->xvel << 8, pSprite->yvel << 8, 0, 0, 0, CLIPMASK0);
if (nSector != sprite[nSprite].sectnum) if (nSector != pSprite->sectnum)
{ {
changespritesect(nSprite, nSector); changespritesect(nSprite, nSector);
sprite[nSprite].x = x; pSprite->x = x;
sprite[nSprite].y = y; pSprite->y = y;
sprite[nSprite].z = z; pSprite->z = z;
sprite[nSprite].ang = (sprite[nSprite].ang + ((RandomWord() & 0x3FF) + 1024)) & kAngleMask; pSprite->ang = (pSprite->ang + ((RandomWord() & 0x3FF) + 1024)) & kAngleMask;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang); pSprite->xvel = bcos(pSprite->ang);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang); pSprite->yvel = bsin(pSprite->ang);
break; break;
} }
@ -375,21 +381,21 @@ void FuncLava(int a, int nDamage, int nRun)
if ((nVal & 0xC000) == 0x8000) if ((nVal & 0xC000) == 0x8000)
{ {
sprite[nSprite].ang = (sprite[nSprite].ang + ((RandomWord() & 0x3FF) + 1024)) & kAngleMask; pSprite->ang = (pSprite->ang + ((RandomWord() & 0x3FF) + 1024)) & kAngleMask;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang); pSprite->xvel = bcos(pSprite->ang);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang); pSprite->yvel = bsin(pSprite->ang);
break; break;
} }
else if ((nVal & 0xC000) == 0xC000) else if ((nVal & 0xC000) == 0xC000)
{ {
if ((nVal & 0x3FFF) == nTarget) if ((nVal & 0x3FFF) == nTarget)
{ {
int nAng = getangle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y); int nAng = getangle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
if (AngleDiff(sprite[nSprite].ang, nAng) < 64) if (AngleDiff(pSprite->ang, nAng) < 64)
{ {
LavaList[nLava].nAction = 2; LavaList[nLava].nAction = 2;
LavaList[nLava].nFrame = 0; LavaList[nLava].nFrame = 0;
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
break; break;
} }
} }
@ -413,7 +419,7 @@ void FuncLava(int a, int nDamage, int nRun)
PlotCourseToSprite(nSprite, nTarget); PlotCourseToSprite(nSprite, nTarget);
sprite[nSprite].cstat |= 0x101; pSprite->cstat |= 0x101;
} }
break; break;
@ -426,7 +432,7 @@ void FuncLava(int a, int nDamage, int nRun)
int nHeight = GetSpriteHeight(nSprite); int nHeight = GetSpriteHeight(nSprite);
GetUpAngle(nSprite, -64000, nTarget, (-(nHeight >> 1))); GetUpAngle(nSprite, -64000, nTarget, (-(nHeight >> 1)));
BuildBullet(nSprite, 10, bcos(sprite[nSprite].ang, 8), bsin(sprite[nSprite].ang, 8), -1, sprite[nSprite].ang, nTarget + 10000, 1); BuildBullet(nSprite, 10, bcos(pSprite->ang, 8), bsin(pSprite->ang, 8), -1, pSprite->ang, nTarget + 10000, 1);
} }
else if (var_1C) else if (var_1C)
{ {
@ -443,7 +449,7 @@ void FuncLava(int a, int nDamage, int nRun)
if (var_1C) if (var_1C)
{ {
LavaList[nLava].nAction = 7; LavaList[nLava].nAction = 7;
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
} }
break; break;
@ -482,8 +488,8 @@ void FuncLava(int a, int nDamage, int nRun)
} }
while (ecx < 30); while (ecx < 30);
runlist_DoSubRunRec(sprite[nSprite].owner); runlist_DoSubRunRec(pSprite->owner);
runlist_FreeRun(sprite[nSprite].lotag - 1); runlist_FreeRun(pSprite->lotag - 1);
runlist_SubRunRec(LavaList[nLava].nRun); runlist_SubRunRec(LavaList[nLava].nRun);
mydeletesprite(nSprite); mydeletesprite(nSprite);
} }
@ -507,14 +513,14 @@ void FuncLava(int a, int nDamage, int nRun)
{ {
LavaList[nLava].nAction = 0; LavaList[nLava].nAction = 0;
LavaList[nLava].nFrame = 0; LavaList[nLava].nFrame = 0;
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
} }
break; break;
} }
} }
// loc_31521: // loc_31521:
sprite[nSprite].pal = 1; pSprite->pal = 1;
} }
} }
} }

View file

@ -352,27 +352,28 @@ void AddFlash(short nSector, int x, int y, int z, int val)
SectIterator it(nSector); SectIterator it(nSector);
while ((nSprite = it.NextIndex()) >= 0) while ((nSprite = it.NextIndex()) >= 0)
{ {
if (sprite[nSprite].pal < 4) auto pSprite = &sprite[nSprite];
if (pSprite->pal < 4)
{ {
short nFlash3 = GrabFlash(); short nFlash3 = GrabFlash();
if (nFlash3 >= 0) if (nFlash3 >= 0)
{ {
sFlash[nFlash3].field_0 = var_20 | 4; sFlash[nFlash3].field_0 = var_20 | 4;
sFlash[nFlash3].shade = sprite[nSprite].shade; sFlash[nFlash3].shade = pSprite->shade;
sFlash[nFlash3].field_1 = nSprite; sFlash[nFlash3].field_1 = nSprite;
sprite[nSprite].pal += 7; pSprite->pal += 7;
int eax = -255; int eax = -255;
if (!var_18) if (!var_18)
{ {
int xDiff = x - sprite[nSprite].x; int xDiff = x - pSprite->x;
if (xDiff < 0) { if (xDiff < 0) {
xDiff = -xDiff; xDiff = -xDiff;
} }
int yDiff = y - sprite[nSprite].y; int yDiff = y - pSprite->y;
if (yDiff < 0) { if (yDiff < 0) {
yDiff = -yDiff; yDiff = -yDiff;
} }
@ -382,12 +383,12 @@ void AddFlash(short nSector, int x, int y, int z, int val)
if (eax < 0) if (eax < 0)
{ {
short shade = sprite[nSprite].shade + eax; short shade = pSprite->shade + eax;
if (shade < -127) { if (shade < -127) {
shade = -127; shade = -127;
} }
sprite[nSprite].shade = (int8_t)shade; pSprite->shade = (int8_t)shade;
} }
} }
} }

View file

@ -85,40 +85,42 @@ int BuildLion(short nSprite, int x, int y, int z, short nSector, short nAngle)
{ {
auto nLion = LionList.Reserve(1); auto nLion = LionList.Reserve(1);
auto pSprite = &sprite[nSprite];
if (nSprite == -1) if (nSprite == -1)
{ {
nSprite = insertsprite(nSector, 104); nSprite = insertsprite(nSector, 104);
pSprite = &sprite[nSprite];
} }
else else
{ {
changespritestat(nSprite, 104); changespritestat(nSprite, 104);
x = sprite[nSprite].x; x = pSprite->x;
y = sprite[nSprite].y; y = pSprite->y;
z = sector[sprite[nSprite].sectnum].floorz; z = sector[pSprite->sectnum].floorz;
nAngle = sprite[nSprite].ang; nAngle = pSprite->ang;
} }
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
sprite[nSprite].x = x; pSprite->x = x;
sprite[nSprite].y = y; pSprite->y = y;
sprite[nSprite].z = z; pSprite->z = z;
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
sprite[nSprite].clipdist = 60; pSprite->clipdist = 60;
sprite[nSprite].shade = -12; pSprite->shade = -12;
sprite[nSprite].xrepeat = 40; pSprite->xrepeat = 40;
sprite[nSprite].yrepeat = 40; pSprite->yrepeat = 40;
sprite[nSprite].picnum = 1; pSprite->picnum = 1;
sprite[nSprite].pal = sector[sprite[nSprite].sectnum].ceilingpal; pSprite->pal = sector[pSprite->sectnum].ceilingpal;
sprite[nSprite].xoffset = 0; pSprite->xoffset = 0;
sprite[nSprite].yoffset = 0; pSprite->yoffset = 0;
sprite[nSprite].ang = nAngle; pSprite->ang = nAngle;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].hitag = 0; pSprite->hitag = 0;
sprite[nSprite].extra = -1; pSprite->extra = -1;
// GrabTimeSlot(3); // GrabTimeSlot(3);
@ -130,7 +132,7 @@ int BuildLion(short nSprite, int x, int y, int z, short nSector, short nAngle)
LionList[nLion].nCount = 0; LionList[nLion].nCount = 0;
LionList[nLion].nIndex = nLion; LionList[nLion].nIndex = nLion;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nLion | 0x130000); pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nLion | 0x130000);
LionList[nLion].nRun = runlist_AddRunRec(NewRun, nLion | 0x130000); LionList[nLion].nRun = runlist_AddRunRec(NewRun, nLion | 0x130000);
@ -145,6 +147,7 @@ void FuncLion(int a, int nDamage, int nRun)
assert(nLion >= 0 && nLion < (int)LionList.Size()); assert(nLion >= 0 && nLion < (int)LionList.Size());
short nSprite = LionList[nLion].nSprite; short nSprite = LionList[nLion].nSprite;
auto pSprite = &sprite[nSprite];
short nAction = LionList[nLion].nAction; short nAction = LionList[nLion].nAction;
bool bVal = false; bool bVal = false;
@ -179,10 +182,10 @@ void FuncLion(int a, int nDamage, int nRun)
if (LionList[nLion].nHealth <= 0) if (LionList[nLion].nHealth <= 0)
{ {
// R.I.P. // R.I.P.
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
LionList[nLion].nHealth = 0; LionList[nLion].nHealth = 0;
@ -219,22 +222,22 @@ void FuncLion(int a, int nDamage, int nRun)
if (RandomSize(8) <= (LionList[nLion].nHealth >> 2)) if (RandomSize(8) <= (LionList[nLion].nHealth >> 2))
{ {
LionList[nLion].nAction = 4; LionList[nLion].nAction = 4;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
else if (RandomSize(1)) else if (RandomSize(1))
{ {
PlotCourseToSprite(nSprite, nTarget); PlotCourseToSprite(nSprite, nTarget);
LionList[nLion].nAction = 5; LionList[nLion].nAction = 5;
LionList[nLion].nCount = RandomSize(3); LionList[nLion].nCount = RandomSize(3);
sprite[nSprite].ang = (sprite[nSprite].ang - (RandomSize(1) << 8)) + (RandomSize(1) << 8); // NOTE: no angle mask in original code pSprite->ang = (pSprite->ang - (RandomSize(1) << 8)) + (RandomSize(1) << 8); // NOTE: no angle mask in original code
} }
else else
{ {
LionList[nLion].nAction = 8; LionList[nLion].nAction = 8;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
} }
LionList[nLion].nFrame = 0; LionList[nLion].nFrame = 0;
@ -253,7 +256,7 @@ void FuncLion(int a, int nDamage, int nRun)
short nSeq = SeqOffsets[kSeqLion] + LionSeq[nAction].a; short nSeq = SeqOffsets[kSeqLion] + LionSeq[nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, LionList[nLion].nFrame); pSprite->picnum = seq_GetSeqPicnum2(nSeq, LionList[nLion].nFrame);
seq_MoveSequence(nSprite, nSeq, LionList[nLion].nFrame); seq_MoveSequence(nSprite, nSeq, LionList[nLion].nFrame);
@ -288,8 +291,8 @@ void FuncLion(int a, int nDamage, int nRun)
LionList[nLion].nAction = 2; LionList[nLion].nAction = 2;
LionList[nLion].nFrame = 0; LionList[nLion].nFrame = 0;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1); pSprite->xvel = bcos(pSprite->ang, -1);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1); pSprite->yvel = bsin(pSprite->ang, -1);
LionList[nLion].nTarget = nTarget; LionList[nLion].nTarget = nTarget;
return; return;
} }
@ -303,14 +306,14 @@ void FuncLion(int a, int nDamage, int nRun)
{ {
if (RandomBit()) if (RandomBit())
{ {
sprite[nSprite].ang = RandomWord() & kAngleMask; pSprite->ang = RandomWord() & kAngleMask;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1); pSprite->xvel = bcos(pSprite->ang, -1);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1); pSprite->yvel = bsin(pSprite->ang, -1);
} }
else else
{ {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
LionList[nLion].nCount = 100; LionList[nLion].nCount = 100;
@ -326,17 +329,17 @@ void FuncLion(int a, int nDamage, int nRun)
{ {
PlotCourseToSprite(nSprite, nTarget); PlotCourseToSprite(nSprite, nTarget);
int nAng = sprite[nSprite].ang & 0xFFF8; int nAng = pSprite->ang & 0xFFF8;
if (sprite[nSprite].cstat & 0x8000) if (pSprite->cstat & 0x8000)
{ {
sprite[nSprite].xvel = bcos(nAng, 1); pSprite->xvel = bcos(nAng, 1);
sprite[nSprite].yvel = bsin(nAng, 1); pSprite->yvel = bsin(nAng, 1);
} }
else else
{ {
sprite[nSprite].xvel = bcos(nAng, -1); pSprite->xvel = bcos(nAng, -1);
sprite[nSprite].yvel = bsin(nAng, -1); pSprite->yvel = bsin(nAng, -1);
} }
} }
@ -347,27 +350,27 @@ void FuncLion(int a, int nDamage, int nRun)
else if ((nMov & 0xC000) == 0x8000) else if ((nMov & 0xC000) == 0x8000)
{ {
// loc_378FA: // loc_378FA:
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask; pSprite->ang = (pSprite->ang + 256) & kAngleMask;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1); pSprite->xvel = bcos(pSprite->ang, -1);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1); pSprite->yvel = bsin(pSprite->ang, -1);
break; break;
} }
else if ((nMov & 0xC000) == 0xC000) else if ((nMov & 0xC000) == 0xC000)
{ {
if ((nMov & 0x3FFF) == nTarget) if ((nMov & 0x3FFF) == nTarget)
{ {
if (sprite[nSprite].cstat & 0x8000) if (pSprite->cstat & 0x8000)
{ {
LionList[nLion].nAction = 9; LionList[nLion].nAction = 9;
sprite[nSprite].cstat &= 0x7FFF; pSprite->cstat &= 0x7FFF;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
else else
{ {
int nAng = getangle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y); int nAng = getangle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
if (AngleDiff(sprite[nSprite].ang, nAng) < 64) if (AngleDiff(pSprite->ang, nAng) < 64)
{ {
LionList[nLion].nAction = 3; LionList[nLion].nAction = 3;
} }
@ -379,9 +382,9 @@ void FuncLion(int a, int nDamage, int nRun)
else else
{ {
// loc_378FA: // loc_378FA:
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask; pSprite->ang = (pSprite->ang + 256) & kAngleMask;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1); pSprite->xvel = bcos(pSprite->ang, -1);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1); pSprite->yvel = bsin(pSprite->ang, -1);
break; break;
} }
} }
@ -421,8 +424,8 @@ void FuncLion(int a, int nDamage, int nRun)
if (nMov & 0x20000) if (nMov & 0x20000)
{ {
sprite[nSprite].xvel >>= 1; pSprite->xvel >>= 1;
sprite[nSprite].yvel >>= 1; pSprite->yvel >>= 1;
} }
return; return;
@ -433,17 +436,17 @@ void FuncLion(int a, int nDamage, int nRun)
LionList[nLion].nCount--; LionList[nLion].nCount--;
if (LionList[nLion].nCount <= 0) if (LionList[nLion].nCount <= 0)
{ {
sprite[nSprite].zvel = -4000; pSprite->zvel = -4000;
LionList[nLion].nCount = 0; LionList[nLion].nCount = 0;
int x = sprite[nSprite].x; int x = pSprite->x;
int y = sprite[nSprite].y; int y = pSprite->y;
int z = sprite[nSprite].z - (GetSpriteHeight(nSprite) >> 1); int z = pSprite->z - (GetSpriteHeight(nSprite) >> 1);
int nCheckDist = 0x7FFFFFFF; int nCheckDist = 0x7FFFFFFF;
short nAngle = sprite[nSprite].ang; short nAngle = pSprite->ang;
short nScanAngle = (sprite[nSprite].ang - 512) & kAngleMask; short nScanAngle = (pSprite->ang - 512) & kAngleMask;
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
@ -452,7 +455,7 @@ void FuncLion(int a, int nDamage, int nRun)
vec3_t startPos = { x, y, z }; vec3_t startPos = { x, y, z };
hitdata_t hitData; hitdata_t hitData;
hitscan(&startPos, sprite[nSprite].sectnum, bcos(nScanAngle), bsin(nScanAngle), 0, &hitData, CLIPMASK1); hitscan(&startPos, pSprite->sectnum, bcos(nScanAngle), bsin(nScanAngle), 0, &hitData, CLIPMASK1);
hitx = hitData.pos.x; hitx = hitData.pos.x;
hity = hitData.pos.y; hity = hitData.pos.y;
@ -474,11 +477,11 @@ void FuncLion(int a, int nDamage, int nRun)
nScanAngle &= kAngleMask; nScanAngle &= kAngleMask;
} }
sprite[nSprite].ang = nAngle; pSprite->ang = nAngle;
LionList[nLion].nAction = 6; LionList[nLion].nAction = 6;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang) - bcos(sprite[nSprite].ang, -3); pSprite->xvel = bcos(pSprite->ang) - bcos(pSprite->ang, -3);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang) - bsin(sprite[nSprite].ang, -3); pSprite->yvel = bsin(pSprite->ang) - bsin(pSprite->ang, -3);
D3PlayFX(StaticSound[kSound24], nSprite); D3PlayFX(StaticSound[kSound24], nSprite);
} }
@ -497,7 +500,7 @@ void FuncLion(int a, int nDamage, int nRun)
if ((nMov & 0xC000) == 0x8000) if ((nMov & 0xC000) == 0x8000)
{ {
LionList[nLion].nAction = 7; LionList[nLion].nAction = 7;
sprite[nSprite].ang = (GetWallNormal(nMov & 0x3FFF) + 1024) & kAngleMask; pSprite->ang = (GetWallNormal(nMov & 0x3FFF) + 1024) & kAngleMask;
LionList[nLion].nCount = RandomSize(4); LionList[nLion].nCount = RandomSize(4);
return; return;
} }
@ -505,8 +508,8 @@ void FuncLion(int a, int nDamage, int nRun)
{ {
if ((nMov & 0x3FFF) == nTarget) if ((nMov & 0x3FFF) == nTarget)
{ {
int nAng = getangle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y); int nAng = getangle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
if (AngleDiff(sprite[nSprite].ang, nAng) < 64) if (AngleDiff(pSprite->ang, nAng) < 64)
{ {
LionList[nLion].nAction = 3; LionList[nLion].nAction = 3;
LionList[nLion].nFrame = 0; LionList[nLion].nFrame = 0;
@ -515,9 +518,9 @@ void FuncLion(int a, int nDamage, int nRun)
else else
{ {
// loc_378FA: // loc_378FA:
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask; pSprite->ang = (pSprite->ang + 256) & kAngleMask;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1); pSprite->xvel = bcos(pSprite->ang, -1);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1); pSprite->yvel = bsin(pSprite->ang, -1);
break; break;
} }
} }
@ -538,14 +541,14 @@ void FuncLion(int a, int nDamage, int nRun)
} }
else else
{ {
sprite[nSprite].ang = (RandomSize(9) + (sprite[nSprite].ang + 768)) & kAngleMask; pSprite->ang = (RandomSize(9) + (pSprite->ang + 768)) & kAngleMask;
} }
sprite[nSprite].zvel = -1000; pSprite->zvel = -1000;
LionList[nLion].nAction = 6; LionList[nLion].nAction = 6;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang) - bcos(sprite[nSprite].ang, -3); pSprite->xvel = bcos(pSprite->ang) - bcos(pSprite->ang, -3);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang) - bsin(sprite[nSprite].ang, -3); pSprite->yvel = bsin(pSprite->ang) - bsin(pSprite->ang, -3);
D3PlayFX(StaticSound[kSound24], nSprite); D3PlayFX(StaticSound[kSound24], nSprite);
} }
@ -558,7 +561,7 @@ void FuncLion(int a, int nDamage, int nRun)
{ {
LionList[nLion].nAction = 2; LionList[nLion].nAction = 2;
LionList[nLion].nFrame = 0; LionList[nLion].nFrame = 0;
sprite[nSprite].cstat |= 0x8000; pSprite->cstat |= 0x8000;
} }
return; return;
} }
@ -569,7 +572,7 @@ void FuncLion(int a, int nDamage, int nRun)
{ {
LionList[nLion].nFrame = 0; LionList[nLion].nFrame = 0;
LionList[nLion].nAction = 2; LionList[nLion].nAction = 2;
sprite[nSprite].cstat |= 0x101; pSprite->cstat |= 0x101;
} }
return; return;
} }
@ -579,9 +582,9 @@ void FuncLion(int a, int nDamage, int nRun)
{ {
if (bVal) if (bVal)
{ {
runlist_SubRunRec(sprite[nSprite].owner); runlist_SubRunRec(pSprite->owner);
runlist_SubRunRec(LionList[nLion].nRun); runlist_SubRunRec(LionList[nLion].nRun);
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
} }
return; return;
} }
@ -596,8 +599,8 @@ void FuncLion(int a, int nDamage, int nRun)
LionList[nLion].nFrame = 0; LionList[nLion].nFrame = 0;
LionList[nLion].nCount = 100; LionList[nLion].nCount = 100;
LionList[nLion].nTarget = -1; LionList[nLion].nTarget = -1;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
} }

View file

@ -284,8 +284,9 @@ void BuildNear(int x, int y, int walldist, int nSector)
int BelowNear(short nSprite) int BelowNear(short nSprite)
{ {
short nSector = sprite[nSprite].sectnum; auto pSprite = &sprite[nSprite];
int z = sprite[nSprite].z; short nSector = pSprite->sectnum;
int z = pSprite->z;
int var_24, z2; int var_24, z2;
@ -325,11 +326,11 @@ int BelowNear(short nSprite)
} }
} }
if (z2 < sprite[nSprite].z) if (z2 < pSprite->z)
{ {
sprite[nSprite].z = z2; pSprite->z = z2;
overridesect = nSector; overridesect = nSector;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
bTouchFloor = true; bTouchFloor = true;
@ -516,7 +517,8 @@ int movespritez(short nSprite, int z, int height, int, int clipdist)
int GetSpriteHeight(int nSprite) int GetSpriteHeight(int nSprite)
{ {
return tileHeight(sprite[nSprite].picnum) * sprite[nSprite].yrepeat * 4; auto pSprite = &sprite[nSprite];
return tileHeight(pSprite->picnum) * pSprite->yrepeat * 4;
} }
int movesprite(short nSprite, int dx, int dy, int dz, int, int flordist, unsigned int clipmask) int movesprite(short nSprite, int dx, int dy, int dz, int, int flordist, unsigned int clipmask)
@ -601,65 +603,68 @@ int movesprite(short nSprite, int dx, int dy, int dz, int, int flordist, unsigne
void Gravity(short nSprite) void Gravity(short nSprite)
{ {
short nSector = sprite[nSprite].sectnum; auto pSprite = &sprite[nSprite];
short nSector = pSprite->sectnum;
if (SectFlag[nSector] & kSectUnderwater) if (SectFlag[nSector] & kSectUnderwater)
{ {
if (sprite[nSprite].statnum != 100) if (pSprite->statnum != 100)
{ {
if (sprite[nSprite].zvel <= 1024) if (pSprite->zvel <= 1024)
{ {
if (sprite[nSprite].zvel < 2048) { if (pSprite->zvel < 2048) {
sprite[nSprite].zvel += 512; pSprite->zvel += 512;
} }
} }
else else
{ {
sprite[nSprite].zvel -= 64; pSprite->zvel -= 64;
} }
} }
else else
{ {
if (sprite[nSprite].zvel > 0) if (pSprite->zvel > 0)
{ {
sprite[nSprite].zvel -= 64; pSprite->zvel -= 64;
if (sprite[nSprite].zvel < 0) { if (pSprite->zvel < 0) {
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
} }
} }
else if (sprite[nSprite].zvel < 0) else if (pSprite->zvel < 0)
{ {
sprite[nSprite].zvel += 64; pSprite->zvel += 64;
if (sprite[nSprite].zvel > 0) { if (pSprite->zvel > 0) {
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
} }
} }
} }
} }
else else
{ {
sprite[nSprite].zvel += 512; pSprite->zvel += 512;
if (sprite[nSprite].zvel > 16384) { if (pSprite->zvel > 16384) {
sprite[nSprite].zvel = 16384; pSprite->zvel = 16384;
} }
} }
} }
int MoveCreature(short nSprite) int MoveCreature(short nSprite)
{ {
return movesprite(nSprite, sprite[nSprite].xvel << 8, sprite[nSprite].yvel << 8, sprite[nSprite].zvel, 15360, -5120, CLIPMASK0); auto pSprite = &sprite[nSprite];
return movesprite(nSprite, pSprite->xvel << 8, pSprite->yvel << 8, pSprite->zvel, 15360, -5120, CLIPMASK0);
} }
int MoveCreatureWithCaution(int nSprite) int MoveCreatureWithCaution(int nSprite)
{ {
int x = sprite[nSprite].x; auto pSprite = &sprite[nSprite];
int y = sprite[nSprite].y; int x = pSprite->x;
int z = sprite[nSprite].z; int y = pSprite->y;
short nSectorPre = sprite[nSprite].sectnum; int z = pSprite->z;
short nSectorPre = pSprite->sectnum;
int ecx = MoveCreature(nSprite); int ecx = MoveCreature(nSprite);
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
if (nSector != nSectorPre) if (nSector != nSectorPre)
{ {
@ -670,15 +675,15 @@ int MoveCreatureWithCaution(int nSprite)
if (zDiff > 15360 || (SectFlag[nSector] & kSectUnderwater) || (SectBelow[nSector] > -1 && SectFlag[SectBelow[nSector]]) || SectDamage[nSector]) if (zDiff > 15360 || (SectFlag[nSector] & kSectUnderwater) || (SectBelow[nSector] > -1 && SectFlag[SectBelow[nSector]]) || SectDamage[nSector])
{ {
sprite[nSprite].x = x; pSprite->x = x;
sprite[nSprite].y = y; pSprite->y = y;
sprite[nSprite].z = z; pSprite->z = z;
mychangespritesect(nSprite, nSectorPre); mychangespritesect(nSprite, nSectorPre);
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask; pSprite->ang = (pSprite->ang + 256) & kAngleMask;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -2); pSprite->xvel = bcos(pSprite->ang, -2);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -2); pSprite->yvel = bsin(pSprite->ang, -2);
return 0; return 0;
} }
} }
@ -691,7 +696,10 @@ int GetAngleToSprite(int nSprite1, int nSprite2)
if (nSprite1 < 0 || nSprite2 < 0) if (nSprite1 < 0 || nSprite2 < 0)
return -1; return -1;
return GetMyAngle(sprite[nSprite2].x - sprite[nSprite1].x, sprite[nSprite2].y - sprite[nSprite1].y); auto pSprite1 = &sprite[nSprite1];
auto pSprite2 = &sprite[nSprite2];
return GetMyAngle(pSprite2->x - pSprite1->x, pSprite2->y - pSprite1->y);
} }
int PlotCourseToSprite(int nSprite1, int nSprite2) int PlotCourseToSprite(int nSprite1, int nSprite2)
@ -699,10 +707,12 @@ int PlotCourseToSprite(int nSprite1, int nSprite2)
if (nSprite1 < 0 || nSprite2 < 0) if (nSprite1 < 0 || nSprite2 < 0)
return -1; return -1;
int x = sprite[nSprite2].x - sprite[nSprite1].x; auto pSprite1 = &sprite[nSprite1];
int y = sprite[nSprite2].y - sprite[nSprite1].y; auto pSprite2 = &sprite[nSprite2];
int x = pSprite2->x - pSprite1->x;
int y = pSprite2->y - pSprite1->y;
sprite[nSprite1].ang = GetMyAngle(x, y); pSprite1->ang = GetMyAngle(x, y);
uint32_t x2 = abs(x); uint32_t x2 = abs(x);
uint32_t y2 = abs(y); uint32_t y2 = abs(y);
@ -720,6 +730,7 @@ int PlotCourseToSprite(int nSprite1, int nSprite2)
int FindPlayer(int nSprite, int nDistance) int FindPlayer(int nSprite, int nDistance)
{ {
auto pSprite = &sprite[nSprite];
int var_18 = 0; int var_18 = 0;
if (nSprite >= 0) if (nSprite >= 0)
var_18 = 1; var_18 = 1;
@ -730,11 +741,11 @@ int FindPlayer(int nSprite, int nDistance)
if (nDistance < 0) if (nDistance < 0)
nDistance = 100; nDistance = 100;
int x = sprite[nSprite].x; int x = pSprite->x;
int y = sprite[nSprite].y; int y = pSprite->y;
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
int z = sprite[nSprite].z - GetSpriteHeight(nSprite); int z = pSprite->z - GetSpriteHeight(nSprite);
nDistance <<= 8; nDistance <<= 8;
@ -798,11 +809,13 @@ void CheckSectorFloor(short nSector, int z, int *x, int *y)
int GetUpAngle(short nSprite1, int nVal, short nSprite2, int ecx) int GetUpAngle(short nSprite1, int nVal, short nSprite2, int ecx)
{ {
int x = sprite[nSprite2].x - sprite[nSprite1].x; auto pSprite1 = &sprite[nSprite1];
int y = sprite[nSprite2].y - sprite[nSprite1].y; auto pSprite2 = &sprite[nSprite2];
int x = pSprite2->x - pSprite1->x;
int y = pSprite2->y - pSprite1->y;
int ebx = (sprite[nSprite2].z + ecx) - (sprite[nSprite1].z + nVal); int ebx = (pSprite2->z + ecx) - (pSprite1->z + nVal);
int edx = (sprite[nSprite2].z + ecx) - (sprite[nSprite1].z + nVal); int edx = (pSprite2->z + ecx) - (pSprite1->z + nVal);
ebx >>= 4; ebx >>= 4;
edx >>= 8; edx >>= 8;
@ -854,13 +867,14 @@ void CreatePushBlock(int nSector)
sBlockInfo[nBlock].y = yAvg; sBlockInfo[nBlock].y = yAvg;
int nSprite = insertsprite(nSector, 0); int nSprite = insertsprite(nSector, 0);
auto pSprite = &sprite[nSprite];
sBlockInfo[nBlock].nSprite = nSprite; sBlockInfo[nBlock].nSprite = nSprite;
sprite[nSprite].x = xAvg; pSprite->x = xAvg;
sprite[nSprite].y = yAvg; pSprite->y = yAvg;
sprite[nSprite].z = sector[nSector].floorz - 256; pSprite->z = sector[nSector].floorz - 256;
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
int var_28 = 0; int var_28 = 0;
@ -885,7 +899,7 @@ void CreatePushBlock(int nSector)
sBlockInfo[nBlock].field_8 = var_28; sBlockInfo[nBlock].field_8 = var_28;
sprite[nSprite].clipdist = (var_28 & 0xFF) << 2; pSprite->clipdist = (var_28 & 0xFF) << 2;
sector[nSector].extra = nBlock; sector[nSector].extra = nBlock;
} }
@ -1133,8 +1147,9 @@ void MoveSector(short nSector, int nAngle, int *nXVel, int *nYVel)
void SetQuake(short nSprite, int nVal) void SetQuake(short nSprite, int nVal)
{ {
int x = sprite[nSprite].x; auto pSprite = &sprite[nSprite];
int y = sprite[nSprite].y; int x = pSprite->x;
int y = pSprite->y;
nVal *= 256; nVal *= 256;
@ -1181,7 +1196,8 @@ void SetQuake(short nSprite, int nVal)
int AngleChase(int nSprite, int nSprite2, int ebx, int ecx, int push1) int AngleChase(int nSprite, int nSprite2, int ebx, int ecx, int push1)
{ {
int nClipType = sprite[nSprite].statnum != 107; auto pSprite = &sprite[nSprite];
int nClipType = pSprite->statnum != 107;
/* bjd - need to handle cliptype to clipmask change that occured in later build engine version */ /* bjd - need to handle cliptype to clipmask change that occured in later build engine version */
if (nClipType == 1) { if (nClipType == 1) {
@ -1195,17 +1211,19 @@ int AngleChase(int nSprite, int nSprite2, int ebx, int ecx, int push1)
if (nSprite2 < 0) if (nSprite2 < 0)
{ {
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
nAngle = sprite[nSprite].ang; nAngle = pSprite->ang;
} }
else else
{ {
int nHeight = tileHeight(sprite[nSprite2].picnum) * sprite[nSprite2].yrepeat * 2; auto pSprite2 = &sprite[nSprite2];
int nMyAngle = GetMyAngle(sprite[nSprite2].x - sprite[nSprite].x, sprite[nSprite2].y - sprite[nSprite].y); int nHeight = tileHeight(pSprite2->picnum) * pSprite2->yrepeat * 2;
uint32_t xDiff = abs(sprite[nSprite2].x - sprite[nSprite].x); int nMyAngle = GetMyAngle(pSprite2->x - pSprite->x, pSprite2->y - pSprite->y);
uint32_t yDiff = abs(sprite[nSprite2].y - sprite[nSprite].y);
uint32_t xDiff = abs(pSprite2->x - pSprite->x);
uint32_t yDiff = abs(pSprite2->y - pSprite->y);
uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff; uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff;
@ -1217,9 +1235,9 @@ int AngleChase(int nSprite, int nSprite2, int ebx, int ecx, int push1)
int nSqrt = ksqrt(sqrtNum); int nSqrt = ksqrt(sqrtNum);
int var_18 = GetMyAngle(nSqrt, ((sprite[nSprite2].z - nHeight) - sprite[nSprite].z) >> 8); int var_18 = GetMyAngle(nSqrt, ((pSprite2->z - nHeight) - pSprite->z) >> 8);
int nAngDelta = AngleDelta(sprite[nSprite].ang, nMyAngle, 1024); int nAngDelta = AngleDelta(pSprite->ang, nMyAngle, 1024);
int nAngDelta2 = abs(nAngDelta); int nAngDelta2 = abs(nAngDelta);
if (nAngDelta2 > 63) if (nAngDelta2 > 63)
@ -1243,15 +1261,15 @@ int AngleChase(int nSprite, int nSprite2, int ebx, int ecx, int push1)
nAngDelta = -push1; nAngDelta = -push1;
} }
nAngle = (nAngDelta + sprite[nSprite].ang) & kAngleMask; nAngle = (nAngDelta + pSprite->ang) & kAngleMask;
int nAngDeltaD = AngleDelta(sprite[nSprite].zvel, var_18, 24); int nAngDeltaD = AngleDelta(pSprite->zvel, var_18, 24);
sprite[nSprite].zvel = (sprite[nSprite].zvel + nAngDeltaD) & kAngleMask; pSprite->zvel = (pSprite->zvel + nAngDeltaD) & kAngleMask;
} }
sprite[nSprite].ang = nAngle; pSprite->ang = nAngle;
int eax = abs(bcos(sprite[nSprite].zvel)); int eax = abs(bcos(pSprite->zvel));
int x = ((bcos(nAngle) * ebx) >> 14) * eax; int x = ((bcos(nAngle) * ebx) >> 14) * eax;
int y = ((bsin(nAngle) * ebx) >> 14) * eax; int y = ((bsin(nAngle) * ebx) >> 14) * eax;
@ -1267,7 +1285,7 @@ int AngleChase(int nSprite, int nSprite2, int ebx, int ecx, int push1)
sqrtNum = INT_MAX; sqrtNum = INT_MAX;
} }
int z = bsin(sprite[nSprite].zvel) * ksqrt(sqrtNum); int z = bsin(pSprite->zvel) * ksqrt(sqrtNum);
return movesprite(nSprite, x >> 2, y >> 2, (z >> 13) + bsin(ecx, -5), 0, 0, nClipType); return movesprite(nSprite, x >> 2, y >> 2, (z >> 13) + bsin(ecx, -5), 0, 0, nClipType);
} }
@ -1285,18 +1303,19 @@ int GetWallNormal(short nWall)
void WheresMyMouth(int nPlayer, int *x, int *y, int *z, short *sectnum) void WheresMyMouth(int nPlayer, int *x, int *y, int *z, short *sectnum)
{ {
int nSprite = PlayerList[nPlayer].nSprite; int nSprite = PlayerList[nPlayer].nSprite;
auto pSprite = &sprite[nSprite];
*x = sprite[nSprite].x; *x = pSprite->x;
*y = sprite[nSprite].y; *y = pSprite->y;
int height = GetSpriteHeight(nSprite) / 2; int height = GetSpriteHeight(nSprite) / 2;
*z = sprite[nSprite].z - height; *z = pSprite->z - height;
*sectnum = sprite[nSprite].sectnum; *sectnum = pSprite->sectnum;
clipmove_old((int32_t*)x, (int32_t*)y, (int32_t*)z, sectnum, clipmove_old((int32_t*)x, (int32_t*)y, (int32_t*)z, sectnum,
bcos(sprite[nSprite].ang, 7), bcos(pSprite->ang, 7),
bsin(sprite[nSprite].ang, 7), bsin(pSprite->ang, 7),
5120, 1280, 1280, CLIPMASK1); 5120, 1280, 1280, CLIPMASK1);
} }
@ -1315,25 +1334,27 @@ void InitChunks()
int GrabBodyGunSprite() int GrabBodyGunSprite()
{ {
int nSprite = nBodyGunSprite[nCurBodyGunNum]; int nSprite = nBodyGunSprite[nCurBodyGunNum];
auto pSprite = &sprite[nSprite];
if (nSprite == -1) if (nSprite == -1)
{ {
nSprite = insertsprite(0, 899); nSprite = insertsprite(0, 899);
pSprite = &sprite[nSprite];
nBodyGunSprite[nCurBodyGunNum] = nSprite; nBodyGunSprite[nCurBodyGunNum] = nSprite;
sprite[nSprite].lotag = -1; pSprite->lotag = -1;
sprite[nSprite].owner = -1; pSprite->owner = -1;
} }
else else
{ {
int nAnim = sprite[nSprite].owner; int nAnim = pSprite->owner;
if (nAnim != -1) { if (nAnim != -1) {
DestroyAnim(nAnim); DestroyAnim(nAnim);
} }
sprite[nSprite].lotag = -1; pSprite->lotag = -1;
sprite[nSprite].owner = -1; pSprite->owner = -1;
} }
nCurBodyGunNum++; nCurBodyGunNum++;
@ -1341,7 +1362,7 @@ int GrabBodyGunSprite()
nCurBodyGunNum = 0; nCurBodyGunNum = 0;
} }
sprite[nSprite].cstat = 0; pSprite->cstat = 0;
return nSprite; return nSprite;
} }
@ -1350,41 +1371,46 @@ int GrabBody()
{ {
int nSprite; int nSprite;
spritetype* pSprite = nullptr;
do do
{ {
nSprite = nBodySprite[nCurBodyNum]; nSprite = nBodySprite[nCurBodyNum];
pSprite = &sprite[nSprite];
if (nSprite == -1) if (nSprite == -1)
{ {
nSprite = insertsprite(0, 899); nSprite = insertsprite(0, 899);
pSprite = &sprite[nSprite];
nBodySprite[nCurBodyNum] = nSprite; nBodySprite[nCurBodyNum] = nSprite;
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
} }
nCurBodyNum++; nCurBodyNum++;
if (nCurBodyNum >= 50) { if (nCurBodyNum >= 50) {
nCurBodyNum = 0; nCurBodyNum = 0;
} }
} while (sprite[nSprite].cstat & 0x101); } while (pSprite->cstat & 0x101);
if (nBodyTotal < 50) { if (nBodyTotal < 50) {
nBodyTotal++; nBodyTotal++;
} }
sprite[nSprite].cstat = 0; pSprite->cstat = 0;
return nSprite; return nSprite;
} }
int GrabChunkSprite() int GrabChunkSprite()
{ {
int nSprite = nChunkSprite[nCurChunkNum]; int nSprite = nChunkSprite[nCurChunkNum];
auto pSprite = &sprite[nSprite];
if (nSprite == -1) if (nSprite == -1)
{ {
nSprite = insertsprite(0, 899); nSprite = insertsprite(0, 899);
pSprite = &sprite[nSprite];
nChunkSprite[nCurChunkNum] = nSprite; nChunkSprite[nCurChunkNum] = nSprite;
} }
else if (sprite[nSprite].statnum) else if (pSprite->statnum)
{ {
// TODO MonoOut("too many chunks being used at once!\n"); // TODO MonoOut("too many chunks being used at once!\n");
return -1; return -1;
@ -1399,7 +1425,7 @@ int GrabChunkSprite()
if (nChunkTotal < kMaxMoveChunks) if (nChunkTotal < kMaxMoveChunks)
nChunkTotal++; nChunkTotal++;
sprite[nSprite].cstat = 0x80; pSprite->cstat = 0x80;
return nSprite; return nSprite;
} }
@ -1413,6 +1439,7 @@ int BuildCreatureChunk(int nVal, int nPic)
if (nSprite == -1) { if (nSprite == -1) {
return -1; return -1;
} }
auto pSprite = &sprite[nSprite];
if (nVal & 0x4000) if (nVal & 0x4000)
{ {
@ -1426,40 +1453,40 @@ int BuildCreatureChunk(int nVal, int nPic)
nVal &= 0xFFFF; nVal &= 0xFFFF;
sprite[nSprite].x = sprite[nVal].x; pSprite->x = sprite[nVal].x;
sprite[nSprite].y = sprite[nVal].y; pSprite->y = sprite[nVal].y;
sprite[nSprite].z = sprite[nVal].z; pSprite->z = sprite[nVal].z;
mychangespritesect(nSprite, sprite[nVal].sectnum); mychangespritesect(nSprite, sprite[nVal].sectnum);
sprite[nSprite].cstat = 0x80; pSprite->cstat = 0x80;
sprite[nSprite].shade = -12; pSprite->shade = -12;
sprite[nSprite].pal = 0; pSprite->pal = 0;
sprite[nSprite].xvel = (RandomSize(5) - 16) << 7; pSprite->xvel = (RandomSize(5) - 16) << 7;
sprite[nSprite].yvel = (RandomSize(5) - 16) << 7; pSprite->yvel = (RandomSize(5) - 16) << 7;
sprite[nSprite].zvel = (-(RandomSize(8) + 512)) << 3; pSprite->zvel = (-(RandomSize(8) + 512)) << 3;
if (var_14) if (var_14)
{ {
sprite[nSprite].xvel *= 4; pSprite->xvel *= 4;
sprite[nSprite].yvel *= 4; pSprite->yvel *= 4;
sprite[nSprite].zvel *= 2; pSprite->zvel *= 2;
} }
sprite[nSprite].xrepeat = 64; pSprite->xrepeat = 64;
sprite[nSprite].yrepeat = 64; pSprite->yrepeat = 64;
sprite[nSprite].xoffset = 0; pSprite->xoffset = 0;
sprite[nSprite].yoffset = 0; pSprite->yoffset = 0;
sprite[nSprite].picnum = nPic; pSprite->picnum = nPic;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].clipdist = 40; pSprite->clipdist = 40;
// GrabTimeSlot(3); // GrabTimeSlot(3);
sprite[nSprite].extra = -1; pSprite->extra = -1;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nSprite | 0xD0000); pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nSprite | 0xD0000);
sprite[nSprite].hitag = runlist_AddRunRec(NewRun, nSprite | 0xD0000); pSprite->hitag = runlist_AddRunRec(NewRun, nSprite | 0xD0000);
return nSprite | 0xD0000; return nSprite | 0xD0000;
} }
@ -1468,6 +1495,7 @@ void FuncCreatureChunk(int a, int, int nRun)
{ {
int nSprite = RunData[nRun].nVal; int nSprite = RunData[nRun].nVal;
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
auto pSprite = &sprite[nSprite];
int nMessage = a & 0x7F0000; int nMessage = a & 0x7F0000;
@ -1476,20 +1504,20 @@ void FuncCreatureChunk(int a, int, int nRun)
Gravity(nSprite); Gravity(nSprite);
int nSector = sprite[nSprite].sectnum; int nSector = pSprite->sectnum;
sprite[nSprite].pal = sector[nSector].ceilingpal; pSprite->pal = sector[nSector].ceilingpal;
int nVal = movesprite(nSprite, sprite[nSprite].xvel << 10, sprite[nSprite].yvel << 10, sprite[nSprite].zvel, 2560, -2560, CLIPMASK1); int nVal = movesprite(nSprite, pSprite->xvel << 10, pSprite->yvel << 10, pSprite->zvel, 2560, -2560, CLIPMASK1);
if (sprite[nSprite].z >= sector[nSector].floorz) if (pSprite->z >= sector[nSector].floorz)
{ {
// re-grab this variable as it may have changed in movesprite(). Note the check above is against the value *before* movesprite so don't change it. // re-grab this variable as it may have changed in movesprite(). Note the check above is against the value *before* movesprite so don't change it.
nSector = sprite[nSprite].sectnum; nSector = pSprite->sectnum;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].z = sector[nSector].floorz; pSprite->z = sector[nSector].floorz;
} }
else else
{ {
@ -1500,15 +1528,15 @@ void FuncCreatureChunk(int a, int, int nRun)
if (nVal & 0x20000) if (nVal & 0x20000)
{ {
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
} }
else else
{ {
if ((nVal & 0x3C000) == 0x10000) if ((nVal & 0x3C000) == 0x10000)
{ {
sprite[nSprite].xvel >>= 1; pSprite->xvel >>= 1;
sprite[nSprite].yvel >>= 1; pSprite->yvel >>= 1;
sprite[nSprite].zvel = -sprite[nSprite].zvel; pSprite->zvel = -pSprite->zvel;
return; return;
} }
else if ((nVal & 0x3C000) == 0xC000) else if ((nVal & 0x3C000) == 0xC000)
@ -1525,22 +1553,22 @@ void FuncCreatureChunk(int a, int, int nRun)
} }
// loc_16E0C // loc_16E0C
int nSqrt = lsqrt(((sprite[nSprite].yvel >> 10) * (sprite[nSprite].yvel >> 10) int nSqrt = lsqrt(((pSprite->yvel >> 10) * (pSprite->yvel >> 10)
+ (sprite[nSprite].xvel >> 10) * (sprite[nSprite].xvel >> 10)) >> 8); + (pSprite->xvel >> 10) * (pSprite->xvel >> 10)) >> 8);
sprite[nSprite].xvel = bcos(nAngle) * (nSqrt >> 1); pSprite->xvel = bcos(nAngle) * (nSqrt >> 1);
sprite[nSprite].yvel = bsin(nAngle) * (nSqrt >> 1); pSprite->yvel = bsin(nAngle) * (nSqrt >> 1);
return; return;
} }
} }
runlist_DoSubRunRec(sprite[nSprite].owner); runlist_DoSubRunRec(pSprite->owner);
runlist_FreeRun(sprite[nSprite].lotag - 1); runlist_FreeRun(pSprite->lotag - 1);
runlist_SubRunRec(sprite[nSprite].hitag); runlist_SubRunRec(pSprite->hitag);
changespritestat(nSprite, 0); changespritestat(nSprite, 0);
sprite[nSprite].hitag = 0; pSprite->hitag = 0;
sprite[nSprite].lotag = 0; pSprite->lotag = 0;
} }
short UpdateEnemy(short *nEnemy) short UpdateEnemy(short *nEnemy)

View file

@ -82,42 +82,44 @@ void InitMummy()
int BuildMummy(int nSprite, int x, int y, int z, int nSector, int nAngle) int BuildMummy(int nSprite, int x, int y, int z, int nSector, int nAngle)
{ {
auto nMummy = MummyList.Reserve(1); auto nMummy = MummyList.Reserve(1);
auto pSprite = &sprite[nSprite];
if (nSprite == -1) if (nSprite == -1)
{ {
nSprite = insertsprite(nSector, 102); nSprite = insertsprite(nSector, 102);
pSprite = &sprite[nSprite];
} }
else else
{ {
x = sprite[nSprite].x; x = pSprite->x;
y = sprite[nSprite].y; y = pSprite->y;
z = sprite[nSprite].z; z = pSprite->z;
nAngle = sprite[nSprite].ang; nAngle = pSprite->ang;
changespritestat(nSprite, 102); changespritestat(nSprite, 102);
} }
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
sprite[nSprite].x = x; pSprite->x = x;
sprite[nSprite].y = y; pSprite->y = y;
sprite[nSprite].z = z; pSprite->z = z;
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
sprite[nSprite].shade = -12; pSprite->shade = -12;
sprite[nSprite].clipdist = 32; pSprite->clipdist = 32;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].xrepeat = 42; pSprite->xrepeat = 42;
sprite[nSprite].yrepeat = 42; pSprite->yrepeat = 42;
sprite[nSprite].pal = sector[sprite[nSprite].sectnum].ceilingpal; pSprite->pal = sector[pSprite->sectnum].ceilingpal;
sprite[nSprite].xoffset = 0; pSprite->xoffset = 0;
sprite[nSprite].yoffset = 0; pSprite->yoffset = 0;
sprite[nSprite].ang = nAngle; pSprite->ang = nAngle;
sprite[nSprite].picnum = 1; pSprite->picnum = 1;
sprite[nSprite].hitag = 0; pSprite->hitag = 0;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].extra = -1; pSprite->extra = -1;
// GrabTimeSlot(3); // GrabTimeSlot(3);
@ -129,7 +131,7 @@ int BuildMummy(int nSprite, int x, int y, int z, int nSector, int nAngle)
MummyList[nMummy].nIndex = nMummy; MummyList[nMummy].nIndex = nMummy;
MummyList[nMummy].nCount = 0; MummyList[nMummy].nCount = 0;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nMummy | 0xE0000); pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nMummy | 0xE0000);
MummyList[nMummy].nRun = runlist_AddRunRec(NewRun, nMummy | 0xE0000); MummyList[nMummy].nRun = runlist_AddRunRec(NewRun, nMummy | 0xE0000);
@ -141,6 +143,7 @@ int BuildMummy(int nSprite, int x, int y, int z, int nSector, int nAngle)
void CheckMummyRevive(short nMummy) void CheckMummyRevive(short nMummy)
{ {
short nSprite = MummyList[nMummy].nSprite; short nSprite = MummyList[nMummy].nSprite;
auto pSprite = &sprite[nSprite];
for (unsigned i = 0; i < MummyList.Size(); i++) for (unsigned i = 0; i < MummyList.Size(); i++)
{ {
@ -155,12 +158,12 @@ void CheckMummyRevive(short nMummy)
continue; continue;
} }
int x = abs(sprite[nSprite2].x - sprite[nSprite].x) >> 8; int x = abs(sprite[nSprite2].x - pSprite->x) >> 8;
int y = abs(sprite[nSprite2].y - sprite[nSprite].y) >> 8; int y = abs(sprite[nSprite2].y - pSprite->y) >> 8;
if (x <= 20 && y <= 20) if (x <= 20 && y <= 20)
{ {
if (cansee(sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z - 8192, sprite[nSprite].sectnum, if (cansee(pSprite->x, pSprite->y, pSprite->z - 8192, pSprite->sectnum,
sprite[nSprite2].x, sprite[nSprite2].y, sprite[nSprite2].z - 8192, sprite[nSprite2].sectnum)) sprite[nSprite2].x, sprite[nSprite2].y, sprite[nSprite2].z - 8192, sprite[nSprite2].sectnum))
{ {
sprite[nSprite2].cstat = 0; sprite[nSprite2].cstat = 0;
@ -180,6 +183,7 @@ void FuncMummy(int a, int nDamage, int nRun)
short nTarget = UpdateEnemy(&MummyList[nMummy].nTarget); short nTarget = UpdateEnemy(&MummyList[nMummy].nTarget);
short nSprite = MummyList[nMummy].nSprite; short nSprite = MummyList[nMummy].nSprite;
auto pSprite = &sprite[nSprite];
short nAction = MummyList[nMummy].nAction; short nAction = MummyList[nMummy].nAction;
int nMessage = a & kMessageMask; int nMessage = a & kMessageMask;
@ -198,7 +202,7 @@ void FuncMummy(int a, int nDamage, int nRun)
int nSeq = SeqOffsets[kSeqMummy] + MummySeq[nAction].a; int nSeq = SeqOffsets[kSeqMummy] + MummySeq[nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, MummyList[nMummy].nFrame); pSprite->picnum = seq_GetSeqPicnum2(nSeq, MummyList[nMummy].nFrame);
short nFrame = SeqBase[nSeq] + MummyList[nMummy].nFrame; short nFrame = SeqBase[nSeq] + MummyList[nMummy].nFrame;
short nFrameFlag = FrameFlag[nFrame]; short nFrameFlag = FrameFlag[nFrame];
@ -221,8 +225,8 @@ void FuncMummy(int a, int nDamage, int nRun)
{ {
MummyList[nMummy].nAction = 0; MummyList[nMummy].nAction = 0;
MummyList[nMummy].nFrame = 0; MummyList[nMummy].nFrame = 0;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
} }
@ -237,7 +241,7 @@ void FuncMummy(int a, int nDamage, int nRun)
{ {
if ((MummyList[nMummy].nIndex & 0x1F) == (totalmoves & 0x1F)) if ((MummyList[nMummy].nIndex & 0x1F) == (totalmoves & 0x1F))
{ {
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
if (nTarget < 0) if (nTarget < 0)
{ {
@ -250,8 +254,8 @@ void FuncMummy(int a, int nDamage, int nRun)
MummyList[nMummy].nAction = 1; MummyList[nMummy].nAction = 1;
MummyList[nMummy].nCount = 90; MummyList[nMummy].nCount = 90;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -2); pSprite->xvel = bcos(pSprite->ang, -2);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -2); pSprite->yvel = bsin(pSprite->ang, -2);
} }
} }
} }
@ -267,7 +271,7 @@ void FuncMummy(int a, int nDamage, int nRun)
if ((MummyList[nMummy].nIndex & 0x1F) == (totalmoves & 0x1F)) if ((MummyList[nMummy].nIndex & 0x1F) == (totalmoves & 0x1F))
{ {
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
PlotCourseToSprite(nSprite, nTarget); PlotCourseToSprite(nSprite, nTarget);
@ -275,14 +279,14 @@ void FuncMummy(int a, int nDamage, int nRun)
{ {
if (RandomBit()) if (RandomBit())
{ {
if (cansee(sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z - GetSpriteHeight(nSprite), sprite[nSprite].sectnum, if (cansee(pSprite->x, pSprite->y, pSprite->z - GetSpriteHeight(nSprite), pSprite->sectnum,
sprite[nTarget].x, sprite[nTarget].y, sprite[nTarget].z - GetSpriteHeight(nTarget), sprite[nTarget].sectnum)) sprite[nTarget].x, sprite[nTarget].y, sprite[nTarget].z - GetSpriteHeight(nTarget), sprite[nTarget].sectnum))
{ {
MummyList[nMummy].nAction = 3; MummyList[nMummy].nAction = 3;
MummyList[nMummy].nFrame = 0; MummyList[nMummy].nFrame = 0;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
return; return;
} }
} }
@ -292,39 +296,39 @@ void FuncMummy(int a, int nDamage, int nRun)
// loc_2B5A8 // loc_2B5A8
if (!MummyList[nMummy].nFrame) if (!MummyList[nMummy].nFrame)
{ {
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1); pSprite->xvel = bcos(pSprite->ang, -1);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1); pSprite->yvel = bsin(pSprite->ang, -1);
} }
if (sprite[nSprite].xvel || sprite[nSprite].yvel) if (pSprite->xvel || pSprite->yvel)
{ {
if (sprite[nSprite].xvel > 0) if (pSprite->xvel > 0)
{ {
sprite[nSprite].xvel -= 1024; pSprite->xvel -= 1024;
if (sprite[nSprite].xvel < 0) { if (pSprite->xvel < 0) {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
} }
} }
else if (sprite[nSprite].xvel < 0) else if (pSprite->xvel < 0)
{ {
sprite[nSprite].xvel += 1024; pSprite->xvel += 1024;
if (sprite[nSprite].xvel > 0) { if (pSprite->xvel > 0) {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
} }
} }
if (sprite[nSprite].yvel > 0) if (pSprite->yvel > 0)
{ {
sprite[nSprite].yvel -= 1024; pSprite->yvel -= 1024;
if (sprite[nSprite].yvel < 0) { if (pSprite->yvel < 0) {
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
} }
else if (sprite[nSprite].yvel < 0) else if (pSprite->yvel < 0)
{ {
sprite[nSprite].yvel += 1024; pSprite->yvel += 1024;
if (sprite[nSprite].yvel > 0) { if (pSprite->yvel > 0) {
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
} }
} }
@ -335,9 +339,9 @@ void FuncMummy(int a, int nDamage, int nRun)
{ {
case 0x8000: case 0x8000:
{ {
sprite[nSprite].ang = (sprite[nSprite].ang + ((RandomWord() & 0x3FF) + 1024)) & kAngleMask; pSprite->ang = (pSprite->ang + ((RandomWord() & 0x3FF) + 1024)) & kAngleMask;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -2); pSprite->xvel = bcos(pSprite->ang, -2);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -2); pSprite->yvel = bsin(pSprite->ang, -2);
return; return;
} }
@ -345,14 +349,14 @@ void FuncMummy(int a, int nDamage, int nRun)
{ {
if ((nMov & 0x3FFF) == nTarget) if ((nMov & 0x3FFF) == nTarget)
{ {
int nAngle = getangle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y); int nAngle = getangle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
if (AngleDiff(sprite[nSprite].ang, nAngle) < 64) if (AngleDiff(pSprite->ang, nAngle) < 64)
{ {
MummyList[nMummy].nAction = 2; MummyList[nMummy].nAction = 2;
MummyList[nMummy].nFrame = 0; MummyList[nMummy].nFrame = 0;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
} }
return; return;
@ -400,7 +404,7 @@ void FuncMummy(int a, int nDamage, int nRun)
SetQuake(nSprite, 100); SetQuake(nSprite, 100);
// low 16 bits of returned var contains the sprite index, the high 16 the bullet number // low 16 bits of returned var contains the sprite index, the high 16 the bullet number
int nBullet = BuildBullet(nSprite, 9, 0, 0, -15360, sprite[nSprite].ang, nTarget + 10000, 1); int nBullet = BuildBullet(nSprite, 9, 0, 0, -15360, pSprite->ang, nTarget + 10000, 1);
CheckMummyRevive(nMummy); CheckMummyRevive(nMummy);
if (nBullet > -1) if (nBullet > -1)
@ -437,7 +441,7 @@ void FuncMummy(int a, int nDamage, int nRun)
{ {
if (bVal) if (bVal)
{ {
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
MummyList[nMummy].nAction = 0; MummyList[nMummy].nAction = 0;
MummyList[nMummy].nHealth = 300; MummyList[nMummy].nHealth = 300;
@ -452,15 +456,15 @@ void FuncMummy(int a, int nDamage, int nRun)
{ {
if (nMov & 0x20000) if (nMov & 0x20000)
{ {
sprite[nSprite].xvel >>= 1; pSprite->xvel >>= 1;
sprite[nSprite].yvel >>= 1; pSprite->yvel >>= 1;
} }
if (bVal) if (bVal)
{ {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
MummyList[nMummy].nAction = 0; MummyList[nMummy].nAction = 0;
MummyList[nMummy].nFrame = 0; MummyList[nMummy].nFrame = 0;
@ -503,7 +507,7 @@ void FuncMummy(int a, int nDamage, int nRun)
if (MummyList[nMummy].nHealth <= 0) if (MummyList[nMummy].nHealth <= 0)
{ {
MummyList[nMummy].nHealth = 0; MummyList[nMummy].nHealth = 0;
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
nCreaturesKilled++; nCreaturesKilled++;
DropMagic(nSprite); DropMagic(nSprite);
@ -511,10 +515,10 @@ void FuncMummy(int a, int nDamage, int nRun)
MummyList[nMummy].nFrame = 0; MummyList[nMummy].nFrame = 0;
MummyList[nMummy].nAction = 4; MummyList[nMummy].nAction = 4;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].z = sector[sprite[nSprite].sectnum].floorz; pSprite->z = sector[pSprite->sectnum].floorz;
} }
else else
{ {
@ -523,8 +527,8 @@ void FuncMummy(int a, int nDamage, int nRun)
MummyList[nMummy].nAction = 7; MummyList[nMummy].nAction = 7;
MummyList[nMummy].nFrame = 0; MummyList[nMummy].nFrame = 0;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
} }

View file

@ -429,11 +429,12 @@ int BuildWallSprite(int nSector)
int y2 = wall[nWall + 1].y; int y2 = wall[nWall + 1].y;
int nSprite = insertsprite(nSector, 401); int nSprite = insertsprite(nSector, 401);
auto pSprite = &sprite[nSprite];
sprite[nSprite].x = (x + x2) / 2; pSprite->x = (x + x2) / 2;
sprite[nSprite].y = (y + y2) / 2; pSprite->y = (y + y2) / 2;
sprite[nSprite].z = (sector[nSector].floorz + sector[nSector].ceilingz) / 2; pSprite->z = (sector[nSector].floorz + sector[nSector].ceilingz) / 2;
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
return nSprite; return nSprite;
} }
@ -501,14 +502,15 @@ short FindWallSprites(short nSector)
if (nSprite < 0) if (nSprite < 0)
{ {
nSprite = insertsprite(nSector, 401); nSprite = insertsprite(nSector, 401);
auto pSprite = &sprite[nSprite];
sprite[nSprite].x = (var_24 + esi) / 2; pSprite->x = (var_24 + esi) / 2;
sprite[nSprite].y = (ecx + edi) / 2; pSprite->y = (ecx + edi) / 2;
sprite[nSprite].z = sector[nSector].floorz; pSprite->z = sector[nSector].floorz;
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
sprite[nSprite].owner = -1; pSprite->owner = -1;
sprite[nSprite].lotag = 0; pSprite->lotag = 0;
sprite[nSprite].hitag = 0; pSprite->hitag = 0;
} }
return nSprite; return nSprite;
@ -643,7 +645,8 @@ int CheckSectorSprites(short nSector, int nVal)
SectIterator it(nSector); SectIterator it(nSector);
while ((nSprite = it.NextIndex()) >= 0) while ((nSprite = it.NextIndex()) >= 0)
{ {
if ((sprite[nSprite].cstat & 0x101) && (nZDiff < GetSpriteHeight(nSprite))) auto pSprite = &sprite[nSprite];
if ((pSprite->cstat & 0x101) && (nZDiff < GetSpriteHeight(nSprite)))
{ {
if (nVal != 1) { if (nVal != 1) {
return 1; return 1;
@ -653,13 +656,13 @@ int CheckSectorSprites(short nSector, int nVal)
runlist_DamageEnemy(nSprite, -1, 5); runlist_DamageEnemy(nSprite, -1, 5);
if (sprite[nSprite].statnum == 100 && PlayerList[GetPlayerFromSprite(nSprite)].nHealth <= 0) if (pSprite->statnum == 100 && PlayerList[GetPlayerFromSprite(nSprite)].nHealth <= 0)
{ {
PlayFXAtXYZ(StaticSound[kSoundJonFDie], PlayFXAtXYZ(StaticSound[kSoundJonFDie],
sprite[nSprite].x, pSprite->x,
sprite[nSprite].y, pSprite->y,
sprite[nSprite].z, pSprite->z,
sprite[nSprite].sectnum | 0x4000); pSprite->sectnum | 0x4000);
} }
} }
} }
@ -691,10 +694,11 @@ void MoveSectorSprites(int nSector, int z)
SectIterator it(nSector); SectIterator it(nSector);
while ((nSprite = it.NextIndex()) >= 0) while ((nSprite = it.NextIndex()) >= 0)
{ {
int z = sprite[nSprite].z; auto pSprite = &sprite[nSprite];
if ((sprite[nSprite].statnum != 200 && z >= minz && z <= maxz) || sprite[nSprite].statnum >= 900) int z = pSprite->z;
if ((pSprite->statnum != 200 && z >= minz && z <= maxz) || pSprite->statnum >= 900)
{ {
sprite[nSprite].z = newz; pSprite->z = newz;
} }
} }
} }
@ -1111,13 +1115,14 @@ int BuildSlide(int nChannel, int nStartWall, int nWall1, int ecx, int nWall2, in
int nSprite = insertsprite(nSector, 899); int nSprite = insertsprite(nSector, 899);
auto pSprite = &sprite[nSprite];
SlideData[nSlide].nSprite = nSprite; SlideData[nSlide].nSprite = nSprite;
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
sprite[nSprite].x = wall[nStartWall].x; pSprite->x = wall[nStartWall].x;
sprite[nSprite].y = wall[nStartWall].y; pSprite->y = wall[nStartWall].y;
sprite[nSprite].z = sector[nSector].floorz; pSprite->z = sector[nSector].floorz;
sprite[nSprite].backuppos(); pSprite->backuppos();
SlideData[nSlide].field_8a = 0; SlideData[nSlide].field_8a = 0;
@ -1296,6 +1301,7 @@ void FuncSlide(int a, int, int nRun)
int BuildTrap(int nSprite, int edx, int ebx, int ecx) int BuildTrap(int nSprite, int edx, int ebx, int ecx)
{ {
auto pSprite = &sprite[nSprite];
int var_14 = edx; int var_14 = edx;
int var_18 = ebx; int var_18 = ebx;
int var_10 = ecx; int var_10 = ecx;
@ -1304,15 +1310,15 @@ int BuildTrap(int nSprite, int edx, int ebx, int ecx)
changespritestat(nSprite, 0); changespritestat(nSprite, 0);
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].extra = -1; pSprite->extra = -1;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].hitag = runlist_AddRunRec(NewRun, nTrap | 0x1F0000); pSprite->hitag = runlist_AddRunRec(NewRun, nTrap | 0x1F0000);
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nTrap | 0x1F0000); pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nTrap | 0x1F0000);
// GrabTimeSlot(3); // GrabTimeSlot(3);
@ -1335,7 +1341,7 @@ int BuildTrap(int nSprite, int edx, int ebx, int ecx)
sTrap[nTrap].field_6 = -1; sTrap[nTrap].field_6 = -1;
sTrap[nTrap].field_8 = -1; sTrap[nTrap].field_8 = -1;
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
short nWall = sector[nSector].wallptr; short nWall = sector[nSector].wallptr;
int i = 0; int i = 0;
@ -1364,7 +1370,7 @@ int BuildTrap(int nSprite, int edx, int ebx, int ecx)
ecx++; ecx++;
nWall++; nWall++;
} }
sprite[nSprite].backuppos(); pSprite->backuppos();
} }
@ -1372,6 +1378,7 @@ void FuncTrap(int a, int, int nRun)
{ {
short nTrap = RunData[nRun].nVal; short nTrap = RunData[nRun].nVal;
short nSprite = sTrap[nTrap].nSprite; short nSprite = sTrap[nTrap].nSprite;
auto pSprite = &sprite[nSprite];
int nMessage = a & 0x7F0000; int nMessage = a & 0x7F0000;
@ -1430,7 +1437,7 @@ void FuncTrap(int a, int, int nRun)
return; return;
} }
int nBullet = BuildBullet(nSprite, nType, 0, 0, 0, sprite[nSprite].ang, 0, 1); int nBullet = BuildBullet(nSprite, nType, 0, 0, 0, pSprite->ang, 0, 1);
if (nBullet > -1) if (nBullet > -1)
{ {
short nBulletSprite = nBullet & 0xFFFF; // isolate the sprite index (disregard top 16 bits) short nBulletSprite = nBullet & 0xFFFF; // isolate the sprite index (disregard top 16 bits)
@ -1490,7 +1497,8 @@ int BuildFireBall(int nSprite, int a, int b)
int BuildSpark(int nSprite, int nVal) int BuildSpark(int nSprite, int nVal)
{ {
int var_14 = insertsprite(sprite[nSprite].sectnum, 0); auto pSprite = &sprite[nSprite];
int var_14 = insertsprite(pSprite->sectnum, 0);
if (var_14 < 0) { if (var_14 < 0) {
return -1; return -1;
@ -1499,8 +1507,8 @@ int BuildSpark(int nSprite, int nVal)
assert(var_14 < kMaxSprites); assert(var_14 < kMaxSprites);
spr->x = sprite[nSprite].x; spr->x = pSprite->x;
spr->y = sprite[nSprite].y; spr->y = pSprite->y;
spr->cstat = 0; spr->cstat = 0;
spr->shade = -127; spr->shade = -127;
spr->pal = 1; spr->pal = 1;
@ -1521,13 +1529,13 @@ int BuildSpark(int nSprite, int nVal)
} }
else else
{ {
spr->xrepeat = sprite[nSprite].xrepeat + 15; spr->xrepeat = pSprite->xrepeat + 15;
spr->yrepeat = sprite[nSprite].xrepeat + 15; spr->yrepeat = pSprite->xrepeat + 15;
} }
} }
else else
{ {
int nAngle = (sprite[nSprite].ang + 256) - RandomSize(9); int nAngle = (pSprite->ang + 256) - RandomSize(9);
if (nVal) if (nVal)
{ {
@ -1544,7 +1552,7 @@ int BuildSpark(int nSprite, int nVal)
spr->picnum = kTile985 + nVal; spr->picnum = kTile985 + nVal;
} }
spr->z = sprite[nSprite].z; spr->z = pSprite->z;
spr->lotag = runlist_HeadRun() + 1; spr->lotag = runlist_HeadRun() + 1;
spr->clipdist = 1; spr->clipdist = 1;
spr->hitag = 0; spr->hitag = 0;
@ -1562,6 +1570,8 @@ int BuildSpark(int nSprite, int nVal)
void FuncSpark(int a, int, int nRun) void FuncSpark(int a, int, int nRun)
{ {
int nSprite = RunData[nRun].nVal; int nSprite = RunData[nRun].nVal;
auto pSprite = &sprite[nSprite];
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
int nMessage = a & 0x7F0000; int nMessage = a & 0x7F0000;
@ -1570,46 +1580,46 @@ void FuncSpark(int a, int, int nRun)
return; return;
} }
sprite[nSprite].shade += 3; pSprite->shade += 3;
sprite[nSprite].xrepeat -= 2; pSprite->xrepeat -= 2;
if (sprite[nSprite].xrepeat >= 4 && sprite[nSprite].shade <= 100) if (pSprite->xrepeat >= 4 && pSprite->shade <= 100)
{ {
sprite[nSprite].yrepeat -= 2; pSprite->yrepeat -= 2;
// calling BuildSpark() with 2nd parameter as '1' will set kTile986 // calling BuildSpark() with 2nd parameter as '1' will set kTile986
if (sprite[nSprite].picnum == kTile986 && (sprite[nSprite].xrepeat & 2)) if (pSprite->picnum == kTile986 && (pSprite->xrepeat & 2))
{ {
BuildSpark(nSprite, 2); BuildSpark(nSprite, 2);
} }
if (sprite[nSprite].picnum >= kTile3000) { if (pSprite->picnum >= kTile3000) {
return; return;
} }
sprite[nSprite].zvel += 128; pSprite->zvel += 128;
int nMov = movesprite(nSprite, sprite[nSprite].xvel << 12, sprite[nSprite].yvel << 12, sprite[nSprite].zvel, 2560, -2560, CLIPMASK1); int nMov = movesprite(nSprite, pSprite->xvel << 12, pSprite->yvel << 12, pSprite->zvel, 2560, -2560, CLIPMASK1);
if (!nMov) { if (!nMov) {
return; return;
} }
if (sprite[nSprite].zvel <= 0) { if (pSprite->zvel <= 0) {
return; return;
} }
} }
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
if (sprite[nSprite].picnum > kTile3000) { if (pSprite->picnum > kTile3000) {
nSmokeSparks--; nSmokeSparks--;
} }
runlist_DoSubRunRec(sprite[nSprite].owner); runlist_DoSubRunRec(pSprite->owner);
runlist_FreeRun(sprite[nSprite].lotag - 1); runlist_FreeRun(pSprite->lotag - 1);
runlist_SubRunRec(sprite[nSprite].hitag); runlist_SubRunRec(pSprite->hitag);
mydeletesprite(nSprite); mydeletesprite(nSprite);
} }
@ -1796,7 +1806,9 @@ void KillCreatures()
void ExplodeEnergyBlock(int nSprite) void ExplodeEnergyBlock(int nSprite)
{ {
short nSector = sprite[nSprite].sectnum; auto pSprite = &sprite[nSprite];
short nSector = pSprite->sectnum;
short startwall = sector[nSector].wallptr; short startwall = sector[nSector].wallptr;
short nWalls = sector[nSector].wallnum; short nWalls = sector[nSector].wallnum;
@ -1826,24 +1838,24 @@ void ExplodeEnergyBlock(int nSprite)
sector[nSector].floorshade = 50; sector[nSector].floorshade = 50;
sector[nSector].extra = -1; sector[nSector].extra = -1;
sector[nSector].floorz = sprite[nSprite].z; sector[nSector].floorz = pSprite->z;
sprite[nSprite].z = (sprite[nSprite].z + sector[nSector].floorz) / 2; pSprite->z = (pSprite->z + sector[nSector].floorz) / 2;
BuildSpark(nSprite, 3); BuildSpark(nSprite, 3);
sprite[nSprite].cstat = 0; pSprite->cstat = 0;
sprite[nSprite].xrepeat = 100; pSprite->xrepeat = 100;
PlayFX2(StaticSound[kSound78], nSprite); PlayFX2(StaticSound[kSound78], nSprite);
sprite[nSprite].xrepeat = 0; pSprite->xrepeat = 0;
nEnergyTowers--; nEnergyTowers--;
for (i = 0; i < 20; i++) for (i = 0; i < 20; i++)
{ {
sprite[nSprite].ang = RandomSize(11); pSprite->ang = RandomSize(11);
BuildSpark(nSprite, 1); // shoot out blue orbs BuildSpark(nSprite, 1); // shoot out blue orbs
} }
@ -1949,11 +1961,12 @@ void FuncEnergyBlock(int a, int nDamage, int nRun)
spr->xrepeat -= nDamage; spr->xrepeat -= nDamage;
int nSprite2 = insertsprite(lasthitsect, 0); int nSprite2 = insertsprite(lasthitsect, 0);
auto pSprite2 = &sprite[nSprite2];
sprite[nSprite2].ang = a & 0xFFFF; pSprite2->ang = a & 0xFFFF;
sprite[nSprite2].x = lasthitx; pSprite2->x = lasthitx;
sprite[nSprite2].y = lasthity; pSprite2->y = lasthity;
sprite[nSprite2].z = lasthitz; pSprite2->z = lasthitz;
BuildSpark(nSprite2, 0); // shoot out blue orb when damaged BuildSpark(nSprite2, 0); // shoot out blue orb when damaged
mydeletesprite(nSprite2); mydeletesprite(nSprite2);
@ -2011,12 +2024,13 @@ int BuildObject(int const nSprite, int nOjectType, int nHitag)
} }
int nSprite2 = insertsprite(spr->sectnum, 0); int nSprite2 = insertsprite(spr->sectnum, 0);
auto pSprite2 = &sprite[nSprite2];
ObjectList[nObject].field_10 = nSprite2; ObjectList[nObject].field_10 = nSprite2;
sprite[nSprite2].cstat = 0x8000; pSprite2->cstat = 0x8000;
sprite[nSprite2].x = spr->x; pSprite2->x = spr->x;
sprite[nSprite2].y = spr->y; pSprite2->y = spr->y;
sprite[nSprite2].z = spr->z; pSprite2->z = spr->z;
} }
else else
{ {
@ -2038,13 +2052,14 @@ int BuildObject(int const nSprite, int nOjectType, int nHitag)
// in-game destructable wall mounted screen // in-game destructable wall mounted screen
void ExplodeScreen(short nSprite) void ExplodeScreen(short nSprite)
{ {
sprite[nSprite].z -= GetSpriteHeight(nSprite) / 2; auto pSprite = &sprite[nSprite];
pSprite->z -= GetSpriteHeight(nSprite) / 2;
for (int i = 0; i < 30; i++) { for (int i = 0; i < 30; i++) {
BuildSpark(nSprite, 0); // shoot out blue orbs BuildSpark(nSprite, 0); // shoot out blue orbs
} }
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
PlayFX2(StaticSound[kSound78], nSprite); PlayFX2(StaticSound[kSound78], nSprite);
} }
@ -2053,7 +2068,8 @@ void FuncObject(int a, int b, int nRun)
short nObject = RunData[nRun].nVal; short nObject = RunData[nRun].nVal;
short nSprite = ObjectList[nObject].nSprite; short nSprite = ObjectList[nObject].nSprite;
short nStat = sprite[nSprite].statnum; auto pSprite = &sprite[nSprite];
short nStat = pSprite->statnum;
short bx = ObjectList[nObject].field_8; short bx = ObjectList[nObject].field_8;
int nMessage = a & 0x7F0000; int nMessage = a & 0x7F0000;
@ -2109,7 +2125,7 @@ void FuncObject(int a, int b, int nRun)
case 0xA0000: case 0xA0000:
{ {
if (ObjectList[nObject].nHealth > 0 && sprite[nSprite].cstat & 0x101 if (ObjectList[nObject].nHealth > 0 && pSprite->cstat & 0x101
&& (nStat != kStatExplodeTarget && (nStat != kStatExplodeTarget
|| sprite[nRadialSpr].statnum == 201 || sprite[nRadialSpr].statnum == 201
|| (nRadialBullet != 3 && nRadialBullet > -1) || (nRadialBullet != 3 && nRadialBullet > -1)
@ -2120,28 +2136,28 @@ void FuncObject(int a, int b, int nRun)
return; return;
} }
if (sprite[nSprite].statnum != kStatAnubisDrum) { if (pSprite->statnum != kStatAnubisDrum) {
ObjectList[nObject].nHealth -= nDamage; ObjectList[nObject].nHealth -= nDamage;
} }
if (sprite[nSprite].statnum == kStatExplodeTarget) if (pSprite->statnum == kStatExplodeTarget)
{ {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
} }
else if (sprite[nSprite].statnum != kStatAnubisDrum) else if (pSprite->statnum != kStatAnubisDrum)
{ {
sprite[nSprite].xvel >>= 1; pSprite->xvel >>= 1;
sprite[nSprite].yvel >>= 1; pSprite->yvel >>= 1;
sprite[nSprite].zvel >>= 1; pSprite->zvel >>= 1;
} }
if (ObjectList[nObject].nHealth > 0) { if (ObjectList[nObject].nHealth > 0) {
return; return;
} }
if (sprite[nSprite].statnum == kStatExplodeTarget) if (pSprite->statnum == kStatExplodeTarget)
{ {
ObjectList[nObject].nHealth = -1; ObjectList[nObject].nHealth = -1;
short ax = ObjectList[nObject].field_10; short ax = ObjectList[nObject].field_10;
@ -2152,7 +2168,7 @@ void FuncObject(int a, int b, int nRun)
ObjectList[ax].nHealth = -1; ObjectList[ax].nHealth = -1;
} }
else if (sprite[nSprite].statnum == kStatDestructibleSprite) else if (pSprite->statnum == kStatDestructibleSprite)
{ {
ObjectList[nObject].nHealth = 0; ObjectList[nObject].nHealth = 0;
@ -2169,7 +2185,7 @@ void FuncObject(int a, int b, int nRun)
case 0x20000: case 0x20000:
{ {
if (nStat == 97 || (!(sprite[nSprite].cstat & 0x101))) { if (nStat == 97 || (!(pSprite->cstat & 0x101))) {
return; return;
} }
@ -2185,7 +2201,7 @@ void FuncObject(int a, int b, int nRun)
ObjectList[nObject].field_0 = 0; ObjectList[nObject].field_0 = 0;
} }
sprite[nSprite].picnum = seq_GetSeqPicnum2(bx, ObjectList[nObject].field_0); pSprite->picnum = seq_GetSeqPicnum2(bx, ObjectList[nObject].field_0);
} }
if (ObjectList[nObject].nHealth >= 0) { if (ObjectList[nObject].nHealth >= 0) {
@ -2199,22 +2215,22 @@ void FuncObject(int a, int b, int nRun)
FUNCOBJECT_GOTO: FUNCOBJECT_GOTO:
if (nStat != kStatExplodeTarget) if (nStat != kStatExplodeTarget)
{ {
int nMov = movesprite(nSprite, sprite[nSprite].xvel << 6, sprite[nSprite].yvel << 6, sprite[nSprite].zvel, 0, 0, CLIPMASK0); int nMov = movesprite(nSprite, pSprite->xvel << 6, pSprite->yvel << 6, pSprite->zvel, 0, 0, CLIPMASK0);
if (sprite[nSprite].statnum == kStatExplodeTrigger) { if (pSprite->statnum == kStatExplodeTrigger) {
sprite[nSprite].pal = 1; pSprite->pal = 1;
} }
if (nMov & 0x20000) if (nMov & 0x20000)
{ {
sprite[nSprite].xvel -= sprite[nSprite].xvel >> 3; pSprite->xvel -= pSprite->xvel >> 3;
sprite[nSprite].yvel -= sprite[nSprite].yvel >> 3; pSprite->yvel -= pSprite->yvel >> 3;
} }
if (((nMov & 0xC000) > 0x8000) && ((nMov & 0xC000) == 0xC000)) if (((nMov & 0xC000) > 0x8000) && ((nMov & 0xC000) == 0xC000))
{ {
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
} }
} }
@ -2225,7 +2241,7 @@ FUNCOBJECT_GOTO:
int var_18; int var_18;
// red branch // red branch
if ((nStat == kStatExplodeTarget) || (sprite[nSprite].z < sector[sprite[nSprite].sectnum].floorz)) if ((nStat == kStatExplodeTarget) || (pSprite->z < sector[pSprite->sectnum].floorz))
{ {
var_18 = 36; var_18 = 36;
} }
@ -2234,8 +2250,8 @@ FUNCOBJECT_GOTO:
var_18 = 34; var_18 = 34;
} }
AddFlash(sprite[nSprite].sectnum, sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, 128); AddFlash(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 128);
BuildAnim(-1, var_18, 0, sprite[nSprite].x, sprite[nSprite].y, sector[sprite[nSprite].sectnum].floorz, sprite[nSprite].sectnum, 240, 4); BuildAnim(-1, var_18, 0, pSprite->x, pSprite->y, sector[pSprite->sectnum].floorz, pSprite->sectnum, 240, 4);
// int edi = nSprite | 0x4000; // int edi = nSprite | 0x4000;
@ -2256,7 +2272,7 @@ FUNCOBJECT_GOTO:
if (!(currentLevel->gameflags & LEVEL_EX_MULTI) || nStat != kStatExplodeTrigger) if (!(currentLevel->gameflags & LEVEL_EX_MULTI) || nStat != kStatExplodeTrigger)
{ {
runlist_SubRunRec(sprite[nSprite].owner); runlist_SubRunRec(pSprite->owner);
runlist_SubRunRec(ObjectList[nObject].field_4); runlist_SubRunRec(ObjectList[nObject].field_4);
mydeletesprite(nSprite); mydeletesprite(nSprite);
@ -2267,9 +2283,9 @@ FUNCOBJECT_GOTO:
StartRegenerate(nSprite); StartRegenerate(nSprite);
ObjectList[nObject].nHealth = 120; ObjectList[nObject].nHealth = 120;
sprite[nSprite].x = sprite[ObjectList[nObject].field_10].x; pSprite->x = sprite[ObjectList[nObject].field_10].x;
sprite[nSprite].y = sprite[ObjectList[nObject].field_10].y; pSprite->y = sprite[ObjectList[nObject].field_10].y;
sprite[nSprite].z = sprite[ObjectList[nObject].field_10].z; pSprite->z = sprite[ObjectList[nObject].field_10].z;
mychangespritesect(nSprite, sprite[ObjectList[nObject].field_10].sectnum); mychangespritesect(nSprite, sprite[ObjectList[nObject].field_10].sectnum);
return; return;
@ -2281,10 +2297,11 @@ FUNCOBJECT_GOTO:
void BuildDrip(int nSprite) void BuildDrip(int nSprite)
{ {
auto pSprite = &sprite[nSprite];
auto nDrips = sDrip.Reserve(1); auto nDrips = sDrip.Reserve(1);
sDrip[nDrips].nSprite = nSprite; sDrip[nDrips].nSprite = nSprite;
sDrip[nDrips].field_2 = RandomSize(8) + 90; sDrip[nDrips].field_2 = RandomSize(8) + 90;
sprite[nSprite].cstat = 0x8000u; pSprite->cstat = 0x8000u;
} }
void DoDrips() void DoDrips()
@ -2295,10 +2312,11 @@ void DoDrips()
if (sDrip[i].field_2 <= 0) if (sDrip[i].field_2 <= 0)
{ {
short nSprite = sDrip[i].nSprite; short nSprite = sDrip[i].nSprite;
auto pSprite = &sprite[nSprite];
short nSeqOffset = SeqOffsets[kSeqDrips]; short nSeqOffset = SeqOffsets[kSeqDrips];
if (!(SectFlag[sprite[nSprite].sectnum] & kSectLava)) { if (!(SectFlag[pSprite->sectnum] & kSectLava)) {
nSeqOffset++; nSeqOffset++;
} }
@ -2413,10 +2431,11 @@ int FindTrail(int nVal)
// ok ? // ok ?
void ProcessTrailSprite(int nSprite, int nLotag, int nHitag) void ProcessTrailSprite(int nSprite, int nLotag, int nHitag)
{ {
auto pSprite = &sprite[nSprite];
auto nPoint = sTrailPoint.Reserve(1); auto nPoint = sTrailPoint.Reserve(1);
sTrailPoint[nPoint].x = sprite[nSprite].x; sTrailPoint[nPoint].x = pSprite->x;
sTrailPoint[nPoint].y = sprite[nSprite].y; sTrailPoint[nPoint].y = pSprite->y;
int nTrail = FindTrail(nHitag); int nTrail = FindTrail(nHitag);
@ -2752,7 +2771,8 @@ void PostProcess()
{ {
wall[nWall].pal = 1; wall[nWall].pal = 1;
int nSprite = insertsprite(i, 407); int nSprite = insertsprite(i, 407);
sprite[nSprite].cstat = 0x8000; auto pSprite = &sprite[nSprite];
pSprite->cstat = 0x8000;
} }
nWall++; nWall++;

View file

@ -244,7 +244,8 @@ void InitPlayerInventory(short nPlayer)
short GetPlayerFromSprite(short nSprite) short GetPlayerFromSprite(short nSprite)
{ {
return RunData[sprite[nSprite].owner].nVal; auto pSprite = &sprite[nSprite];
return RunData[pSprite->owner].nVal;
} }
void RestartPlayer(short nPlayer) void RestartPlayer(short nPlayer)
@ -478,9 +479,10 @@ void StartDeathSeq(int nPlayer, int nVal)
FreeRa(nPlayer); FreeRa(nPlayer);
short nSprite = PlayerList[nPlayer].nSprite; short nSprite = PlayerList[nPlayer].nSprite;
auto pSprite = &sprite[nSprite];
PlayerList[nPlayer].nHealth = 0; PlayerList[nPlayer].nHealth = 0;
short nLotag = sector[sprite[nSprite].sectnum].lotag; short nLotag = sector[pSprite->sectnum].lotag;
if (nLotag > 0) { if (nLotag > 0) {
runlist_SignalRun(nLotag - 1, nPlayer | 0x70000); runlist_SignalRun(nLotag - 1, nPlayer | 0x70000);
@ -498,7 +500,7 @@ void StartDeathSeq(int nPlayer, int nVal)
if (nWeapon > kWeaponSword && nWeapon <= kWeaponRing) if (nWeapon > kWeaponSword && nWeapon <= kWeaponRing)
{ {
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
if (SectBelow[nSector] > -1) { if (SectBelow[nSector] > -1) {
nSector = SectBelow[nSector]; nSector = SectBelow[nSector];
} }
@ -506,8 +508,8 @@ void StartDeathSeq(int nPlayer, int nVal)
int nGunSprite = GrabBodyGunSprite(); int nGunSprite = GrabBodyGunSprite();
changespritesect(nGunSprite, nSector); changespritesect(nGunSprite, nSector);
sprite[nGunSprite].x = sprite[nSprite].x; sprite[nGunSprite].x = pSprite->x;
sprite[nGunSprite].y = sprite[nSprite].y; sprite[nGunSprite].y = pSprite->y;
sprite[nGunSprite].z = sector[nSector].floorz - 512; sprite[nGunSprite].z = sector[nSector].floorz - 512;
changespritestat(nGunSprite, nGunLotag[nWeapon] + 900); changespritestat(nGunSprite, nGunLotag[nWeapon] + 900);
@ -526,11 +528,11 @@ void StartDeathSeq(int nPlayer, int nVal)
PlayerList[nPlayer].nInvisible = 0; PlayerList[nPlayer].nInvisible = 0;
dVertPan[nPlayer] = 15; dVertPan[nPlayer] = 15;
sprite[nSprite].cstat &= 0x7FFF; pSprite->cstat &= 0x7FFF;
SetNewWeaponImmediate(nPlayer, -2); SetNewWeaponImmediate(nPlayer, -2);
if (SectDamage[sprite[nSprite].sectnum] <= 0) if (SectDamage[pSprite->sectnum] <= 0)
{ {
nDeathType[nPlayer] = nVal; nDeathType[nPlayer] = nVal;
} }
@ -541,7 +543,7 @@ void StartDeathSeq(int nPlayer, int nVal)
nVal *= 2; nVal *= 2;
if (nVal || !(SectFlag[sprite[nSprite].sectnum] & kSectUnderwater)) if (nVal || !(SectFlag[pSprite->sectnum] & kSectUnderwater))
{ {
PlayerList[nPlayer].nAction = nVal + 17; PlayerList[nPlayer].nAction = nVal + 17;
} }
@ -551,7 +553,7 @@ void StartDeathSeq(int nPlayer, int nVal)
PlayerList[nPlayer].field_2 = 0; PlayerList[nPlayer].field_2 = 0;
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
if (nTotalPlayers == 1) if (nTotalPlayers == 1)
{ {
@ -599,9 +601,10 @@ int AddAmmo(int nPlayer, int nWeapon, int nAmmoAmount)
void SetPlayerMummified(int nPlayer, int bIsMummified) void SetPlayerMummified(int nPlayer, int bIsMummified)
{ {
int nSprite = PlayerList[nPlayer].nSprite; int nSprite = PlayerList[nPlayer].nSprite;
auto pSprite = &sprite[nSprite];
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
PlayerList[nPlayer].bIsMummified = bIsMummified; PlayerList[nPlayer].bIsMummified = bIsMummified;
@ -659,6 +662,7 @@ void FuncPlayer(int a, int nDamage, int nRun)
assert(nPlayer >= 0 && nPlayer < kMaxPlayers); assert(nPlayer >= 0 && nPlayer < kMaxPlayers);
short nPlayerSprite = PlayerList[nPlayer].nSprite; short nPlayerSprite = PlayerList[nPlayer].nSprite;
auto pPlayerSprite = &sprite[nPlayerSprite];
short nDopple = nDoppleSprite[nPlayer]; short nDopple = nDoppleSprite[nPlayer];
@ -733,7 +737,7 @@ void FuncPlayer(int a, int nDamage, int nRun)
return; return;
} }
if (SectFlag[sprite[nPlayerSprite].sectnum] & kSectUnderwater) if (SectFlag[pPlayerSprite->sectnum] & kSectUnderwater)
{ {
if (nAction != 12) if (nAction != 12)
{ {
@ -805,8 +809,8 @@ void FuncPlayer(int a, int nDamage, int nRun)
case 0x20000: case 0x20000:
{ {
sprite[nPlayerSprite].xvel = sPlayerInput[nPlayer].xVel >> 14; pPlayerSprite->xvel = sPlayerInput[nPlayer].xVel >> 14;
sprite[nPlayerSprite].yvel = sPlayerInput[nPlayer].yVel >> 14; pPlayerSprite->yvel = sPlayerInput[nPlayer].yVel >> 14;
if (sPlayerInput[nPlayer].nItem > -1) if (sPlayerInput[nPlayer].nItem > -1)
{ {
@ -816,8 +820,8 @@ void FuncPlayer(int a, int nDamage, int nRun)
int var_EC = PlayerList[nPlayer].field_2; int var_EC = PlayerList[nPlayer].field_2;
sprite[nPlayerSprite].picnum = seq_GetSeqPicnum(PlayerList[nPlayer].nSeq, PlayerSeq[nHeightTemplate[nAction]].a, var_EC); pPlayerSprite->picnum = seq_GetSeqPicnum(PlayerList[nPlayer].nSeq, PlayerSeq[nHeightTemplate[nAction]].a, var_EC);
sprite[nDopple].picnum = sprite[nPlayerSprite].picnum; sprite[nDopple].picnum = pPlayerSprite->picnum;
if (PlayerList[nPlayer].nTorch > 0) if (PlayerList[nPlayer].nTorch > 0)
{ {
@ -831,10 +835,10 @@ void FuncPlayer(int a, int nDamage, int nRun)
if (nPlayer != nLocalPlayer) if (nPlayer != nLocalPlayer)
{ {
nFlashDepth = 5; nFlashDepth = 5;
AddFlash(sprite[nPlayerSprite].sectnum, AddFlash(pPlayerSprite->sectnum,
sprite[nPlayerSprite].x, pPlayerSprite->x,
sprite[nPlayerSprite].y, pPlayerSprite->y,
sprite[nPlayerSprite].z, 0); pPlayerSprite->z, 0);
} }
} }
} }
@ -852,7 +856,7 @@ void FuncPlayer(int a, int nDamage, int nRun)
PlayerList[nPlayer].nInvisible--; PlayerList[nPlayer].nInvisible--;
if (PlayerList[nPlayer].nInvisible == 0) if (PlayerList[nPlayer].nInvisible == 0)
{ {
sprite[nPlayerSprite].cstat &= 0x7FFF; // set visible pPlayerSprite->cstat &= 0x7FFF; // set visible
short nFloorSprite = nPlayerFloorSprite[nPlayerSprite]; short nFloorSprite = nPlayerFloorSprite[nPlayerSprite];
if (nFloorSprite > -1) { if (nFloorSprite > -1) {
@ -892,29 +896,29 @@ void FuncPlayer(int a, int nDamage, int nRun)
UpdatePlayerSpriteAngle(pPlayer); UpdatePlayerSpriteAngle(pPlayer);
} }
// sprite[nPlayerSprite].zvel is modified within Gravity() // pPlayerSprite->zvel is modified within Gravity()
short zVel = sprite[nPlayerSprite].zvel; short zVel = pPlayerSprite->zvel;
Gravity(nPlayerSprite); Gravity(nPlayerSprite);
if (sprite[nPlayerSprite].zvel >= 6500 && zVel < 6500) if (pPlayerSprite->zvel >= 6500 && zVel < 6500)
{ {
D3PlayFX(StaticSound[kSound17], nPlayerSprite); D3PlayFX(StaticSound[kSound17], nPlayerSprite);
} }
// loc_1A4E6 // loc_1A4E6
short nSector = sprite[nPlayerSprite].sectnum; short nSector = pPlayerSprite->sectnum;
short nSectFlag = SectFlag[nPlayerViewSect[nPlayer]]; short nSectFlag = SectFlag[nPlayerViewSect[nPlayer]];
int playerX = sprite[nPlayerSprite].x; int playerX = pPlayerSprite->x;
int playerY = sprite[nPlayerSprite].y; int playerY = pPlayerSprite->y;
int x = (sPlayerInput[nPlayer].xVel * 4) >> 2; int x = (sPlayerInput[nPlayer].xVel * 4) >> 2;
int y = (sPlayerInput[nPlayer].yVel * 4) >> 2; int y = (sPlayerInput[nPlayer].yVel * 4) >> 2;
int z = (sprite[nPlayerSprite].zvel * 4) >> 2; int z = (pPlayerSprite->zvel * 4) >> 2;
if (sprite[nPlayerSprite].zvel > 8192) if (pPlayerSprite->zvel > 8192)
sprite[nPlayerSprite].zvel = 8192; pPlayerSprite->zvel = 8192;
if (PlayerList[nPlayer].bIsMummified) if (PlayerList[nPlayer].bIsMummified)
{ {
@ -922,15 +926,15 @@ void FuncPlayer(int a, int nDamage, int nRun)
y /= 2; y /= 2;
} }
int spr_x = sprite[nPlayerSprite].x; int spr_x = pPlayerSprite->x;
int spr_y = sprite[nPlayerSprite].y; int spr_y = pPlayerSprite->y;
int spr_z = sprite[nPlayerSprite].z; int spr_z = pPlayerSprite->z;
int spr_sectnum = sprite[nPlayerSprite].sectnum; int spr_sectnum = pPlayerSprite->sectnum;
// TODO // TODO
// nSectFlag & kSectUnderwater; // nSectFlag & kSectUnderwater;
zVel = sprite[nPlayerSprite].zvel; zVel = pPlayerSprite->zvel;
int nMove = 0; // TEMP int nMove = 0; // TEMP
@ -938,41 +942,41 @@ void FuncPlayer(int a, int nDamage, int nRun)
{ {
nMove = 0; nMove = 0;
sprite[nPlayerSprite].x += (x >> 14); pPlayerSprite->x += (x >> 14);
sprite[nPlayerSprite].y += (y >> 14); pPlayerSprite->y += (y >> 14);
vec3_t pos = { sprite[nPlayerSprite].x, sprite[nPlayerSprite].y, sprite[nPlayerSprite].z }; vec3_t pos = { pPlayerSprite->x, pPlayerSprite->y, pPlayerSprite->z };
setsprite(nPlayerSprite, &pos); setsprite(nPlayerSprite, &pos);
sprite[nPlayerSprite].z = sector[sprite[nPlayerSprite].sectnum].floorz; pPlayerSprite->z = sector[pPlayerSprite->sectnum].floorz;
} }
else else
{ {
nMove = movesprite(nPlayerSprite, x, y, z, 5120, -5120, CLIPMASK0); nMove = movesprite(nPlayerSprite, x, y, z, 5120, -5120, CLIPMASK0);
short var_54 = sprite[nPlayerSprite].sectnum; short var_54 = pPlayerSprite->sectnum;
pushmove_old(&sprite[nPlayerSprite].x, &sprite[nPlayerSprite].y, &sprite[nPlayerSprite].z, &var_54, sprite[nPlayerSprite].clipdist << 2, 5120, -5120, CLIPMASK0); pushmove_old(&pPlayerSprite->x, &pPlayerSprite->y, &pPlayerSprite->z, &var_54, pPlayerSprite->clipdist << 2, 5120, -5120, CLIPMASK0);
if (var_54 != sprite[nPlayerSprite].sectnum) { if (var_54 != pPlayerSprite->sectnum) {
mychangespritesect(nPlayerSprite, var_54); mychangespritesect(nPlayerSprite, var_54);
} }
} }
// loc_1A6E4 // loc_1A6E4
if (inside(sprite[nPlayerSprite].x, sprite[nPlayerSprite].y, sprite[nPlayerSprite].sectnum) != 1) if (inside(pPlayerSprite->x, pPlayerSprite->y, pPlayerSprite->sectnum) != 1)
{ {
mychangespritesect(nPlayerSprite, spr_sectnum); mychangespritesect(nPlayerSprite, spr_sectnum);
sprite[nPlayerSprite].x = spr_x; pPlayerSprite->x = spr_x;
sprite[nPlayerSprite].y = spr_y; pPlayerSprite->y = spr_y;
if (zVel < sprite[nPlayerSprite].zvel) { if (zVel < pPlayerSprite->zvel) {
sprite[nPlayerSprite].zvel = zVel; pPlayerSprite->zvel = zVel;
} }
} }
// int _bTouchFloor = bTouchFloor; // int _bTouchFloor = bTouchFloor;
short bUnderwater = SectFlag[sprite[nPlayerSprite].sectnum] & kSectUnderwater; short bUnderwater = SectFlag[pPlayerSprite->sectnum] & kSectUnderwater;
if (bUnderwater) if (bUnderwater)
{ {
@ -981,22 +985,22 @@ void FuncPlayer(int a, int nDamage, int nRun)
} }
// Trigger Ramses? // Trigger Ramses?
if ((SectFlag[sprite[nPlayerSprite].sectnum] & 0x8000) && bTouchFloor) if ((SectFlag[pPlayerSprite->sectnum] & 0x8000) && bTouchFloor)
{ {
if (nTotalPlayers <= 1) if (nTotalPlayers <= 1)
{ {
auto ang = GetAngleToSprite(nPlayerSprite, nSpiritSprite) & kAngleMask; auto ang = GetAngleToSprite(nPlayerSprite, nSpiritSprite) & kAngleMask;
PlayerList[nPlayer].angle.settarget(ang, true); PlayerList[nPlayer].angle.settarget(ang, true);
sprite[nPlayerSprite].ang = ang; pPlayerSprite->ang = ang;
PlayerList[nPlayer].horizon.settarget(0, true); PlayerList[nPlayer].horizon.settarget(0, true);
lPlayerXVel = 0; lPlayerXVel = 0;
lPlayerYVel = 0; lPlayerYVel = 0;
sprite[nPlayerSprite].xvel = 0; pPlayerSprite->xvel = 0;
sprite[nPlayerSprite].yvel = 0; pPlayerSprite->yvel = 0;
sprite[nPlayerSprite].zvel = 0; pPlayerSprite->zvel = 0;
if (nFreeze < 1) if (nFreeze < 1)
{ {
@ -1040,18 +1044,18 @@ void FuncPlayer(int a, int nDamage, int nRun)
if (zVel >= 6500) if (zVel >= 6500)
{ {
sprite[nPlayerSprite].xvel >>= 2; pPlayerSprite->xvel >>= 2;
sprite[nPlayerSprite].yvel >>= 2; pPlayerSprite->yvel >>= 2;
runlist_DamageEnemy(nPlayerSprite, -1, ((zVel - 6500) >> 7) + 10); runlist_DamageEnemy(nPlayerSprite, -1, ((zVel - 6500) >> 7) + 10);
if (PlayerList[nPlayer].nHealth <= 0) if (PlayerList[nPlayer].nHealth <= 0)
{ {
sprite[nPlayerSprite].xvel = 0; pPlayerSprite->xvel = 0;
sprite[nPlayerSprite].yvel = 0; pPlayerSprite->yvel = 0;
StopSpriteSound(nPlayerSprite); StopSpriteSound(nPlayerSprite);
PlayFXAtXYZ(StaticSound[kSoundJonFDie], sprite[nPlayerSprite].x, sprite[nPlayerSprite].y, sprite[nPlayerSprite].z, sprite[nPlayerSprite].sectnum, CHANF_NONE, 1); // CHECKME PlayFXAtXYZ(StaticSound[kSoundJonFDie], pPlayerSprite->x, pPlayerSprite->y, pPlayerSprite->z, pPlayerSprite->sectnum, CHANF_NONE, 1); // CHECKME
} }
else else
{ {
@ -1078,7 +1082,7 @@ void FuncPlayer(int a, int nDamage, int nRun)
if ((sector[sectnum].hitag == 45) && bTouchFloor) if ((sector[sectnum].hitag == 45) && bTouchFloor)
{ {
int nNormal = GetWallNormal(nMove & 0x3FFF); int nNormal = GetWallNormal(nMove & 0x3FFF);
int nDiff = AngleDiff(nNormal, (sprite[nPlayerSprite].ang + 1024) & kAngleMask); int nDiff = AngleDiff(nNormal, (pPlayerSprite->ang + 1024) & kAngleMask);
if (nDiff < 0) { if (nDiff < 0) {
nDiff = -nDiff; nDiff = -nDiff;
@ -1105,9 +1109,9 @@ void FuncPlayer(int a, int nDamage, int nRun)
} }
else else
{ {
sprite[nPlayerSprite].x = spr_x; pPlayerSprite->x = spr_x;
sprite[nPlayerSprite].y = spr_y; pPlayerSprite->y = spr_y;
sprite[nPlayerSprite].z = spr_z; pPlayerSprite->z = spr_z;
mychangespritesect(nPlayerSprite, spr_sectnum); mychangespritesect(nPlayerSprite, spr_sectnum);
} }
@ -1134,11 +1138,11 @@ void FuncPlayer(int a, int nDamage, int nRun)
sectdone: sectdone:
if (!PlayerList[nPlayer].bPlayerPan && !PlayerList[nPlayer].bLockPan) if (!PlayerList[nPlayer].bPlayerPan && !PlayerList[nPlayer].bLockPan)
{ {
PlayerList[nPlayer].nDestVertPan = q16horiz(clamp((spr_z - sprite[nPlayerSprite].z) << 9, gi->playerHorizMin(), gi->playerHorizMax())); PlayerList[nPlayer].nDestVertPan = q16horiz(clamp((spr_z - pPlayerSprite->z) << 9, gi->playerHorizMin(), gi->playerHorizMax()));
} }
playerX -= sprite[nPlayerSprite].x; playerX -= pPlayerSprite->x;
playerY -= sprite[nPlayerSprite].y; playerY -= pPlayerSprite->y;
uint32_t sqrtNum = playerX * playerX + playerY * playerY; uint32_t sqrtNum = playerX * playerX + playerY * playerY;
@ -1151,9 +1155,9 @@ sectdone:
ototalvel[nPlayer] = totalvel[nPlayer]; ototalvel[nPlayer] = totalvel[nPlayer];
totalvel[nPlayer] = ksqrt(sqrtNum); totalvel[nPlayer] = ksqrt(sqrtNum);
int nViewSect = sprite[nPlayerSprite].sectnum; int nViewSect = pPlayerSprite->sectnum;
int EyeZ = eyelevel[nPlayer] + sprite[nPlayerSprite].z + nQuake[nPlayer]; int EyeZ = eyelevel[nPlayer] + pPlayerSprite->z + nQuake[nPlayer];
while (1) while (1)
{ {
@ -1171,34 +1175,34 @@ sectdone:
// Do underwater sector check // Do underwater sector check
if (bUnderwater) if (bUnderwater)
{ {
if (nViewSect != sprite[nPlayerSprite].sectnum) if (nViewSect != pPlayerSprite->sectnum)
{ {
if ((nMove & 0xC000) == 0x8000) if ((nMove & 0xC000) == 0x8000)
{ {
int var_C4 = sprite[nPlayerSprite].x; int var_C4 = pPlayerSprite->x;
int var_D4 = sprite[nPlayerSprite].y; int var_D4 = pPlayerSprite->y;
int var_C8 = sprite[nPlayerSprite].z; int var_C8 = pPlayerSprite->z;
mychangespritesect(nPlayerSprite, nViewSect); mychangespritesect(nPlayerSprite, nViewSect);
sprite[nPlayerSprite].x = spr_x; pPlayerSprite->x = spr_x;
sprite[nPlayerSprite].y = spr_y; pPlayerSprite->y = spr_y;
int var_FC = sector[nViewSect].floorz + (-5120); int var_FC = sector[nViewSect].floorz + (-5120);
sprite[nPlayerSprite].z = var_FC; pPlayerSprite->z = var_FC;
if ((movesprite(nPlayerSprite, x, y, 0, 5120, 0, CLIPMASK0) & 0xC000) == 0x8000) if ((movesprite(nPlayerSprite, x, y, 0, 5120, 0, CLIPMASK0) & 0xC000) == 0x8000)
{ {
mychangespritesect(nPlayerSprite, sprite[nPlayerSprite].sectnum); mychangespritesect(nPlayerSprite, pPlayerSprite->sectnum);
sprite[nPlayerSprite].x = var_C4; pPlayerSprite->x = var_C4;
sprite[nPlayerSprite].y = var_D4; pPlayerSprite->y = var_D4;
sprite[nPlayerSprite].z = var_C8; pPlayerSprite->z = var_C8;
} }
else else
{ {
sprite[nPlayerSprite].z = var_FC - 256; pPlayerSprite->z = var_FC - 256;
D3PlayFX(StaticSound[kSound42], nPlayerSprite); D3PlayFX(StaticSound[kSound42], nPlayerSprite);
} }
} }
@ -1208,8 +1212,8 @@ sectdone:
// loc_1ADAF // loc_1ADAF
nPlayerViewSect[nPlayer] = nViewSect; nPlayerViewSect[nPlayer] = nViewSect;
nPlayerDX[nPlayer] = sprite[nPlayerSprite].x - spr_x; nPlayerDX[nPlayer] = pPlayerSprite->x - spr_x;
nPlayerDY[nPlayer] = sprite[nPlayerSprite].y - spr_y; nPlayerDY[nPlayer] = pPlayerSprite->y - spr_y;
int var_5C = SectFlag[nViewSect] & kSectUnderwater; int var_5C = SectFlag[nViewSect] & kSectUnderwater;
@ -1290,9 +1294,9 @@ sectdone:
} }
else else
{ {
int nTmpSectNum = sprite[nPlayerSprite].sectnum; int nTmpSectNum = pPlayerSprite->sectnum;
if (totalvel[nPlayer] > 25 && sprite[nPlayerSprite].z > sector[nTmpSectNum].floorz) if (totalvel[nPlayer] > 25 && pPlayerSprite->z > sector[nTmpSectNum].floorz)
{ {
if (SectDepth[nTmpSectNum] && !SectSpeed[nTmpSectNum] && !SectDamage[nTmpSectNum]) if (SectDepth[nTmpSectNum] && !SectSpeed[nTmpSectNum] && !SectDamage[nTmpSectNum])
{ {
@ -1328,15 +1332,15 @@ sectdone:
{ {
int nFloorSprite = nPlayerFloorSprite[nPlayer]; int nFloorSprite = nPlayerFloorSprite[nPlayer];
sprite[nFloorSprite].x = sprite[nPlayerSprite].x; sprite[nFloorSprite].x = pPlayerSprite->x;
sprite[nFloorSprite].y = sprite[nPlayerSprite].y; sprite[nFloorSprite].y = pPlayerSprite->y;
if (sprite[nFloorSprite].sectnum != sprite[nPlayerSprite].sectnum) if (sprite[nFloorSprite].sectnum != pPlayerSprite->sectnum)
{ {
mychangespritesect(nFloorSprite, sprite[nPlayerSprite].sectnum); mychangespritesect(nFloorSprite, pPlayerSprite->sectnum);
} }
sprite[nFloorSprite].z = sector[sprite[nPlayerSprite].sectnum].floorz; sprite[nFloorSprite].z = sector[pPlayerSprite->sectnum].floorz;
} }
int var_30 = 0; int var_30 = 0;
@ -1358,19 +1362,20 @@ sectdone:
short nValB; short nValB;
// neartag finds the nearest sector, wall, and sprite which has its hitag and/or lotag set to a value. // neartag finds the nearest sector, wall, and sprite which has its hitag and/or lotag set to a value.
neartag(sprite[nPlayerSprite].x, sprite[nPlayerSprite].y, sprite[nPlayerSprite].z, sprite[nPlayerSprite].sectnum, sprite[nPlayerSprite].ang, neartag(pPlayerSprite->x, pPlayerSprite->y, pPlayerSprite->z, pPlayerSprite->sectnum, pPlayerSprite->ang,
&nearTagSector, &nearTagWall, &nearTagSprite, (int32_t*)&nearHitDist, 1024, 2, NULL); &nearTagSector, &nearTagWall, &nearTagSprite, (int32_t*)&nearHitDist, 1024, 2, NULL);
feebtag(sprite[nPlayerSprite].x, sprite[nPlayerSprite].y, sprite[nPlayerSprite].z, sprite[nPlayerSprite].sectnum, feebtag(pPlayerSprite->x, pPlayerSprite->y, pPlayerSprite->z, pPlayerSprite->sectnum,
&nValB, var_30, 768); &nValB, var_30, 768);
auto pSprite = &sprite[nValB];
// Item pickup code // Item pickup code
if (nValB >= 0 && sprite[nValB].statnum >= 900) if (nValB >= 0 && pSprite->statnum >= 900)
{ {
int var_8C = 16; int var_8C = 16;
int var_88 = 9; int var_88 = 9;
int var_70 = sprite[nValB].statnum - 900; int var_70 = pSprite->statnum - 900;
int var_44 = 0; int var_44 = 0;
// item lotags start at 6 (1-5 reserved?) so 0-offset them // item lotags start at 6 (1-5 reserved?) so 0-offset them
@ -1416,7 +1421,7 @@ do_default_b:
} }
case 0: // Speed Loader case 0: // Speed Loader
{ {
if (AddAmmo(nPlayer, 1, sprite[nValB].hitag)) if (AddAmmo(nPlayer, 1, pSprite->hitag))
{ {
var_88 = StaticSound[kSoundAmmoPickup]; var_88 = StaticSound[kSoundAmmoPickup];
goto do_default; goto do_default;
@ -1426,7 +1431,7 @@ do_default_b:
} }
case 1: // Fuel Canister case 1: // Fuel Canister
{ {
if (AddAmmo(nPlayer, 3, sprite[nValB].hitag)) if (AddAmmo(nPlayer, 3, pSprite->hitag))
{ {
var_88 = StaticSound[kSoundAmmoPickup]; var_88 = StaticSound[kSoundAmmoPickup];
goto do_default; goto do_default;
@ -1435,7 +1440,7 @@ do_default_b:
} }
case 2: // M - 60 Ammo Belt case 2: // M - 60 Ammo Belt
{ {
if (AddAmmo(nPlayer, 2, sprite[nValB].hitag)) if (AddAmmo(nPlayer, 2, pSprite->hitag))
{ {
var_88 = StaticSound[kSoundAmmoPickup]; var_88 = StaticSound[kSoundAmmoPickup];
CheckClip(nPlayer); CheckClip(nPlayer);
@ -1458,7 +1463,7 @@ do_default_b:
if (var_70 == 55) if (var_70 == 55)
{ {
sprite[nValB].cstat = 0x8000; pSprite->cstat = 0x8000;
DestroyItemAnim(nValB); DestroyItemAnim(nValB);
// loc_1BA74: - repeated block, see in default case // loc_1BA74: - repeated block, see in default case
@ -1514,7 +1519,7 @@ do_default_b:
case 6: // Berry Twig case 6: // Berry Twig
{ {
if (sprite[nValB].hitag == 0) { if (pSprite->hitag == 0) {
break; break;
} }
@ -1542,8 +1547,8 @@ do_default_b:
if (var_70 == 12) if (var_70 == 12)
{ {
sprite[nValB].hitag = 0; pSprite->hitag = 0;
sprite[nValB].picnum++; pSprite->picnum++;
changespritestat(nValB, 0); changespritestat(nValB, 0);
@ -1611,8 +1616,8 @@ do_default_b:
if (var_70 == 12) if (var_70 == 12)
{ {
sprite[nValB].hitag = 0; pSprite->hitag = 0;
sprite[nValB].picnum++; pSprite->picnum++;
changespritestat(nValB, 0); changespritestat(nValB, 0);
@ -1680,8 +1685,8 @@ do_default_b:
if (var_70 == 12) if (var_70 == 12)
{ {
sprite[nValB].hitag = 0; pSprite->hitag = 0;
sprite[nValB].picnum++; pSprite->picnum++;
changespritestat(nValB, 0); changespritestat(nValB, 0);
@ -1847,7 +1852,7 @@ do_default_b:
goto do_default; goto do_default;
} }
sprite[nValB].cstat = 0x8000; pSprite->cstat = 0x8000;
DestroyItemAnim(nValB); DestroyItemAnim(nValB);
//// ////
// loc_1BA74: - repeated block, see in default case // loc_1BA74: - repeated block, see in default case
@ -1909,7 +1914,7 @@ do_default_b:
goto do_default; goto do_default;
} }
sprite[nValB].cstat = 0x8000; pSprite->cstat = 0x8000;
DestroyItemAnim(nValB); DestroyItemAnim(nValB);
//// ////
// loc_1BA74: - repeated block, see in default case // loc_1BA74: - repeated block, see in default case
@ -1971,7 +1976,7 @@ do_default_b:
goto do_default; goto do_default;
} }
sprite[nValB].cstat = 0x8000; pSprite->cstat = 0x8000;
DestroyItemAnim(nValB); DestroyItemAnim(nValB);
//// ////
// loc_1BA74: - repeated block, see in default case // loc_1BA74: - repeated block, see in default case
@ -2033,7 +2038,7 @@ do_default_b:
goto do_default; goto do_default;
} }
sprite[nValB].cstat = 0x8000; pSprite->cstat = 0x8000;
DestroyItemAnim(nValB); DestroyItemAnim(nValB);
//// ////
// loc_1BA74: - repeated block, see in default case // loc_1BA74: - repeated block, see in default case
@ -2095,7 +2100,7 @@ do_default_b:
goto do_default; goto do_default;
} }
sprite[nValB].cstat = 0x8000; pSprite->cstat = 0x8000;
DestroyItemAnim(nValB); DestroyItemAnim(nValB);
//// ////
// loc_1BA74: - repeated block, see in default case // loc_1BA74: - repeated block, see in default case
@ -2157,7 +2162,7 @@ do_default_b:
goto do_default; goto do_default;
} }
sprite[nValB].cstat = 0x8000; pSprite->cstat = 0x8000;
DestroyItemAnim(nValB); DestroyItemAnim(nValB);
//// ////
// loc_1BA74: - repeated block, see in default case // loc_1BA74: - repeated block, see in default case
@ -2192,7 +2197,7 @@ do_default_b:
case 32: // Raw Energy case 32: // Raw Energy
{ {
if (AddAmmo(nPlayer, 6, sprite[nValB].hitag)) { if (AddAmmo(nPlayer, 6, pSprite->hitag)) {
var_88 = StaticSound[kSoundAmmoPickup]; var_88 = StaticSound[kSoundAmmoPickup];
goto do_default; goto do_default;
} }
@ -2247,7 +2252,7 @@ do_default_b:
{ {
if (nLocalPlayer == nPlayer) if (nLocalPlayer == nPlayer)
{ {
short nAnim = sprite[nValB].owner; short nAnim = pSprite->owner;
AnimList[nAnim].nSeq++; AnimList[nAnim].nSeq++;
AnimList[nAnim].AnimFlags &= 0xEF; AnimList[nAnim].AnimFlags &= 0xEF;
AnimList[nAnim].field_2 = 0; AnimList[nAnim].field_2 = 0;
@ -2255,7 +2260,7 @@ do_default_b:
changespritestat(nValB, 899); changespritestat(nValB, 899);
} }
SetSavePoint(nPlayer, sprite[nPlayerSprite].x, sprite[nPlayerSprite].y, sprite[nPlayerSprite].z, sprite[nPlayerSprite].sectnum, sprite[nPlayerSprite].ang); SetSavePoint(nPlayer, pPlayerSprite->x, pPlayerSprite->y, pPlayerSprite->z, pPlayerSprite->sectnum, pPlayerSprite->ang);
break; break;
} }
@ -2277,22 +2282,22 @@ do_default_b:
// CORRECT ? // loc_1BAF9: // CORRECT ? // loc_1BAF9:
if (bTouchFloor) if (bTouchFloor)
{ {
if (sector[sprite[nPlayerSprite].sectnum].lotag > 0) if (sector[pPlayerSprite->sectnum].lotag > 0)
{ {
runlist_SignalRun(sector[sprite[nPlayerSprite].sectnum].lotag - 1, nPlayer | 0x50000); runlist_SignalRun(sector[pPlayerSprite->sectnum].lotag - 1, nPlayer | 0x50000);
} }
} }
if (nSector != sprite[nPlayerSprite].sectnum) if (nSector != pPlayerSprite->sectnum)
{ {
if (sector[nSector].lotag > 0) if (sector[nSector].lotag > 0)
{ {
runlist_SignalRun(sector[nSector].lotag - 1, nPlayer | 0x70000); runlist_SignalRun(sector[nSector].lotag - 1, nPlayer | 0x70000);
} }
if (sector[sprite[nPlayerSprite].sectnum].lotag > 0) if (sector[pPlayerSprite->sectnum].lotag > 0)
{ {
runlist_SignalRun(sector[sprite[nPlayerSprite].sectnum].lotag - 1, nPlayer | 0x60000); runlist_SignalRun(sector[pPlayerSprite->sectnum].lotag - 1, nPlayer | 0x60000);
} }
} }
@ -2325,8 +2330,8 @@ do_default_b:
// loc_1BC57: // loc_1BC57:
// CHECKME - are we finished with 'nSector' variable at this point? if so, maybe set it to sprite[nPlayerSprite].sectnum so we can make this code a bit neater. Don't assume sprite[nPlayerSprite].sectnum == nSector here!! // CHECKME - are we finished with 'nSector' variable at this point? if so, maybe set it to pPlayerSprite->sectnum so we can make this code a bit neater. Don't assume pPlayerSprite->sectnum == nSector here!!
if (nStandHeight > (sector[sprite[nPlayerSprite].sectnum].floorz - sector[sprite[nPlayerSprite].sectnum].ceilingz)) { if (nStandHeight > (sector[pPlayerSprite->sectnum].floorz - sector[pPlayerSprite->sectnum].ceilingz)) {
var_48 = 1; var_48 = 1;
} }
@ -2335,14 +2340,14 @@ do_default_b:
{ {
if (bUnderwater) if (bUnderwater)
{ {
sprite[nPlayerSprite].zvel = -2048; pPlayerSprite->zvel = -2048;
nActionB = 10; nActionB = 10;
} }
else if (bTouchFloor) else if (bTouchFloor)
{ {
if (nAction < 6 || nAction > 8) if (nAction < 6 || nAction > 8)
{ {
sprite[nPlayerSprite].zvel = -3584; pPlayerSprite->zvel = -3584;
nActionB = 3; nActionB = 3;
} }
} }
@ -2353,7 +2358,7 @@ do_default_b:
{ {
if (bUnderwater) if (bUnderwater)
{ {
sprite[nPlayerSprite].zvel = 2048; pPlayerSprite->zvel = 2048;
nActionB = 10; nActionB = 10;
} }
else else
@ -2522,9 +2527,9 @@ loc_1BD2E:
{ {
if (nAction != 20) if (nAction != 20)
{ {
sprite[nPlayerSprite].picnum = seq_GetSeqPicnum(kSeqJoe, 120, 0); pPlayerSprite->picnum = seq_GetSeqPicnum(kSeqJoe, 120, 0);
sprite[nPlayerSprite].cstat = 0; pPlayerSprite->cstat = 0;
sprite[nPlayerSprite].z = sector[sprite[nPlayerSprite].sectnum].floorz; pPlayerSprite->z = sector[pPlayerSprite->sectnum].floorz;
} }
// will invalidate nPlayerSprite // will invalidate nPlayerSprite
@ -2572,8 +2577,8 @@ loc_1BD2E:
case 16: case 16:
PlayerList[nPlayer].field_2 = SeqSize[var_AC] - 1; PlayerList[nPlayer].field_2 = SeqSize[var_AC] - 1;
if (sprite[nPlayerSprite].z < sector[sprite[nPlayerSprite].sectnum].floorz) { if (pPlayerSprite->z < sector[pPlayerSprite->sectnum].floorz) {
sprite[nPlayerSprite].z += 256; pPlayerSprite->z += 256;
} }
if (!RandomSize(5)) if (!RandomSize(5))
@ -2582,14 +2587,14 @@ loc_1BD2E:
short mouthSect; short mouthSect;
WheresMyMouth(nPlayer, &mouthX, &mouthY, &mouthZ, &mouthSect); WheresMyMouth(nPlayer, &mouthX, &mouthY, &mouthZ, &mouthSect);
BuildAnim(-1, 71, 0, mouthX, mouthY, sprite[nPlayerSprite].z + 3840, mouthSect, 75, 128); BuildAnim(-1, 71, 0, mouthX, mouthY, pPlayerSprite->z + 3840, mouthSect, 75, 128);
} }
break; break;
case 17: case 17:
PlayerList[nPlayer].nAction = 18; PlayerList[nPlayer].nAction = 18;
break; break;
case 19: case 19:
sprite[nPlayerSprite].cstat |= 0x8000; pPlayerSprite->cstat |= 0x8000;
PlayerList[nPlayer].nAction = 20; PlayerList[nPlayer].nAction = 20;
break; break;
} }
@ -2598,11 +2603,11 @@ loc_1BD2E:
// loc_1C3B4: // loc_1C3B4:
if (nPlayer == nLocalPlayer) if (nPlayer == nLocalPlayer)
{ {
initx = sprite[nPlayerSprite].x; initx = pPlayerSprite->x;
inity = sprite[nPlayerSprite].y; inity = pPlayerSprite->y;
initz = sprite[nPlayerSprite].z; initz = pPlayerSprite->z;
initsect = sprite[nPlayerSprite].sectnum; initsect = pPlayerSprite->sectnum;
inita = sprite[nPlayerSprite].ang; inita = pPlayerSprite->ang;
} }
if (!PlayerList[nPlayer].nHealth) if (!PlayerList[nPlayer].nHealth)
@ -2632,7 +2637,7 @@ loc_1BD2E:
} }
else if (PlayerList[nPlayer].horizon.horiz.asq16() <= 0) else if (PlayerList[nPlayer].horizon.horiz.asq16() <= 0)
{ {
if (!(SectFlag[sprite[nPlayerSprite].sectnum] & kSectUnderwater)) if (!(SectFlag[pPlayerSprite->sectnum] & kSectUnderwater))
{ {
SetNewWeapon(nPlayer, nDeathType[nPlayer] + 8); SetNewWeapon(nPlayer, nDeathType[nPlayer] + 8);
} }
@ -2644,14 +2649,14 @@ loc_1BD2E:
} }
// loc_1C4E1 // loc_1C4E1
sprite[nDopple].x = sprite[nPlayerSprite].x; sprite[nDopple].x = pPlayerSprite->x;
sprite[nDopple].y = sprite[nPlayerSprite].y; sprite[nDopple].y = pPlayerSprite->y;
sprite[nDopple].z = sprite[nPlayerSprite].z; sprite[nDopple].z = pPlayerSprite->z;
if (SectAbove[sprite[nPlayerSprite].sectnum] > -1) if (SectAbove[pPlayerSprite->sectnum] > -1)
{ {
sprite[nDopple].ang = sprite[nPlayerSprite].ang; sprite[nDopple].ang = pPlayerSprite->ang;
mychangespritesect(nDopple, SectAbove[sprite[nPlayerSprite].sectnum]); mychangespritesect(nDopple, SectAbove[pPlayerSprite->sectnum]);
sprite[nDopple].cstat = 0x101; sprite[nDopple].cstat = 0x101;
} }
else else

View file

@ -236,10 +236,11 @@ void BlowChunks(int nSprite)
void DestroyEgg(short nEgg) void DestroyEgg(short nEgg)
{ {
short nSprite = QueenEgg[nEgg].nSprite; short nSprite = QueenEgg[nEgg].nSprite;
auto pSprite = &sprite[nSprite];
if (QueenEgg[nEgg].nAction != 4) if (QueenEgg[nEgg].nAction != 4)
{ {
BuildAnim(-1, 34, 0, sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, sprite[nSprite].sectnum, sprite[nSprite].xrepeat, 4); BuildAnim(-1, 34, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, pSprite->xrepeat, 4);
} }
else else
{ {
@ -249,8 +250,8 @@ void DestroyEgg(short nEgg)
} }
} }
runlist_DoSubRunRec(sprite[nSprite].owner); runlist_DoSubRunRec(pSprite->owner);
runlist_DoSubRunRec(sprite[nSprite].lotag - 1); runlist_DoSubRunRec(pSprite->lotag - 1);
runlist_SubRunRec(QueenEgg[nEgg].nRunPtr); runlist_SubRunRec(QueenEgg[nEgg].nRunPtr);
QueenEgg[nEgg].nRunPtr = -1; QueenEgg[nEgg].nRunPtr = -1;
@ -272,10 +273,11 @@ void DestroyAllEggs()
void SetHeadVel(short nSprite) void SetHeadVel(short nSprite)
{ {
short nAngle = sprite[nSprite].ang; auto pSprite = &sprite[nSprite];
short nAngle = pSprite->ang;
sprite[nSprite].xvel = bcos(nAngle, nVelShift); pSprite->xvel = bcos(nAngle, nVelShift);
sprite[nSprite].yvel = bsin(nAngle, nVelShift); pSprite->yvel = bsin(nAngle, nVelShift);
} }
int QueenAngleChase(short nSprite, short nSprite2, int val1, int val2) int QueenAngleChase(short nSprite, short nSprite2, int val1, int val2)
@ -329,7 +331,7 @@ int QueenAngleChase(short nSprite, short nSprite2, int val1, int val2)
nAngDelta = val2; nAngDelta = val2;
} }
nAngle = (nAngDelta + sprite[nSprite].ang) & kAngleMask; nAngle = (nAngDelta + pSprite->ang) & kAngleMask;
pSprite->zvel = (AngleDelta(pSprite->zvel, var_14, 24) + pSprite->zvel) & kAngleMask; pSprite->zvel = (AngleDelta(pSprite->zvel, var_14, 24) + pSprite->zvel) & kAngleMask;
} }
@ -382,39 +384,41 @@ int DestroyTailPart()
void BuildTail() void BuildTail()
{ {
short nSprite = QueenHead.nSprite; short nSprite = QueenHead.nSprite;
auto pSprite = &sprite[nSprite];
int x = sprite[nSprite].x; int x = pSprite->x;
int y = sprite[nSprite].x; int y = pSprite->x;
int z = sprite[nSprite].x; int z = pSprite->x;
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
int i; int i;
for (i = 0; i < kMaxTails; i++) for (i = 0; i < kMaxTails; i++)
{ {
short nTailSprite = insertsprite(nSector, 121); short nTailSprite = insertsprite(nSector, 121);
auto pTailSprite = &sprite[nTailSprite];
tailspr[i] = nTailSprite; tailspr[i] = nTailSprite;
if (nTailSprite < 0) { if (nTailSprite < 0) {
I_Error("Can't create queen's tail!\n"); I_Error("Can't create queen's tail!\n");
} }
sprite[nTailSprite].lotag = runlist_HeadRun() + 1; pTailSprite->lotag = runlist_HeadRun() + 1;
sprite[nTailSprite].owner = runlist_AddRunRec(sprite[nTailSprite].lotag - 1, (i + 1) | 0x1B0000); pTailSprite->owner = runlist_AddRunRec(sprite[nTailSprite].lotag - 1, (i + 1) | 0x1B0000);
sprite[nTailSprite].shade = -12; pTailSprite->shade = -12;
sprite[nTailSprite].x = x; pTailSprite->x = x;
sprite[nTailSprite].y = y; pTailSprite->y = y;
sprite[nTailSprite].hitag = 0; pTailSprite->hitag = 0;
sprite[nTailSprite].cstat = 0; pTailSprite->cstat = 0;
sprite[nTailSprite].clipdist = 100; pTailSprite->clipdist = 100;
sprite[nTailSprite].xrepeat = 80; pTailSprite->xrepeat = 80;
sprite[nTailSprite].yrepeat = 80; pTailSprite->yrepeat = 80;
sprite[nTailSprite].picnum = 1; pTailSprite->picnum = 1;
sprite[nTailSprite].pal = sector[sprite[nTailSprite].sectnum].ceilingpal; pTailSprite->pal = sector[sprite[nTailSprite].sectnum].ceilingpal;
sprite[nTailSprite].xoffset = 0; pTailSprite->xoffset = 0;
sprite[nTailSprite].yoffset = 0; pTailSprite->yoffset = 0;
sprite[nTailSprite].z = z; pTailSprite->z = z;
sprite[nTailSprite].extra = -1; pTailSprite->extra = -1;
} }
for (i = 0; i < 24 + 1; i++) for (i = 0; i < 24 + 1; i++)
@ -438,50 +442,52 @@ int BuildQueenEgg(short nQueen, int nVal)
} }
short nSprite = QueenList[nQueen].nSprite; short nSprite = QueenList[nQueen].nSprite;
auto pSprite = &sprite[nSprite];
int x = sprite[nSprite].x; int x = pSprite->x;
int y = sprite[nSprite].y; int y = pSprite->y;
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
int nFloorZ = sector[nSector].floorz; int nFloorZ = sector[nSector].floorz;
short nAngle = sprite[nSprite].ang; short nAngle = pSprite->ang;
int nSprite2 = insertsprite(nSector, 121); int nSprite2 = insertsprite(nSector, 121);
assert(nSprite2 >= 0 && nSprite2 < kMaxSprites); assert(nSprite2 >= 0 && nSprite2 < kMaxSprites);
auto pSprite2 = &sprite[nSprite2];
sprite[nSprite2].x = x; pSprite2->x = x;
sprite[nSprite2].y = y; pSprite2->y = y;
sprite[nSprite2].z = nFloorZ; pSprite2->z = nFloorZ;
sprite[nSprite2].pal = 0; pSprite2->pal = 0;
sprite[nSprite2].clipdist = 50; pSprite2->clipdist = 50;
sprite[nSprite2].xoffset = 0; pSprite2->xoffset = 0;
sprite[nSprite2].yoffset = 0; pSprite2->yoffset = 0;
sprite[nSprite2].shade = -12; pSprite2->shade = -12;
sprite[nSprite2].picnum = 1; pSprite2->picnum = 1;
sprite[nSprite2].ang = (RandomSize(9) + (nAngle - 256)) & kAngleMask; pSprite2->ang = (RandomSize(9) + (nAngle - 256)) & kAngleMask;
sprite[nSprite2].backuppos(); pSprite2->backuppos();
if (!nVal) if (!nVal)
{ {
sprite[nSprite2].xrepeat = 30; pSprite2->xrepeat = 30;
sprite[nSprite2].yrepeat = 30; pSprite2->yrepeat = 30;
sprite[nSprite2].xvel = bcos(sprite[nSprite2].ang); pSprite2->xvel = bcos(pSprite2->ang);
sprite[nSprite2].yvel = bsin(sprite[nSprite2].ang); pSprite2->yvel = bsin(pSprite2->ang);
sprite[nSprite2].zvel = -6000; pSprite2->zvel = -6000;
sprite[nSprite2].cstat = 0; pSprite2->cstat = 0;
} }
else else
{ {
sprite[nSprite2].xrepeat = 60; pSprite2->xrepeat = 60;
sprite[nSprite2].yrepeat = 60; pSprite2->yrepeat = 60;
sprite[nSprite2].xvel = 0; pSprite2->xvel = 0;
sprite[nSprite2].yvel = 0; pSprite2->yvel = 0;
sprite[nSprite2].zvel = -2000; pSprite2->zvel = -2000;
sprite[nSprite2].cstat = 0x101; pSprite2->cstat = 0x101;
} }
sprite[nSprite2].lotag = runlist_HeadRun() + 1; pSprite2->lotag = runlist_HeadRun() + 1;
sprite[nSprite2].extra = -1; pSprite2->extra = -1;
sprite[nSprite2].hitag = 0; pSprite2->hitag = 0;
GrabTimeSlot(3); GrabTimeSlot(3);
@ -499,7 +505,7 @@ int BuildQueenEgg(short nQueen, int nVal)
QueenEgg[nEgg].nAction = nVal; QueenEgg[nEgg].nAction = nVal;
sprite[nSprite2].owner = runlist_AddRunRec(sprite[nSprite2].lotag - 1, nEgg | 0x1D0000); pSprite2->owner = runlist_AddRunRec(pSprite2->lotag - 1, nEgg | 0x1D0000);
QueenEgg[nEgg].nRunPtr = runlist_AddRunRec(NewRun, nEgg | 0x1D0000); QueenEgg[nEgg].nRunPtr = runlist_AddRunRec(NewRun, nEgg | 0x1D0000);
return 0; return 0;
@ -511,6 +517,7 @@ void FuncQueenEgg(int a, int nDamage, int nRun)
Egg *pEgg = &QueenEgg[nEgg]; Egg *pEgg = &QueenEgg[nEgg];
short nSprite = pEgg->nSprite; short nSprite = pEgg->nSprite;
auto pSprite = &sprite[nSprite];
short nAction = pEgg->nAction; short nAction = pEgg->nAction;
short nTarget; short nTarget;
@ -541,7 +548,7 @@ void FuncQueenEgg(int a, int nDamage, int nRun)
short nSeq = SeqOffsets[kSeqQueenEgg] + EggSeq[nAction].a; short nSeq = SeqOffsets[kSeqQueenEgg] + EggSeq[nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, pEgg->nFrame); pSprite->picnum = seq_GetSeqPicnum2(nSeq, pEgg->nFrame);
if (nAction != 4) if (nAction != 4)
{ {
@ -606,9 +613,9 @@ void FuncQueenEgg(int a, int nDamage, int nRun)
break; break;
} }
sprite[nSprite].ang = nAngle; pSprite->ang = nAngle;
sprite[nSprite].xvel = bcos(nAngle, -1); pSprite->xvel = bcos(nAngle, -1);
sprite[nSprite].yvel = bsin(nAngle, -1); pSprite->yvel = bsin(nAngle, -1);
} }
break; break;
@ -619,7 +626,7 @@ void FuncQueenEgg(int a, int nDamage, int nRun)
if (bVal) if (bVal)
{ {
pEgg->nAction = 3; pEgg->nAction = 3;
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
} }
break; break;
} }
@ -638,11 +645,11 @@ void FuncQueenEgg(int a, int nDamage, int nRun)
} }
fallthrough__; fallthrough__;
case 0x8000: case 0x8000:
sprite[nSprite].ang += (RandomSize(9) + 768); pSprite->ang += (RandomSize(9) + 768);
sprite[nSprite].ang &= kAngleMask; pSprite->ang &= kAngleMask;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -3); pSprite->xvel = bcos(pSprite->ang, -3);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -3); pSprite->yvel = bsin(pSprite->ang, -3);
sprite[nSprite].zvel = -RandomSize(5); pSprite->zvel = -RandomSize(5);
break; break;
} }
@ -655,18 +662,18 @@ void FuncQueenEgg(int a, int nDamage, int nRun)
if (nMov & 0x20000) if (nMov & 0x20000)
{ {
sprite[nSprite].zvel = -(sprite[nSprite].zvel - 256); pSprite->zvel = -(pSprite->zvel - 256);
if (sprite[nSprite].zvel < -512) if (pSprite->zvel < -512)
{ {
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
} }
} }
pEgg->field_C--; pEgg->field_C--;
if (pEgg->field_C <= 0) if (pEgg->field_C <= 0)
{ {
short nWaspSprite = BuildWasp(-2, sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, sprite[nSprite].sectnum, sprite[nSprite].ang); short nWaspSprite = BuildWasp(-2, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, pSprite->ang);
sprite[nSprite].z = sprite[nWaspSprite].z; pSprite->z = sprite[nWaspSprite].z;
DestroyEgg(nEgg); DestroyEgg(nEgg);
} }
@ -678,7 +685,7 @@ void FuncQueenEgg(int a, int nDamage, int nRun)
case 0xA0000: case 0xA0000:
{ {
if (sprite[nRadialSpr].statnum != 121 && (sprite[nSprite].cstat & 0x101) != 0) if (sprite[nRadialSpr].statnum != 121 && (pSprite->cstat & 0x101) != 0)
{ {
nDamage = runlist_CheckRadialDamage(nSprite); nDamage = runlist_CheckRadialDamage(nSprite);
@ -710,37 +717,39 @@ void FuncQueenEgg(int a, int nDamage, int nRun)
int BuildQueenHead(short nQueen) int BuildQueenHead(short nQueen)
{ {
short nSprite = QueenList[nQueen].nSprite; short nSprite = QueenList[nQueen].nSprite;
auto pSprite = &sprite[nSprite];
int x = sprite[nSprite].x; int x = pSprite->x;
int y = sprite[nSprite].y; int y = pSprite->y;
short nAngle = sprite[nSprite].ang; short nAngle = pSprite->ang;
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
int z = sector[nSector].floorz; int z = sector[nSector].floorz;
int nSprite2 = insertsprite(nSector, 121); int nSprite2 = insertsprite(nSector, 121);
assert(nSprite2 >= 0 && nSprite2 < kMaxSprites); assert(nSprite2 >= 0 && nSprite2 < kMaxSprites);
auto pSprite2 = &sprite[nSprite2];
sprite[nSprite2].x = x; pSprite2->x = x;
sprite[nSprite2].y = y; pSprite2->y = y;
sprite[nSprite2].z = z; pSprite2->z = z;
sprite[nSprite2].clipdist = 70; pSprite2->clipdist = 70;
sprite[nSprite2].xrepeat = 80; pSprite2->xrepeat = 80;
sprite[nSprite2].yrepeat = 80; pSprite2->yrepeat = 80;
sprite[nSprite2].cstat = 0; pSprite2->cstat = 0;
sprite[nSprite2].picnum = 1; pSprite2->picnum = 1;
sprite[nSprite2].shade = -12; pSprite2->shade = -12;
sprite[nSprite2].pal = 0; pSprite2->pal = 0;
sprite[nSprite2].xoffset = 0; pSprite2->xoffset = 0;
sprite[nSprite2].yoffset = 0; pSprite2->yoffset = 0;
sprite[nSprite2].ang = nAngle; pSprite2->ang = nAngle;
nVelShift = 2; nVelShift = 2;
SetHeadVel(nSprite2); SetHeadVel(nSprite2);
sprite[nSprite2].zvel = -8192; pSprite2->zvel = -8192;
sprite[nSprite2].lotag = runlist_HeadRun() + 1; pSprite2->lotag = runlist_HeadRun() + 1;
sprite[nSprite2].hitag = 0; pSprite2->hitag = 0;
sprite[nSprite2].extra = -1; pSprite2->extra = -1;
GrabTimeSlot(3); GrabTimeSlot(3);
@ -751,7 +760,7 @@ int BuildQueenHead(short nQueen)
QueenHead.nSprite = nSprite2; QueenHead.nSprite = nSprite2;
QueenHead.field_C = 0; QueenHead.field_C = 0;
sprite[nSprite2].owner = runlist_AddRunRec(sprite[nSprite2].lotag - 1, 0x1B0000); pSprite2->owner = runlist_AddRunRec(pSprite2->lotag - 1, 0x1B0000);
QueenHead.field_8 = runlist_AddRunRec(NewRun, 0x1B0000); QueenHead.field_8 = runlist_AddRunRec(NewRun, 0x1B0000);
QueenHead.tails = 0; QueenHead.tails = 0;
@ -764,7 +773,9 @@ void FuncQueenHead(int a, int nDamage, int nRun)
short nHead = RunData[nRun].nVal; short nHead = RunData[nRun].nVal;
short nSprite = QueenHead.nSprite; short nSprite = QueenHead.nSprite;
int nSector = sprite[nSprite].sectnum; auto pSprite = &sprite[nSprite];
int nSector = pSprite->sectnum;
assert(nSector >= 0 && nSector < kMaxSectors); assert(nSector >= 0 && nSector < kMaxSectors);
short nAction = QueenHead.nAction; short nAction = QueenHead.nAction;
@ -787,7 +798,7 @@ void FuncQueenHead(int a, int nDamage, int nRun)
seq_MoveSequence(nSprite, nSeq, QueenHead.nFrame); seq_MoveSequence(nSprite, nSeq, QueenHead.nFrame);
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, QueenHead.nFrame); pSprite->picnum = seq_GetSeqPicnum2(nSeq, QueenHead.nFrame);
QueenHead.nFrame++; QueenHead.nFrame++;
if (QueenHead.nFrame >= SeqSize[nSeq]) if (QueenHead.nFrame >= SeqSize[nSeq])
@ -824,11 +835,11 @@ void FuncQueenHead(int a, int nDamage, int nRun)
QueenHead.nAction = 6; QueenHead.nAction = 6;
nHeadVel = 800; nHeadVel = 800;
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
} }
else if (QueenHead.field_C < 60) else if (QueenHead.field_C < 60)
{ {
sprite[nSprite].shade--; pSprite->shade--;
} }
} }
else else
@ -836,7 +847,7 @@ void FuncQueenHead(int a, int nDamage, int nRun)
int nMov = MoveCreature(nSprite); int nMov = MoveCreature(nSprite);
// original BUG - this line doesn't exist in original code? // original BUG - this line doesn't exist in original code?
short nNewAng = sprite[nSprite].ang; short nNewAng = pSprite->ang;
switch (nMov & 0xFC000) switch (nMov & 0xFC000)
{ {
@ -849,18 +860,18 @@ void FuncQueenHead(int a, int nDamage, int nRun)
nNewAng = GetWallNormal(nMov & 0x3FFF); nNewAng = GetWallNormal(nMov & 0x3FFF);
break; break;
case 0x20000: case 0x20000:
sprite[nSprite].zvel = -(sprite[nSprite].zvel >> 1); pSprite->zvel = -(pSprite->zvel >> 1);
if (sprite[nSprite].zvel > -256) if (pSprite->zvel > -256)
{ {
nVelShift = 100; nVelShift = 100;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
} }
break; break;
} }
// original BUG - var_18 isn't being set if the check above == 0x20000 ? // original BUG - var_18 isn't being set if the check above == 0x20000 ?
sprite[nSprite].ang = nNewAng; pSprite->ang = nNewAng;
nVelShift++; nVelShift++;
if (nVelShift < 5) if (nVelShift < 5)
@ -869,10 +880,10 @@ void FuncQueenHead(int a, int nDamage, int nRun)
} }
else else
{ {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
if (sprite[nSprite].zvel == 0) if (pSprite->zvel == 0)
{ {
QueenHead.field_C = 120; QueenHead.field_C = 120;
} }
@ -891,14 +902,14 @@ void FuncQueenHead(int a, int nDamage, int nRun)
fallthrough__; fallthrough__;
case 1: case 1:
if ((sprite[nTarget].z - 51200) > sprite[nSprite].z) if ((sprite[nTarget].z - 51200) > pSprite->z)
{ {
QueenHead.nAction = 4; QueenHead.nAction = 4;
QueenHead.nFrame = 0; QueenHead.nFrame = 0;
} }
else else
{ {
sprite[nSprite].z -= 2048; pSprite->z -= 2048;
goto __MOVEQS; goto __MOVEQS;
} }
break; break;
@ -938,10 +949,10 @@ void FuncQueenHead(int a, int nDamage, int nRun)
runlist_DamageEnemy(nTarget, nSprite, 10); runlist_DamageEnemy(nTarget, nSprite, 10);
D3PlayFX(StaticSound[kSoundQTail] | 0x2000, nSprite); D3PlayFX(StaticSound[kSoundQTail] | 0x2000, nSprite);
sprite[nSprite].ang += RandomSize(9) + 768; pSprite->ang += RandomSize(9) + 768;
sprite[nSprite].ang &= kAngleMask; pSprite->ang &= kAngleMask;
sprite[nSprite].zvel = (-20) - RandomSize(6); pSprite->zvel = (-20) - RandomSize(6);
SetHeadVel(nSprite); SetHeadVel(nSprite);
} }
@ -951,12 +962,12 @@ void FuncQueenHead(int a, int nDamage, int nRun)
// switch break. MoveQS stuff? // switch break. MoveQS stuff?
__MOVEQS: __MOVEQS:
MoveQX[nQHead] = sprite[nSprite].x; MoveQX[nQHead] = pSprite->x;
MoveQY[nQHead] = sprite[nSprite].y; MoveQY[nQHead] = pSprite->y;
MoveQZ[nQHead] = sprite[nSprite].z; MoveQZ[nQHead] = pSprite->z;
assert(sprite[nSprite].sectnum >= 0 && sprite[nSprite].sectnum < kMaxSectors); assert(pSprite->sectnum >= 0 && pSprite->sectnum < kMaxSectors);
MoveQS[nQHead] = sprite[nSprite].sectnum; MoveQS[nQHead] = pSprite->sectnum;
MoveQA[nQHead] = sprite[nSprite].ang; MoveQA[nQHead] = pSprite->ang;
nHd = nQHead; nHd = nQHead;
@ -1001,16 +1012,16 @@ __MOVEQS:
{ {
if (QueenHead.tails >= 15 || QueenHead.tails < 10) if (QueenHead.tails >= 15 || QueenHead.tails < 10)
{ {
int x = sprite[nSprite].x; int x = pSprite->x;
int y = sprite[nSprite].y; int y = pSprite->y;
int z = sprite[nSprite].z; int z = pSprite->z;
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
int nAngle = RandomSize(11) & kAngleMask; int nAngle = RandomSize(11) & kAngleMask;
sprite[nSprite].xrepeat = 127 - QueenHead.tails; pSprite->xrepeat = 127 - QueenHead.tails;
sprite[nSprite].yrepeat = 127 - QueenHead.tails; pSprite->yrepeat = 127 - QueenHead.tails;
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
// DEMO-TODO: in disassembly angle was used without masking and thus causing OOB issue. // DEMO-TODO: in disassembly angle was used without masking and thus causing OOB issue.
// This behavior probably would be needed emulated for demo compatibility // This behavior probably would be needed emulated for demo compatibility
@ -1025,9 +1036,9 @@ __MOVEQS:
mychangespritesect(nSprite, nSector); mychangespritesect(nSprite, nSector);
sprite[nSprite].x = x; pSprite->x = x;
sprite[nSprite].y = y; pSprite->y = y;
sprite[nSprite].z = z; pSprite->z = z;
if (QueenHead.tails < 10) { if (QueenHead.tails < 10) {
for (int i = (10 - QueenHead.tails) * 2; i > 0; i--) for (int i = (10 - QueenHead.tails) * 2; i > 0; i--)
@ -1053,7 +1064,7 @@ __MOVEQS:
BuildLavaLimb(nSprite, i, GetSpriteHeight(nSprite)); BuildLavaLimb(nSprite, i, GetSpriteHeight(nSprite));
} }
runlist_SubRunRec(sprite[nSprite].owner); runlist_SubRunRec(pSprite->owner);
runlist_SubRunRec(QueenHead.field_8); runlist_SubRunRec(QueenHead.field_8);
mydeletesprite(nSprite); mydeletesprite(nSprite);
runlist_ChangeChannel(QueenChan[0], 1); runlist_ChangeChannel(QueenChan[0], 1);
@ -1065,7 +1076,7 @@ __MOVEQS:
} }
case 0xA0000: case 0xA0000:
if (sprite[nRadialSpr].statnum != 121 && (sprite[nSprite].cstat & 0x101) != 0) if (sprite[nRadialSpr].statnum != 121 && (pSprite->cstat & 0x101) != 0)
{ {
nDamage = runlist_CheckRadialDamage(nSprite); nDamage = runlist_CheckRadialDamage(nSprite);
if (!nDamage) if (!nDamage)
@ -1101,7 +1112,7 @@ __MOVEQS:
QueenHead.nFrame = 0; QueenHead.nFrame = 0;
QueenHead.field_C = 0; QueenHead.field_C = 0;
QueenHead.tails = 80; QueenHead.tails = 80;
sprite[nSprite].cstat = 0; pSprite->cstat = 0;
} }
} }
} }
@ -1144,41 +1155,44 @@ int BuildQueen(int nSprite, int x, int y, int z, int nSector, int nAngle, int nC
if (nQueen < 0) { if (nQueen < 0) {
return -1; return -1;
} }
auto pSprite = &sprite[nSprite];
if (nSprite == -1) if (nSprite == -1)
{ {
nSprite = insertsprite(nSector, 121); nSprite = insertsprite(nSector, 121);
pSprite = &sprite[nSprite];
} }
else else
{ {
changespritestat(nSprite, 121); changespritestat(nSprite, 121);
x = sprite[nSprite].x; x = pSprite->x;
y = sprite[nSprite].y; y = pSprite->y;
z = sector[sprite[nSprite].sectnum].floorz; z = sector[pSprite->sectnum].floorz;
nAngle = sprite[nSprite].ang; nAngle = pSprite->ang;
} }
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
sprite[nSprite].x = x; pSprite->x = x;
sprite[nSprite].y = y; pSprite->y = y;
sprite[nSprite].z = z; pSprite->z = z;
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
sprite[nSprite].pal = 0; pSprite->pal = 0;
sprite[nSprite].shade = -12; pSprite->shade = -12;
sprite[nSprite].clipdist = 100; pSprite->clipdist = 100;
sprite[nSprite].xrepeat = 80; pSprite->xrepeat = 80;
sprite[nSprite].yrepeat = 80; pSprite->yrepeat = 80;
sprite[nSprite].xoffset = 0; pSprite->xoffset = 0;
sprite[nSprite].yoffset = 0; pSprite->yoffset = 0;
sprite[nSprite].picnum = 1; pSprite->picnum = 1;
sprite[nSprite].ang = nAngle; pSprite->ang = nAngle;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].extra = -1; pSprite->extra = -1;
sprite[nSprite].hitag = 0; pSprite->hitag = 0;
GrabTimeSlot(3); GrabTimeSlot(3);
@ -1195,7 +1209,7 @@ int BuildQueen(int nSprite, int x, int y, int z, int nSector, int nAngle, int nC
nHeadVel = 800; nHeadVel = 800;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nQueen | 0x1A0000); pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nQueen | 0x1A0000);
runlist_AddRunRec(NewRun, nQueen | 0x1A0000); runlist_AddRunRec(NewRun, nQueen | 0x1A0000);
@ -1206,8 +1220,10 @@ int BuildQueen(int nSprite, int x, int y, int z, int nSector, int nAngle, int nC
void SetQueenSpeed(short nSprite, int nSpeed) void SetQueenSpeed(short nSprite, int nSpeed)
{ {
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -(2 - nSpeed)); auto pSprite = &sprite[nSprite];
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -(2 - nSpeed));
pSprite->xvel = bcos(pSprite->ang, -(2 - nSpeed));
pSprite->yvel = bsin(pSprite->ang, -(2 - nSpeed));
} }
void FuncQueen(int a, int nDamage, int nRun) void FuncQueen(int a, int nDamage, int nRun)
@ -1216,6 +1232,7 @@ void FuncQueen(int a, int nDamage, int nRun)
assert(nQueen >= 0 && nQueen < kMaxQueens); assert(nQueen >= 0 && nQueen < kMaxQueens);
short nSprite = QueenList[nQueen].nSprite; short nSprite = QueenList[nQueen].nSprite;
auto pSprite = &sprite[nSprite];
short nAction = QueenList[nQueen].nAction; short nAction = QueenList[nQueen].nAction;
short si = QueenList[nQueen].field_A; short si = QueenList[nQueen].field_A;
short nTarget = QueenList[nQueen].nTarget; short nTarget = QueenList[nQueen].nTarget;
@ -1241,7 +1258,7 @@ void FuncQueen(int a, int nDamage, int nRun)
short nSeq = SeqOffsets[kSeqQueen] + QueenSeq[nAction].a; short nSeq = SeqOffsets[kSeqQueen] + QueenSeq[nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, QueenList[nQueen].nFrame); pSprite->picnum = seq_GetSeqPicnum2(nSeq, QueenList[nQueen].nFrame);
seq_MoveSequence(nSprite, nSeq, QueenList[nQueen].nFrame); seq_MoveSequence(nSprite, nSeq, QueenList[nQueen].nFrame);
@ -1258,7 +1275,7 @@ void FuncQueen(int a, int nDamage, int nRun)
{ {
if (nAction < 7) if (nAction < 7)
{ {
if (!(sprite[nSprite].cstat & 0x101)) if (!(pSprite->cstat & 0x101))
{ {
nTarget = -1; nTarget = -1;
QueenList[nQueen].nTarget = -1; QueenList[nQueen].nTarget = -1;
@ -1312,8 +1329,8 @@ void FuncQueen(int a, int nDamage, int nRun)
if (QueenList[nQueen].field_C <= 0) if (QueenList[nQueen].field_C <= 0)
{ {
QueenList[nQueen].nFrame = 0; QueenList[nQueen].nFrame = 0;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
QueenList[nQueen].nAction = si + 4; QueenList[nQueen].nAction = si + 4;
QueenList[nQueen].field_C = RandomSize(6) + 30; QueenList[nQueen].field_C = RandomSize(6) + 30;
break; break;
@ -1363,8 +1380,8 @@ void FuncQueen(int a, int nDamage, int nRun)
} }
fallthrough__; fallthrough__;
case 0x8000: case 0x8000:
sprite[nSprite].ang += 256; pSprite->ang += 256;
sprite[nSprite].ang &= kAngleMask; pSprite->ang &= kAngleMask;
SetQueenSpeed(nSprite, si); SetQueenSpeed(nSprite, si);
break; break;
@ -1380,8 +1397,8 @@ void FuncQueen(int a, int nDamage, int nRun)
QueenList[nQueen].field_C = 100; QueenList[nQueen].field_C = 100;
QueenList[nQueen].nTarget = -1; QueenList[nQueen].nTarget = -1;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
} }
@ -1406,7 +1423,7 @@ void FuncQueen(int a, int nDamage, int nRun)
if (!si) if (!si)
{ {
BuildBullet(nSprite, 12, 0, 0, -1, sprite[nSprite].ang, nTarget + 10000, 1); BuildBullet(nSprite, 12, 0, 0, -1, pSprite->ang, nTarget + 10000, 1);
} }
else else
{ {
@ -1439,7 +1456,7 @@ void FuncQueen(int a, int nDamage, int nRun)
QueenList[nQueen].field_C--; QueenList[nQueen].field_C--;
if (QueenList[nQueen].field_C <= 0) if (QueenList[nQueen].field_C <= 0)
{ {
sprite[nSprite].cstat = 0; pSprite->cstat = 0;
for (int i = 0; i < 20; i++) for (int i = 0; i < 20; i++)
{ {
@ -1458,10 +1475,10 @@ void FuncQueen(int a, int nDamage, int nRun)
PlayFXAtXYZ( PlayFXAtXYZ(
StaticSound[kSound40], StaticSound[kSound40],
sprite[nSprite].x, pSprite->x,
sprite[nSprite].y, pSprite->y,
sprite[nSprite].z, pSprite->z,
sprite[nSprite].sectnum); pSprite->sectnum);
BuildQueenHead(nQueen); BuildQueenHead(nQueen);
@ -1477,7 +1494,7 @@ void FuncQueen(int a, int nDamage, int nRun)
case 10: case 10:
{ {
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
break; break;
} }
} }
@ -1486,7 +1503,7 @@ void FuncQueen(int a, int nDamage, int nRun)
case 0xA0000: case 0xA0000:
{ {
if (sprite[nRadialSpr].statnum != 121 && (sprite[nSprite].cstat & 0x101) != 0) if (sprite[nRadialSpr].statnum != 121 && (pSprite->cstat & 0x101) != 0)
{ {
nDamage = runlist_CheckRadialDamage(nSprite); nDamage = runlist_CheckRadialDamage(nSprite);
@ -1508,9 +1525,9 @@ void FuncQueen(int a, int nDamage, int nRun)
if (QueenList[nQueen].nHealth <= 0) if (QueenList[nQueen].nHealth <= 0)
{ {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
QueenList[nQueen].field_A++; QueenList[nQueen].field_A++;
@ -1520,7 +1537,7 @@ void FuncQueen(int a, int nDamage, int nRun)
QueenList[nQueen].nHealth = 4000; QueenList[nQueen].nHealth = 4000;
QueenList[nQueen].nAction = 7; QueenList[nQueen].nAction = 7;
BuildAnim(-1, 36, 0, sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z - 7680, sprite[nSprite].sectnum, sprite[nSprite].xrepeat, 4); BuildAnim(-1, 36, 0, pSprite->x, pSprite->y, pSprite->z - 7680, pSprite->sectnum, pSprite->xrepeat, 4);
break; break;
case 2: case 2:
QueenList[nQueen].nHealth = 4000; QueenList[nQueen].nHealth = 4000;

View file

@ -64,10 +64,11 @@ void FreeRa(short nPlayer)
{ {
int nRun = Ra[nPlayer].nRun; int nRun = Ra[nPlayer].nRun;
int nSprite = Ra[nPlayer].nSprite; int nSprite = Ra[nPlayer].nSprite;
auto pSprite = &sprite[nSprite];
runlist_SubRunRec(nRun); runlist_SubRunRec(nRun);
runlist_DoSubRunRec(sprite[nSprite].owner); runlist_DoSubRunRec(pSprite->owner);
runlist_FreeRun(sprite[nSprite].lotag - 1); runlist_FreeRun(pSprite->lotag - 1);
mydeletesprite(nSprite); mydeletesprite(nSprite);
} }
@ -77,21 +78,22 @@ int BuildRa(short nPlayer)
short nPlayerSprite = PlayerList[nPlayer].nSprite; short nPlayerSprite = PlayerList[nPlayer].nSprite;
int nSprite = insertsprite(sprite[nPlayerSprite].sectnum, 203); int nSprite = insertsprite(sprite[nPlayerSprite].sectnum, 203);
auto pSprite = &sprite[nSprite];
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].extra = -1; pSprite->extra = -1;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].hitag = 0; pSprite->hitag = 0;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nPlayer | 0x210000); pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nPlayer | 0x210000);
sprite[nSprite].pal = 1; pSprite->pal = 1;
sprite[nSprite].xrepeat = 64; pSprite->xrepeat = 64;
sprite[nSprite].yrepeat = 64; pSprite->yrepeat = 64;
sprite[nSprite].x = sprite[nPlayerSprite].x; pSprite->x = sprite[nPlayerSprite].x;
sprite[nSprite].y = sprite[nPlayerSprite].y; pSprite->y = sprite[nPlayerSprite].y;
sprite[nSprite].z = sprite[nPlayerSprite].z; pSprite->z = sprite[nPlayerSprite].z;
// GrabTimeSlot(3); // GrabTimeSlot(3);
@ -117,6 +119,7 @@ void MoveRaToEnemy(short nPlayer)
short nTarget = Ra[nPlayer].nTarget; short nTarget = Ra[nPlayer].nTarget;
short nSprite = Ra[nPlayer].nSprite; short nSprite = Ra[nPlayer].nSprite;
short nAction = Ra[nPlayer].nAction; short nAction = Ra[nPlayer].nAction;
auto pSprite = &sprite[nSprite];
if (nTarget != -1) if (nTarget != -1)
{ {
@ -133,7 +136,7 @@ void MoveRaToEnemy(short nPlayer)
} }
else else
{ {
if (sprite[nSprite].sectnum != sprite[nTarget].sectnum) { if (pSprite->sectnum != sprite[nTarget].sectnum) {
mychangespritesect(nSprite, sprite[nTarget].sectnum); mychangespritesect(nSprite, sprite[nTarget].sectnum);
} }
} }
@ -151,15 +154,15 @@ void MoveRaToEnemy(short nPlayer)
return; return;
} }
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
nTarget = PlayerList[nPlayer].nSprite; nTarget = PlayerList[nPlayer].nSprite;
} }
sprite[nSprite].x = sprite[nTarget].x; pSprite->x = sprite[nTarget].x;
sprite[nSprite].y = sprite[nTarget].y; pSprite->y = sprite[nTarget].y;
sprite[nSprite].z = sprite[nTarget].z - GetSpriteHeight(nTarget); pSprite->z = sprite[nTarget].z - GetSpriteHeight(nTarget);
if (sprite[nSprite].sectnum != sprite[nTarget].sectnum) { if (pSprite->sectnum != sprite[nTarget].sectnum) {
mychangespritesect(nSprite, sprite[nTarget].sectnum); mychangespritesect(nSprite, sprite[nTarget].sectnum);
} }
} }
@ -171,6 +174,7 @@ void FuncRa(int a, int, int nRun)
short nSeq = SeqOffsets[kSeqEyeHit] + RaSeq[Ra[nPlayer].nAction].a; short nSeq = SeqOffsets[kSeqEyeHit] + RaSeq[Ra[nPlayer].nAction].a;
short nSprite = Ra[nPlayer].nSprite; short nSprite = Ra[nPlayer].nSprite;
auto pSprite = &sprite[nSprite];
bool bVal = false; bool bVal = false;
@ -191,7 +195,7 @@ void FuncRa(int a, int, int nRun)
case 0x20000: case 0x20000:
{ {
Ra[nPlayer].nTarget = sPlayerInput[nPlayer].nTarget; Ra[nPlayer].nTarget = sPlayerInput[nPlayer].nTarget;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, Ra[nPlayer].nFrame); pSprite->picnum = seq_GetSeqPicnum2(nSeq, Ra[nPlayer].nFrame);
if (Ra[nPlayer].nAction) if (Ra[nPlayer].nAction)
{ {
@ -213,11 +217,11 @@ void FuncRa(int a, int, int nRun)
if (!Ra[nPlayer].field_C || Ra[nPlayer].nTarget <= -1) if (!Ra[nPlayer].field_C || Ra[nPlayer].nTarget <= -1)
{ {
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
} }
else else
{ {
sprite[nSprite].cstat &= 0x7FFF; pSprite->cstat &= 0x7FFF;
Ra[nPlayer].nAction = 1; Ra[nPlayer].nAction = 1;
Ra[nPlayer].nFrame = 0; Ra[nPlayer].nFrame = 0;
} }
@ -288,7 +292,7 @@ void FuncRa(int a, int, int nRun)
{ {
if (bVal) if (bVal)
{ {
sprite[nSprite].cstat |= 0x8000; pSprite->cstat |= 0x8000;
Ra[nPlayer].nAction = 0; Ra[nPlayer].nAction = 0;
Ra[nPlayer].nFrame = 0; Ra[nPlayer].nFrame = 0;
Ra[nPlayer].field_C = 0; Ra[nPlayer].field_C = 0;

View file

@ -101,45 +101,50 @@ void InitRats()
void SetRatVel(short nSprite) void SetRatVel(short nSprite)
{ {
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -2); auto pSprite = &sprite[nSprite];
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -2);
pSprite->xvel = bcos(pSprite->ang, -2);
pSprite->yvel = bsin(pSprite->ang, -2);
} }
int BuildRat(short nSprite, int x, int y, int z, short nSector, int nAngle) int BuildRat(short nSprite, int x, int y, int z, short nSector, int nAngle)
{ {
auto nRat = RatList.Reserve(1); auto nRat = RatList.Reserve(1);
auto pSprite = &sprite[nSprite];
if (nSprite < 0) if (nSprite < 0)
{ {
nSprite = insertsprite(nSector, 108); nSprite = insertsprite(nSector, 108);
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
pSprite = &sprite[nSprite];
sprite[nSprite].x = x; pSprite->x = x;
sprite[nSprite].y = y; pSprite->y = y;
sprite[nSprite].z = z; pSprite->z = z;
} }
else else
{ {
nAngle = sprite[nSprite].ang; nAngle = pSprite->ang;
changespritestat(nSprite, 108); changespritestat(nSprite, 108);
} }
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
sprite[nSprite].shade = -12; pSprite->shade = -12;
sprite[nSprite].xoffset = 0; pSprite->xoffset = 0;
sprite[nSprite].yoffset = 0; pSprite->yoffset = 0;
sprite[nSprite].picnum = 1; pSprite->picnum = 1;
sprite[nSprite].pal = sector[sprite[nSprite].sectnum].ceilingpal; pSprite->pal = sector[pSprite->sectnum].ceilingpal;
sprite[nSprite].clipdist = 30; pSprite->clipdist = 30;
sprite[nSprite].ang = nAngle; pSprite->ang = nAngle;
sprite[nSprite].xrepeat = 50; pSprite->xrepeat = 50;
sprite[nSprite].yrepeat = 50; pSprite->yrepeat = 50;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].hitag = 0; pSprite->hitag = 0;
sprite[nSprite].extra = -1; pSprite->extra = -1;
if (nAngle >= 0) { if (nAngle >= 0) {
RatList[nRat].nAction = 2; RatList[nRat].nAction = 2;
@ -154,7 +159,7 @@ int BuildRat(short nSprite, int x, int y, int z, short nSector, int nAngle)
RatList[nRat].nCount = RandomSize(5); RatList[nRat].nCount = RandomSize(5);
RatList[nRat].nIndex = RandomSize(3); RatList[nRat].nIndex = RandomSize(3);
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nRat | 0x240000); pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nRat | 0x240000);
RatList[nRat].nRun = runlist_AddRunRec(NewRun, nRat | 0x240000); RatList[nRat].nRun = runlist_AddRunRec(NewRun, nRat | 0x240000);
return 0; return 0;
@ -162,10 +167,12 @@ int BuildRat(short nSprite, int x, int y, int z, short nSector, int nAngle)
int FindFood(short nSprite) int FindFood(short nSprite)
{ {
short nSector = sprite[nSprite].sectnum; auto pSprite = &sprite[nSprite];
int x = sprite[nSprite].x;
int y = sprite[nSprite].y; short nSector = pSprite->sectnum;
int z = sprite[nSprite].z; int x = pSprite->x;
int y = pSprite->y;
int z = pSprite->z;
int z2 = (z + sector[nSector].ceilingz) / 2; int z2 = (z + sector[nSector].ceilingz) / 2;
@ -203,6 +210,7 @@ void FuncRat(int a, int nDamage, int nRun)
short nRat = RunData[nRun].nVal; short nRat = RunData[nRun].nVal;
short nSprite = RatList[nRat].nSprite; short nSprite = RatList[nRat].nSprite;
short nAction = RatList[nRat].nAction; short nAction = RatList[nRat].nAction;
auto pSprite = &sprite[nSprite];
bool bVal = false; bool bVal = false;
@ -226,9 +234,9 @@ void FuncRat(int a, int nDamage, int nRun)
{ {
if (nDamage) if (nDamage)
{ {
sprite[nSprite].cstat = 0; pSprite->cstat = 0;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
RatList[nRat].nAction = 3; RatList[nRat].nAction = 3;
RatList[nRat].nFrame = 0; RatList[nRat].nFrame = 0;
} }
@ -244,7 +252,7 @@ void FuncRat(int a, int nDamage, int nRun)
case 0x20000: case 0x20000:
{ {
int nSeq = SeqOffsets[kSeqRat] + RatSeq[nAction].a; int nSeq = SeqOffsets[kSeqRat] + RatSeq[nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, RatList[nRat].nFrame); pSprite->picnum = seq_GetSeqPicnum2(nSeq, RatList[nRat].nFrame);
seq_MoveSequence(nSprite, nSeq, RatList[nRat].nFrame); seq_MoveSequence(nSprite, nSeq, RatList[nRat].nFrame);
@ -271,8 +279,8 @@ void FuncRat(int a, int nDamage, int nRun)
return; return;
} }
int xVal = abs(sprite[nSprite].x - sprite[nTarget].x); int xVal = abs(pSprite->x - sprite[nTarget].x);
int yVal = abs(sprite[nSprite].y - sprite[nTarget].y); int yVal = abs(pSprite->y - sprite[nTarget].y);
if (xVal > 50 || yVal > 50) if (xVal > 50 || yVal > 50)
{ {
@ -280,8 +288,8 @@ void FuncRat(int a, int nDamage, int nRun)
RatList[nRat].nFrame = 0; RatList[nRat].nFrame = 0;
RatList[nRat].nTarget = -1; RatList[nRat].nTarget = -1;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
return; return;
} }
@ -318,14 +326,14 @@ void FuncRat(int a, int nDamage, int nRun)
RatList[nRat].nFrame = 0; RatList[nRat].nFrame = 0;
RatList[nRat].nTarget = -1; RatList[nRat].nTarget = -1;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
MoveCreature(nSprite); MoveCreature(nSprite);
int xVal = abs(sprite[nSprite].x - sprite[nTarget].x); int xVal = abs(pSprite->x - sprite[nTarget].x);
int yVal = abs(sprite[nSprite].y - sprite[nTarget].y); int yVal = abs(pSprite->y - sprite[nTarget].y);
if (xVal >= 50 || yVal >= 50) if (xVal >= 50 || yVal >= 50)
{ {
@ -345,13 +353,13 @@ void FuncRat(int a, int nDamage, int nRun)
RatList[nRat].nFrame = 0; RatList[nRat].nFrame = 0;
RatList[nRat].nIndex = RandomSize(3); RatList[nRat].nIndex = RandomSize(3);
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
return; return;
} }
case 2: case 2:
{ {
if (sprite[nSprite].xvel || sprite[nSprite].yvel || sprite[nSprite].zvel) { if (pSprite->xvel || pSprite->yvel || pSprite->zvel) {
MoveCreature(nSprite); MoveCreature(nSprite);
} }
@ -363,14 +371,14 @@ void FuncRat(int a, int nDamage, int nRun)
if (RatList[nRat].nTarget <= -1) if (RatList[nRat].nTarget <= -1)
{ {
RatList[nRat].nCount = RandomSize(6); RatList[nRat].nCount = RandomSize(6);
if (sprite[nSprite].xvel || sprite[nSprite].yvel) if (pSprite->xvel || pSprite->yvel)
{ {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
return; return;
} }
sprite[nSprite].ang = RandomSize(11); pSprite->ang = RandomSize(11);
SetRatVel(nSprite); SetRatVel(nSprite);
return; return;
} }
@ -391,11 +399,11 @@ void FuncRat(int a, int nDamage, int nRun)
{ {
if (bVal) if (bVal)
{ {
runlist_DoSubRunRec(sprite[nSprite].owner); runlist_DoSubRunRec(pSprite->owner);
runlist_FreeRun(sprite[nSprite].lotag - 1); runlist_FreeRun(pSprite->lotag - 1);
runlist_SubRunRec(RatList[nRat].nRun); runlist_SubRunRec(RatList[nRat].nRun);
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
mydeletesprite(nSprite); mydeletesprite(nSprite);
} }
return; return;

View file

@ -80,41 +80,43 @@ void InitRexs()
int BuildRex(short nSprite, int x, int y, int z, short nSector, short nAngle, int nChannel) int BuildRex(short nSprite, int x, int y, int z, short nSector, short nAngle, int nChannel)
{ {
int nRex = RexList.Reserve(1); int nRex = RexList.Reserve(1);
auto pSprite = &sprite[nSprite];
if (nSprite == -1) if (nSprite == -1)
{ {
nSprite = insertsprite(nSector, 119); nSprite = insertsprite(nSector, 119);
pSprite = &sprite[nSprite];
} }
else else
{ {
changespritestat(nSprite, 119); changespritestat(nSprite, 119);
x = sprite[nSprite].x; x = pSprite->x;
y = sprite[nSprite].y; y = pSprite->y;
z = sector[sprite[nSprite].sectnum].floorz; z = sector[pSprite->sectnum].floorz;
nAngle = sprite[nSprite].ang; nAngle = pSprite->ang;
} }
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
sprite[nSprite].x = x; pSprite->x = x;
sprite[nSprite].y = y; pSprite->y = y;
sprite[nSprite].z = z; pSprite->z = z;
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
sprite[nSprite].clipdist = 80; pSprite->clipdist = 80;
sprite[nSprite].shade = -12; pSprite->shade = -12;
sprite[nSprite].xrepeat = 64; pSprite->xrepeat = 64;
sprite[nSprite].yrepeat = 64; pSprite->yrepeat = 64;
sprite[nSprite].picnum = 1; pSprite->picnum = 1;
sprite[nSprite].pal = sector[sprite[nSprite].sectnum].ceilingpal; pSprite->pal = sector[pSprite->sectnum].ceilingpal;
sprite[nSprite].xoffset = 0; pSprite->xoffset = 0;
sprite[nSprite].yoffset = 0; pSprite->yoffset = 0;
sprite[nSprite].ang = nAngle; pSprite->ang = nAngle;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].extra = -1; pSprite->extra = -1;
sprite[nSprite].hitag = 0; pSprite->hitag = 0;
GrabTimeSlot(3); GrabTimeSlot(3);
@ -127,7 +129,7 @@ int BuildRex(short nSprite, int x, int y, int z, short nSector, short nAngle, in
RexList[nRex].nChannel = nChannel; RexList[nRex].nChannel = nChannel;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nRex | 0x180000); pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nRex | 0x180000);
// this isn't stored anywhere. // this isn't stored anywhere.
runlist_AddRunRec(NewRun, nRex | 0x180000); runlist_AddRunRec(NewRun, nRex | 0x180000);
@ -144,6 +146,7 @@ void FuncRex(int a, int nDamage, int nRun)
short nAction = RexList[nRex].nAction; short nAction = RexList[nRex].nAction;
short nSprite = RexList[nRex].nSprite; short nSprite = RexList[nRex].nSprite;
auto pSprite = &sprite[nSprite];
bool bVal = false; bool bVal = false;
@ -183,10 +186,10 @@ void FuncRex(int a, int nDamage, int nRun)
if (RexList[nRex].nHealth <= 0) if (RexList[nRex].nHealth <= 0)
{ {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
RexList[nRex].nHealth = 0; RexList[nRex].nHealth = 0;
@ -215,7 +218,7 @@ void FuncRex(int a, int nDamage, int nRun)
int nSeq = SeqOffsets[kSeqRex] + RexSeq[nAction].a; int nSeq = SeqOffsets[kSeqRex] + RexSeq[nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, RexList[nRex].nFrame); pSprite->picnum = seq_GetSeqPicnum2(nSeq, RexList[nRex].nFrame);
int ecx = 2; int ecx = 2;
@ -253,9 +256,9 @@ void FuncRex(int a, int nDamage, int nRun)
{ {
if (nTarget < 0) if (nTarget < 0)
{ {
short nAngle = sprite[nSprite].ang; // make backup of this variable short nAngle = pSprite->ang; // make backup of this variable
RexList[nRex].nTarget = FindPlayer(nSprite, 60); RexList[nRex].nTarget = FindPlayer(nSprite, 60);
sprite[nSprite].ang = nAngle; pSprite->ang = nAngle;
} }
else else
{ {
@ -271,8 +274,8 @@ void FuncRex(int a, int nDamage, int nRun)
RexList[nRex].nAction = 1; RexList[nRex].nAction = 1;
RexList[nRex].nFrame = 0; RexList[nRex].nFrame = 0;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -2); pSprite->xvel = bcos(pSprite->ang, -2);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -2); pSprite->yvel = bsin(pSprite->ang, -2);
D3PlayFX(StaticSound[kSound48], nSprite); D3PlayFX(StaticSound[kSound48], nSprite);
@ -296,17 +299,17 @@ void FuncRex(int a, int nDamage, int nRun)
{ {
RexList[nRex].nAction = 5; RexList[nRex].nAction = 5;
RexList[nRex].nFrame = 0; RexList[nRex].nFrame = 0;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
return; return;
} }
else else
{ {
if (((PlotCourseToSprite(nSprite, nTarget) >> 8) >= 60) || RexList[nRex].nCount > 0) if (((PlotCourseToSprite(nSprite, nTarget) >> 8) >= 60) || RexList[nRex].nCount > 0)
{ {
int nAngle = sprite[nSprite].ang & 0xFFF8; int nAngle = pSprite->ang & 0xFFF8;
sprite[nSprite].xvel = bcos(nAngle, -2); pSprite->xvel = bcos(nAngle, -2);
sprite[nSprite].yvel = bsin(nAngle, -2); pSprite->yvel = bsin(nAngle, -2);
} }
else else
{ {
@ -336,9 +339,9 @@ void FuncRex(int a, int nDamage, int nRun)
} }
case 0x8000: case 0x8000:
{ {
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask; pSprite->ang = (pSprite->ang + 256) & kAngleMask;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -2); pSprite->xvel = bcos(pSprite->ang, -2);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -2); pSprite->yvel = bsin(pSprite->ang, -2);
RexList[nRex].nAction = 1; RexList[nRex].nAction = 1;
RexList[nRex].nFrame = 0; RexList[nRex].nFrame = 0;
nAction = 1; nAction = 1;
@ -356,8 +359,8 @@ void FuncRex(int a, int nDamage, int nRun)
{ {
PlotCourseToSprite(nSprite, nTarget); PlotCourseToSprite(nSprite, nTarget);
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1); pSprite->xvel = bcos(pSprite->ang, -1);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1); pSprite->yvel = bsin(pSprite->ang, -1);
int nMov = MoveCreatureWithCaution(nSprite); int nMov = MoveCreatureWithCaution(nSprite);
@ -368,9 +371,9 @@ void FuncRex(int a, int nDamage, int nRun)
SetQuake(nSprite, 25); SetQuake(nSprite, 25);
RexList[nRex].nCount = 60; RexList[nRex].nCount = 60;
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask; pSprite->ang = (pSprite->ang + 256) & kAngleMask;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -2); pSprite->xvel = bcos(pSprite->ang, -2);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -2); pSprite->yvel = bsin(pSprite->ang, -2);
RexList[nRex].nAction = 1; RexList[nRex].nAction = 1;
RexList[nRex].nFrame = 0; RexList[nRex].nFrame = 0;
nAction = 1; nAction = 1;
@ -385,7 +388,7 @@ void FuncRex(int a, int nDamage, int nRun)
if (sprite[nSprite2].statnum && sprite[nSprite2].statnum < 107) if (sprite[nSprite2].statnum && sprite[nSprite2].statnum < 107)
{ {
short nAngle = sprite[nSprite].ang; short nAngle = pSprite->ang;
runlist_DamageEnemy(nSprite2, nSprite, 15); runlist_DamageEnemy(nSprite2, nSprite, 15);
@ -473,7 +476,7 @@ void FuncRex(int a, int nDamage, int nRun)
case 7: case 7:
{ {
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
return; return;
} }
} }
@ -487,8 +490,8 @@ void FuncRex(int a, int nDamage, int nRun)
RexList[nRex].nFrame = 0; RexList[nRex].nFrame = 0;
RexList[nRex].nCount = 0; RexList[nRex].nCount = 0;
RexList[nRex].nTarget = -1; RexList[nRex].nTarget = -1;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
} }
return; return;

View file

@ -84,40 +84,42 @@ int BuildRoach(int nType, int nSprite, int x, int y, int z, short nSector, int a
{ {
auto RoachCount = RoachList.Reserve(1); auto RoachCount = RoachList.Reserve(1);
auto pSprite = &sprite[nSprite];
if (nSprite == -1) if (nSprite == -1)
{ {
nSprite = insertsprite(nSector, 105); nSprite = insertsprite(nSector, 105);
pSprite = &sprite[nSprite];
} }
else else
{ {
changespritestat(nSprite, 105); changespritestat(nSprite, 105);
x = sprite[nSprite].x; x = pSprite->x;
y = sprite[nSprite].y; y = pSprite->y;
z = sector[sprite[nSprite].sectnum].floorz; z = sector[pSprite->sectnum].floorz;
angle = sprite[nSprite].ang; angle = pSprite->ang;
} }
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
sprite[nSprite].x = x; pSprite->x = x;
sprite[nSprite].y = y; pSprite->y = y;
sprite[nSprite].z = z; pSprite->z = z;
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
sprite[nSprite].shade = -12; pSprite->shade = -12;
sprite[nSprite].xoffset = 0; pSprite->xoffset = 0;
sprite[nSprite].yoffset = 0; pSprite->yoffset = 0;
sprite[nSprite].picnum = 1; pSprite->picnum = 1;
sprite[nSprite].pal = sector[sprite[nSprite].sectnum].ceilingpal; pSprite->pal = sector[pSprite->sectnum].ceilingpal;
sprite[nSprite].clipdist = 60; pSprite->clipdist = 60;
sprite[nSprite].ang = angle; pSprite->ang = angle;
sprite[nSprite].xrepeat = 40; pSprite->xrepeat = 40;
sprite[nSprite].yrepeat = 40; pSprite->yrepeat = 40;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].hitag = 0; pSprite->hitag = 0;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].extra = -1; pSprite->extra = -1;
// GrabTimeSlot(3); // GrabTimeSlot(3);
@ -136,7 +138,7 @@ int BuildRoach(int nType, int nSprite, int x, int y, int z, short nSector, int a
RoachList[RoachCount].nTarget = -1; RoachList[RoachCount].nTarget = -1;
RoachList[RoachCount].nHealth = 600; RoachList[RoachCount].nHealth = 600;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, RoachCount | 0x1C0000); pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, RoachCount | 0x1C0000);
RoachList[RoachCount].nRun = runlist_AddRunRec(NewRun, RoachCount | 0x1C0000); RoachList[RoachCount].nRun = runlist_AddRunRec(NewRun, RoachCount | 0x1C0000);
nCreaturesTotal++; nCreaturesTotal++;
@ -146,8 +148,9 @@ int BuildRoach(int nType, int nSprite, int x, int y, int z, short nSector, int a
void GoRoach(short nSprite) void GoRoach(short nSprite)
{ {
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1) - bcos(sprite[nSprite].ang, -3); auto pSprite = &sprite[nSprite];
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1) - bsin(sprite[nSprite].ang, -3); pSprite->xvel = bcos(pSprite->ang, -1) - bcos(pSprite->ang, -3);
pSprite->yvel = bsin(pSprite->ang, -1) - bsin(pSprite->ang, -3);
} }
void FuncRoach(int a, int nDamage, int nRun) void FuncRoach(int a, int nDamage, int nRun)
@ -156,6 +159,7 @@ void FuncRoach(int a, int nDamage, int nRun)
assert(nRoach >= 0 && nRoach < (int)RoachList.Size()); assert(nRoach >= 0 && nRoach < (int)RoachList.Size());
short nSprite = RoachList[nRoach].nSprite; short nSprite = RoachList[nRoach].nSprite;
auto pSprite = &sprite[nSprite];
short nAction = RoachList[nRoach].nAction; short nAction = RoachList[nRoach].nAction;
bool bVal = false; bool bVal = false;
@ -192,10 +196,10 @@ void FuncRoach(int a, int nDamage, int nRun)
RoachList[nRoach].nHealth -= dmgAdjust(nDamage); RoachList[nRoach].nHealth -= dmgAdjust(nDamage);
if (RoachList[nRoach].nHealth <= 0) if (RoachList[nRoach].nHealth <= 0)
{ {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
RoachList[nRoach].nHealth = 0; RoachList[nRoach].nHealth = 0;
@ -244,7 +248,7 @@ void FuncRoach(int a, int nDamage, int nRun)
int nSeq = SeqOffsets[kSeqRoach] + RoachSeq[RoachList[nRoach].nAction].a; int nSeq = SeqOffsets[kSeqRoach] + RoachSeq[RoachList[nRoach].nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, RoachList[nRoach].nFrame); pSprite->picnum = seq_GetSeqPicnum2(nSeq, RoachList[nRoach].nFrame);
seq_MoveSequence(nSprite, nSeq, RoachList[nRoach].nFrame); seq_MoveSequence(nSprite, nSeq, RoachList[nRoach].nFrame);
RoachList[nRoach].nFrame++; RoachList[nRoach].nFrame++;
@ -329,21 +333,21 @@ void FuncRoach(int a, int nDamage, int nRun)
RoachList[nRoach].nIndex = RandomSize(2) + 1; RoachList[nRoach].nIndex = RandomSize(2) + 1;
RoachList[nRoach].nAction = 3; RoachList[nRoach].nAction = 3;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].ang = GetMyAngle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y); pSprite->ang = GetMyAngle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
RoachList[nRoach].nFrame = 0; RoachList[nRoach].nFrame = 0;
} }
else else
{ {
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask; pSprite->ang = (pSprite->ang + 256) & kAngleMask;
GoRoach(nSprite); GoRoach(nSprite);
} }
} }
else if ((nMov & 0xC000) == 0x8000) else if ((nMov & 0xC000) == 0x8000)
{ {
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask; pSprite->ang = (pSprite->ang + 256) & kAngleMask;
GoRoach(nSprite); GoRoach(nSprite);
} }
else else
@ -358,9 +362,9 @@ void FuncRoach(int a, int nDamage, int nRun)
RoachList[nRoach].nIndex = RandomSize(2) + 1; RoachList[nRoach].nIndex = RandomSize(2) + 1;
RoachList[nRoach].nAction = 3; RoachList[nRoach].nAction = 3;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].ang = GetMyAngle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y); pSprite->ang = GetMyAngle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
RoachList[nRoach].nFrame = 0; RoachList[nRoach].nFrame = 0;
} }
@ -372,8 +376,8 @@ void FuncRoach(int a, int nDamage, int nRun)
RoachList[nRoach].nFrame = 0; RoachList[nRoach].nFrame = 0;
RoachList[nRoach].nCount = 100; RoachList[nRoach].nCount = 100;
RoachList[nRoach].nTarget = -1; RoachList[nRoach].nTarget = -1;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
return; return;
@ -396,7 +400,7 @@ void FuncRoach(int a, int nDamage, int nRun)
{ {
if (nFlag & 0x80) if (nFlag & 0x80)
{ {
BuildBullet(nSprite, 13, 0, 0, -1, sprite[nSprite].ang, nTarget + 10000, 1); BuildBullet(nSprite, 13, 0, 0, -1, pSprite->ang, nTarget + 10000, 1);
} }
} }
@ -418,7 +422,7 @@ void FuncRoach(int a, int nDamage, int nRun)
{ {
if (bVal) if (bVal)
{ {
sprite[nSprite].cstat = 0; pSprite->cstat = 0;
RoachList[nRoach].nAction = 6; RoachList[nRoach].nAction = 6;
RoachList[nRoach].nFrame = 0; RoachList[nRoach].nFrame = 0;
} }

View file

@ -1531,25 +1531,27 @@ void runlist_ProcessWallTag(int nWall, short nLotag, short nHitag)
int runlist_CheckRadialDamage(short nSprite) int runlist_CheckRadialDamage(short nSprite)
{ {
auto pSprite = &sprite[nSprite];
if (nSprite == nRadialSpr) { if (nSprite == nRadialSpr) {
return 0; return 0;
} }
if (!(sprite[nSprite].cstat & 0x101)) { if (!(pSprite->cstat & 0x101)) {
return 0; return 0;
} }
if (sprite[nSprite].statnum >= kMaxStatus || sprite[nRadialSpr].statnum >= kMaxStatus) { if (pSprite->statnum >= kMaxStatus || sprite[nRadialSpr].statnum >= kMaxStatus) {
return 0; return 0;
} }
if (sprite[nSprite].statnum != 100 && nSprite == nRadialOwner) { if (pSprite->statnum != 100 && nSprite == nRadialOwner) {
return 0; return 0;
} }
int x = (sprite[nSprite].x - sprite[nRadialSpr].x) >> 8; int x = (pSprite->x - sprite[nRadialSpr].x) >> 8;
int y = (sprite[nSprite].y - sprite[nRadialSpr].y) >> 8; int y = (pSprite->y - sprite[nRadialSpr].y) >> 8;
int z = (sprite[nSprite].z - sprite[nRadialSpr].z) >> 12; int z = (pSprite->z - sprite[nRadialSpr].z) >> 12;
if (abs(x) > nDamageRadius) { if (abs(x) > nDamageRadius) {
return 0; return 0;
@ -1580,18 +1582,18 @@ int runlist_CheckRadialDamage(short nSprite)
if (nDist < nDamageRadius) if (nDist < nDamageRadius)
{ {
uint16_t nCStat = sprite[nSprite].cstat; uint16_t nCStat = pSprite->cstat;
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
if (((kStatExplodeTarget - sprite[nSprite].statnum) <= 1) || if (((kStatExplodeTarget - pSprite->statnum) <= 1) ||
cansee(sprite[nRadialSpr].x, cansee(sprite[nRadialSpr].x,
sprite[nRadialSpr].y, sprite[nRadialSpr].y,
sprite[nRadialSpr].z - 512, sprite[nRadialSpr].z - 512,
sprite[nRadialSpr].sectnum, sprite[nRadialSpr].sectnum,
sprite[nSprite].x, pSprite->x,
sprite[nSprite].y, pSprite->y,
sprite[nSprite].z - 8192, pSprite->z - 8192,
sprite[nSprite].sectnum)) pSprite->sectnum))
{ {
edi = (nRadialDamage * (nDamageRadius - nDist)) / nDamageRadius; edi = (nRadialDamage * (nDamageRadius - nDist)) / nDamageRadius;
@ -1602,17 +1604,17 @@ int runlist_CheckRadialDamage(short nSprite)
{ {
int nAngle = GetMyAngle(x, y); int nAngle = GetMyAngle(x, y);
sprite[nSprite].xvel += (edi * bcos(nAngle)) >> 3; pSprite->xvel += (edi * bcos(nAngle)) >> 3;
sprite[nSprite].yvel += (edi * bsin(nAngle)) >> 3; pSprite->yvel += (edi * bsin(nAngle)) >> 3;
sprite[nSprite].zvel -= edi * 24; pSprite->zvel -= edi * 24;
if (sprite[nSprite].zvel < -3584) { if (pSprite->zvel < -3584) {
sprite[nSprite].zvel = -3584; pSprite->zvel = -3584;
} }
} }
} }
sprite[nSprite].cstat = nCStat; pSprite->cstat = nCStat;
} }
if (edi > 0x7FFF) { if (edi > 0x7FFF) {
@ -1624,6 +1626,8 @@ int runlist_CheckRadialDamage(short nSprite)
void runlist_RadialDamageEnemy(short nSprite, short nDamage, short nRadius) void runlist_RadialDamageEnemy(short nSprite, short nDamage, short nRadius)
{ {
auto pSprite = &sprite[nSprite];
if (!nRadius) { if (!nRadius) {
return; return;
} }
@ -1633,7 +1637,7 @@ void runlist_RadialDamageEnemy(short nSprite, short nDamage, short nRadius)
nRadialDamage = nDamage * 4; nRadialDamage = nDamage * 4;
nDamageRadius = nRadius; nDamageRadius = nRadius;
nRadialSpr = nSprite; nRadialSpr = nSprite;
nRadialOwner = sprite[nSprite].owner; nRadialOwner = pSprite->owner;
runlist_ExplodeSignalRun(); runlist_ExplodeSignalRun();
@ -1643,11 +1647,13 @@ void runlist_RadialDamageEnemy(short nSprite, short nDamage, short nRadius)
void runlist_DamageEnemy(int nSprite, int nSprite2, short nDamage) void runlist_DamageEnemy(int nSprite, int nSprite2, short nDamage)
{ {
if (sprite[nSprite].statnum >= kMaxStatus) { auto pSprite = &sprite[nSprite];
if (pSprite->statnum >= kMaxStatus) {
return; return;
} }
short nRun = sprite[nSprite].owner; short nRun = pSprite->owner;
if (nRun <= -1) { if (nRun <= -1) {
return; return;
} }

View file

@ -91,41 +91,44 @@ int BuildScorp(short nSprite, int x, int y, int z, short nSector, short nAngle,
{ {
auto nScorp = scorpion.Reserve(1); auto nScorp = scorpion.Reserve(1);
auto pSprite = &sprite[nSprite];
if (nSprite == -1) if (nSprite == -1)
{ {
nSprite = insertsprite(nSector, 122); nSprite = insertsprite(nSector, 122);
pSprite = &sprite[nSprite];
} }
else else
{ {
changespritestat(nSprite, 122); changespritestat(nSprite, 122);
x = sprite[nSprite].x; x = pSprite->x;
y = sprite[nSprite].y; y = pSprite->y;
z = sector[sprite[nSprite].sectnum].floorz; z = sector[pSprite->sectnum].floorz;
nAngle = sprite[nSprite].ang; nAngle = pSprite->ang;
} }
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
sprite[nSprite].x = x; pSprite->x = x;
sprite[nSprite].y = y; pSprite->y = y;
sprite[nSprite].z = z; pSprite->z = z;
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
sprite[nSprite].clipdist = 70; pSprite->clipdist = 70;
sprite[nSprite].shade = -12; pSprite->shade = -12;
sprite[nSprite].xrepeat = 80; pSprite->xrepeat = 80;
sprite[nSprite].yrepeat = 80; pSprite->yrepeat = 80;
sprite[nSprite].picnum = 1; pSprite->picnum = 1;
sprite[nSprite].pal = sector[sprite[nSprite].sectnum].ceilingpal; pSprite->pal = sector[pSprite->sectnum].ceilingpal;
sprite[nSprite].xoffset = 0; pSprite->xoffset = 0;
sprite[nSprite].yoffset = 0; pSprite->yoffset = 0;
sprite[nSprite].ang = nAngle; pSprite->ang = nAngle;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].extra = -1; pSprite->extra = -1;
sprite[nSprite].hitag = 0; pSprite->hitag = 0;
// GrabTimeSlot(3); // GrabTimeSlot(3);
@ -139,7 +142,7 @@ int BuildScorp(short nSprite, int x, int y, int z, short nSector, short nAngle,
scorpion[nScorp].nChannel = nChannel; scorpion[nScorp].nChannel = nChannel;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nScorp | 0x220000); pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nScorp | 0x220000);
scorpion[nScorp].nRun = runlist_AddRunRec(NewRun, nScorp | 0x220000); scorpion[nScorp].nRun = runlist_AddRunRec(NewRun, nScorp | 0x220000);
nCreaturesTotal++; nCreaturesTotal++;
@ -154,6 +157,7 @@ void FuncScorp(int a, int nDamage, int nRun)
short nSprite = scorpion[nScorp].nSprite; short nSprite = scorpion[nScorp].nSprite;
short nAction = scorpion[nScorp].nAction; short nAction = scorpion[nScorp].nAction;
auto pSprite = &sprite[nSprite];
bool bVal = false; bool bVal = false;
@ -200,10 +204,10 @@ void FuncScorp(int a, int nDamage, int nRun)
scorpion[nScorp].nFrame = 0; scorpion[nScorp].nFrame = 0;
scorpion[nScorp].nCount = 10; scorpion[nScorp].nCount = 10;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
nCreaturesKilled++; nCreaturesKilled++;
return; return;
@ -214,7 +218,7 @@ void FuncScorp(int a, int nDamage, int nRun)
if (nTarget >= 0) if (nTarget >= 0)
{ {
if (sprite[nSprite].statnum == 100 || (sprite[nSprite].statnum < 199 && !RandomSize(5))) if (pSprite->statnum == 100 || (pSprite->statnum < 199 && !RandomSize(5)))
{ {
scorpion[nScorp].nTarget = nTarget; scorpion[nScorp].nTarget = nTarget;
} }
@ -245,7 +249,7 @@ void FuncScorp(int a, int nDamage, int nRun)
int nSeq = SeqOffsets[kSeqScorp] + ScorpSeq[nAction].a; int nSeq = SeqOffsets[kSeqScorp] + ScorpSeq[nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, scorpion[nScorp].nFrame); pSprite->picnum = seq_GetSeqPicnum2(nSeq, scorpion[nScorp].nFrame);
seq_MoveSequence(nSprite, nSeq, scorpion[nScorp].nFrame); seq_MoveSequence(nSprite, nSeq, scorpion[nScorp].nFrame);
scorpion[nScorp].nFrame++; scorpion[nScorp].nFrame++;
@ -283,8 +287,8 @@ void FuncScorp(int a, int nDamage, int nRun)
D3PlayFX(StaticSound[kSound41], nSprite); D3PlayFX(StaticSound[kSound41], nSprite);
scorpion[nScorp].nFrame = 0; scorpion[nScorp].nFrame = 0;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang); pSprite->xvel = bcos(pSprite->ang);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang); pSprite->yvel = bsin(pSprite->ang);
scorpion[nScorp].nAction = 1; scorpion[nScorp].nAction = 1;
scorpion[nScorp].nTarget = nTarget; scorpion[nScorp].nTarget = nTarget;
@ -312,8 +316,8 @@ void FuncScorp(int a, int nDamage, int nRun)
{ {
if (nTarget == (nMov & 0x3FFF)) if (nTarget == (nMov & 0x3FFF))
{ {
int nAngle = getangle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y); int nAngle = getangle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
if (AngleDiff(sprite[nSprite].ang, nAngle) < 64) if (AngleDiff(pSprite->ang, nAngle) < 64)
{ {
scorpion[nScorp].nAction = 2; scorpion[nScorp].nAction = 2;
scorpion[nScorp].nFrame = 0; scorpion[nScorp].nFrame = 0;
@ -368,8 +372,8 @@ void FuncScorp(int a, int nDamage, int nRun)
{ {
scorpion[nScorp].nAction = 1; scorpion[nScorp].nAction = 1;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang); pSprite->xvel = bcos(pSprite->ang);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang); pSprite->yvel = bsin(pSprite->ang);
scorpion[nScorp].nFrame = 0; scorpion[nScorp].nFrame = 0;
return; return;
@ -380,7 +384,7 @@ void FuncScorp(int a, int nDamage, int nRun)
return; return;
} }
short nBulletSprite = BuildBullet(nSprite, 16, 0, 0, -1, sprite[nSprite].ang, nTarget + 10000, 1) & 0xFFFF; short nBulletSprite = BuildBullet(nSprite, 16, 0, 0, -1, pSprite->ang, nTarget + 10000, 1) & 0xFFFF;
if (nBulletSprite > -1) if (nBulletSprite > -1)
{ {
PlotCourseToSprite(nBulletSprite, nTarget); PlotCourseToSprite(nBulletSprite, nTarget);
@ -430,7 +434,7 @@ void FuncScorp(int a, int nDamage, int nRun)
return; return;
} }
int nSpider = BuildSpider(-1, sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, sprite[nSprite].sectnum, sprite[nSprite].ang); int nSpider = BuildSpider(-1, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, pSprite->ang);
if (nSpider != -1) if (nSpider != -1)
{ {
short nSpiderSprite = nSpider & 0xFFFF; short nSpiderSprite = nSpider & 0xFFFF;
@ -449,13 +453,13 @@ void FuncScorp(int a, int nDamage, int nRun)
case 9: case 9:
{ {
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
if (bVal) if (bVal)
{ {
runlist_SubRunRec(scorpion[nScorp].nRun); runlist_SubRunRec(scorpion[nScorp].nRun);
runlist_DoSubRunRec(sprite[nSprite].owner); runlist_DoSubRunRec(pSprite->owner);
runlist_FreeRun(sprite[nSprite].lotag - 1); runlist_FreeRun(pSprite->lotag - 1);
mydeletesprite(nSprite); mydeletesprite(nSprite);
} }
@ -470,11 +474,11 @@ void FuncScorp(int a, int nDamage, int nRun)
FS_Pink_A: FS_Pink_A:
PlotCourseToSprite(nSprite, nTarget); PlotCourseToSprite(nSprite, nTarget);
sprite[nSprite].ang += RandomSize(7) - 63; pSprite->ang += RandomSize(7) - 63;
sprite[nSprite].ang &= kAngleMask; pSprite->ang &= kAngleMask;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang); pSprite->xvel = bcos(pSprite->ang);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang); pSprite->yvel = bsin(pSprite->ang);
FS_Pink_B: FS_Pink_B:
if (scorpion[nScorp].nCount) if (scorpion[nScorp].nCount)
@ -485,12 +489,12 @@ FS_Pink_B:
{ {
scorpion[nScorp].nCount = 45; scorpion[nScorp].nCount = 45;
if (cansee(sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z - GetSpriteHeight(nSprite), sprite[nSprite].sectnum, if (cansee(pSprite->x, pSprite->y, pSprite->z - GetSpriteHeight(nSprite), pSprite->sectnum,
sprite[nTarget].x, sprite[nTarget].y, sprite[nTarget].z - GetSpriteHeight(nTarget), sprite[nTarget].sectnum)) sprite[nTarget].x, sprite[nTarget].y, sprite[nTarget].z - GetSpriteHeight(nTarget), sprite[nTarget].sectnum))
{ {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].ang = GetMyAngle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y); pSprite->ang = GetMyAngle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
scorpion[nScorp].nIndex = RandomSize(2) + RandomSize(3); scorpion[nScorp].nIndex = RandomSize(2) + RandomSize(3);
@ -517,8 +521,8 @@ FS_Red:
scorpion[nScorp].nCount = 30; scorpion[nScorp].nCount = 30;
scorpion[nScorp].nTarget = -1; scorpion[nScorp].nTarget = -1;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
} }
END_PS_NS END_PS_NS

View file

@ -89,40 +89,42 @@ void InitSets()
int BuildSet(short nSprite, int x, int y, int z, short nSector, short nAngle, int nChannel) int BuildSet(short nSprite, int x, int y, int z, short nSector, short nAngle, int nChannel)
{ {
auto nSet = SetList.Reserve(1); auto nSet = SetList.Reserve(1);
auto pSprite = &sprite[nSprite];
if (nSprite == -1) if (nSprite == -1)
{ {
nSprite = insertsprite(nSector, 120); nSprite = insertsprite(nSector, 120);
pSprite = &sprite[nSprite];
} }
else else
{ {
changespritestat(nSprite, 120); changespritestat(nSprite, 120);
x = sprite[nSprite].x; x = pSprite->x;
y = sprite[nSprite].y; y = pSprite->y;
z = sector[sprite[nSprite].sectnum].floorz; z = sector[pSprite->sectnum].floorz;
nAngle = sprite[nSprite].ang; nAngle = pSprite->ang;
} }
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
sprite[nSprite].x = x; pSprite->x = x;
sprite[nSprite].y = y; pSprite->y = y;
sprite[nSprite].z = z; pSprite->z = z;
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
sprite[nSprite].shade = -12; pSprite->shade = -12;
sprite[nSprite].clipdist = 110; pSprite->clipdist = 110;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].xrepeat = 87; pSprite->xrepeat = 87;
sprite[nSprite].yrepeat = 96; pSprite->yrepeat = 96;
sprite[nSprite].pal = sector[sprite[nSprite].sectnum].ceilingpal; pSprite->pal = sector[pSprite->sectnum].ceilingpal;
sprite[nSprite].xoffset = 0; pSprite->xoffset = 0;
sprite[nSprite].yoffset = 0; pSprite->yoffset = 0;
sprite[nSprite].ang = nAngle; pSprite->ang = nAngle;
sprite[nSprite].picnum = 1; pSprite->picnum = 1;
sprite[nSprite].hitag = 0; pSprite->hitag = 0;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].extra = -1; pSprite->extra = -1;
// GrabTimeSlot(3); // GrabTimeSlot(3);
@ -137,7 +139,7 @@ int BuildSet(short nSprite, int x, int y, int z, short nSector, short nAngle, in
SetList[nSet].nChannel = nChannel; SetList[nSet].nChannel = nChannel;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nSet | 0x190000); pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nSet | 0x190000);
// this isn't stored anywhere. // this isn't stored anywhere.
runlist_AddRunRec(NewRun, nSet | 0x190000); runlist_AddRunRec(NewRun, nSet | 0x190000);
@ -151,35 +153,36 @@ int BuildSoul(int nSet)
{ {
int nSetSprite = SetList[nSet].nSprite; int nSetSprite = SetList[nSet].nSprite;
int nSprite = insertsprite(sprite[nSetSprite].sectnum, 0); int nSprite = insertsprite(sprite[nSetSprite].sectnum, 0);
auto pSprite = &sprite[nSprite];
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
sprite[nSprite].cstat = 0x8000; pSprite->cstat = 0x8000;
sprite[nSprite].shade = -127; pSprite->shade = -127;
sprite[nSprite].xrepeat = 1; pSprite->xrepeat = 1;
sprite[nSprite].yrepeat = 1; pSprite->yrepeat = 1;
sprite[nSprite].pal = 0; pSprite->pal = 0;
sprite[nSprite].clipdist = 5; pSprite->clipdist = 5;
sprite[nSprite].xoffset = 0; pSprite->xoffset = 0;
sprite[nSprite].yoffset = 0; pSprite->yoffset = 0;
sprite[nSprite].picnum = seq_GetSeqPicnum(kSeqSet, 75, 0); pSprite->picnum = seq_GetSeqPicnum(kSeqSet, 75, 0);
sprite[nSprite].ang = RandomSize(11); pSprite->ang = RandomSize(11);
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = (-256) - RandomSize(10); pSprite->zvel = (-256) - RandomSize(10);
sprite[nSprite].x = sprite[nSetSprite].x; pSprite->x = sprite[nSetSprite].x;
sprite[nSprite].y = sprite[nSetSprite].y; pSprite->y = sprite[nSetSprite].y;
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
sprite[nSprite].z = (RandomSize(8) << 8) + 8192 + sector[nSector].ceilingz - GetSpriteHeight(nSprite); pSprite->z = (RandomSize(8) << 8) + 8192 + sector[nSector].ceilingz - GetSpriteHeight(nSprite);
sprite[nSprite].hitag = nSet; pSprite->hitag = nSet;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].extra = 0; pSprite->extra = 0;
// GrabTimeSlot(3); // GrabTimeSlot(3);
sprite[nSprite].owner = runlist_AddRunRec(NewRun, nSprite | 0x230000); pSprite->owner = runlist_AddRunRec(NewRun, nSprite | 0x230000);
return nSprite | 0x230000; return nSprite | 0x230000;
} }
@ -187,6 +190,7 @@ int BuildSoul(int nSet)
void FuncSoul(int a, int, int nRun) void FuncSoul(int a, int, int nRun)
{ {
short nSprite = RunData[nRun].nVal; short nSprite = RunData[nRun].nVal;
auto pSprite = &sprite[nSprite];
int nMessage = a & kMessageMask; int nMessage = a & kMessageMask;
@ -196,28 +200,28 @@ void FuncSoul(int a, int, int nRun)
{ {
seq_MoveSequence(nSprite, SeqOffsets[kSeqSet] + 75, 0); seq_MoveSequence(nSprite, SeqOffsets[kSeqSet] + 75, 0);
if (sprite[nSprite].xrepeat < 32) if (pSprite->xrepeat < 32)
{ {
sprite[nSprite].xrepeat++; pSprite->xrepeat++;
sprite[nSprite].yrepeat++; pSprite->yrepeat++;
} }
sprite[nSprite].extra += (nSprite & 0x0F) + 5; pSprite->extra += (nSprite & 0x0F) + 5;
sprite[nSprite].extra &= kAngleMask; pSprite->extra &= kAngleMask;
int nVel = bcos(sprite[nSprite].extra, -7); int nVel = bcos(pSprite->extra, -7);
if (movesprite(nSprite, bcos(sprite[nSprite].ang) * nVel, bsin(sprite[nSprite].ang) * nVel, sprite[nSprite].zvel, 5120, 0, CLIPMASK0) & 0x10000) if (movesprite(nSprite, bcos(pSprite->ang) * nVel, bsin(pSprite->ang) * nVel, pSprite->zvel, 5120, 0, CLIPMASK0) & 0x10000)
{ {
int nSet = sprite[nSprite].hitag; int nSet = pSprite->hitag;
int nSetSprite = SetList[nSet].nSprite; int nSetSprite = SetList[nSet].nSprite;
sprite[nSprite].cstat = 0; pSprite->cstat = 0;
sprite[nSprite].yrepeat = 1; pSprite->yrepeat = 1;
sprite[nSprite].xrepeat = 1; pSprite->xrepeat = 1;
sprite[nSprite].x = sprite[nSetSprite].x; pSprite->x = sprite[nSetSprite].x;
sprite[nSprite].y = sprite[nSetSprite].y; pSprite->y = sprite[nSetSprite].y;
sprite[nSprite].z = sprite[nSetSprite].z - (GetSpriteHeight(nSetSprite) >> 1); pSprite->z = sprite[nSetSprite].z - (GetSpriteHeight(nSetSprite) >> 1);
mychangespritesect(nSprite, sprite[nSetSprite].sectnum); mychangespritesect(nSprite, sprite[nSetSprite].sectnum);
return; return;
} }
@ -240,6 +244,7 @@ void FuncSet(int a, int nDamage, int nRun)
short nSprite = SetList[nSet].nSprite; short nSprite = SetList[nSet].nSprite;
short nAction = SetList[nSet].nAction; short nAction = SetList[nSet].nAction;
auto pSprite = &sprite[nSprite];
bool bVal = false; bool bVal = false;
@ -274,10 +279,10 @@ void FuncSet(int a, int nDamage, int nRun)
if (SetList[nSet].nHealth <= 0) if (SetList[nSet].nHealth <= 0)
{ {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
SetList[nSet].nHealth = 0; SetList[nSet].nHealth = 0;
@ -309,7 +314,7 @@ void FuncSet(int a, int nDamage, int nRun)
Gravity(nSprite); Gravity(nSprite);
short nSeq = SeqOffsets[kSeqSet] + SetSeq[SetList[nSet].nAction].a; short nSeq = SeqOffsets[kSeqSet] + SetSeq[SetList[nSet].nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, SetList[nSet].nFrame); pSprite->picnum = seq_GetSeqPicnum2(nSeq, SetList[nSet].nFrame);
seq_MoveSequence(nSprite, nSeq, SetList[nSet].nFrame); seq_MoveSequence(nSprite, nSeq, SetList[nSet].nFrame);
if (nAction == 3) if (nAction == 3)
@ -342,9 +347,9 @@ void FuncSet(int a, int nDamage, int nRun)
int nMov = MoveCreature(nSprite); int nMov = MoveCreature(nSprite);
pushmove_old(&sprite[nSprite].x, &sprite[nSprite].y, &sprite[nSprite].z, &sprite[nSprite].sectnum, sprite[nSprite].clipdist << 2, 5120, -5120, CLIPMASK0); pushmove_old(&pSprite->x, &pSprite->y, &pSprite->z, &pSprite->sectnum, pSprite->clipdist << 2, 5120, -5120, CLIPMASK0);
if (sprite[nSprite].zvel > 4000) if (pSprite->zvel > 4000)
{ {
if (nMov & 0x20000) if (nMov & 0x20000)
{ {
@ -372,8 +377,8 @@ void FuncSet(int a, int nDamage, int nRun)
SetList[nSet].nFrame = 0; SetList[nSet].nFrame = 0;
SetList[nSet].nTarget = nTarget; SetList[nSet].nTarget = nTarget;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1); pSprite->xvel = bcos(pSprite->ang, -1);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1); pSprite->yvel = bsin(pSprite->ang, -1);
} }
} }
@ -403,8 +408,8 @@ void FuncSet(int a, int nDamage, int nRun)
SetList[nSet].nIndex = 0; SetList[nSet].nIndex = 0;
SetList[nSet].nFrame = 0; SetList[nSet].nFrame = 0;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
SetList[nSet].nTarget = FindPlayer(nSprite, 1000); SetList[nSet].nTarget = FindPlayer(nSprite, 1000);
} }
@ -434,8 +439,8 @@ void FuncSet(int a, int nDamage, int nRun)
SetList[nSet].nIndex = 0; SetList[nSet].nIndex = 0;
SetList[nSet].nAction = 7; SetList[nSet].nAction = 7;
SetList[nSet].nFrame = 0; SetList[nSet].nFrame = 0;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
return; return;
} }
case 1: case 1:
@ -445,8 +450,8 @@ void FuncSet(int a, int nDamage, int nRun)
SetList[nSet].nAction = 6; SetList[nSet].nAction = 6;
SetList[nSet].nFrame = 0; SetList[nSet].nFrame = 0;
SetList[nSet].nRun = 5; SetList[nSet].nRun = 5;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
return; return;
} }
default: default:
@ -465,14 +470,14 @@ void FuncSet(int a, int nDamage, int nRun)
} }
// loc_338E2 // loc_338E2
int nAngle = sprite[nSprite].ang & 0xFFF8; int nAngle = pSprite->ang & 0xFFF8;
sprite[nSprite].xvel = bcos(nAngle, -1); pSprite->xvel = bcos(nAngle, -1);
sprite[nSprite].yvel = bsin(nAngle, -1); pSprite->yvel = bsin(nAngle, -1);
if (SetList[nSet].nIndex2) if (SetList[nSet].nIndex2)
{ {
sprite[nSprite].xvel *= 2; pSprite->xvel *= 2;
sprite[nSprite].yvel *= 2; pSprite->yvel *= 2;
} }
if ((nMov & 0xC000) == 0x8000) if ((nMov & 0xC000) == 0x8000)
@ -482,31 +487,31 @@ void FuncSet(int a, int nDamage, int nRun)
if (nSector >= 0) if (nSector >= 0)
{ {
if ((sprite[nSprite].z - sector[nSector].floorz) < 55000) if ((pSprite->z - sector[nSector].floorz) < 55000)
{ {
if (sprite[nSprite].z > sector[nSector].ceilingz) if (pSprite->z > sector[nSector].ceilingz)
{ {
SetList[nSet].nIndex = 1; SetList[nSet].nIndex = 1;
SetList[nSet].nAction = 7; SetList[nSet].nAction = 7;
SetList[nSet].nFrame = 0; SetList[nSet].nFrame = 0;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
return; return;
} }
} }
} }
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask; pSprite->ang = (pSprite->ang + 256) & kAngleMask;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1); pSprite->xvel = bcos(pSprite->ang, -1);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1); pSprite->yvel = bsin(pSprite->ang, -1);
break; break;
} }
else if ((nMov & 0xC000) == 0xC000) else if ((nMov & 0xC000) == 0xC000)
{ {
if (nTarget == (nMov & 0x3FFF)) if (nTarget == (nMov & 0x3FFF))
{ {
int nAng = getangle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y); int nAng = getangle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
if (AngleDiff(sprite[nSprite].ang, nAng) < 64) if (AngleDiff(pSprite->ang, nAng) < 64)
{ {
SetList[nSet].nAction = 4; SetList[nSet].nAction = 4;
SetList[nSet].nFrame = 0; SetList[nSet].nFrame = 0;
@ -518,8 +523,8 @@ void FuncSet(int a, int nDamage, int nRun)
SetList[nSet].nIndex = 1; SetList[nSet].nIndex = 1;
SetList[nSet].nAction = 7; SetList[nSet].nAction = 7;
SetList[nSet].nFrame = 0; SetList[nSet].nFrame = 0;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
return; return;
} }
} }
@ -571,7 +576,7 @@ void FuncSet(int a, int nDamage, int nRun)
if (nFlag & 0x80) if (nFlag & 0x80)
{ {
// low 16 bits of returned var contains the sprite index, the high 16 the bullet number // low 16 bits of returned var contains the sprite index, the high 16 the bullet number
int nBullet = BuildBullet(nSprite, 11, 0, 0, -1, sprite[nSprite].ang, nTarget + 10000, 1); int nBullet = BuildBullet(nSprite, 11, 0, 0, -1, pSprite->ang, nTarget + 10000, 1);
SetBulletEnemy(FixedToInt(nBullet), nTarget); // isolate the bullet number (shift off the sprite index) SetBulletEnemy(FixedToInt(nBullet), nTarget); // isolate the bullet number (shift off the sprite index)
SetList[nSet].nRun--; SetList[nSet].nRun--;
@ -590,18 +595,18 @@ void FuncSet(int a, int nDamage, int nRun)
{ {
if (SetList[nSet].nIndex) if (SetList[nSet].nIndex)
{ {
sprite[nSprite].zvel = -10000; pSprite->zvel = -10000;
} }
else else
{ {
sprite[nSprite].zvel = -(PlotCourseToSprite(nSprite, nTarget)); pSprite->zvel = -(PlotCourseToSprite(nSprite, nTarget));
} }
SetList[nSet].nAction = 8; SetList[nSet].nAction = 8;
SetList[nSet].nFrame = 0; SetList[nSet].nFrame = 0;
sprite[nSprite].xvel = bcos(sprite[nSprite].ang); pSprite->xvel = bcos(pSprite->ang);
sprite[nSprite].yvel = bsin(sprite[nSprite].ang); pSprite->yvel = bsin(pSprite->ang);
} }
return; return;
} }
@ -624,13 +629,13 @@ void FuncSet(int a, int nDamage, int nRun)
case 9: case 9:
{ {
sprite[nSprite].xvel >>= 1; pSprite->xvel >>= 1;
sprite[nSprite].yvel >>= 1; pSprite->yvel >>= 1;
if (bVal) if (bVal)
{ {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
PlotCourseToSprite(nSprite, nTarget); PlotCourseToSprite(nSprite, nTarget);
@ -638,8 +643,8 @@ void FuncSet(int a, int nDamage, int nRun)
SetList[nSet].nFrame = 0; SetList[nSet].nFrame = 0;
SetList[nSet].nRun = 5; SetList[nSet].nRun = 5;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
return; return;
} }
@ -648,9 +653,9 @@ void FuncSet(int a, int nDamage, int nRun)
{ {
if (nFlag & 0x80) if (nFlag & 0x80)
{ {
sprite[nSprite].z -= GetSpriteHeight(nSprite); pSprite->z -= GetSpriteHeight(nSprite);
BuildCreatureChunk(nSprite, seq_GetSeqPicnum(kSeqSet, 76, 0)); BuildCreatureChunk(nSprite, seq_GetSeqPicnum(kSeqSet, 76, 0));
sprite[nSprite].z += GetSpriteHeight(nSprite); pSprite->z += GetSpriteHeight(nSprite);
} }
if (bVal) if (bVal)
@ -670,7 +675,7 @@ void FuncSet(int a, int nDamage, int nRun)
case 11: case 11:
{ {
sprite[nSprite].cstat &= 0xFEFE; pSprite->cstat &= 0xFEFE;
return; return;
} }
} }
@ -686,8 +691,8 @@ void FuncSet(int a, int nDamage, int nRun)
SetList[nSet].nFrame = 0; SetList[nSet].nFrame = 0;
SetList[nSet].nCount = 100; SetList[nSet].nCount = 100;
SetList[nSet].nTarget = -1; SetList[nSet].nTarget = -1;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
} }
} }
} }

View file

@ -75,9 +75,10 @@ void DestroySnake(int nSnake)
for (int i = 0; i < kSnakeSprites; i++) for (int i = 0; i < kSnakeSprites; i++)
{ {
short nSprite = SnakeList[nSnake].nSprites[i]; short nSprite = SnakeList[nSnake].nSprites[i];
auto pSprite = &sprite[nSprite];
runlist_DoSubRunRec(sprite[nSprite].lotag - 1); runlist_DoSubRunRec(pSprite->lotag - 1);
runlist_DoSubRunRec(sprite[nSprite].owner); runlist_DoSubRunRec(pSprite->owner);
mydeletesprite(nSprite); mydeletesprite(nSprite);
} }
@ -92,6 +93,7 @@ void DestroySnake(int nSnake)
void ExplodeSnakeSprite(int nSprite, short nPlayer) void ExplodeSnakeSprite(int nSprite, short nPlayer)
{ {
auto pSprite = &sprite[nSprite];
short nDamage = BulletInfo[kWeaponStaff].nDamage; short nDamage = BulletInfo[kWeaponStaff].nDamage;
if (PlayerList[nPlayer].nDouble > 0) { if (PlayerList[nPlayer].nDouble > 0) {
@ -99,16 +101,16 @@ void ExplodeSnakeSprite(int nSprite, short nPlayer)
} }
// take a copy of this, to revert after call to runlist_RadialDamageEnemy() // take a copy of this, to revert after call to runlist_RadialDamageEnemy()
short nOwner = sprite[nSprite].owner; short nOwner = pSprite->owner;
sprite[nSprite].owner = PlayerList[nPlayer].nSprite; pSprite->owner = PlayerList[nPlayer].nSprite;
runlist_RadialDamageEnemy(nSprite, nDamage, BulletInfo[kWeaponStaff].nRadius); runlist_RadialDamageEnemy(nSprite, nDamage, BulletInfo[kWeaponStaff].nRadius);
sprite[nSprite].owner = nOwner; pSprite->owner = nOwner;
BuildAnim(-1, 23, 0, sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, sprite[nSprite].sectnum, 40, 4); BuildAnim(-1, 23, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 40, 4);
AddFlash(sprite[nSprite].sectnum, sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, 128); AddFlash(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 128);
StopSpriteSound(nSprite); StopSpriteSound(nSprite);
} }
@ -159,9 +161,10 @@ int BuildSnake(short nPlayer, short zVal)
{ {
BackUpBullet(&hitx, &hity, nAngle); BackUpBullet(&hitx, &hity, nAngle);
nSprite = insertsprite(hitsect, 202); nSprite = insertsprite(hitsect, 202);
sprite[nSprite].x = hitx; auto pSprite = &sprite[nSprite];
sprite[nSprite].y = hity; pSprite->x = hitx;
sprite[nSprite].z = hitz; pSprite->y = hity;
pSprite->z = hitz;
ExplodeSnakeSprite(nSprite, nPlayer); ExplodeSnakeSprite(nSprite, nPlayer);
mydeletesprite(nSprite); mydeletesprite(nSprite);
@ -188,48 +191,49 @@ int BuildSnake(short nPlayer, short zVal)
for (int i = 0; i < kSnakeSprites; i++) for (int i = 0; i < kSnakeSprites; i++)
{ {
nSprite = insertsprite(nViewSect, 202); nSprite = insertsprite(nViewSect, 202);
auto pSprite = &sprite[nSprite];
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
sprite[nSprite].owner = nPlayerSprite; pSprite->owner = nPlayerSprite;
sprite[nSprite].picnum = nPic; pSprite->picnum = nPic;
if (i == 0) if (i == 0)
{ {
sprite[nSprite].x = sprite[nPlayerSprite].x; pSprite->x = sprite[nPlayerSprite].x;
sprite[nSprite].y = sprite[nPlayerSprite].y; pSprite->y = sprite[nPlayerSprite].y;
sprite[nSprite].z = sprite[nPlayerSprite].z + zVal; pSprite->z = sprite[nPlayerSprite].z + zVal;
sprite[nSprite].xrepeat = 32; pSprite->xrepeat = 32;
sprite[nSprite].yrepeat = 32; pSprite->yrepeat = 32;
nViewSect = sprite[nSprite].sectnum; nViewSect = pSprite->sectnum;
var_24 = nSprite; var_24 = nSprite;
} }
else else
{ {
sprite[nSprite].x = sprite[var_24].x; pSprite->x = sprite[var_24].x;
sprite[nSprite].y = sprite[var_24].y; pSprite->y = sprite[var_24].y;
sprite[nSprite].z = sprite[var_24].z; pSprite->z = sprite[var_24].z;
sprite[nSprite].xrepeat = 40 - 3*i; pSprite->xrepeat = 40 - 3*i;
sprite[nSprite].yrepeat = 40 - 3*i; pSprite->yrepeat = 40 - 3*i;
} }
sprite[nSprite].clipdist = 10; pSprite->clipdist = 10;
sprite[nSprite].cstat = 0; pSprite->cstat = 0;
sprite[nSprite].shade = -64; pSprite->shade = -64;
sprite[nSprite].pal = 0; pSprite->pal = 0;
sprite[nSprite].xoffset = 0; pSprite->xoffset = 0;
sprite[nSprite].yoffset = 0; pSprite->yoffset = 0;
sprite[nSprite].ang = sprite[nPlayerSprite].ang; pSprite->ang = sprite[nPlayerSprite].ang;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].hitag = 0; pSprite->hitag = 0;
sprite[nSprite].extra = -1; pSprite->extra = -1;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].backuppos(); pSprite->backuppos();
SnakeList[nSnake].nSprites[i] = nSprite; SnakeList[nSnake].nSprites[i] = nSprite;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, ((nSnake << 8) | i) | 0x110000); pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, ((nSnake << 8) | i) | 0x110000);
} }
SnakeList[nSnake].nRun = runlist_AddRunRec(NewRun, nSnake | 0x110000); SnakeList[nSnake].nRun = runlist_AddRunRec(NewRun, nSnake | 0x110000);
@ -265,9 +269,10 @@ int FindSnakeEnemy(short nSnake)
short nPlayerSprite = PlayerList[nPlayer].nSprite; short nPlayerSprite = PlayerList[nPlayer].nSprite;
short nSprite = SnakeList[nSnake].nSprites[0]; // CHECKME short nSprite = SnakeList[nSnake].nSprites[0]; // CHECKME
auto pSprite = &sprite[nSprite];
short nAngle = sprite[nSprite].ang; short nAngle = pSprite->ang;
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
int esi = 2048; int esi = 2048;
@ -320,6 +325,7 @@ void FuncSnake(int a, int, int nRun)
assert(nSnake >= 0 && nSnake < kMaxSnakes); assert(nSnake >= 0 && nSnake < kMaxSnakes);
short nSprite = SnakeList[nSnake].nSprites[0]; short nSprite = SnakeList[nSnake].nSprites[0];
auto pSprite = &sprite[nSprite];
seq_MoveSequence(nSprite, SeqOffsets[kSeqSnakehed], 0); seq_MoveSequence(nSprite, SeqOffsets[kSeqSnakehed], 0);
@ -332,8 +338,8 @@ void FuncSnake(int a, int, int nRun)
{ {
SEARCH_ENEMY: SEARCH_ENEMY:
nMov = movesprite(nSprite, nMov = movesprite(nSprite,
600 * bcos(sprite[nSprite].ang), 600 * bcos(pSprite->ang),
600 * bsin(sprite[nSprite].ang), 600 * bsin(pSprite->ang),
bsin(SnakeList[nSnake].sE, -5), bsin(SnakeList[nSnake].sE, -5),
0, 0, CLIPMASK1); 0, 0, CLIPMASK1);
@ -349,11 +355,11 @@ SEARCH_ENEMY:
goto SEARCH_ENEMY; goto SEARCH_ENEMY;
} }
zVal = sprite[nSprite].z; zVal = pSprite->z;
nMov = AngleChase(nSprite, nEnemySprite, 1200, SnakeList[nSnake].sE, 32); nMov = AngleChase(nSprite, nEnemySprite, 1200, SnakeList[nSnake].sE, 32);
zVal = sprite[nSprite].z - zVal; zVal = pSprite->z - zVal;
} }
if (nMov) if (nMov)
@ -368,7 +374,7 @@ SEARCH_ENEMY:
} }
else else
{ {
short nAngle = sprite[nSprite].ang; short nAngle = pSprite->ang;
int var_30 = -bcos(nAngle, 6); int var_30 = -bcos(nAngle, 6);
int var_34 = -bsin(nAngle, 6); int var_34 = -bsin(nAngle, 6);
@ -377,11 +383,11 @@ SEARCH_ENEMY:
SnakeList[nSnake].sE = (SnakeList[nSnake].sE + 64) & 0x7FF; SnakeList[nSnake].sE = (SnakeList[nSnake].sE + 64) & 0x7FF;
int var_28 = (nAngle + 512) & kAngleMask; int var_28 = (nAngle + 512) & kAngleMask;
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
int x = sprite[nSprite].x; int x = pSprite->x;
int y = sprite[nSprite].y; int y = pSprite->y;
int z = sprite[nSprite].z; int z = pSprite->z;
for (int i = 7; i > 0; i--) for (int i = 7; i > 0; i--)
{ {

View file

@ -212,18 +212,20 @@ void DrawView(double smoothRatio, bool sceneonly)
pm_smoothratio = (int)smoothRatio; pm_smoothratio = (int)smoothRatio;
int nPlayerSprite = PlayerList[nLocalPlayer].nSprite; int nPlayerSprite = PlayerList[nLocalPlayer].nSprite;
int nPlayerOldCstat = sprite[nPlayerSprite].cstat; auto pPlayerSprite = &sprite[nPlayerSprite];
int nPlayerOldCstat = pPlayerSprite->cstat;
int nDoppleOldCstat = sprite[nDoppleSprite[nLocalPlayer]].cstat; int nDoppleOldCstat = sprite[nDoppleSprite[nLocalPlayer]].cstat;
if (nSnakeCam >= 0 && !sceneonly) if (nSnakeCam >= 0 && !sceneonly)
{ {
int nSprite = SnakeList[nSnakeCam].nSprites[0]; int nSprite = SnakeList[nSnakeCam].nSprites[0];
auto pSprite = &sprite[nSprite];
playerX = sprite[nSprite].x; playerX = pSprite->x;
playerY = sprite[nSprite].y; playerY = pSprite->y;
playerZ = sprite[nSprite].z; playerZ = pSprite->z;
nSector = sprite[nSprite].sectnum; nSector = pSprite->sectnum;
nAngle = buildang(sprite[nSprite].ang); nAngle = buildang(pSprite->ang);
rotscrnang = buildang(0); rotscrnang = buildang(0);
SetGreenPal(); SetGreenPal();
@ -265,12 +267,12 @@ void DrawView(double smoothRatio, bool sceneonly)
if (!bCamera) if (!bCamera)
{ {
sprite[nPlayerSprite].cstat |= CSTAT_SPRITE_INVISIBLE; pPlayerSprite->cstat |= CSTAT_SPRITE_INVISIBLE;
sprite[nDoppleSprite[nLocalPlayer]].cstat |= CSTAT_SPRITE_INVISIBLE; sprite[nDoppleSprite[nLocalPlayer]].cstat |= CSTAT_SPRITE_INVISIBLE;
} }
else else
{ {
sprite[nPlayerSprite].cstat |= CSTAT_SPRITE_TRANSLUCENT; pPlayerSprite->cstat |= CSTAT_SPRITE_TRANSLUCENT;
sprite[nDoppleSprite[nLocalPlayer]].cstat |= CSTAT_SPRITE_INVISIBLE; sprite[nDoppleSprite[nLocalPlayer]].cstat |= CSTAT_SPRITE_INVISIBLE;
} }
pan = q16horiz(clamp(pan.asq16(), gi->playerHorizMin(), gi->playerHorizMax())); pan = q16horiz(clamp(pan.asq16(), gi->playerHorizMin(), gi->playerHorizMax()));
@ -286,7 +288,7 @@ void DrawView(double smoothRatio, bool sceneonly)
else else
{ {
viewz = playerZ + nQuake[nLocalPlayer]; viewz = playerZ + nQuake[nLocalPlayer];
int floorZ = sector[sprite[nPlayerSprite].sectnum].floorz; int floorZ = sector[pPlayerSprite->sectnum].floorz;
if (viewz > floorZ) if (viewz > floorZ)
viewz = floorZ; viewz = floorZ;
@ -393,9 +395,9 @@ void DrawView(double smoothRatio, bool sceneonly)
{ {
nHeadStage = 5; nHeadStage = 5;
sprite[nPlayerSprite].cstat |= 0x8000; pPlayerSprite->cstat |= 0x8000;
int ang2 = nCameraa.asbuild() - sprite[nPlayerSprite].ang; int ang2 = nCameraa.asbuild() - pPlayerSprite->ang;
if (ang2 < 0) if (ang2 < 0)
ang2 = -ang2; ang2 = -ang2;
@ -451,7 +453,7 @@ void DrawView(double smoothRatio, bool sceneonly)
twod->ClearScreen(); twod->ClearScreen();
} }
sprite[nPlayerSprite].cstat = nPlayerOldCstat; pPlayerSprite->cstat = nPlayerOldCstat;
sprite[nDoppleSprite[nLocalPlayer]].cstat = nDoppleOldCstat; sprite[nDoppleSprite[nLocalPlayer]].cstat = nDoppleOldCstat;
RestoreInterpolations(); RestoreInterpolations();

View file

@ -88,8 +88,9 @@ void InitWasps()
void SetWaspVel(short nSprite) void SetWaspVel(short nSprite)
{ {
sprite[nSprite].xvel = bcos(sprite[nSprite].ang); auto pSprite = &sprite[nSprite];
sprite[nSprite].yvel = bsin(sprite[nSprite].ang); pSprite->xvel = bcos(pSprite->ang);
pSprite->yvel = bsin(pSprite->ang);
} }
int BuildWasp(short nSprite, int x, int y, int z, short nSector, short nAngle) int BuildWasp(short nSprite, int x, int y, int z, short nSector, short nAngle)
@ -100,48 +101,50 @@ int BuildWasp(short nSprite, int x, int y, int z, short nSector, short nAngle)
if (nSprite == -2) { if (nSprite == -2) {
bEggWasp = true; bEggWasp = true;
} }
auto pSprite = &sprite[nSprite];
if (nSprite < 0) if (nSprite < 0)
{ {
nSprite = insertsprite(nSector, 107); nSprite = insertsprite(nSector, 107);
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
pSprite = &sprite[nSprite];
sprite[nSprite].x = x; pSprite->x = x;
sprite[nSprite].y = y; pSprite->y = y;
sprite[nSprite].z = z; pSprite->z = z;
} }
else else
{ {
nAngle = sprite[nSprite].ang; nAngle = pSprite->ang;
changespritestat(nSprite, 107); changespritestat(nSprite, 107);
} }
sprite[nSprite].shade = -12; pSprite->shade = -12;
sprite[nSprite].cstat = 0x101; pSprite->cstat = 0x101;
sprite[nSprite].pal = sector[sprite[nSprite].sectnum].ceilingpal; pSprite->pal = sector[pSprite->sectnum].ceilingpal;
sprite[nSprite].clipdist = 70; pSprite->clipdist = 70;
if (bEggWasp) if (bEggWasp)
{ {
sprite[nSprite].xrepeat = 20; pSprite->xrepeat = 20;
sprite[nSprite].yrepeat = 20; pSprite->yrepeat = 20;
} }
else else
{ {
sprite[nSprite].xrepeat = 50; pSprite->xrepeat = 50;
sprite[nSprite].yrepeat = 50; pSprite->yrepeat = 50;
} }
sprite[nSprite].xoffset = 0; pSprite->xoffset = 0;
sprite[nSprite].yoffset = 0; pSprite->yoffset = 0;
sprite[nSprite].picnum = 1; pSprite->picnum = 1;
sprite[nSprite].ang = nAngle; pSprite->ang = nAngle;
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
sprite[nSprite].hitag = 0; pSprite->hitag = 0;
sprite[nSprite].lotag = runlist_HeadRun() + 1; pSprite->lotag = runlist_HeadRun() + 1;
sprite[nSprite].extra = -1; pSprite->extra = -1;
// GrabTimeSlot(3); // GrabTimeSlot(3);
@ -166,7 +169,7 @@ int BuildWasp(short nSprite, int x, int y, int z, short nSector, short nAngle)
WaspList[nWasp].nVel = 0; WaspList[nWasp].nVel = 0;
WaspList[nWasp].nAngle2 = RandomSize(7) + 127; WaspList[nWasp].nAngle2 = RandomSize(7) + 127;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nWasp | 0x1E0000); pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nWasp | 0x1E0000);
WaspList[nWasp].nRun = runlist_AddRunRec(NewRun, nWasp | 0x1E0000); WaspList[nWasp].nRun = runlist_AddRunRec(NewRun, nWasp | 0x1E0000);
@ -178,6 +181,7 @@ void FuncWasp(int a, int nDamage, int nRun)
{ {
short nWasp = RunData[nRun].nVal; short nWasp = RunData[nRun].nVal;
short nSprite = WaspList[nWasp].nSprite; short nSprite = WaspList[nWasp].nSprite;
auto pSprite = &sprite[nSprite];
short nAction = WaspList[nWasp].nAction; short nAction = WaspList[nWasp].nAction;
short nTarget = -1; short nTarget = -1;
@ -196,7 +200,7 @@ void FuncWasp(int a, int nDamage, int nRun)
case 0xA0000: case 0xA0000:
{ {
if (!(sprite[nSprite].cstat & 0x101)) if (!(pSprite->cstat & 0x101))
return; return;
nDamage = runlist_CheckRadialDamage(nSprite); nDamage = runlist_CheckRadialDamage(nSprite);
@ -223,12 +227,12 @@ void FuncWasp(int a, int nDamage, int nRun)
} }
WaspList[nWasp].nAction = 1; WaspList[nWasp].nAction = 1;
sprite[nSprite].ang += RandomSize(9) + 768; pSprite->ang += RandomSize(9) + 768;
sprite[nSprite].ang &= kAngleMask; pSprite->ang &= kAngleMask;
WaspList[nWasp].nVel = 3000; WaspList[nWasp].nVel = 3000;
sprite[nSprite].zvel = (-20) - RandomSize(6); pSprite->zvel = (-20) - RandomSize(6);
} }
else else
{ {
@ -236,12 +240,12 @@ void FuncWasp(int a, int nDamage, int nRun)
WaspList[nWasp].nAction = 4; WaspList[nWasp].nAction = 4;
WaspList[nWasp].nFrame = 0; WaspList[nWasp].nFrame = 0;
sprite[nSprite].cstat = 0; pSprite->cstat = 0;
sprite[nSprite].ang = (sprite[nSprite].ang + 1024) & kAngleMask; pSprite->ang = (pSprite->ang + 1024) & kAngleMask;
SetWaspVel(nSprite); SetWaspVel(nSprite);
sprite[nSprite].zvel = 512; pSprite->zvel = 512;
nCreaturesKilled++; nCreaturesKilled++;
} }
@ -253,7 +257,7 @@ void FuncWasp(int a, int nDamage, int nRun)
{ {
short nSeq = SeqOffsets[kSeqWasp] + WaspSeq[nAction].a; short nSeq = SeqOffsets[kSeqWasp] + WaspSeq[nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, WaspList[nWasp].nFrame); pSprite->picnum = seq_GetSeqPicnum2(nSeq, WaspList[nWasp].nFrame);
seq_MoveSequence(nSprite, nSeq, WaspList[nWasp].nFrame); seq_MoveSequence(nSprite, nSeq, WaspList[nWasp].nFrame);
@ -285,7 +289,7 @@ void FuncWasp(int a, int nDamage, int nRun)
case 0: case 0:
{ {
sprite[nSprite].zvel = bsin(WaspList[nWasp].nAngle, -4); pSprite->zvel = bsin(WaspList[nWasp].nAngle, -4);
WaspList[nWasp].nAngle += WaspList[nWasp].nAngle2; WaspList[nWasp].nAngle += WaspList[nWasp].nAngle2;
WaspList[nWasp].nAngle &= kAngleMask; WaspList[nWasp].nAngle &= kAngleMask;
@ -301,7 +305,7 @@ void FuncWasp(int a, int nDamage, int nRun)
} }
else else
{ {
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
WaspList[nWasp].nAction = 1; WaspList[nWasp].nAction = 1;
WaspList[nWasp].nFrame = 0; WaspList[nWasp].nFrame = 0;
WaspList[nWasp].nVel = 1500; WaspList[nWasp].nVel = 1500;
@ -346,8 +350,8 @@ void FuncWasp(int a, int nDamage, int nRun)
short nSprite2 = (nChaseVal & 0x3FFF); short nSprite2 = (nChaseVal & 0x3FFF);
if (nSprite2 == nTarget) if (nSprite2 == nTarget)
{ {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
runlist_DamageEnemy(nSprite2, nSprite, WaspList[nWasp].nDamage); runlist_DamageEnemy(nSprite2, nSprite, WaspList[nWasp].nDamage);
WaspList[nWasp].nAction = 2; WaspList[nWasp].nAction = 2;
WaspList[nWasp].nFrame = 0; WaspList[nWasp].nFrame = 0;
@ -364,9 +368,9 @@ void FuncWasp(int a, int nDamage, int nRun)
{ {
if (bVal) if (bVal)
{ {
sprite[nSprite].ang += RandomSize(9) + 768; pSprite->ang += RandomSize(9) + 768;
sprite[nSprite].ang &= kAngleMask; pSprite->ang &= kAngleMask;
sprite[nSprite].zvel = (-20) - RandomSize(6); pSprite->zvel = (-20) - RandomSize(6);
WaspList[nWasp].nAction = 1; WaspList[nWasp].nAction = 1;
WaspList[nWasp].nVel = 3000; WaspList[nWasp].nVel = 3000;
@ -380,9 +384,9 @@ void FuncWasp(int a, int nDamage, int nRun)
if (nMove) if (nMove)
{ {
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 1024; pSprite->zvel = 1024;
WaspList[nWasp].nAction = 5; WaspList[nWasp].nAction = 5;
WaspList[nWasp].nFrame = 0; WaspList[nWasp].nFrame = 0;
} }
@ -391,21 +395,21 @@ void FuncWasp(int a, int nDamage, int nRun)
} }
case 5: case 5:
{ {
short nSector = sprite[nSprite].sectnum; short nSector = pSprite->sectnum;
sprite[nSprite].z += sprite[nSprite].zvel; pSprite->z += pSprite->zvel;
if (sprite[nSprite].z >= sector[nSector].floorz) if (pSprite->z >= sector[nSector].floorz)
{ {
if (SectBelow[nSector] > -1) if (SectBelow[nSector] > -1)
{ {
BuildSplash(nSprite, nSector); BuildSplash(nSprite, nSector);
sprite[nSprite].cstat |= 0x8000; pSprite->cstat |= 0x8000;
} }
sprite[nSprite].xvel = 0; pSprite->xvel = 0;
sprite[nSprite].yvel = 0; pSprite->yvel = 0;
sprite[nSprite].zvel = 0; pSprite->zvel = 0;
WaspList[nWasp].nAction = 6; WaspList[nWasp].nAction = 6;
WaspList[nWasp].nFrame = 0; WaspList[nWasp].nFrame = 0;
runlist_SubRunRec(WaspList[nWasp].nRun); runlist_SubRunRec(WaspList[nWasp].nRun);

View file

@ -64,23 +64,24 @@ int COVERinsertsprite(short sectnum, short stat)
{ {
short spnum; short spnum;
spnum = insertsprite(sectnum, stat); spnum = insertsprite(sectnum, stat);
auto pSprite = &sprite[spnum];
PRODUCTION_ASSERT(spnum >= 0); PRODUCTION_ASSERT(spnum >= 0);
sprite[spnum].x = sprite[spnum].y = sprite[spnum].z = 0; pSprite->x = sprite[spnum].y = sprite[spnum].z = 0;
sprite[spnum].cstat = 0; pSprite->cstat = 0;
sprite[spnum].picnum = 0; pSprite->picnum = 0;
sprite[spnum].shade = 0; pSprite->shade = 0;
sprite[spnum].pal = 0; pSprite->pal = 0;
sprite[spnum].clipdist = 0; pSprite->clipdist = 0;
sprite[spnum].xrepeat = sprite[spnum].yrepeat = 0; pSprite->xrepeat = sprite[spnum].yrepeat = 0;
sprite[spnum].xoffset = sprite[spnum].yoffset = 0; pSprite->xoffset = sprite[spnum].yoffset = 0;
sprite[spnum].ang = 0; pSprite->ang = 0;
sprite[spnum].owner = -1; pSprite->owner = -1;
sprite[spnum].xvel = sprite[spnum].yvel = sprite[spnum].zvel = 0; pSprite->xvel = sprite[spnum].yvel = sprite[spnum].zvel = 0;
sprite[spnum].lotag = 0; pSprite->lotag = 0;
sprite[spnum].hitag = 0; pSprite->hitag = 0;
sprite[spnum].extra = 0; pSprite->extra = 0;
return spnum; return spnum;
} }