mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 00:42:08 +00:00
- Exhumed: Split out player view sector code.
This commit is contained in:
parent
9c471e0209
commit
77fa3f6ea9
1 changed files with 57 additions and 51 deletions
|
@ -1024,6 +1024,62 @@ static void updatePlayerFloorActor(Player* const pPlayer)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void updatePlayerViewSector(Player* const pPlayer, const Collision& nMove, const DVector3& spr_pos, const DVector3& spr_vel, const bool bUnderwater)
|
||||
{
|
||||
const auto pPlayerActor = pPlayer->pActor;
|
||||
const double EyeZ = pPlayerActor->getOffsetZ() + pPlayer->nQuake;
|
||||
auto pViewSect = pPlayerActor->sector();
|
||||
|
||||
while (1)
|
||||
{
|
||||
double nCeilZ = pViewSect->ceilingz;
|
||||
|
||||
if (EyeZ >= nCeilZ)
|
||||
break;
|
||||
|
||||
if (pViewSect->pAbove == nullptr)
|
||||
break;
|
||||
|
||||
pViewSect = pViewSect->pAbove;
|
||||
}
|
||||
|
||||
// Do underwater sector check
|
||||
if (bUnderwater && pViewSect != pPlayerActor->sector() && nMove.type == kHitWall)
|
||||
{
|
||||
auto pos = pPlayerActor->spr.pos;
|
||||
ChangeActorSect(pPlayerActor, pViewSect);
|
||||
|
||||
double fz = pViewSect->floorz - 20;
|
||||
pPlayerActor->spr.pos = DVector3(spr_pos.XY(), fz);
|
||||
|
||||
auto coll = movesprite(pPlayerActor, spr_vel.XY(), 0, 0, CLIPMASK0);
|
||||
if (coll.type == kHitWall)
|
||||
{
|
||||
ChangeActorSect(pPlayerActor, pPlayerActor->sector());
|
||||
pPlayerActor->spr.pos = pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
pPlayerActor->spr.pos.Z = fz-1;
|
||||
D3PlayFX(StaticSound[kSound42], pPlayerActor);
|
||||
}
|
||||
}
|
||||
|
||||
pPlayer->pPlayerViewSect = pViewSect;
|
||||
|
||||
if (nLocalPlayer == pPlayer->nPlayer)
|
||||
{
|
||||
pLocalEyeSect = pPlayer->pPlayerViewSect;
|
||||
CheckAmbience(pLocalEyeSect);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void doPlayerFloorDamage(Player* const pPlayer)
|
||||
{
|
||||
const auto pPlayerActor = pPlayer->pActor;
|
||||
|
@ -1190,60 +1246,10 @@ static bool doPlayerMovement(Player* const pPlayer)
|
|||
pPlayer->ototalvel = pPlayer->totalvel;
|
||||
pPlayer->totalvel = int((spr_pos.XY() - pPlayerActor->spr.pos.XY()).Length() * worldtoint);
|
||||
|
||||
auto pViewSect = pPlayerActor->sector();
|
||||
double EyeZ = pPlayerActor->getOffsetZ() + pPlayer->nQuake;
|
||||
updatePlayerViewSector(pPlayer, nMove, spr_pos, spr_vel, bUnderwater);
|
||||
|
||||
while (1)
|
||||
{
|
||||
double nCeilZ = pViewSect->ceilingz;
|
||||
|
||||
if (EyeZ >= nCeilZ)
|
||||
break;
|
||||
|
||||
if (pViewSect->pAbove == nullptr)
|
||||
break;
|
||||
|
||||
pViewSect = pViewSect->pAbove;
|
||||
}
|
||||
|
||||
// Do underwater sector check
|
||||
if (bUnderwater)
|
||||
{
|
||||
if (pViewSect != pPlayerActor->sector())
|
||||
{
|
||||
if (nMove.type == kHitWall)
|
||||
{
|
||||
auto pos = pPlayerActor->spr.pos;
|
||||
|
||||
ChangeActorSect(pPlayerActor, pViewSect);
|
||||
|
||||
double fz = pViewSect->floorz - 20;
|
||||
pPlayerActor->spr.pos = DVector3(spr_pos.XY(), fz);
|
||||
|
||||
auto coll = movesprite(pPlayerActor, spr_vel.XY(), 0, 0, CLIPMASK0);
|
||||
if (coll.type == kHitWall)
|
||||
{
|
||||
ChangeActorSect(pPlayerActor, pPlayerActor->sector());
|
||||
pPlayerActor->spr.pos = pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
pPlayerActor->spr.pos.Z = fz-1;
|
||||
D3PlayFX(StaticSound[kSound42], pPlayerActor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pPlayer->pPlayerViewSect = pViewSect;
|
||||
pPlayer->nPlayerD = (pPlayerActor->spr.pos - spr_pos);
|
||||
|
||||
if (nLocalPlayer == pPlayer->nPlayer)
|
||||
{
|
||||
pLocalEyeSect = pPlayer->pPlayerViewSect;
|
||||
CheckAmbience(pLocalEyeSect);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue