Skip to content

Commit

Permalink
- eliminated spritetype::index.
Browse files Browse the repository at this point in the history
# Conflicts:
#	source/games/blood/src/nnexts.cpp
  • Loading branch information
coelckers committed Sep 6, 2021
1 parent 900c892 commit 406bc58
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 41 deletions.
12 changes: 5 additions & 7 deletions source/build/include/buildtypes.h
Expand Up @@ -253,13 +253,11 @@ struct spritetype
int8_t xoffset, yoffset;
int16_t sectnum, statnum;
int16_t oang, ang, owner;
union {
int16_t xvel, index;
};
int16_t yvel;
union {
int16_t zvel, inittype;
};
int16_t xvel;
int16_t yvel;
union {
int16_t zvel, inittype;
};
union {
int16_t lotag, type;
};
Expand Down
3 changes: 1 addition & 2 deletions source/games/blood/src/_polymost.cpp
Expand Up @@ -35,7 +35,6 @@ void collectTSpritesForPortal(int x, int y, int i, int interpolation)
tspritetype* pTSprite = &pm_tsprite[pm_spritesortcnt++];
*pTSprite = {};
pTSprite->type = pSprite->type;
pTSprite->index = pSprite->index;
pTSprite->sectnum = nSector2;
pTSprite->x = pSprite->x + dx;
pTSprite->y = pSprite->y + dy;
Expand All @@ -50,7 +49,7 @@ void collectTSpritesForPortal(int x, int y, int i, int interpolation)
pTSprite->yoffset = pSprite->yoffset;
pTSprite->cstat = pSprite->cstat;
pTSprite->statnum = kStatDecoration;
pTSprite->owner = pSprite->index;
pTSprite->owner = actor->GetIndex();
pTSprite->flags = pSprite->hitag | 0x200;
pTSprite->x = dx + interpolatedvalue(pSprite->ox, pSprite->x, interpolation);
pTSprite->y = dy + interpolatedvalue(pSprite->oy, pSprite->y, interpolation);
Expand Down
9 changes: 4 additions & 5 deletions source/games/blood/src/actor.cpp
Expand Up @@ -5517,7 +5517,7 @@ void actExplodeSprite(DBloodActor* actor)
nType = kExplosionFireball;
seqSpawn(9, actor, -1);
if (Chance(0x8000)) pSprite->cstat |= 4;
sfxPlay3DSound(actor, 306, 24 + (pSprite->index & 3), FX_GlobalChannel); // ouch...
sfxPlay3DSound(actor, 306, 24 + (actor->GetIndex() & 3), FX_GlobalChannel); // ouch...
GibSprite(actor, GIBTYPE_5, nullptr, nullptr);
break;

Expand Down Expand Up @@ -5837,7 +5837,7 @@ static void actCheckThings()
}
actAirDrag(actor, 128);

