From 40d065a024d0326278c88d73a338582a1fdeed56 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Tue, 9 Apr 2019 23:55:25 -0500 Subject: [PATCH] Fix thrown items desyncing during frame advance --- src/g_game.c | 10 +++++++--- src/p_tick.c | 11 +++++++++++ src/p_user.c | 13 +++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 37aa4a5e..0dd24ecb 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2407,6 +2407,7 @@ void G_Ticker(boolean run) buf = gametic % BACKUPTICS; + if (!demo.playback) // read/write demo and check turbo cheat for (i = 0; i < MAXPLAYERS; i++) { @@ -2414,15 +2415,18 @@ void G_Ticker(boolean run) if (playeringame[i]) { + //@TODO all this throwdir stuff shouldn't be here! But it stays for now to maintain 1.0.4 compat... + // Remove for 1.1! + // SRB2kart // Save the dir the player is holding // to allow items to be thrown forward or backward. if (cmd->buttons & BT_FORWARD) - players[i].kartstuff[k_throwdir] = 1; + players[i].kartstuff[k_throwdir] = 1; else if (cmd->buttons & BT_BACKWARD) - players[i].kartstuff[k_throwdir] = -1; + players[i].kartstuff[k_throwdir] = -1; else - players[i].kartstuff[k_throwdir] = 0; + players[i].kartstuff[k_throwdir] = 0; G_CopyTiccmd(cmd, &netcmds[buf][i], 1); diff --git a/src/p_tick.c b/src/p_tick.c index a5f6313b..038d00a2 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -628,7 +628,18 @@ void P_Ticker(boolean run) G_ReadDemoExtraData(); for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i]) + { + //@TODO all this throwdir stuff shouldn't be here! But it's added to maintain 1.0.4 compat for now... + // Remove for 1.1! + if (players[i].cmd.buttons & BT_FORWARD) + players[i].kartstuff[k_throwdir] = 1; + else if (players[i].cmd.buttons & BT_BACKWARD) + players[i].kartstuff[k_throwdir] = -1; + else + players[i].kartstuff[k_throwdir] = 0; + G_ReadDemoTiccmd(&players[i].cmd, i); + } #ifdef DEMO_COMPAT_100 } #endif diff --git a/src/p_user.c b/src/p_user.c index 509cc4d7..26ee9f8c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8779,6 +8779,19 @@ void P_PlayerThink(player_t *player) cmd = &player->cmd; + //@TODO This fixes a one-tic latency on direction handling, AND makes behavior consistent while paused, but is not BC with 1.0.4. Do this for 1.1! +#if 0 + // SRB2kart + // Save the dir the player is holding + // to allow items to be thrown forward or backward. + if (cmd->buttons & BT_FORWARD) + player->kartstuff[k_throwdir] = 1; + else if (cmd->buttons & BT_BACKWARD) + player->kartstuff[k_throwdir] = -1; + else + player->kartstuff[k_throwdir] = 0; +#endif + // Add some extra randomization. if (cmd->forwardmove) P_RandomFixed();