- SW: Wrap calls that add/subtract PLAYER::PlayerNowPosition.Z.

This commit is contained in:
Mitchell Richters 2022-11-16 13:29:04 +11:00 committed by Christoph Oelckers
parent 6226d302f5
commit 4e0aa1add1
2 changed files with 19 additions and 15 deletions

View file

@ -724,6 +724,10 @@ struct PLAYER
{ {
PlayerNowPosition.Z = val; PlayerNowPosition.Z = val;
} }
void posZadd(const double val)
{
PlayerNowPosition.Z += val;
}
}; };
extern PLAYER Player[MAX_SW_PLAYERS_REG+1]; extern PLAYER Player[MAX_SW_PLAYERS_REG+1];

View file

@ -1486,7 +1486,7 @@ void DoPlayerSetWadeDepth(PLAYER* pp)
void DoPlayerHeight(PLAYER* pp) void DoPlayerHeight(PLAYER* pp)
{ {
double diff = pp->PlayerNowPosition.Z - (pp->loz - PLAYER_HEIGHTF); double diff = pp->PlayerNowPosition.Z - (pp->loz - PLAYER_HEIGHTF);
pp->PlayerNowPosition.Z -= diff * 0.375; pp->posZadd(-diff * 0.375);
} }
void DoPlayerJumpHeight(PLAYER* pp) void DoPlayerJumpHeight(PLAYER* pp)
@ -1504,7 +1504,7 @@ void DoPlayerJumpHeight(PLAYER* pp)
void DoPlayerCrawlHeight(PLAYER* pp) void DoPlayerCrawlHeight(PLAYER* pp)
{ {
double diff = pp->PlayerNowPosition.Z - (pp->loz - PLAYER_CRAWL_HEIGHTF); double diff = pp->PlayerNowPosition.Z - (pp->loz - PLAYER_CRAWL_HEIGHTF);
pp->PlayerNowPosition.Z -= diff * 0.375; pp->posZadd(-diff * 0.375);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -2986,7 +2986,7 @@ void DoPlayerJump(PLAYER* pp)
} }
// adjust height by jump speed // adjust height by jump speed
pp->PlayerNowPosition.Z += pp->jump_speed * JUMP_FACTOR; pp->posZadd(pp->jump_speed * JUMP_FACTOR);
// if player gets to close the ceiling while jumping // if player gets to close the ceiling while jumping
if (PlayerCeilingHit(pp, pp->hiz + 4)) if (PlayerCeilingHit(pp, pp->hiz + 4))
@ -3060,7 +3060,7 @@ void DoPlayerForceJump(PLAYER* pp)
} }
// adjust height by jump speed // adjust height by jump speed
pp->PlayerNowPosition.Z += pp->jump_speed * JUMP_FACTOR; pp->posZadd(pp->jump_speed * JUMP_FACTOR);
// if player gets to close the ceiling while jumping // if player gets to close the ceiling while jumping
//if (pp->PlayerNowPositionz < pp->hiz + Z(4)) //if (pp->PlayerNowPositionz < pp->hiz + Z(4))
@ -3161,7 +3161,7 @@ void DoPlayerFall(PLAYER* pp)
pp->jump_speed = 4100; pp->jump_speed = 4100;
// adjust player height by jump speed // adjust player height by jump speed
pp->PlayerNowPosition.Z += pp->jump_speed * JUMP_FACTOR; pp->posZadd(pp->jump_speed * JUMP_FACTOR);
if (pp->jump_speed > 2000) if (pp->jump_speed > 2000)
{ {
@ -3227,7 +3227,7 @@ void DoPlayerFall(PLAYER* pp)
// this was causing the z to snap immediately // this was causing the z to snap immediately
// changed it so it stays gradual // changed it so it stays gradual
pp->PlayerNowPosition.Z += recoil_amnt; pp->posZadd(recoil_amnt);
DoPlayerHeight(pp); DoPlayerHeight(pp);
} }
@ -3421,7 +3421,7 @@ void DoPlayerClimb(PLAYER* pp)
// moving UP // moving UP
if (climbVel > 0) if (climbVel > 0)
{ {
pp->PlayerNowPosition.Z -= climbVel; pp->posZadd(-climbVel);
pp->climb_ndx &= 1023; pp->climb_ndx &= 1023;
// if player gets to close the ceiling while climbing // if player gets to close the ceiling while climbing
@ -3455,7 +3455,7 @@ void DoPlayerClimb(PLAYER* pp)
// move DOWN // move DOWN
if (climbVel < 0) if (climbVel < 0)
{ {
pp->PlayerNowPosition.Z -= climbVel; pp->posZadd(-climbVel);
pp->climb_ndx &= 1023; pp->climb_ndx &= 1023;
// if you are touching the floor // if you are touching the floor
@ -3790,7 +3790,7 @@ void DoPlayerFly(PLAYER* pp)
pp->z_speed *= FixedToFloat(58000); pp->z_speed *= FixedToFloat(58000);
pp->PlayerNowPosition.Z += pp->z_speed; pp->posZadd(pp->z_speed);
// Make the min distance from the ceiling/floor match bobbing amount // Make the min distance from the ceiling/floor match bobbing amount
// so the player never goes into the ceiling/floor // so the player never goes into the ceiling/floor
@ -3990,7 +3990,7 @@ int PlayerCanDive(PLAYER* pp)
{ {
if (PlayerInDiveArea(pp)) if (PlayerInDiveArea(pp))
{ {
pp->PlayerNowPosition.Z += 20; pp->posZadd(20);
pp->z_speed = 20; pp->z_speed = 20;
pp->jump_speed = 0; pp->jump_speed = 0;
@ -4357,7 +4357,7 @@ void DoPlayerWarpToSurface(PLAYER* pp)
DoPlayerZrange(pp); DoPlayerZrange(pp);
DoPlayerSetWadeDepth(pp); DoPlayerSetWadeDepth(pp);
pp->PlayerNowPosition.Z -= pp->WadeDepth; pp->posZadd(-pp->WadeDepth);
pp->PlayerPrevPosition = pp->PlayerNowPosition; pp->PlayerPrevPosition = pp->PlayerNowPosition;
@ -4683,7 +4683,7 @@ void DoPlayerDive(PLAYER* pp)
if (abs(pp->z_speed) < 1./16) if (abs(pp->z_speed) < 1./16)
pp->z_speed = 0; pp->z_speed = 0;
pp->PlayerNowPosition.Z += pp->z_speed; pp->posZadd(pp->z_speed);
if (pp->z_speed < 0 && FAF_ConnectArea(pp->cursector)) if (pp->z_speed < 0 && FAF_ConnectArea(pp->cursector))
{ {
@ -5583,7 +5583,7 @@ void DoPlayerDeathJump(PLAYER* pp)
} }
// adjust height by jump speed // adjust height by jump speed
pp->PlayerNowPosition.Z += pp->jump_speed * JUMP_FACTOR; pp->posZadd(pp->jump_speed * JUMP_FACTOR);
// if player gets to close the ceiling while jumping // if player gets to close the ceiling while jumping
//if (pp->posz < pp->hiz + Z(4)) //if (pp->posz < pp->hiz + Z(4))
@ -5620,7 +5620,7 @@ void DoPlayerDeathFall(PLAYER* pp)
pp->jump_speed += PLAYER_DEATH_GRAV; pp->jump_speed += PLAYER_DEATH_GRAV;
// adjust player height by jump speed // adjust player height by jump speed
pp->PlayerNowPosition.Z += pp->jump_speed * JUMP_FACTOR; pp->posZadd(pp->jump_speed * JUMP_FACTOR);
if (pp->lo_sectp && (pp->lo_sectp->extra & SECTFX_SINK)) if (pp->lo_sectp && (pp->lo_sectp->extra & SECTFX_SINK))
{ {
@ -6390,7 +6390,7 @@ void DoPlayerDeathDrown(PLAYER* pp)
if ((pp->Flags & PF_FALLING)) if ((pp->Flags & PF_FALLING))
{ {
pp->PlayerNowPosition.Z += 2; pp->posZadd(2);
if (MoveSkip2 == 0) if (MoveSkip2 == 0)
actor->spr.pos.Z += 4; actor->spr.pos.Z += 4;