if (((pSprite->index >> 8) & 15) == (gFrameCount & 15) && (pSprite->flags & 2)) pSprite->flags |= 4;
if (((actor->GetIndex() >> 8) & 15) == (gFrameCount & 15) && (pSprite->flags & 2)) pSprite->flags |= 4;
if ((pSprite->flags & 4) || actor->xvel || actor->yvel || actor->zvel || velFloor[pSprite->sectnum] || velCeil[pSprite->sectnum])
{
Collision hit = MoveThing(actor);
Expand Down Expand Up @@ -6525,7 +6525,7 @@ DBloodActor* actSpawnThing(int nSector, int x, int y, int z, int nThingType)
pSprite->pal = pThingInfo->pal;
if (pThingInfo->xrepeat) pSprite->xrepeat = pThingInfo->xrepeat;
if (pThingInfo->yrepeat) pSprite->yrepeat = pThingInfo->yrepeat;
show2dsprite.Set(pSprite->index);
show2dsprite.Set(actor->GetIndex());
switch (nThingType)
{
case kThingVoodooHead:
Expand Down Expand Up @@ -6741,8 +6741,7 @@ DBloodActor* actFireMissile(DBloodActor* actor, int a2, int a3, int a4, int a5,
}
auto spawned = actSpawnSprite(pSprite->sectnum, x, y, z, 5, 1);
spritetype* pMissile = &spawned->s();
int nMissile = pMissile->index;
show2dsprite.Set(nMissile);
show2dsprite.Set(spawned->GetIndex());
pMissile->type = nType;
pMissile->shade = pMissileInfo->shade;
pMissile->pal = 0;
Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/ai.cpp
Expand Up @@ -1670,7 +1670,7 @@ void aiProcessDudes(void)
if (pXSprite->aiState && pXSprite->aiState->moveFunc)
pXSprite->aiState->moveFunc(actor);

if (pXSprite->aiState->thinkFunc && (gFrameCount & 3) == (pSprite->index & 3)) // ouch, ouch! :(
if (pXSprite->aiState->thinkFunc && (gFrameCount & 3) == (actor->GetIndex() & 3)) // ouch, ouch! :(
pXSprite->aiState->thinkFunc(actor);

switch (pSprite->type) {
Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/animatesprite.cpp
Expand Up @@ -895,7 +895,7 @@ void viewProcessSprites(spritetype* tsprite, int& spritesortcnt, int32_t cX, int
}
}

if (pTSprite->owner != gView->pSprite->index || gViewPos != VIEWPOS_0) {
if (pTSprite->owner != gView->actor->GetIndex() || gViewPos != VIEWPOS_0) {
if (getflorzofslope(pTSprite->sectnum, pTSprite->x, pTSprite->y) >= cZ)
{
viewAddEffect(tsprite, spritesortcnt, nTSprite, kViewEffectShadow);
Expand Down
14 changes: 7 additions & 7 deletions source/games/blood/src/bloodactor.h
Expand Up @@ -132,7 +132,7 @@ class DBloodActor

void SetOwner(DBloodActor* own)
{
s().owner = own ? own->s().index : -1;
s().owner = own ? own->GetIndex() : -1;
}

DBloodActor* GetOwner()
Expand All @@ -143,7 +143,7 @@ class DBloodActor

void SetTarget(DBloodActor* own)
{
x().target_i = own ? own->s().index : -1;
x().target_i = own ? own->GetIndex() : -1;
}

DBloodActor* GetTarget()
Expand All @@ -164,7 +164,7 @@ class DBloodActor

void SetBurnSource(DBloodActor* own)
{
x().burnSource = own ? own->s().index : -1;
x().burnSource = own ? own->GetIndex() : -1;
}

DBloodActor* GetBurnSource()
Expand Down Expand Up @@ -320,7 +320,7 @@ class BloodLinearSpriteIterator

inline int DeleteSprite(DBloodActor* nSprite)
{
if (nSprite) return DeleteSprite(nSprite->s().index);
if (nSprite) return DeleteSprite(nSprite->GetIndex());
return 0;
}

Expand Down Expand Up @@ -362,12 +362,12 @@ inline void sfxKill3DSound(DBloodActor* pSprite, int a2 = -1, int a3 = -1)

inline void ChangeActorStat(DBloodActor* actor, int stat)
{
ChangeSpriteStat(actor->s().index, stat);
ChangeSpriteStat(actor->GetIndex(), stat);
}

inline void ChangeActorSect(DBloodActor* actor, int stat)
{
ChangeSpriteSect(actor->s().index, stat);
ChangeSpriteSect(actor->GetIndex(), stat);
}

inline int Collision::actorIndex(DBloodActor* actor)
Expand All @@ -382,7 +382,7 @@ inline DBloodActor* Collision::Actor(int a)

inline void setActorPos(DBloodActor* actor, vec3_t* pos)
{
setsprite(actor->s().index, pos);
setsprite(actor->GetIndex(), pos);
}

END_BLD_NS
2 changes: 1 addition & 1 deletion source/games/blood/src/callback.cpp
Expand Up @@ -608,7 +608,7 @@ void sub_76A08(DBloodActor *actor, spritetype *pSprite2, PLAYER *pPlayer) // ???
ChangeActorSect(actor, pSprite2->sectnum);
sfxPlay3DSound(pSprite2, 201, -1, 0);
actor->xvel = actor->yvel = actor->zvel = 0;
viewBackupSpriteLoc(pSprite->index, pSprite);
viewBackupSpriteLoc(actor->GetIndex(), pSprite);
if (pPlayer)
{
playerResetInertia(pPlayer);
Expand Down
5 changes: 1 addition & 4 deletions source/games/blood/src/db.cpp
Expand Up @@ -167,7 +167,6 @@ void qinitspritelists(void) // Replace
for (short i = 0; i < nMaxSprites; i++)
{
sprite[i].sectnum = -1;
sprite[i].index = -1;
InsertSpriteStat(i, kMaxStatus);
}
memset(gStatCount, 0, sizeof(gStatCount));
Expand All @@ -194,7 +193,6 @@ DBloodActor* InsertSprite(int nSector, int nStat)
pSprite->clipdist = 32;
pSprite->xrepeat = pSprite->yrepeat = 64;
actor->SetOwner(nullptr);
pSprite->index = nSprite;

Numsprites++;

Expand Down Expand Up @@ -837,7 +835,6 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
InsertSpriteSect(i, pSprite->sectnum);
InsertSpriteStat(i, pSprite->statnum);
Numsprites++;
pSprite->index = i;
if (pSprite->extra > 0)
{
char pBuffer[nXSpriteSize];
Expand Down Expand Up @@ -906,7 +903,7 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
pXSprite->dudeAmbush = bitReader.readUnsigned(1);
pXSprite->dudeGuard = bitReader.readUnsigned(1);
pXSprite->dudeFlag4 = bitReader.readUnsigned(1);
pXSprite->target_i = bitReader.readSigned(16);
/*pXSprite->target_i = */ bitReader.readSigned(16);
pXSprite->targetX = bitReader.readSigned(32);
pXSprite->targetY = bitReader.readSigned(32);
pXSprite->targetZ = bitReader.readSigned(32);
Expand Down
12 changes: 5 additions & 7 deletions source/games/blood/src/nnexts.cpp
Expand Up @@ -1266,13 +1266,11 @@ void nnExtProcessSuperSprites()
if ((!pXSightSpr->Interrutable && pXSightSpr->state != pXSightSpr->restState) || pXSightSpr->locked == 1 ||
pXSightSpr->isTriggered) continue; // don't process locked or triggered sprites

int index = pSightSpr->index;

// sprite is drawn for one of players
if ((pXSightSpr->unused3 & kTriggerSpriteScreen) && show2dsprite[index])
if ((pXSightSpr->unused3 & kTriggerSpriteScreen) && show2dsprite[gSightSpritesList[i]->GetIndex()])
{
trTriggerSprite(gSightSpritesList[i], kCmdSpriteSight);
show2dsprite.Clear(index);
show2dsprite.Clear(gSightSpritesList[i]->GetIndex());
continue;
}

Expand Down Expand Up @@ -1392,7 +1390,7 @@ void nnExtProcessSuperSprites()
debrisactor->xvel += MulScale(nSpeed, Cos(pPlayer->pSprite->ang), 30);
debrisactor->yvel += MulScale(nSpeed, Sin(pPlayer->pSprite->ang), 30);

debrisactor->hit.hit = pPlayer->pSprite->index | 0xc000;
debrisactor->hit.hit = pPlayer->actor->GetIndex() | 0xc000;
}
}
}
Expand Down Expand Up @@ -7574,7 +7572,7 @@ void nnExtAiSetDirection(DBloodActor* actor, int a3)
XSPRITE* pXSprite = &actor->x();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);

int nSprite = pSprite->index;
int nSprite = actor->GetIndex();
int vc = ((a3 + 1024 - pSprite->ang) & 2047) - 1024;
int t1 = DMulScale(actor->xvel, Cos(pSprite->ang), actor->yvel, Sin(pSprite->ang), 30);
int vsi = ((t1 * 15) >> 12) / 2;
Expand Down Expand Up @@ -8358,7 +8356,7 @@ DBloodActor* aiPatrolSearchTargets(DBloodActor* actor)
sndy = emitter->y;

// sound attached to the sprite
if (pSpr != emitter && emitter->owner != pSpr->index)
if (pSpr != emitter && emitter->owner != actor->GetIndex())
{

if (!sectRangeIsFine(emitter->sectnum)) return false;
Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/player.cpp
Expand Up @@ -672,7 +672,7 @@ void playerStart(int nPlayer, int bNewLevel)
playerResetPosture(pPlayer);
seqSpawn(pDudeInfo->seqStartID, actor, -1);
if (pPlayer == gMe)
show2dsprite.Set(pSprite->index);
show2dsprite.Set(actor->GetIndex());
int top, bottom;
GetSpriteExtents(pSprite, &top, &bottom);
pSprite->z -= bottom - pSprite->z;
Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/sfx.cpp
Expand Up @@ -91,7 +91,7 @@ void BloodSoundEngine::CalcPosVel(int type, const void* source, const float pt[3
{
auto sprt = (spritetype*)source;
assert(sprt != nullptr);
auto actor = &bloodActors[sprt->index];
auto actor = &bloodActors[sprt - sprite];

// Engine expects velocity in units per second, not units per tic.
if (vel) *vel = { actor->xvel * (30 / 65536.f), actor->zvel * (-30 / 65536.f), actor->yvel * (-30 / 65536.f) };
Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/triggers.cpp
Expand Up @@ -1459,7 +1459,7 @@ void OperateTeleport(unsigned int nSector, XSECTOR *pXSector)
ChangeActorSect(actor, pDest->sectnum);
sfxPlay3DSound(pDest, 201, -1, 0);
actor->xvel = actor->yvel = actor->zvel = 0;
int nSprite = actor->s().index;
int nSprite = actor->GetIndex();
gInterpolateSprite.Clear(nSprite);
viewBackupSpriteLoc(actor);
if (pPlayer)
Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/view.h
Expand Up @@ -180,7 +180,7 @@ inline void viewBackupSpriteLoc(int nSprite, spritetype *pSprite)

inline void viewBackupSpriteLoc(DBloodActor* actor)
{
viewBackupSpriteLoc(actor->s().index, &actor->s());
viewBackupSpriteLoc(actor->GetIndex(), &actor->s());
}


Expand Down
4 changes: 2 additions & 2 deletions source/games/blood/src/warp.cpp
Expand Up @@ -198,7 +198,7 @@ int CheckLink(DBloodActor *actor)
else
z2 = getceilzofslope(pSprite->sectnum, pSprite->x, pSprite->y);
pSprite->z += z2-z;
gInterpolateSprite.Clear(pSprite->index);
gInterpolateSprite.Clear(actor->GetIndex());
return pUpper->type;
}
}
Expand All @@ -225,7 +225,7 @@ int CheckLink(DBloodActor *actor)
else
z2 = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y);
pSprite->z += z2-z;
gInterpolateSprite.Clear(pSprite->index);
gInterpolateSprite.Clear(actor->GetIndex());
return pLower->type;
}
}
Expand Down

0 comments on commit 406bc58

Please sign in to comment.