Commit 6a78dde8 authored by Richard Gobeille's avatar Richard Gobeille

Duke3d: fix jittery view on moving sectors

This also fixes the interpolation for gamefunc_TurnAround and stomping on enemies. Fixes terminx/eduke32#60.
parent 7ac897a5
......@@ -1350,7 +1350,9 @@ ACTOR_STATIC void G_MovePlayers(void)
{
int const nextSprite = nextspritestat[spriteNum];
auto const pSprite = &sprite[spriteNum];
auto const pPlayer = g_player[P_GetP(pSprite)].ps;
int const playerNum = P_GetP(pSprite);
auto & thisPlayer = g_player[playerNum];
auto const pPlayer = thisPlayer.ps;
if (pSprite->owner >= 0)
{
......@@ -1395,11 +1397,20 @@ ACTOR_STATIC void G_MovePlayers(void)
if (G_TileHasActor(sprite[spriteNum].picnum))
A_Execute(spriteNum, P_GetP(pSprite), otherPlayerDist);
thisPlayer.smoothcamera = false;
pPlayer->q16angvel = P_GetQ16AngleDeltaForTic(pPlayer);
pPlayer->oq16ang = pPlayer->q16ang;
pPlayer->oq16horiz = pPlayer->q16horiz;
pPlayer->oq16horizoff = pPlayer->q16horizoff;
if (pPlayer->one_eighty_count < 0)
{
thisPlayer.smoothcamera = true;
pPlayer->one_eighty_count += 128;
pPlayer->q16ang += F16(128);
}
if (g_netServer || ud.multimode > 1)
{
if (sprite[g_player[otherp].ps->i].extra > 0)
......@@ -1423,6 +1434,14 @@ ACTOR_STATIC void G_MovePlayers(void)
}
}
if (pPlayer->actorsqu >= 0)
{
thisPlayer.smoothcamera = true;
pPlayer->q16ang += fix16_from_int(
G_GetAngleDelta(fix16_to_int(pPlayer->q16ang), getangle(sprite[pPlayer->actorsqu].x - pPlayer->pos.x, sprite[pPlayer->actorsqu].y - pPlayer->pos.y))
>> 2);
}
if (ud.god)
{
pSprite->extra = pPlayer->max_player_health;
......@@ -1457,6 +1476,7 @@ ACTOR_STATIC void G_MovePlayers(void)
if (pPlayer->wackedbyactor >= 0 && sprite[pPlayer->wackedbyactor].statnum < MAXSTATUS)
{
thisPlayer.smoothcamera = true;
pPlayer->q16ang += fix16_from_int(G_GetAngleDelta(fix16_to_int(pPlayer->q16ang),
getangle(sprite[pPlayer->wackedbyactor].x - pPlayer->pos.x,
sprite[pPlayer->wackedbyactor].y - pPlayer->pos.y))
......@@ -1857,6 +1877,7 @@ ACTOR_STATIC void G_MoveStandables(void)
pSprite->owner = -2;
g_player[p].ps->on_crane = spriteNum;
A_PlaySound(DUKE_GRUNT,g_player[p].ps->i);
g_player[p].smoothcamera = true;
g_player[p].ps->q16ang = fix16_from_int(pSprite->ang+1024);
}
else
......@@ -3699,8 +3720,9 @@ ACTOR_STATIC void G_MoveTransports(void)
case STAT_PLAYER:
if (sprite[sectSprite].owner != -1)
{
int const playerNum = P_Get(sectSprite);
auto const pPlayer = g_player[playerNum].ps;
int const playerNum = P_Get(sectSprite);
auto & thisPlayer = g_player[playerNum];
auto const pPlayer = thisPlayer.ps;
pPlayer->on_warping_sector = 1;
......@@ -3724,6 +3746,7 @@ ACTOR_STATIC void G_MoveTransports(void)
}
}
thisPlayer.smoothcamera = true;
pPlayer->q16ang = fix16_from_int(sprite[OW(spriteNum)].ang);
if (sprite[OW(spriteNum)].owner != OW(spriteNum))
......@@ -3752,12 +3775,12 @@ ACTOR_STATIC void G_MoveTransports(void)
}
if (onFloor == 0 && klabs(SZ(spriteNum) - pPlayer->pos.z) < 6144)
if (!pPlayer->jetpack_on || TEST_SYNC_KEY(g_player[playerNum].input->bits, SK_JUMP)
|| TEST_SYNC_KEY(g_player[playerNum].input->bits, SK_CROUCH))
if (!pPlayer->jetpack_on || TEST_SYNC_KEY(thisPlayer.input->bits, SK_JUMP)
|| TEST_SYNC_KEY(thisPlayer.input->bits, SK_CROUCH))
{
pPlayer->pos.x += sprite[OW(spriteNum)].x - SX(spriteNum);
pPlayer->pos.y += sprite[OW(spriteNum)].y - SY(spriteNum);
pPlayer->pos.z = (pPlayer->jetpack_on && (TEST_SYNC_KEY(g_player[playerNum].input->bits, SK_JUMP)
pPlayer->pos.z = (pPlayer->jetpack_on && (TEST_SYNC_KEY(thisPlayer.input->bits, SK_JUMP)
|| pPlayer->jetpack_on < 11))
? sprite[OW(spriteNum)].z - 6144
: sprite[OW(spriteNum)].z + 6144;
......@@ -6271,6 +6294,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
if (pPlayer->cursectnum == pSprite->sectnum && pPlayer->on_ground == 1)
{
g_player[playerNum].smoothcamera = true;
pPlayer->q16ang += fix16_from_int(l*q);
pPlayer->q16ang &= 0x7FFFFFF;
......@@ -6494,6 +6518,8 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
pPlayer->bobpos.x += m;
pPlayer->bobpos.y += x;
g_player[playerNum].smoothcamera = true;
pPlayer->q16ang += fix16_from_int(q);
pPlayer->q16ang &= 0x7FFFFFF;
......
......@@ -746,7 +746,8 @@ static void G_ReadGLFrame(void)
void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
{
auto const pPlayer = g_player[playerNum].ps;
auto const &thisPlayer = g_player[playerNum];
auto const pPlayer = thisPlayer.ps;
int const viewingRange = viewingrange;
......@@ -962,8 +963,8 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
pPlayer->opos.z + mulscale16(pPlayer->pos.z - pPlayer->opos.z, smoothRatio) };
CAMERA(pos) = camVect;
if (pPlayer->wackedbyactor >= 0)
if (thisPlayer.smoothcamera)
{
CAMERA(q16ang) = pPlayer->oq16ang
+ mulscale16(((pPlayer->q16ang + F16(1024) - pPlayer->oq16ang) & 0x7FFFFFF) - F16(1024), smoothRatio)
......
......@@ -5115,12 +5115,6 @@ void P_ProcessInput(int playerNum)
if (!ud.noclip)
pushmove(&pPlayer->pos, &pPlayer->cursectnum, pPlayer->clipdist - 1, (4L<<8), stepHeight, CLIPMASK0);
if (pPlayer->one_eighty_count < 0)
{
pPlayer->one_eighty_count += 128;
pPlayer->q16ang += F16(128);
}
// Shrinking code
if (sectorLotag == ST_2_UNDERWATER)
......@@ -5782,11 +5776,6 @@ RECHECK:
}
pPlayer->actorsqu = -1;
}
else if (pPlayer->actorsqu >= 0)
pPlayer->q16ang += fix16_from_int(
G_GetAngleDelta(fix16_to_int(pPlayer->q16ang),
getangle(sprite[pPlayer->actorsqu].x - pPlayer->pos.x, sprite[pPlayer->actorsqu].y - pPlayer->pos.y))
>> 2);
}
#endif
......
......@@ -217,12 +217,12 @@ typedef struct
fix16_t horizSkew;
int32_t netsynctime;
int16_t ping, filler;
int32_t pcolor, pteam;
int16_t ping;
// NOTE: wchoice[HANDREMOTE_WEAPON .. MAX_WEAPONS-1] unused
uint8_t frags[MAXPLAYERS], wchoice[MAX_WEAPONS];
char smoothcamera;
char vote, gotvote, pingcnt, playerquitflag,
ready; // currently unused. May be used later to indicate that a player has pressed use on intermission to indicate they are ready to go on to the next map
char user_name[32];
......
......@@ -738,7 +738,8 @@ void P_ResetMultiPlayer(int playerNum)
void P_ResetPlayer(int playerNum)
{
auto &p = *g_player[playerNum].ps;
auto &thisPlayer = g_player[playerNum];
auto &p = *thisPlayer.ps;
ud.show_help = 0;
ud.showallmap = 0;
......@@ -838,9 +839,10 @@ void P_ResetPlayer(int playerNum)
? PWEAPON(playerNum, p.curr_weapon, TotalTime)
: 0;
g_player[playerNum].horizRecenter = 0;
g_player[playerNum].horizSkew = 0;
g_player[playerNum].horizAngleAdjust = 0;
thisPlayer.smoothcamera = false;
thisPlayer.horizRecenter = false;
thisPlayer.horizSkew = 0;
thisPlayer.horizAngleAdjust = 0;
P_UpdateScreenPal(&p);
VM_OnEvent(EVENT_RESETPLAYER, p.i, playerNum);
......
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