Merge branch 'distance-to-finland' into 'master'

More consistent finish line distance & positions

See merge request KartKrew/Kart!237
This commit is contained in:
Sal 2020-04-22 16:40:19 -04:00
commit 9671090d06
3 changed files with 25 additions and 7 deletions

View file

@ -6289,10 +6289,6 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
void K_KartPlayerAfterThink(player_t *player)
{
// Moved to afterthink, as at this point the players have had their distances to the finish line updated
// and this will correctly account for all players
K_KartUpdatePosition(player);
if (player->kartstuff[k_curshield]
|| player->kartstuff[k_invincibilitytimer]
|| (player->kartstuff[k_growshrinktimer] != 0 && player->kartstuff[k_growshrinktimer] % 5 == 4)) // 4 instead of 0 because this is afterthink!
@ -6609,7 +6605,7 @@ static boolean K_PlayerCloserToNextWaypoints(waypoint_t *const waypoint, player_
}
/*--------------------------------------------------
static void K_UpdateDistanceFromFinishLine(player_t *const player)
void K_UpdateDistanceFromFinishLine(player_t *const player)
Updates the distance a player has to the finish line.
@ -6619,7 +6615,7 @@ static boolean K_PlayerCloserToNextWaypoints(waypoint_t *const waypoint, player_
Return:-
None
--------------------------------------------------*/
static void K_UpdateDistanceFromFinishLine(player_t *const player)
void K_UpdateDistanceFromFinishLine(player_t *const player)
{
if ((player != NULL) && (player->mo != NULL))
{
@ -7169,7 +7165,6 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
boolean HOLDING_ITEM = (player->kartstuff[k_itemheld] || player->kartstuff[k_eggmanheld]);
boolean NO_HYUDORO = (player->kartstuff[k_stolentimer] == 0 && player->kartstuff[k_stealingtimer] == 0);
K_UpdateDistanceFromFinishLine(player);
player->pflags &= ~PF_HITFINISHLINE;
if (!player->exiting)

View file

@ -59,6 +59,7 @@ void K_UpdateHnextList(player_t *player, boolean clean);
void K_DropHnextList(player_t *player, boolean keepshields);
void K_RepairOrbitChain(mobj_t *orbit);
player_t *K_FindJawzTarget(mobj_t *actor, player_t *source);
void K_UpdateDistanceFromFinishLine(player_t *const player);
boolean K_CheckPlayersRespawnColliding(INT32 playernum, fixed_t x, fixed_t y);
INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue);
INT32 K_GetKartDriftSparkValue(player_t *player);

View file

@ -616,6 +616,17 @@ void P_Ticker(boolean run)
G_ReadDemoTiccmd(&players[i].cmd, i);
}
// First loop: Ensure all players' distance to the finish line are all accurate
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
K_UpdateDistanceFromFinishLine(&players[i]);
// Second loop: Ensure all player positions reflect everyone's distances
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
K_KartUpdatePosition(&players[i]);
// OK! Now that we got all of that sorted, players can think!
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
P_PlayerThink(&players[i]);
@ -778,6 +789,17 @@ void P_PreTicker(INT32 frames)
{
P_MapStart();
// First loop: Ensure all players' distance to the finish line are all accurate
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
K_UpdateDistanceFromFinishLine(&players[i]);
// Second loop: Ensure all player positions reflect everyone's distances
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
K_KartUpdatePosition(&players[i]);
// OK! Now that we got all of that sorted, players can think!
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
{