diff --git a/src/d_clisrv.c b/src/d_clisrv.c index aa4199fce..2f38f0aef 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -115,7 +115,7 @@ UINT32 playerpingtable[MAXPLAYERS]; //table of player latency values. static tic_t lowest_lag; boolean server_lagless; static CV_PossibleValue_t mindelay_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}}; -consvar_t cv_mindelay = CVAR_INIT ("mindelay", "0", 0, mindelay_cons_t, NULL); +consvar_t cv_mindelay = CVAR_INIT ("mindelay", "0", CV_SAVE, mindelay_cons_t, NULL); SINT8 nodetoplayer[MAXNETNODES]; SINT8 nodetoplayer2[MAXNETNODES]; // say the numplayer for this node if any (splitscreen) @@ -5650,7 +5650,7 @@ static inline void PingUpdate(void) if (nodeingame[i]) HSendPacket(i, true, 0, sizeof(INT32) * (MAXPLAYERS+1)); - pingmeasurecount = 1; //Reset count + pingmeasurecount = 0; //Reset count } static tic_t gametime = 0; @@ -5667,7 +5667,7 @@ static void UpdatePingTable(void) if (netgame && !(gametime % 35)) // update once per second. PingUpdate(); - fastest = cv_mindelay.value; + fastest = 0; // update node latency values so we can take an average later. for (i = 0; i < MAXPLAYERS; i++) @@ -5690,6 +5690,10 @@ 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) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index fd57f4a36..2ffc80bc7 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -79,6 +79,7 @@ typedef enum patch_t *pinggfx[5]; // small ping graphic patch_t *mping[5]; // smaller ping graphic patch_t *pingmeasure[2]; // ping measurement graphic +patch_t *pinglocal[2]; // mindelay indecator patch_t *framecounter; patch_t *frameslash; // framerate stuff. Used in screen.c @@ -197,6 +198,9 @@ void HU_LoadGraphics(void) HU_UpdatePatch(&pingmeasure[0], "PINGD"); HU_UpdatePatch(&pingmeasure[1], "PINGMS"); + HU_UpdatePatch(&pinglocal[0], "PINGGFXL"); + HU_UpdatePatch(&pinglocal[1], "MPINGL"); + // fps stuff HU_UpdatePatch(&framecounter, "FRAMER"); HU_UpdatePatch(&frameslash, "FRAMESL"); @@ -2346,25 +2350,47 @@ Ping_gfx_num (int lag) return 4; } +static int +Ping_gfx_color (int lag) +{ + if (lag < 2) + return SKINCOLOR_JAWZ; + else if (lag < 4) + return SKINCOLOR_MINT; + else if (lag < 7) + return SKINCOLOR_GOLD; + else if (lag < 10) + return SKINCOLOR_RASPBERRY; + else + return SKINCOLOR_MAGENTA; +} + // // HU_drawPing // -void HU_drawPing(INT32 x, INT32 y, UINT32 lag, INT32 flags) +void HU_drawPing(INT32 x, INT32 y, UINT32 lag, INT32 flags, boolean offline) { 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); gfxnum = Ping_gfx_num(lag); if (measureid == 1) V_DrawScaledPatch(x+11 - pingmeasure[measureid]->width, y+9, flags, pingmeasure[measureid]); - V_DrawScaledPatch(x+2, y, flags, pinggfx[gfxnum]); + + if (drawlocal) + V_DrawScaledPatch(x+2, y, flags, pinglocal[0]); + else + V_DrawScaledPatch(x+2, y, flags, pinggfx[gfxnum]); + + 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_RASPBERRY, GTC_CACHE); + colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_WHITE, GTC_CACHE); } if (cv_pingmeasurement.value) @@ -2389,7 +2415,10 @@ HU_drawMiniPing (INT32 x, INT32 y, UINT32 lag, INT32 flags) w /= 2; } - patch = mping[Ping_gfx_num(lag)]; + if (cv_mindelay.value && (tic_t)cv_mindelay.value <= lag) + patch = pinglocal[1]; + else + patch = mping[Ping_gfx_num(lag)]; if (( flags & V_SNAPTORIGHT )) x += ( w - SHORT (patch->width) ); diff --git a/src/hu_stuff.h b/src/hu_stuff.h index cc9959467..9bcf45e09 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -138,7 +138,7 @@ void HU_Drawer(void); char HU_dequeueChatChar(void); void HU_Erase(void); void HU_clearChatChars(void); -void HU_drawPing(INT32 x, INT32 y, UINT32 ping, INT32 flags); // Lat': Ping drawer for scoreboard. +void HU_drawPing(INT32 x, INT32 y, UINT32 ping, INT32 flags, boolean offline); // Lat': Ping drawer for scoreboard. void HU_drawMiniPing(INT32 x, INT32 y, UINT32 ping, INT32 flags); INT32 HU_CreateTeamScoresTbl(playersort_t *tab, UINT32 dmtotals[]); diff --git a/src/k_hud.c b/src/k_hud.c index 96635584e..2496e5393 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -2177,7 +2177,7 @@ void K_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, IN } else if (tab[i].num != serverplayer || !server_lagless) { - HU_drawPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, playerpingtable[tab[i].num], 0); + HU_drawPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, playerpingtable[tab[i].num], 0, false); } } @@ -4878,7 +4878,7 @@ void K_drawKartHUD(void) V_DrawCenteredString(BASEVIDWIDTH>>1, 176, V_REDMAP|V_SNAPTOBOTTOM, "WRONG WAY"); } - if (netgame && r_splitscreen) + if ((netgame || cv_mindelay.value) && r_splitscreen) { K_drawMiniPing(); } diff --git a/src/k_menudef.c b/src/k_menudef.c index d97083509..fe243c38c 100644 --- a/src/k_menudef.c +++ b/src/k_menudef.c @@ -1035,6 +1035,12 @@ menuitem_t OPTIONS_Gameplay[] = {IT_STRING | IT_CVAR, "Karma Comeback", "Enable Karma Comeback in Battle mode.", NULL, {.cvar = &cv_kartcomeback}, 0, 0}, + {IT_SPACE | IT_NOTHING, NULL, NULL, + NULL, {NULL}, 0, 0}, + + {IT_STRING | IT_CVAR, "Offline Input Delay", "Practice for online play in offline modes. Higher = more delay.", + NULL, {.cvar = &cv_mindelay}, 0, 0}, + {IT_SPACE | IT_NOTHING, NULL, NULL, NULL, {NULL}, 0, 0}, diff --git a/src/screen.c b/src/screen.c index 5d6b59ee8..f1b53a7f2 100644 --- a/src/screen.c +++ b/src/screen.c @@ -628,11 +628,14 @@ void SCR_DisplayTicRate(void) void SCR_DisplayLocalPing(void) { + boolean offline; + UINT32 ping = playerpingtable[consoleplayer]; // consoleplayer's ping is everyone's ping in a splitnetgame :P if (! r_splitscreen && ( cv_showping.value == 1 || (cv_showping.value == 2 && ping > servermaxping) )) // only show 2 (warning) if our ping is at a bad level { INT32 dispy = cv_ticrate.value ? 160 : 181; - HU_drawPing(307, dispy, ping, V_SNAPTORIGHT | V_SNAPTOBOTTOM | V_HUDTRANS); + offline = (consoleplayer == serverplayer); + HU_drawPing(307, dispy, ping, V_SNAPTORIGHT | V_SNAPTOBOTTOM | V_HUDTRANS, offline); } } diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 2361a5349..09b2f6bbf 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1219,6 +1219,8 @@ void I_FinishUpdate(void) } } } + if (cv_mindelay.value && consoleplayer == serverplayer) + SCR_DisplayLocalPing(); } if (marathonmode)