Skip to content

Commit

Permalink
- Exhumed: Move moving block check code back into player ticker for now.
Browse files Browse the repository at this point in the history
* Reverts 52b2d1c
* Upon closer inspection, the original code here used `zz` on the player stack, which was re-obtained again using the actor's Z vel, however the actor's Z vel gets modified along the way which could break how this code is meant to work.
* Should be split again but requires holistic thought.
  • Loading branch information
mjr4077au committed Mar 24, 2023
1 parent e2d3c4d commit 0271a49
Showing 1 changed file with 58 additions and 72 deletions.
130 changes: 58 additions & 72 deletions source/games/exhumed/src/player.cpp
Expand Up @@ -752,77 +752,6 @@ void AIPlayer::Damage(RunListEvent* ev)
//
//---------------------------------------------------------------------------

static void CheckMovingBlocks(Player* const pPlayer, Collision& nMove, DVector3& spr_pos, sectortype* spr_sect)
{
const auto pPlayerActor = pPlayer->pActor;
const double zz = pPlayerActor->vel.Z;

if (nMove.type == kHitSector || nMove.type == kHitWall)
{
sectortype* sect;
DAngle nNormal = nullAngle;

if (nMove.type == kHitSector)
{
sect = nMove.hitSector;
// Hm... Normal calculation here was broken.
}
else //if (nMove.type == kHitWall)
{
sect = nMove.hitWall->nextSector();
nNormal = nMove.hitWall->normalAngle();
}

// moving blocks - move this to a separate function!
if (sect != nullptr)
{
const auto nDiff = absangle(nNormal, pPlayerActor->spr.Angles.Yaw + DAngle180);

if ((sect->hitag == 45) && bTouchFloor && nDiff <= DAngle45)
{
pPlayer->pPlayerPushSect = sect;

DVector2 vel = pPlayer->vel;
auto nMyAngle = vel.Angle().Normalized360();

setsectinterpolate(sect);
MoveSector(sect, nMyAngle, vel);

if (pPlayer->nPlayerPushSound == -1)
{
const int nBlock = pPlayer->pPlayerPushSect->extra;
pPlayer->nPlayerPushSound = nBlock;
DExhumedActor* pBlockActor = sBlockInfo[nBlock].pActor;

D3PlayFX(StaticSound[kSound23], pBlockActor, 0x4000);
}
else
{
pPlayerActor->spr.pos = spr_pos;
ChangeActorSect(pPlayerActor, spr_sect);
}

movesprite(pPlayerActor, vel, zz, -20, CLIPMASK0);
}
else if (pPlayer->nPlayerPushSound != -1)
{
if (pPlayer->pPlayerPushSect != nullptr)
{
StopActorSound(sBlockInfo[pPlayer->pPlayerPushSect->extra].pActor);
}

pPlayer->nPlayerPushSound = -1;
}
}
}
}

//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------

static void doPlayerCurrentItem(Player* const pPlayer)
{
UseItem(pPlayer->nPlayer, pPlayer->nCurrentItem);
Expand Down Expand Up @@ -1331,7 +1260,64 @@ void AIPlayer::Tick(RunListEvent* ev)
}
}

CheckMovingBlocks(pPlayer, nMove, spr_pos, spr_sect);
if (nMove.type == kHitSector || nMove.type == kHitWall)
{
sectortype* sect;
DAngle nNormal = nullAngle;

if (nMove.type == kHitSector)
{
sect = nMove.hitSector;
// Hm... Normal calculation here was broken.
}
else //if (nMove.type == kHitWall)
{
sect = nMove.hitWall->nextSector();
nNormal = nMove.hitWall->normalAngle();
}

// moving blocks - move this to a separate function!
if (sect != nullptr)
{
const auto nDiff = absangle(nNormal, pPlayerActor->spr.Angles.Yaw + DAngle180);

if ((sect->hitag == 45) && bTouchFloor && nDiff <= DAngle45)
{
pPlayer->pPlayerPushSect = sect;

DVector2 vel = pPlayer->vel;
auto nMyAngle = vel.Angle().Normalized360();

setsectinterpolate(sect);
MoveSector(sect, nMyAngle, vel);

if (pPlayer->nPlayerPushSound == -1)
{
const int nBlock = pPlayer->pPlayerPushSect->extra;
pPlayer->nPlayerPushSound = nBlock;
DExhumedActor* pBlockActor = sBlockInfo[nBlock].pActor;

D3PlayFX(StaticSound[kSound23], pBlockActor, 0x4000);
}
else
{
pPlayerActor->spr.pos = spr_pos;
ChangeActorSect(pPlayerActor, spr_sect);
}

movesprite(pPlayerActor, vel, zz, -20, CLIPMASK0);
}
else if (pPlayer->nPlayerPushSound != -1)
{
if (pPlayer->pPlayerPushSect != nullptr)
{
StopActorSound(sBlockInfo[pPlayer->pPlayerPushSect->extra].pActor);
}

pPlayer->nPlayerPushSound = -1;
}
}
}
}

if (!pPlayer->bPlayerPan && !pPlayer->bLockPan)
Expand Down

0 comments on commit 0271a49

Please sign in to comment.