- Blood: transitioned several functions in actor.cpp to the new method to acces the x() data.

This commit is contained in:
Christoph Oelckers 2021-11-19 18:08:05 +01:00
parent 32f141ad39
commit ccd6af6272
3 changed files with 27 additions and 41 deletions

View file

@ -2335,12 +2335,9 @@ TArray<POSTPONE> gPost;
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool IsUnderwaterSector(int nSector) bool IsUnderwaterSector(sectortype* pSector)
{ {
int nXSector = sector[nSector].extra; return !!pSector->hasX() && pSector->xs().Underwater;
if (nXSector > 0 && xsector[nXSector].Underwater)
return 1;
return 0;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -4170,13 +4167,9 @@ static void actKickObject(DBloodActor* kicker, DBloodActor* kicked)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static void actTouchFloor(DBloodActor* actor, int nSector) static void actTouchFloor(DBloodActor* actor, sectortype* pSector)
{ {
assert(actor != nullptr); XSECTOR* pXSector = pSector->hasX()? &pSector->xs() : nullptr;
assert(validSectorIndex(nSector));
sectortype* pSector = &sector[nSector];
XSECTOR* pXSector = nullptr;
if (pSector->extra > 0) pXSector = &xsector[pSector->extra];
bool doDamage = (pXSector && (pSector->type == kSectorDamage || pXSector->damageType > 0)); bool doDamage = (pXSector && (pSector->type == kSectorDamage || pXSector->damageType > 0));
// don't allow damage for damage sectors if they are not enabled // don't allow damage for damage sectors if they are not enabled
@ -4196,7 +4189,7 @@ static void actTouchFloor(DBloodActor* actor, int nSector)
actDamageSprite(actor, actor, nDamageType, scale(4, nDamage, 120) << 4); actDamageSprite(actor, actor, nDamageType, scale(4, nDamage, 120) << 4);
} }
if (tileGetSurfType(sector[nSector].floorpicnum) == kSurfLava) if (tileGetSurfType(pSector->floorpicnum) == kSurfLava)
{ {
actDamageSprite(actor, actor, kDamageBurn, 16); actDamageSprite(actor, actor, kDamageBurn, 16);
sfxPlay3DSound(actor, 352, 5, 2); sfxPlay3DSound(actor, 352, 5, 2);
@ -4401,7 +4394,7 @@ static void checkFloorHit(DBloodActor* actor)
case kHitWall: case kHitWall:
break; break;
case kHitSector: case kHitSector:
actTouchFloor(actor, coll.index); actTouchFloor(actor, coll.sector());
break; break;
case kHitSprite: case kHitSprite:
if (coll.actor->hasX()) if (coll.actor->hasX())
@ -4581,14 +4574,11 @@ void actAirDrag(DBloodActor* actor, int a2)
int wind_x = 0; int wind_x = 0;
int wind_y = 0; int wind_y = 0;
int nSector = pSprite->sectnum; assert(validSectorIndex(pSprite->sectnum));
assert(validSectorIndex(nSector)); sectortype* pSector = pSprite->sector();
sectortype* pSector = &sector[nSector]; if (pSector->hasX())
int nXSector = pSector->extra;
if (nXSector > 0)
{ {
assert(nXSector < kMaxXSectors); XSECTOR* pXSector = &pSector->xs();
XSECTOR* pXSector = &xsector[nXSector];
if (pXSector->windVel && (pXSector->windAlways || pXSector->busy)) if (pXSector->windVel && (pXSector->windAlways || pXSector->busy))
{ {
int wind = pXSector->windVel << 12; int wind = pXSector->windVel << 12;
@ -4698,7 +4688,7 @@ static Collision MoveThing(DBloodActor* actor)
GetActorExtents(actor, &top, &bottom); GetActorExtents(actor, &top, &bottom);
if (bottom >= floorZ) if (bottom >= floorZ)
{ {
actTouchFloor(actor, pSprite->sectnum); actTouchFloor(actor, pSprite->sector());
actor->hit.florhit = floorColl; actor->hit.florhit = floorColl;
pSprite->z += floorZ - bottom; pSprite->z += floorZ - bottom;
@ -4913,10 +4903,8 @@ void MoveDude(DBloodActor* actor)
if (pHitWall->nextsector != -1) if (pHitWall->nextsector != -1)
{ {
sectortype* pHitSector = &sector[pHitWall->nextsector]; sectortype* pHitSector = pHitWall->nextSector();
XSECTOR* pHitXSector = nullptr; XSECTOR* pHitXSector = pHitSector->hasX()? &pHitSector->xs() : nullptr;
if (pHitSector->extra > 0)
pHitXSector = &xsector[pHitSector->extra];
if (pDudeInfo->lockOut && pHitXSector && pHitXSector->Wallpush && !pHitXSector->Key && !pHitXSector->dudeLockout && !pHitXSector->state && !pHitXSector->busy && !pPlayer) if (pDudeInfo->lockOut && pHitXSector && pHitXSector->Wallpush && !pHitXSector->Key && !pHitXSector->dudeLockout && !pHitXSector->state && !pHitXSector->busy && !pPlayer)
trTriggerSector(pHitWall->nextsector, pHitXSector, kCmdSectorPush); trTriggerSector(pHitWall->nextsector, pHitXSector, kCmdSectorPush);
@ -4936,24 +4924,23 @@ void MoveDude(DBloodActor* actor)
assert(validSectorIndex(nSector)); assert(validSectorIndex(nSector));
FindSector(pSprite->x, pSprite->y, pSprite->z, &nSector); FindSector(pSprite->x, pSprite->y, pSprite->z, &nSector);
} }
auto pSector = &sector[nSector];
XSECTOR* pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
if (pSprite->sectnum != nSector) if (pSprite->sectnum != nSector)
{ {
assert(validSectorIndex(nSector)); assert(validSectorIndex(pSprite->sectnum));
XSECTOR* pXSector; auto pOldSector = pSprite->sector();
int nXSector = sector[pSprite->sectnum].extra; XSECTOR* pXOldSector = pOldSector->hasX()? &pOldSector->xs() : nullptr;
if (nXSector > 0)
pXSector = &xsector[nXSector]; if (pXOldSector && pXOldSector->Exit && (pPlayer || !pXOldSector->dudeLockout))
else trTriggerSector(pSprite->sectnum, pXOldSector, kCmdSectorExit);
pXSector = nullptr;
if (pXSector && pXSector->Exit && (pPlayer || !pXSector->dudeLockout))
trTriggerSector(pSprite->sectnum, pXSector, kCmdSectorExit);
ChangeActorSect(actor, nSector); ChangeActorSect(actor, nSector);
nXSector = sector[nSector].extra;
pXSector = (nXSector > 0) ? &xsector[nXSector] : nullptr;
if (pXSector && pXSector->Enter && (pPlayer || !pXSector->dudeLockout)) if (pXSector && pXSector->Enter && (pPlayer || !pXSector->dudeLockout))
{ {
if (sector[nSector].type == kSectorTeleport) if (pSector->type == kSectorTeleport)
pXSector->actordata = actor; pXSector->actordata = actor;
trTriggerSector(nSector, pXSector, kCmdSectorEnter); trTriggerSector(nSector, pXSector, kCmdSectorEnter);
} }
@ -4962,9 +4949,8 @@ void MoveDude(DBloodActor* actor)
} }
int bUnderwater = 0; int bUnderwater = 0;
int bDepth = 0; int bDepth = 0;
if (sector[nSector].extra > 0) if (pXSector)
{ {
XSECTOR* pXSector = &xsector[sector[nSector].extra];
if (pXSector->Underwater) bUnderwater = 1; if (pXSector->Underwater) bUnderwater = 1;
if (pXSector->Depth) bDepth = 1; if (pXSector->Depth) bDepth = 1;
} }

View file

@ -210,7 +210,7 @@ void NapalmSeqCallback(int, int);
void sub_3888C(int, int); void sub_3888C(int, int);
void TreeToGibCallback(int, int); void TreeToGibCallback(int, int);
bool IsUnderwaterSector(int nSector); bool IsUnderwaterSector(sectortype* pSector);
void actInit(); void actInit();
int actWallBounceVector(int *x, int *y, int nWall, int a4); int actWallBounceVector(int *x, int *y, int nWall, int a4);
int actFloorBounceVector(int *x, int *y, int *z, int nSector, int a5); int actFloorBounceVector(int *x, int *y, int *z, int nSector, int a5);

View file

@ -771,7 +771,7 @@ void playerStart(int nPlayer, int bNewLevel)
{ {
viewInitializePrediction(); viewInitializePrediction();
} }
if (IsUnderwaterSector(pSprite->sectnum)) if (IsUnderwaterSector(pSprite->sector()))
{ {
pPlayer->posture = 1; pPlayer->posture = 1;
pPlayer->pXSprite->medium = kMediumWater; pPlayer->pXSprite->medium = kMediumWater;