- removed all sprite[] references from gameutil.cpp.

This commit is contained in:
Christoph Oelckers 2021-09-04 20:43:03 +02:00
parent 7a2c661ff9
commit 50f9b67598
3 changed files with 43 additions and 46 deletions

View file

@ -7369,7 +7369,7 @@ void MakeSplash(DBloodActor* actor)
void actBurnSprite(DBloodActor* pSource, DBloodActor* pTarget, int nTime) void actBurnSprite(DBloodActor* pSource, DBloodActor* pTarget, int nTime)
{ {
auto pXSprite = &pTarget->x(); auto pXSprite = &pTarget->x();
pXSprite->burnTime = ClipHigh(pXSprite->burnTime + nTime, sprite[pXSprite->reference].statnum == kStatDude ? 2400 : 1200); pXSprite->burnTime = ClipHigh(pXSprite->burnTime + nTime, pTarget->s().statnum == kStatDude ? 2400 : 1200);
pTarget->SetBurnSource(pSource); pTarget->SetBurnSource(pSource);
} }

View file

@ -221,8 +221,8 @@ static void myThinkTarget(DBloodActor* actor)
for (int p = connecthead; p >= 0; p = connectpoint2[p]) for (int p = connecthead; p >= 0; p = connectpoint2[p])
{ {
PLAYER* pPlayer = &gPlayer[p]; PLAYER* pPlayer = &gPlayer[p];
int nOwner = (pSprite->owner & 0x1000) ? (pSprite->owner & 0xfff) : -1; auto owneractor = actor->GetOwner();
if (nOwner == pPlayer->nSprite || pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0) if (owneractor == nullptr || owneractor == pPlayer->actor() || pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
continue; continue;
int x = pPlayer->pSprite->x; int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y; int y = pPlayer->pSprite->y;

View file

@ -585,33 +585,31 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in
{ {
if (dz > 0) if (dz > 0)
{ {
if (gUpperLink[gHitInfo.hitsect] < 0) auto actor = getUpperLink(gHitInfo.hitsect);
return 2; if (!actor) return 2;
int nSprite = gUpperLink[gHitInfo.hitsect]; auto link = actor->GetOwner();
int nLink = sprite[nSprite].owner & 0xfff;
gHitInfo.clearObj(); gHitInfo.clearObj();
x1 = gHitInfo.hitx + sprite[nLink].x - sprite[nSprite].x; x1 = gHitInfo.hitx + link->s().x - actor->s().x;
y1 = gHitInfo.hity + sprite[nLink].y - sprite[nSprite].y; y1 = gHitInfo.hity + link->s().y - actor->s().y;
z1 = gHitInfo.hitz + sprite[nLink].z - sprite[nSprite].z; z1 = gHitInfo.hitz + link->s().z - actor->s().z;
pos = { x1, y1, z1 }; pos = { x1, y1, z1 };
hitData.pos.z = gHitInfo.hitz; hitData.pos.z = gHitInfo.hitz;
hitscan(&pos, sprite[nLink].sectnum, dx, dy, dz<<4, &hitData, CLIPMASK1); hitscan(&pos, link->s().sectnum, dx, dy, dz<<4, &hitData, CLIPMASK1);
gHitInfo.set(&hitData); gHitInfo.set(&hitData);
continue; continue;
} }
else else
{ {
if (gLowerLink[gHitInfo.hitsect] < 0) auto actor = getLowerLink(gHitInfo.hitsect);
return 1; if (!actor) return 1;
int nSprite = gLowerLink[gHitInfo.hitsect]; auto link = actor->GetOwner();
int nLink = sprite[nSprite].owner & 0xfff;
gHitInfo.clearObj(); gHitInfo.clearObj();
x1 = gHitInfo.hitx + sprite[nLink].x - sprite[nSprite].x; x1 = gHitInfo.hitx + link->s().x - actor->s().x;
y1 = gHitInfo.hity + sprite[nLink].y - sprite[nSprite].y; y1 = gHitInfo.hity + link->s().y - actor->s().y;
z1 = gHitInfo.hitz + sprite[nLink].z - sprite[nSprite].z; z1 = gHitInfo.hitz + link->s().z - actor->s().z;
pos = { x1, y1, z1 }; pos = { x1, y1, z1 };
hitData.pos.z = gHitInfo.hitz; hitData.pos.z = gHitInfo.hitz;
hitscan(&pos, sprite[nLink].sectnum, dx, dy, dz<<4, &hitData, CLIPMASK1); hitscan(&pos, link->s().sectnum, dx, dy, dz<<4, &hitData, CLIPMASK1);
gHitInfo.set(&hitData); gHitInfo.set(&hitData);
continue; continue;
} }
@ -643,14 +641,14 @@ void GetZRange(DBloodActor *actor, int *ceilZ, Collision *ceilColl, int *floorZ,
XSECTOR *pXSector = &xsector[sector[nSector].extra]; XSECTOR *pXSector = &xsector[sector[nSector].extra];
*floorZ += pXSector->Depth << 10; *floorZ += pXSector->Depth << 10;
} }
if (gUpperLink[nSector] >= 0) auto actor = getUpperLink(nSector);
if (actor)
{ {
int nSprite = gUpperLink[nSector]; int nSprite = gUpperLink[nSector];
int nLink = sprite[nSprite].owner & 0xfff; auto link = actor->GetOwner();
vec3_t lpos = { pSprite->x + sprite[nLink].x - sprite[nSprite].x, pSprite->y + sprite[nLink].y - sprite[nSprite].y, vec3_t lpos = { pSprite->x + link->s().x - actor->s().x, pSprite->y + link->s().y - actor->s().y, pSprite->z + link->s().z - actor->s().z };
pSprite->z + sprite[nLink].z - sprite[nSprite].z }; getzrange(&lpos, link->s().sectnum, &nTemp1, &nTemp2, (int32_t*)floorZ, &floorHit, nDist, nMask);
getzrange(&lpos, sprite[nLink].sectnum, &nTemp1, &nTemp2, (int32_t*)floorZ, &floorHit, nDist, nMask); *floorZ -= link->s().z - actor->s().z;
*floorZ -= sprite[nLink].z - sprite[nSprite].z;
floorColl->setFromEngine(floorHit); floorColl->setFromEngine(floorHit);
} }
} }
@ -659,14 +657,13 @@ void GetZRange(DBloodActor *actor, int *ceilZ, Collision *ceilColl, int *floorZ,
int nSector = ceilColl->index; int nSector = ceilColl->index;
if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (sector[nSector].ceilingstat & 1)) if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (sector[nSector].ceilingstat & 1))
*ceilZ = 0x80000000; *ceilZ = 0x80000000;
if (gLowerLink[nSector] >= 0) auto actor = getLowerLink(nSector);
if (actor)
{ {
int nSprite = gLowerLink[nSector]; auto link = actor->GetOwner();
int nLink = sprite[nSprite].owner & 0xfff; vec3_t lpos = { pSprite->x + link->s().x - actor->s().x, pSprite->y + link->s().y - actor->s().y, pSprite->z + link->s().z - actor->s().z };
vec3_t lpos = { pSprite->x + sprite[nLink].x - sprite[nSprite].x, pSprite->y + sprite[nLink].y - sprite[nSprite].y, getzrange(&lpos, link->s().sectnum, (int32_t*)ceilZ, &ceilHit, &nTemp1, &nTemp2, nDist, nMask);
pSprite->z + sprite[nLink].z - sprite[nSprite].z }; *ceilZ -= link->s().z - actor->s().z;
getzrange(&lpos, sprite[nLink].sectnum, (int32_t*)ceilZ, &ceilHit, &nTemp1, &nTemp2, nDist, nMask);
*ceilZ -= sprite[nLink].z - sprite[nSprite].z;
ceilColl->setFromEngine(ceilHit); ceilColl->setFromEngine(ceilHit);
} }
} }
@ -691,14 +688,14 @@ void GetZRangeAtXYZ(int x, int y, int z, int nSector, int *ceilZ, Collision* cei
XSECTOR *pXSector = &xsector[sector[nSector].extra]; XSECTOR *pXSector = &xsector[sector[nSector].extra];
*floorZ += pXSector->Depth << 10; *floorZ += pXSector->Depth << 10;
} }
if (gUpperLink[nSector] >= 0) auto actor = getUpperLink(nSector);
if (actor)
{ {
int nSprite = gUpperLink[nSector]; auto link = actor->GetOwner();
int nLink = sprite[nSprite].owner & 0xfff; lpos = { x+link->s().x-actor->s().x, y+link->s().y-actor->s().y, z+link->s().z-actor->s().z };
lpos = { x + sprite[nLink].x - sprite[nSprite].x, y + sprite[nLink].y - sprite[nSprite].y, getzrange(&lpos, link->s().sectnum, &nTemp1, &nTemp2, (int32_t*)floorZ, &floorHit, nDist, nMask);
z + sprite[nLink].z - sprite[nSprite].z }; floorColl->setFromEngine(floorHit);
getzrange(&lpos, sprite[nLink].sectnum, &nTemp1, &nTemp2, (int32_t*)floorZ, &floorHit, nDist, nMask); *floorZ -= link->s().z - actor->s().z;
*floorZ -= sprite[nLink].z - sprite[nSprite].z;
} }
} }
if (ceilColl->type == kHitSector) if (ceilColl->type == kHitSector)
@ -706,14 +703,14 @@ void GetZRangeAtXYZ(int x, int y, int z, int nSector, int *ceilZ, Collision* cei
int nSector = ceilColl->index; int nSector = ceilColl->index;
if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (sector[nSector].ceilingstat & 1)) if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (sector[nSector].ceilingstat & 1))
*ceilZ = 0x80000000; *ceilZ = 0x80000000;
if (gLowerLink[nSector] >= 0) auto actor = getLowerLink(nSector);
if (actor)
{ {
int nSprite = gLowerLink[nSector]; auto link = actor->GetOwner();
int nLink = sprite[nSprite].owner & 0xfff; lpos = { x+link->s().x-actor->s().x, y+link->s().y-actor->s().y, z+link->s().z-actor->s().z };
lpos = { x + sprite[nLink].x - sprite[nSprite].x, y + sprite[nLink].y - sprite[nSprite].y, getzrange(&lpos, link->s().sectnum, (int32_t*)ceilZ, &ceilHit, &nTemp1, &nTemp2, nDist, nMask);
z + sprite[nLink].z - sprite[nSprite].z }; ceilColl->setFromEngine(ceilHit);
getzrange(&lpos, sprite[nLink].sectnum, (int32_t*)ceilZ, &ceilHit, &nTemp1, &nTemp2, nDist, nMask); *ceilZ -= link->s().z - actor->s().z;
*ceilZ -= sprite[nLink].z - sprite[nSprite].z;
} }
} }
} }