diff --git a/main.c b/main.c index 5f96712..a690033 100644 --- a/main.c +++ b/main.c @@ -1607,7 +1607,7 @@ static void frame(void) int ticks_should_repredict = (int)predicted_to_tick - (int)server_current_tick; - int healthy_num_ticks_ahead = (int)ceil((((double)peer->roundTripTime) / 1000.0) / TIMESTEP) + 6; + int healthy_num_ticks_ahead = (int)ceil((((double)peer->roundTripTime + (double)peer->roundTripTimeVariance * CAUTIOUS_MULTIPLIER) / 1000.0) / TIMESTEP) + 6; int ticks_to_repredict = ticks_should_repredict; diff --git a/types.h b/types.h index eccb622..03c0fd3 100644 --- a/types.h +++ b/types.h @@ -83,6 +83,7 @@ #define VOIP_DISTANCE_WHEN_CANT_HEAR (VISION_RADIUS * 0.8f) // multiplayer +#define CAUTIOUS_MULTIPLIER 0.8 // how overboard to go with the time ahead predicting, makes it less likely that inputs are lost #define TICKS_BEHIND_DO_SNAP 6 // when this many ticks behind, instead of dilating time SNAP to the healthy ticks ahead #define MAX_MS_SPENT_REPREDICTING 30.0f #define TIME_BETWEEN_SEND_GAMESTATE (1.0f / 20.0f)