SW - First step in tying player input to frame rate:

Add the camq16ang and camq16horiz fields to the player struct.
With the exception of DoPlayerTurn and DoPlayerHorizon, whenever
code in player.cpp updates player's q16ang/q16horiz, also write
the updated values to camq16ang/camq16horiz. These variables'
preceding values are never used in these functions.
This commit is contained in:
NY00123 2020-04-10 23:13:44 +03:00 committed by Christoph Oelckers
parent b447feef91
commit 1f9e319d39
2 changed files with 19 additions and 17 deletions

View file

@ -1172,6 +1172,7 @@ struct PLAYERstruct
// variables that do not fit into sprite structure
int hvel,tilt,tilt_dest;
fix16_t q16horiz, q16horizbase, q16horizoff, q16ang;
fix16_t camq16horiz, camq16ang;
short recoil_amt;
short recoil_speed;
short recoil_ndx;

View file

@ -1332,7 +1332,7 @@ DoPlayerTeleportPause(PLAYERp pp)
void
DoPlayerTeleportToSprite(PLAYERp pp, SPRITEp sp)
{
pp->q16ang = pp->oq16ang = fix16_from_int(sp->ang);
pp->camq16ang = pp->q16ang = pp->oq16ang = fix16_from_int(sp->ang);
pp->posx = pp->oposx = pp->oldposx = sp->x;
pp->posy = pp->oposy = pp->oldposy = sp->y;
@ -1646,7 +1646,7 @@ DoPlayerTurnBoat(PLAYERp pp)
if (angvel != 0)
{
pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel));
pp->camq16ang = pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel));
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
}
}
@ -1678,7 +1678,7 @@ DoPlayerTurnTank(PLAYERp pp, int z, int floor_dist)
{
if (MultiClipTurn(pp, NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel), z, floor_dist))
{
pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel));
pp->camq16ang = pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel));
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
}
}
@ -1711,7 +1711,7 @@ DoPlayerTurnTankRect(PLAYERp pp, int *x, int *y, int *ox, int *oy)
{
if (RectClipTurn(pp, NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel), x, y, ox, oy))
{
pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel));
pp->camq16ang = pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel));
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
}
}
@ -1774,7 +1774,7 @@ DoPlayerTurnTurret(PLAYERp pp)
}
}
pp->q16ang = fix16_from_int(new_ang);
pp->camq16ang = pp->q16ang = fix16_from_int(new_ang);
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
}
}
@ -4005,7 +4005,7 @@ DoPlayerClimb(PLAYERp pp)
pp->lx = lsp->x + nx * 5;
pp->ly = lsp->y + ny * 5;
pp->q16ang = fix16_from_int(pp->LadderAngle);
pp->camq16ang = pp->q16ang = fix16_from_int(pp->LadderAngle);
}
}
}
@ -4542,7 +4542,7 @@ PlayerOnLadder(PLAYERp pp)
pp->lx = lsp->x + nx * 5;
pp->ly = lsp->y + ny * 5;
pp->q16ang = fix16_from_int(pp->LadderAngle);
pp->camq16ang = pp->q16ang = fix16_from_int(pp->LadderAngle);
return TRUE;
}
@ -5795,7 +5795,7 @@ DoPlayerBeginOperate(PLAYERp pp)
pp->sop = pp->sop_control = sop;
sop->controller = pp->SpriteP;
pp->q16ang = fix16_from_int(sop->ang);
pp->camq16ang = pp->q16ang = fix16_from_int(sop->ang);
pp->posx = sop->xmid;
pp->posy = sop->ymid;
COVERupdatesector(pp->posx, pp->posy, &pp->cursectnum);
@ -5880,7 +5880,7 @@ DoPlayerBeginRemoteOperate(PLAYERp pp, SECTOR_OBJECTp sop)
save_sectnum = pp->cursectnum;
pp->q16ang = fix16_from_int(sop->ang);
pp->camq16ang = pp->q16ang = fix16_from_int(sop->ang);
pp->posx = sop->xmid;
pp->posy = sop->ymid;
COVERupdatesector(pp->posx, pp->posy, &pp->cursectnum);
@ -6009,9 +6009,9 @@ DoPlayerStopOperate(PLAYERp pp)
if (pp->sop_remote)
{
if (TEST_BOOL1(pp->remote_sprite))
pp->q16ang = pp->oq16ang = fix16_from_int(pp->remote_sprite->ang);
pp->camq16ang = pp->q16ang = pp->oq16ang = fix16_from_int(pp->remote_sprite->ang);
else
pp->q16ang = pp->oq16ang = fix16_from_int(getangle(pp->sop_remote->xmid - pp->posx, pp->sop_remote->ymid - pp->posy));
pp->camq16ang = pp->q16ang = pp->oq16ang = fix16_from_int(getangle(pp->sop_remote->xmid - pp->posx, pp->sop_remote->ymid - pp->posy));
}
if (pp->sop_control)
@ -6609,6 +6609,7 @@ DoPlayerDeathHoriz(PLAYERp pp, short target, short speed)
pp->q16horiz = fix16_from_int(target);
}
pp->camq16horiz = pp->q16horiz;
return pp->q16horiz == fix16_from_int(target);
}
@ -6704,7 +6705,7 @@ void DoPlayerDeathFollowKiller(PLAYERp pp)
ang2 = getangle(kp->x - pp->posx, kp->y - pp->posy);
delta_ang = GetDeltaAngle(ang2, fix16_to_int(pp->q16ang));
pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + (delta_ang >> 4)));
pp->camq16ang = pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + (delta_ang >> 4)));
}
}
}
@ -6765,7 +6766,7 @@ void DoPlayerDeathCheckKeys(PLAYERp pp)
sp->yrepeat = PLAYER_NINJA_YREPEAT;
//pp->tilt = 0;
pp->q16horiz = pp->q16horizbase = fix16_from_int(100);
pp->camq16horiz = pp->q16horiz = pp->q16horizbase = fix16_from_int(100);
DoPlayerResetMovement(pp);
u->ID = NINJA_RUN_R0;
PlayerDeathReset(pp);
@ -7910,7 +7911,7 @@ domovethings(void)
// auto tracking mode for single player multi-game
if (numplayers <= 1 && PlayerTrackingMode && pnum == screenpeek && screenpeek != myconnectindex)
{
Player[screenpeek].q16ang = fix16_from_int(getangle(Player[myconnectindex].posx - Player[screenpeek].posx, Player[myconnectindex].posy - Player[screenpeek].posy));
Player[screenpeek].camq16ang = Player[screenpeek].q16ang = fix16_from_int(getangle(Player[myconnectindex].posx - Player[screenpeek].posx, Player[myconnectindex].posy - Player[screenpeek].posy));
}
if (!TEST(pp->Flags, PF_DEAD))
@ -7990,8 +7991,8 @@ InitAllPlayers(void)
pp->posx = pp->oposx = pfirst->posx;
pp->posy = pp->oposy = pfirst->posy;
pp->posz = pp->oposz = pfirst->posz;
pp->q16ang = pp->oq16ang = pfirst->q16ang;
pp->q16horiz = pp->oq16horiz = pfirst->q16horiz;
pp->camq16ang = pp->q16ang = pp->oq16ang = pfirst->q16ang;
pp->camq16horiz = pp->q16horiz = pp->oq16horiz = pfirst->q16horiz;
pp->cursectnum = pfirst->cursectnum;
// set like this so that player can trigger something on start of the level
pp->lastcursectnum = pfirst->cursectnum+1;
@ -8141,7 +8142,7 @@ PlayerSpawnPosition(PLAYERp pp)
pp->posx = pp->oposx = sp->x;
pp->posy = pp->oposy = sp->y;
pp->posz = pp->oposz = sp->z;
pp->q16ang = pp->oq16ang = fix16_from_int(sp->ang);
pp->camq16ang = pp->q16ang = pp->oq16ang = fix16_from_int(sp->ang);
pp->cursectnum = sp->sectnum;
getzsofslope(pp->cursectnum, pp->posx, pp->posy, &cz, &fz);