Duke3d: fix jittery view on moving sectors

This also fixes the interpolation for gamefunc_TurnAround and stomping on enemies. Fixes terminx/eduke32#60.

# Conflicts:
#	source/duke3d/src/actors.cpp
#	source/duke3d/src/game.cpp
#	source/duke3d/src/premap.cpp
This commit is contained in:
Richard C. Gobeille 2020-06-08 12:21:48 -07:00 committed by Christoph Oelckers
parent f5aa302475
commit a5c9a702e9
5 changed files with 42 additions and 19 deletions

View file

@ -1341,7 +1341,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)
{
@ -1386,11 +1388,19 @@ ACTOR_STATIC void G_MovePlayers(void)
if (G_TileHasActor(sprite[spriteNum].picnum))
A_Execute(spriteNum, P_GetP(pSprite), otherPlayerDist);
thisPlayer.smoothcamera = false;
pPlayer->q16angvel = G_GetQ16AngleDelta(pPlayer->oq16ang, pPlayer->q16ang);
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)
@ -1414,6 +1424,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;
@ -1448,6 +1466,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))
@ -1846,6 +1865,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
@ -3686,7 +3706,8 @@ ACTOR_STATIC void G_MoveTransports(void)
if (sprite[sectSprite].owner != -1)
{
int const playerNum = P_Get(sectSprite);
auto const pPlayer = g_player[playerNum].ps;
auto & thisPlayer = g_player[playerNum];
auto const pPlayer = thisPlayer.ps;
pPlayer->on_warping_sector = 1;
@ -3710,6 +3731,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))
@ -3738,12 +3760,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;
@ -6257,6 +6279,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;
@ -6480,6 +6503,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;

View file

@ -616,7 +616,8 @@ static void G_ClearGotMirror()
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;
@ -726,8 +727,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)

View file

@ -5803,11 +5803,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

View file

@ -222,12 +222,12 @@ typedef struct
double lastInputTicks;
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];

View file

@ -675,7 +675,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;
gFullMap = 0;
@ -774,9 +775,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;
g_player[playerNum].lastInputTicks = 0;
P_UpdateScreenPal(&p);