diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 959f86248..99b3a304a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6305,39 +6305,30 @@ static void UpdatePingTable(void) } } - // Don't gentleman below your mindelay - if (fastest < (tic_t)cv_mindelay.value) - fastest = (tic_t)cv_mindelay.value; - - pingmeasurecount++; - if (server_lagless) lowest_lag = 0; else - { lowest_lag = fastest; - if (fastest) - lag = fastest; - else - lag = GetLag(0); + // Don't gentleman below your mindelay + if (lowest_lag < (tic_t)cv_mindelay.value) + lowest_lag = (tic_t)cv_mindelay.value; - lag = ( realpingtable[0] + lag ); + pingmeasurecount++; - switch (playerpernode[0]) - { - case 4: - realpingtable[nodetoplayer4[0]] = lag; - /*FALLTHRU*/ - case 3: - realpingtable[nodetoplayer3[0]] = lag; - /*FALLTHRU*/ - case 2: - realpingtable[nodetoplayer2[0]] = lag; - /*FALLTHRU*/ - case 1: - realpingtable[nodetoplayer[0]] = lag; - } + switch (playerpernode[0]) + { + case 4: + playerdelaytable[nodetoplayer4[0]] = lowest_lag; + /*FALLTHRU*/ + case 3: + playerdelaytable[nodetoplayer3[0]] = lowest_lag; + /*FALLTHRU*/ + case 2: + playerdelaytable[nodetoplayer2[0]] = lowest_lag; + /*FALLTHRU*/ + case 1: + playerdelaytable[nodetoplayer[0]] = lowest_lag; } } else // We're a client, handle mindelay on the way out. diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 46a68b7c0..0cbfa0d1f 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2183,6 +2183,31 @@ Ping_gfx_color (int lag) return SKINCOLOR_MAGENTA; } +static const UINT8 * +Ping_gfx_colormap (UINT32 ping, UINT32 lag) +{ + const UINT8 *colormap = R_GetTranslationColormap(TC_RAINBOW, Ping_gfx_color(lag), GTC_CACHE); + + if (servermaxping && ping > servermaxping && hu_tick < 4) + { + // flash ping red if too high + colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_WHITE, GTC_CACHE); + } + + return colormap; +} + +static UINT32 +Ping_conversion (UINT32 lag) +{ + if (cv_pingmeasurement.value) + { + lag = (INT32)(lag * (1000.00f / TICRATE)); + } + + return lag; +} + static int PL_gfx_color (int pl) { @@ -2199,20 +2224,13 @@ PL_gfx_color (int pl) // // HU_drawPing // -void HU_drawPing(fixed_t x, fixed_t y, UINT32 lag, UINT32 pl, INT32 flags, boolean offline, SINT8 toside) +void HU_drawPing(fixed_t x, fixed_t y, UINT32 ping, UINT32 lag, UINT32 pl, INT32 flags, SINT8 toside) { - UINT8 *colormap = NULL; + const UINT8 *colormap = NULL; INT32 measureid = cv_pingmeasurement.value ? 1 : 0; INT32 gfxnum; // gfx to draw - boolean drawlocal = (offline && cv_mindelay.value && lag <= (tic_t)cv_mindelay.value); fixed_t x2, y2; - if (!server && lag <= (tic_t)cv_mindelay.value) - { - lag = cv_mindelay.value; - drawlocal = true; - } - x2 = x; y2 = y + FRACUNIT; @@ -2244,7 +2262,7 @@ void HU_drawPing(fixed_t x, fixed_t y, UINT32 lag, UINT32 pl, INT32 flags, boole } } - gfxnum = Ping_gfx_num(lag); + gfxnum = Ping_gfx_num(ping); if (pl) { @@ -2257,7 +2275,7 @@ void HU_drawPing(fixed_t x, fixed_t y, UINT32 lag, UINT32 pl, INT32 flags, boole ); } - if (drawlocal) + if (ping <= lag) { V_DrawFixedPatch( x + (2 * FRACUNIT), @@ -2289,23 +2307,12 @@ void HU_drawPing(fixed_t x, fixed_t y, UINT32 lag, UINT32 pl, INT32 flags, boole ); } - colormap = R_GetTranslationColormap(TC_RAINBOW, Ping_gfx_color(lag), GTC_CACHE); - - if (servermaxping && lag > servermaxping && hu_tick < 4) - { - // flash ping red if too high - colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_WHITE, GTC_CACHE); - } - - if (cv_pingmeasurement.value) - { - lag = (INT32)(lag * (1000.00f / TICRATE)); - } + colormap = Ping_gfx_colormap(ping, lag); x2 = V_DrawPingNum( x2, y2, - flags, lag, + flags, Ping_conversion(lag), colormap ); @@ -2322,7 +2329,7 @@ void HU_drawPing(fixed_t x, fixed_t y, UINT32 lag, UINT32 pl, INT32 flags, boole } void -HU_drawMiniPing (INT32 x, INT32 y, UINT32 lag, INT32 flags) +HU_drawMiniPing (INT32 x, INT32 y, UINT32 ping, UINT32 lag, INT32 flags) { patch_t *patch; INT32 w = BASEVIDWIDTH; @@ -2332,16 +2339,10 @@ HU_drawMiniPing (INT32 x, INT32 y, UINT32 lag, INT32 flags) w /= 2; } - // This looks kinda dumb, but basically: - // Servers with mindelay set modify the ping table. - // Clients with mindelay unset don't, because they can't. - // Both are affected by mindelay, but a client's lag value is pre-adjustment. - if (server && cv_mindelay.value && (tic_t)cv_mindelay.value <= lag) - patch = pinglocal[1]; - else if (!server && cv_mindelay.value && (tic_t)cv_mindelay.value >= lag) - patch = pinglocal[1]; + if (ping <= lag) + patch = pinglocal[1]; // stone shoe else - patch = mping[Ping_gfx_num(lag)]; + patch = mping[Ping_gfx_num(ping)]; if (( flags & V_SNAPTORIGHT )) x += ( w - SHORT (patch->width) ); diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 0a359f4f7..5747cd85e 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -156,8 +156,8 @@ void HU_TickSongCredits(void); char HU_dequeueChatChar(void); void HU_Erase(void); void HU_clearChatChars(void); -void HU_drawPing(fixed_t x, fixed_t y, UINT32 ping, UINT32 packetloss, INT32 flags, boolean offline, SINT8 toside); // Lat': Ping drawer for scoreboard. -void HU_drawMiniPing(INT32 x, INT32 y, UINT32 ping, INT32 flags); +void HU_drawPing(fixed_t x, fixed_t y, UINT32 ping, UINT32 lag, UINT32 packetloss, INT32 flags, SINT8 toside); // Lat': Ping drawer for scoreboard. +void HU_drawMiniPing(INT32 x, INT32 y, UINT32 ping, UINT32 lag, INT32 flags); // CECHO interface. void HU_ClearCEcho(void); diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 75f4ecf27..f13484a0d 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -5535,7 +5535,9 @@ void K_drawKartFreePlay(void) static void Draw_party_ping (int ss, INT32 snap) { - HU_drawMiniPing(0, 0, playerpingtable[displayplayers[ss]], V_SPLITSCREEN|V_SNAPTOTOP|snap); + UINT32 ping = playerpingtable[displayplayers[ss]]; + UINT32 mindelay = playerdelaytable[displayplayers[ss]]; + HU_drawMiniPing(0, 0, ping, std::max(ping, mindelay), V_SPLITSCREEN|V_SNAPTOTOP|snap); } static void diff --git a/src/screen.c b/src/screen.c index 6a864a94d..ecddd741e 100644 --- a/src/screen.c +++ b/src/screen.c @@ -577,13 +577,13 @@ void SCR_DisplayLocalPing(void) return; } + UINT32 mindelay = playerdelaytable[consoleplayer]; UINT32 ping = playerpingtable[consoleplayer]; UINT32 pl = playerpacketlosstable[consoleplayer]; INT32 dispy = cv_ticrate.value ? 170 : 181; - boolean offline = (consoleplayer == serverplayer); - HU_drawPing(307 * FRACUNIT, dispy * FRACUNIT, ping, pl, V_SNAPTORIGHT | V_SNAPTOBOTTOM, offline, 0); + HU_drawPing(307 * FRACUNIT, dispy * FRACUNIT, ping, max(ping, mindelay), pl, V_SNAPTORIGHT | V_SNAPTOBOTTOM, 0); } diff --git a/src/y_inter.cpp b/src/y_inter.cpp index 9f2372180..897f009b4 100644 --- a/src/y_inter.cpp +++ b/src/y_inter.cpp @@ -716,14 +716,14 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 xoffset) kp_cpu );*/ } - else if (pnum != serverplayer || !server_lagless) + else { HU_drawPing( (x2 - 2) * FRACUNIT, (y-2) * FRACUNIT, playerpingtable[pnum], + playerdelaytable[pnum], playerpacketlosstable[pnum], 0, - false, (datarightofcolumn ? 1 : -1) ); }