- deal with most of PLAYER::pSprite.

This commit is contained in:
Christoph Oelckers 2021-12-23 10:44:36 +01:00
parent f59af2cc2d
commit 648537a96b
4 changed files with 55 additions and 61 deletions

View file

@ -1243,9 +1243,9 @@ void nnExtProcessSuperSprites()
if (!pPlayer || !pPlayer->actor->hasX() || pPlayer->pXSprite->health <= 0)
continue;
spritetype* pPlaySprite = pPlayer->pSprite;
GetSpriteExtents(pPlaySprite, &ztop2, &zbot2);
if (cansee(x, y, z, pSightSect, pPlaySprite->pos.X, pPlaySprite->pos.Y, ztop2, pPlaySprite->sector()))
auto plActor = pPlayer->actor;
GetActorExtents(plActor, &ztop2, &zbot2);
if (cansee(x, y, z, pSightSect, plActor->spr.pos.X, plActor->spr.pos.Y, ztop2, plActor->spr.sector()))
{
if (pXSightSpr->Sight)
{
@ -8205,14 +8205,14 @@ DBloodActor* aiPatrolSearchTargets(DBloodActor* actor)
pPlayer = &gPlayer[i];
if (!pPlayer->actor->hasX()) continue;
spritetype* pSpr = pPlayer->pSprite;
auto plActor = pPlayer->actor;
XSPRITE* pXSpr = &pPlayer->actor->x();
if (pXSpr->health <= 0)
continue;
newtarget = nullptr;
seeChance = hearChance = 0x0000;
x = pSpr->pos.X, y = pSpr->pos.Y, z = pSpr->pos.Z, dx = x - actor->spr.pos.X, dy = y - actor->spr.pos.Y; nDist = approxDist(dx, dy);
x = plActor->spr.pos.X, y = plActor->spr.pos.Y, z = plActor->spr.pos.Z, dx = x - actor->spr.pos.X, dy = y - actor->spr.pos.Y; nDist = approxDist(dx, dy);
seeDist = (stealth) ? pDudeInfo->seeDist / 3 : pDudeInfo->seeDist >> 1;
hearDist = pDudeInfo->hearDist; feelDist = hearDist >> 1;
@ -8223,7 +8223,7 @@ DBloodActor* aiPatrolSearchTargets(DBloodActor* actor)
{
eyeAboveZ = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
if (nDist < seeDist >> 3) GetActorExtents(pPlayer->actor, &z, &j); //use ztop of the target sprite
if (!cansee(x, y, z, pSpr->sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - eyeAboveZ, actor->spr.sector()))
if (!cansee(x, y, z, plActor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - eyeAboveZ, actor->spr.sector()))
continue;
}
else
@ -8399,17 +8399,16 @@ DBloodActor* aiPatrolSearchTargets(DBloodActor* actor)
bool trgt = (both || !dude); // target must be in this region
bool crouch = (pSteal->flags & kModernTypeFlag8); // target must crouch
//bool floor = (pSteal->cstat & CSTAT_SPRITE_BLOCK); // target (or dude?) must touch floor of the sector
if (trgt)
{
if (pXSteal->data1 > 0)
{
if (approxDist(abs(pSteal->pos.X - pSpr->pos.X) >> 4, abs(pSteal->pos.Y - pSpr->pos.Y) >> 4) >= pXSteal->data1)
if (approxDist(abs(pSteal->pos.X - plActor->spr.pos.X) >> 4, abs(pSteal->pos.Y - plActor->spr.pos.Y) >> 4) >= pXSteal->data1)
continue;
}
else if (pSpr->sector() != pSteal->sector())
else if (plActor->spr.sector() != pSteal->sector())
continue;
if (crouch && pPlayer->posture == kPostureStand)
@ -8424,7 +8423,7 @@ DBloodActor* aiPatrolSearchTargets(DBloodActor* actor)
continue;
}
else if (pSpr->sector() != pSteal->sector())
else if (plActor->spr.sector() != pSteal->sector())
continue;
}

View file

@ -865,10 +865,10 @@ bool findDroppedLeech(PLAYER *a1, DBloodActor *a2)
bool PickupItem(PLAYER *pPlayer, DBloodActor* itemactor)
{
spritetype *pSprite = pPlayer->pSprite;
char buffer[80];
int pickupSnd = 775;
int nType = itemactor->spr.type - kItemBase;
auto plActor = pPlayer->actor;
switch (itemactor->spr.type) {
case kItemShadowCloak:
@ -1087,7 +1087,7 @@ bool PickupItem(PLAYER *pPlayer, DBloodActor* itemactor)
return 1;
}
sfxPlay3DSound(pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z, pickupSnd, pSprite->sector());
sfxPlay3DSound(plActor->spr.pos.X, plActor->spr.pos.Y, plActor->spr.pos.Z, pickupSnd, plActor->spr.sector());
return 1;
}
@ -1194,11 +1194,11 @@ void PickUp(PLAYER *pPlayer, DBloodActor* actor)
void CheckPickUp(PLAYER *pPlayer)
{
spritetype *pSprite = pPlayer->pSprite;
int x = pSprite->pos.X;
int y = pSprite->pos.Y;
int z = pSprite->pos.Z;
auto pSector = pSprite->sector();
auto plActor = pPlayer->actor;
int x = plActor->spr.pos.X;
int y = plActor->spr.pos.Y;
int z = plActor->spr.pos.Z;
auto pSector = plActor->spr.sector();
BloodStatIterator it(kStatItem);
while (auto itemactor = it.Next())
{
@ -1211,7 +1211,7 @@ void CheckPickUp(PLAYER *pPlayer)
if (dy > 48)
continue;
int top, bottom;
GetSpriteExtents(pSprite, &top, &bottom);
GetActorExtents(plActor, &top, &bottom);
int vb = 0;
if (itemactor->spr.pos.Z < top)
vb = (top-itemactor->spr.pos.Z)>>8;
@ -1231,13 +1231,13 @@ void CheckPickUp(PLAYER *pPlayer)
int ActionScan(PLAYER *pPlayer, HitInfo* out)
{
auto plActor = pPlayer->actor;
*out = {};
spritetype *pSprite = pPlayer->pSprite;
int x = bcos(pSprite->ang);
int y = bsin(pSprite->ang);
int x = bcos(plActor->spr.ang);
int y = bsin(plActor->spr.ang);
int z = pPlayer->slope;
int hit = HitScan(pPlayer->actor, pPlayer->zView, x, y, z, 0x10000040, 128);
int hitDist = approxDist(pSprite->pos.X-gHitInfo.hitpos.X, pSprite->pos.Y-gHitInfo.hitpos.Y)>>4;
int hitDist = approxDist(plActor->spr.pos.X-gHitInfo.hitpos.X, plActor->spr.pos.Y-gHitInfo.hitpos.Y)>>4;
if (hitDist < 64)
{
switch (hit)
@ -1247,7 +1247,6 @@ int ActionScan(PLAYER *pPlayer, HitInfo* out)
auto hitactor = gHitInfo.actor();
if (!hitactor || !hitactor->hasX()) return -1;
out->hitActor = hitactor;
spritetype* pSprite = &hitactor->s();
XSPRITE* pXSprite = &hitactor->x();
if (hitactor->spr.statnum == kStatThing)
{
@ -1304,8 +1303,8 @@ int ActionScan(PLAYER *pPlayer, HitInfo* out)
}
}
}
out->hitSector = pSprite->sector();
if (pSprite->sector()->hasX() && pSprite->sector()->xs().Push)
out->hitSector = plActor->spr.sector();
if (plActor->spr.sector()->hasX() && plActor->spr.sector()->xs().Push)
return 6;
return -1;
}
@ -1329,11 +1328,11 @@ void UpdatePlayerSpriteAngle(PLAYER *pPlayer)
void doslopetilting(PLAYER* pPlayer, double const scaleAdjust = 1)
{
auto* const pSprite = pPlayer->pSprite;
auto plActor = pPlayer->actor;
auto* const pXSprite = pPlayer->pXSprite;
int const florhit = pPlayer->actor->hit.florhit.type;
bool const va = pXSprite->height < 16 && (florhit == kHitSector || florhit == 0) ? 1 : 0;
pPlayer->horizon.calcviewpitch(pSprite->pos.vec2, buildang(pSprite->ang), va, pSprite->sector()->floorstat & CSTAT_SECTOR_SLOPE, pSprite->sector(), scaleAdjust);
pPlayer->horizon.calcviewpitch(plActor->spr.pos.vec2, buildang(plActor->spr.ang), va, plActor->spr.sector()->floorstat & CSTAT_SECTOR_SLOPE, plActor->spr.sector(), scaleAdjust);
}
void ProcessInput(PLAYER *pPlayer)
@ -1350,7 +1349,6 @@ void ProcessInput(PLAYER *pPlayer)
pPlayer->angle.resetadjustment();
DBloodActor* actor = pPlayer->actor;
spritetype *pSprite = pPlayer->pSprite;
XSPRITE *pXSprite = pPlayer->pXSprite;
POSTURE *pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture];
InputPacket *pInput = &pPlayer->input;
@ -1370,7 +1368,7 @@ void ProcessInput(PLAYER *pPlayer)
DBloodActor* fragger = pPlayer->fragger;
if (fragger)
{
pPlayer->angle.addadjustment(getincanglebam(pPlayer->angle.ang, bvectangbam(fragger->spr.pos.X - pSprite->pos.X, fragger->spr.pos.Y - pSprite->pos.Y)));
pPlayer->angle.addadjustment(getincanglebam(pPlayer->angle.ang, bvectangbam(fragger->spr.pos.X - actor->spr.pos.X, fragger->spr.pos.Y - actor->spr.pos.Y)));
}
pPlayer->deathTime += 4;
if (!bSeqStat)
@ -1404,8 +1402,8 @@ void ProcessInput(PLAYER *pPlayer)
}
if (pPlayer->posture == 1)
{
int x = Cos(pSprite->ang);
int y = Sin(pSprite->ang);
int x = Cos(actor->spr.ang);
int y = Sin(actor->spr.ang);
if (pInput->fvel)
{
int forward = pInput->fvel;
@ -1429,8 +1427,8 @@ void ProcessInput(PLAYER *pPlayer)
int speed = 0x10000;
if (pXSprite->height > 0)
speed -= DivScale(pXSprite->height, 256, 16);
int x = Cos(pSprite->ang);
int y = Sin(pSprite->ang);
int x = Cos(actor->spr.ang);
int y = Sin(actor->spr.ang);
if (pInput->fvel)
{
int forward = pInput->fvel;
@ -1654,25 +1652,24 @@ void ProcessInput(PLAYER *pPlayer)
void playerProcess(PLAYER *pPlayer)
{
DBloodActor* actor = pPlayer->actor;
spritetype *pSprite = pPlayer->pSprite;
XSPRITE *pXSprite = pPlayer->pXSprite;
POSTURE* pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture];
powerupProcess(pPlayer);
int top, bottom;
GetSpriteExtents(pSprite, &top, &bottom);
int dzb = (bottom-pSprite->pos.Z)/4;
int dzt = (pSprite->pos.Z-top)/4;
int dw = pSprite->clipdist<<2;
GetActorExtents(actor, &top, &bottom);
int dzb = (bottom-actor->spr.pos.Z)/4;
int dzt = (actor->spr.pos.Z-top)/4;
int dw = actor->spr.clipdist<<2;
if (!gNoClip)
{
auto pSector = pSprite->sector();
if (pushmove(&pSprite->pos, &pSector, dw, dzt, dzb, CLIPMASK0) == -1)
auto pSector = actor->spr.sector();
if (pushmove(&actor->spr.pos, &pSector, dw, dzt, dzb, CLIPMASK0) == -1)
actDamageSprite(actor, actor, kDamageFall, 500<<4);
if (pSprite->sector() != pSector)
if (actor->spr.sector() != pSector)
{
if (pSector == nullptr)
{
pSector = pSprite->sector();
pSector = actor->spr.sector();
actDamageSprite(actor, actor, kDamageFall, 500<<4);
}
else
@ -1744,10 +1741,10 @@ void playerProcess(PLAYER *pPlayer)
if (pPlayer->posture == 1)
{
pPlayer->isUnderwater = 1;
auto link = pSprite->sector()->lowerLink;
auto link = actor->spr.sector()->lowerLink;
if (link && (link->spr.type == kMarkerLowGoo || link->spr.type == kMarkerLowWater))
{
if (getceilzofslopeptr(pSprite->sector(), pSprite->pos.X, pSprite->pos.Y) > pPlayer->zView)
if (getceilzofslopeptr(actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y) > pPlayer->zView)
pPlayer->isUnderwater = 0;
}
}
@ -1929,10 +1926,9 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage
nDamage = playerDamageArmor(pPlayer, nDamageType, nDamage);
pPlayer->painEffect = ClipHigh(pPlayer->painEffect+(nDamage>>3), 600);
spritetype *pSprite = pPlayer->pSprite;
XSPRITE *pXSprite = pPlayer->pXSprite;
DBloodActor* pActor = pPlayer->actor;
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO *pDudeInfo = getDudeInfo(pActor->spr.type);
int nDeathSeqID = -1;
int nKneelingPlayer = -1;
bool va = playerSeqPlaying(pPlayer, 16);
@ -1955,8 +1951,8 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage
default:
{
int top, bottom;
GetSpriteExtents(pSprite, &top, &bottom);
CGibPosition gibPos(pSprite->pos.X, pSprite->pos.Y, top);
GetActorExtents(pActor, &top, &bottom);
CGibPosition gibPos(pActor->spr.pos.X, pActor->spr.pos.Y, top);
CGibVelocity gibVel(pActor->xvel >> 1, pActor->yvel >> 1, -0xccccc);
GibSprite(pActor, GIBTYPE_27, &gibPos, &gibVel);
GibSprite(pActor, GIBTYPE_7, NULL, NULL);
@ -2043,9 +2039,9 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage
if (nDeathSeqID != 16)
{
powerupClear(pPlayer);
if (pSprite->sector()->hasX() && pSprite->sector()->xs().Exit)
trTriggerSector(pSprite->sector(), kCmdSectorExit);
pSprite->flags |= 7;
if (pActor->spr.sector()->hasX() && pActor->spr.sector()->xs().Exit)
trTriggerSector(pActor->spr.sector(), kCmdSectorExit);
pActor->spr.flags |= 7;
for (int p = connecthead; p >= 0; p = connectpoint2[p])
{
if (gPlayer[p].fragger == pPlayer->actor && gPlayer[p].deathTime > 0)
@ -2134,7 +2130,6 @@ void playerLandingSound(PLAYER *pPlayer)
604,
603
};
spritetype *pSprite = pPlayer->pSprite;
SPRITEHIT* pHit = &pPlayer->actor->hit;
if (pHit->florhit.type != kHitNone)
{

View file

@ -75,7 +75,7 @@ void BloodSoundEngine::CalcPosVel(int type, const void* source, const float pt[3
{
FVector3 camera;
if (gMe && gMe->pSprite) camera = GetSoundPos(&gMe->actor->spr.pos);
if (gMe && gMe->actor) camera = GetSoundPos(&gMe->actor->spr.pos);
else camera = { 0, 0, 0 }; // don't crash if there is no player.
if (vel) vel->Zero();
@ -111,7 +111,7 @@ void GameInterface::UpdateSounds()
{
SoundListener listener;
if (gMe->pSprite)
if (gMe->actor)
{
listener.angle = -gMe->actor->spr.ang * float(BAngRadian); // Build uses a period of 2048.
listener.velocity.Zero();

View file

@ -716,7 +716,7 @@ void viewDrawScreen(bool sceneonly)
UpdateStatusBar();
int zn = ((gView->zWeapon-gView->zView-(12<<8))>>7)+220;
PLAYER *pPSprite = &gPlayer[gMe->actor->spr.type-kDudePlayer1];
if (IsPlayerSprite(gMe->pSprite) && pPSprite->hand == 1)
if (gMe->actor->IsPlayerActor() && pPSprite->hand == 1)
{
gChoke.animateChoke(160, zn, (int)gInterpolate);
}
@ -760,7 +760,7 @@ bool GameInterface::DrawAutomapPlayer(int mx, int my, int x, int y, int z, int a
for (int i = connecthead; i >= 0; i = connectpoint2[i])
{
PLAYER* pPlayer = &gPlayer[i];
spritetype* pSprite = pPlayer->pSprite;
auto actor = pPlayer->actor;
int xvect = -bsin(a) * z;
int yvect = -bcos(a) * z;
@ -773,20 +773,20 @@ bool GameInterface::DrawAutomapPlayer(int mx, int my, int x, int y, int z, int a
if (i == gView->nPlayer || gGameOptions.nGameType == 1)
{
int nTile = pSprite->picnum;
int nTile = actor->spr.picnum;
int ceilZ, floorZ;
Collision ceilHit, floorHit;
GetZRange(gView->actor, &ceilZ, &ceilHit, &floorZ, &floorHit, (pSprite->clipdist << 2) + 16, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR);
GetZRange(gView->actor, &ceilZ, &ceilHit, &floorZ, &floorHit, (actor->spr.clipdist << 2) + 16, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR);
int nTop, nBottom;
GetSpriteExtents(pSprite, &nTop, &nBottom);
int nScale = (pSprite->yrepeat + ((floorZ - nBottom) >> 8)) * z;
GetActorExtents(actor, &nTop, &nBottom);
int nScale = (actor->spr.yrepeat + ((floorZ - nBottom) >> 8)) * z;
nScale = ClipRange(nScale, 8000, 65536 << 1);
// Players on automap
double x = xdim / 2. + x1 / double(1 << 12);
double y = ydim / 2. + y1 / double(1 << 12);
// This very likely needs fixing later
DrawTexture(twod, tileGetTexture(nTile, true), xx, yy, DTA_ClipLeft, windowxy1.X, DTA_ClipTop, windowxy1.Y, DTA_ScaleX, z/1536., DTA_ScaleY, z/1536., DTA_CenterOffset, true,
DTA_ClipRight, windowxy2.X + 1, DTA_ClipBottom, windowxy2.Y + 1, DTA_Alpha, (pSprite->cstat & CSTAT_SPRITE_TRANSLUCENT ? 0.5 : 1.), TAG_DONE);
DTA_ClipRight, windowxy2.X + 1, DTA_ClipBottom, windowxy2.Y + 1, DTA_Alpha, (actor->spr.cstat & CSTAT_SPRITE_TRANSLUCENT ? 0.5 : 1.), TAG_DONE);
}
}
return true;