Mindelay: Oni suggestions rollup

This commit is contained in:
AJ Martinez 2022-09-20 19:01:54 -07:00
parent db25599647
commit e242207d10
7 changed files with 55 additions and 11 deletions

View file

@ -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)

View file

@ -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]);
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,6 +2415,9 @@ HU_drawMiniPing (INT32 x, INT32 y, UINT32 lag, INT32 flags)
w /= 2;
}
if (cv_mindelay.value && (tic_t)cv_mindelay.value <= lag)
patch = pinglocal[1];
else
patch = mping[Ping_gfx_num(lag)];
if (( flags & V_SNAPTORIGHT ))

View file

@ -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[]);

View file

@ -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();
}

View file

@ -1038,6 +1038,12 @@ menuitem_t OPTIONS_Gameplay[] =
{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},
{IT_STRING | IT_SUBMENU, "Random Item Toggles...", "Change which items to enable for your games.",
NULL, {.submenu = &OPTIONS_GameplayItemsDef}, 0, 0},

View file

@ -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);
}
}

View file

@ -1219,6 +1219,8 @@ void I_FinishUpdate(void)
}
}
}
if (cv_mindelay.value && consoleplayer == serverplayer)
SCR_DisplayLocalPing();
}
if (marathonmode)