Commit aba6b2f3 authored by NY00123's avatar NY00123
Browse files

SW: Modify DoPlayerTurn/DoPlayerHorizon to make it possible

for them to modify the player's camq16ang/camq16horiz field
instead of q16ang/q16horiz. Additionally, pass to them the
change in angle/horiz via a parameter, as an alternative
to direct access to the corresponding player input field.
parent b371d767
......@@ -1540,10 +1540,8 @@ DoPlayerCrawlHeight(PLAYERp pp)
}
void
DoPlayerTurn(PLAYERp pp)
DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16avel)
{
fix16_t q16avel;
#define TURN_SHIFT 2
if (!TEST(pp->Flags, PF_TURN_180))
......@@ -1556,12 +1554,12 @@ DoPlayerTurn(PLAYERp pp)
FLAG_KEY_RELEASE(pp, SK_TURN_180);
pp->turn180_target = NORM_ANGLE(fix16_to_int(pp->q16ang) + 1024);
pp->turn180_target = NORM_ANGLE(fix16_to_int(*pq16ang) + 1024);
// make the first turn in the clockwise direction
// the rest will follow
delta_ang = GetDeltaAngle(pp->turn180_target, fix16_to_int(pp->q16ang));
pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + (labs(delta_ang) >> TURN_SHIFT)));
delta_ang = GetDeltaAngle(pp->turn180_target, fix16_to_int(*pq16ang));
*pq16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(*pq16ang) + (labs(delta_ang) >> TURN_SHIFT)));
SET(pp->Flags, PF_TURN_180);
}
......@@ -1576,49 +1574,49 @@ DoPlayerTurn(PLAYERp pp)
{
short delta_ang;
delta_ang = GetDeltaAngle(pp->turn180_target, fix16_to_int(pp->q16ang));
pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + (delta_ang >> TURN_SHIFT)));
delta_ang = GetDeltaAngle(pp->turn180_target, fix16_to_int(*pq16ang));
*pq16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(*pq16ang) + (delta_ang >> TURN_SHIFT)));
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
sprite[pp->PlayerSprite].ang = fix16_to_int(*pq16ang);
if (!Prediction)
{
if (pp->PlayerUnderSprite >= 0)
sprite[pp->PlayerUnderSprite].ang = fix16_to_int(pp->q16ang);
sprite[pp->PlayerUnderSprite].ang = fix16_to_int(*pq16ang);
}
// get new delta to see how close we are
delta_ang = GetDeltaAngle(pp->turn180_target, fix16_to_int(pp->q16ang));
delta_ang = GetDeltaAngle(pp->turn180_target, fix16_to_int(*pq16ang));
if (labs(delta_ang) < (3<<TURN_SHIFT))
{
pp->q16ang = fix16_from_int(pp->turn180_target);
*pq16ang = fix16_from_int(pp->turn180_target);
RESET(pp->Flags, PF_TURN_180);
}
else
return;
}
q16avel = fix16_smul(pp->input.q16avel, fix16_from_int(PLAYER_TURN_SCALE));
q16avel = fix16_smul(q16avel, fix16_from_int(PLAYER_TURN_SCALE));
if (q16avel != 0)
{
// running is not handled here now
q16avel += fix16_sdiv(q16avel, fix16_from_int(4));
pp->q16ang += fix16_sdiv(fix16_mul(q16avel, fix16_from_int(synctics)), fix16_from_int(32));
pp->q16ang = NORM_Q16ANGLE(pp->q16ang);
*pq16ang += fix16_sdiv(fix16_mul(q16avel, fix16_from_int(synctics)), fix16_from_int(32));
*pq16ang = NORM_Q16ANGLE(*pq16ang);
if (PEDANTIC_MODE)
pp->q16ang = fix16_floor(pp->q16ang);
*pq16ang = fix16_floor(*pq16ang);
// update players sprite angle
// NOTE: It's also updated in UpdatePlayerSprite, but needs to be
// here to cover
// all cases.
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
sprite[pp->PlayerSprite].ang = fix16_to_int(*pq16ang);
if (!Prediction)
{
if (pp->PlayerUnderSprite >= 0)
sprite[pp->PlayerUnderSprite].ang = fix16_to_int(pp->q16ang);
sprite[pp->PlayerUnderSprite].ang = fix16_to_int(*pq16ang);
}
}
......@@ -1859,7 +1857,7 @@ PlayerAutoLook(PLAYERp pp)
extern int PlaxCeilGlobZadjust, PlaxFloorGlobZadjust;
void
DoPlayerHorizon(PLAYERp pp)
DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16horz)
{
int i;
#define HORIZ_SPEED (16)
......@@ -1869,9 +1867,9 @@ DoPlayerHorizon(PLAYERp pp)
PlayerAutoLook(pp);
if (pp->input.q16horz)
if (q16horz)
{
pp->q16horizbase += pp->input.q16horz;
pp->q16horizbase += q16horz;
SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING);
}
......@@ -1879,7 +1877,7 @@ DoPlayerHorizon(PLAYERp pp)
{
// if (TEST(pp->Flags, PF_MOUSE_AIMING_ON))
{
pp->q16horiz = pp->q16horizbase = fix16_from_int(100);
*pq16horiz = pp->q16horizbase = fix16_from_int(100);
pp->q16horizoff = 0;
}
// else
......@@ -1896,11 +1894,11 @@ DoPlayerHorizon(PLAYERp pp)
// set looking because player is manually looking
SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING);
// adjust pp->q16horiz negative
// adjust *pq16horiz negative
if (TEST_SYNC_KEY(pp, SK_SNAP_DOWN))
pp->q16horizbase -= fix16_from_int((HORIZ_SPEED/2));
// adjust pp->q16horiz positive
// adjust *pq16horiz positive
if (TEST_SYNC_KEY(pp, SK_SNAP_UP))
pp->q16horizbase += fix16_from_int((HORIZ_SPEED/2));
}
......@@ -1912,11 +1910,11 @@ DoPlayerHorizon(PLAYERp pp)
RESET(pp->Flags, PF_LOCK_HORIZ);
SET(pp->Flags, PF_LOOKING);
// adjust pp->q16horiz negative
// adjust *pq16horiz negative
if (TEST_SYNC_KEY(pp, SK_LOOK_DOWN))
pp->q16horizbase -= fix16_from_int(HORIZ_SPEED);
// adjust pp->q16horiz positive
// adjust *pq16horiz positive
if (TEST_SYNC_KEY(pp, SK_LOOK_UP))
pp->q16horizbase += fix16_from_int(HORIZ_SPEED);
}
......@@ -1926,20 +1924,20 @@ DoPlayerHorizon(PLAYERp pp)
{
if (!(TEST_SYNC_KEY(pp, SK_LOOK_UP) || TEST_SYNC_KEY(pp, SK_LOOK_DOWN)))
{
// not pressing the pp->q16horiz keys
// not pressing the *pq16horiz keys
if (pp->q16horizbase != fix16_from_int(100))
{
// move pp->q16horiz back to 100
// move *pq16horiz back to 100
for (i = 1; i; i--)
{
// this formula does not work for pp->q16horiz = 101-103
// this formula does not work for *pq16horiz = 101-103
pp->q16horizbase += fix16_from_int(25 - (fix16_to_int(pp->q16horizbase) >> 2));
}
}
else
{
// not looking anymore because pp->q16horiz is back at 100
// not looking anymore because *pq16horiz is back at 100
RESET(pp->Flags, PF_LOOKING);
}
}
......@@ -1960,14 +1958,14 @@ DoPlayerHorizon(PLAYERp pp)
//MONO_PRINT(ds);
// add base and offsets
pp->q16horiz = pp->q16horizbase + pp->q16horizoff;
*pq16horiz = pp->q16horizbase + pp->q16horizoff;
#else
if (pp->q16horizbase + pp->q16horizoff < fix16_from_int(PLAYER_HORIZ_MIN))
pp->q16horizbase += fix16_from_int(HORIZ_SPEED);
else if (pp->q16horizbase + pp->q16horizoff > fix16_from_int(PLAYER_HORIZ_MAX))
pp->q16horizbase -= HORIZ_SPEED;
pp->q16horiz = pp->q16horizbase + pp->q16horizoff;
*pq16horiz = pp->q16horizbase + pp->q16horizoff;
#endif
}
......@@ -2566,7 +2564,7 @@ DoPlayerMove(PLAYERp pp)
PLAYER_RUN_LOCK(pp);
DoPlayerTurn(pp);
DoPlayerTurn(pp, &pp->q16ang, pp->input.q16avel);
pp->oldposx = pp->posx;
pp->oldposy = pp->posy;
......@@ -2670,7 +2668,7 @@ DoPlayerMove(PLAYERp pp)
DoPlayerSetWadeDepth(pp);
DoPlayerHorizon(pp);
DoPlayerHorizon(pp, &pp->q16horiz, pp->input.q16horz);
if (pp->cursectnum >= 0 && TEST(sector[pp->cursectnum].extra, SECTFX_DYNAMIC_AREA))
{
......@@ -2880,7 +2878,7 @@ DoPlayerMoveBoat(PLAYERp pp)
OperateSectorObject(pp->sop, fix16_to_int(pp->q16ang), pp->posx, pp->posy);
pp->cursectnum = save_sectnum; // for speed
DoPlayerHorizon(pp);
DoPlayerHorizon(pp, &pp->q16horiz, pp->input.q16horz);
}
#if 0
......@@ -3393,7 +3391,7 @@ DoPlayerMoveTank(PLAYERp pp)
OperateSectorObject(pp->sop, fix16_to_int(pp->q16ang), pp->posx, pp->posy);
pp->cursectnum = save_sectnum; // for speed
DoPlayerHorizon(pp);
DoPlayerHorizon(pp, &pp->q16horiz, pp->input.q16horz);
DoTankTreads(pp);
}
......@@ -3412,7 +3410,7 @@ DoPlayerMoveTurret(PLAYERp pp)
OperateSectorObject(pp->sop, fix16_to_int(pp->q16ang), pp->sop->xmid, pp->sop->ymid);
DoPlayerHorizon(pp);
DoPlayerHorizon(pp, &pp->q16horiz, pp->input.q16horz);
}
void
......@@ -4001,7 +3999,7 @@ DoPlayerClimb(PLAYERp pp)
sp->z = pp->posz + PLAYER_HEIGHT;
changespritesect(pp->PlayerSprite, pp->cursectnum);
DoPlayerHorizon(pp);
DoPlayerHorizon(pp, &pp->q16horiz, pp->input.q16horz);
if (FAF_ConnectArea(pp->cursectnum))
{
......@@ -6769,7 +6767,7 @@ void DoPlayerDeathFollowKiller(PLAYERp pp)
// Allow them to turn fast
PLAYER_RUN_LOCK(pp);
DoPlayerTurn(pp);
DoPlayerTurn(pp, &pp->q16ang, pp->input.q16avel);
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment