mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 04:21:47 +00:00
Merge branch 'autocope' into 'master'
Offline input delay cvar See merge request KartKrew/Kart!687
This commit is contained in:
commit
1b373cf0e8
9 changed files with 79 additions and 14 deletions
|
|
@ -114,6 +114,8 @@ UINT32 playerpingtable[MAXPLAYERS]; //table of player latency values.
|
||||||
|
|
||||||
static tic_t lowest_lag;
|
static tic_t lowest_lag;
|
||||||
boolean server_lagless;
|
boolean server_lagless;
|
||||||
|
static CV_PossibleValue_t mindelay_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}};
|
||||||
|
consvar_t cv_mindelay = CVAR_INIT ("mindelay", "2", CV_SAVE, mindelay_cons_t, NULL);
|
||||||
|
|
||||||
SINT8 nodetoplayer[MAXNETNODES];
|
SINT8 nodetoplayer[MAXNETNODES];
|
||||||
SINT8 nodetoplayer2[MAXNETNODES]; // say the numplayer for this node if any (splitscreen)
|
SINT8 nodetoplayer2[MAXNETNODES]; // say the numplayer for this node if any (splitscreen)
|
||||||
|
|
@ -5648,7 +5650,7 @@ static inline void PingUpdate(void)
|
||||||
if (nodeingame[i])
|
if (nodeingame[i])
|
||||||
HSendPacket(i, true, 0, sizeof(INT32) * (MAXPLAYERS+1));
|
HSendPacket(i, true, 0, sizeof(INT32) * (MAXPLAYERS+1));
|
||||||
|
|
||||||
pingmeasurecount = 1; //Reset count
|
pingmeasurecount = 0; //Reset count
|
||||||
}
|
}
|
||||||
|
|
||||||
static tic_t gametime = 0;
|
static tic_t gametime = 0;
|
||||||
|
|
@ -5662,7 +5664,7 @@ static void UpdatePingTable(void)
|
||||||
|
|
||||||
if (server)
|
if (server)
|
||||||
{
|
{
|
||||||
if (netgame && !(gametime % 35)) // update once per second.
|
if (Playing() && !(gametime % 35)) // update once per second.
|
||||||
PingUpdate();
|
PingUpdate();
|
||||||
|
|
||||||
fastest = 0;
|
fastest = 0;
|
||||||
|
|
@ -5688,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++;
|
pingmeasurecount++;
|
||||||
|
|
||||||
if (server_lagless)
|
if (server_lagless)
|
||||||
|
|
@ -5719,6 +5725,11 @@ static void UpdatePingTable(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else // We're a client, handle mindelay on the way out.
|
||||||
|
{
|
||||||
|
if ((neededtic - gametic) < (tic_t)cv_mindelay.value)
|
||||||
|
lowest_lag = cv_mindelay.value - (neededtic - gametic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RenewHolePunch(void)
|
static void RenewHolePunch(void)
|
||||||
|
|
|
||||||
|
|
@ -445,6 +445,7 @@ extern UINT32 playerpingtable[MAXPLAYERS];
|
||||||
extern tic_t servermaxping;
|
extern tic_t servermaxping;
|
||||||
|
|
||||||
extern boolean server_lagless;
|
extern boolean server_lagless;
|
||||||
|
extern consvar_t cv_mindelay;
|
||||||
|
|
||||||
extern consvar_t cv_netticbuffer, cv_allownewplayer, cv_maxconnections, cv_joindelay;
|
extern consvar_t cv_netticbuffer, cv_allownewplayer, cv_maxconnections, cv_joindelay;
|
||||||
extern consvar_t cv_resynchattempts, cv_blamecfail;
|
extern consvar_t cv_resynchattempts, cv_blamecfail;
|
||||||
|
|
|
||||||
|
|
@ -972,6 +972,7 @@ void D_RegisterClientCommands(void)
|
||||||
CV_RegisterVar(&cv_rollingdemos);
|
CV_RegisterVar(&cv_rollingdemos);
|
||||||
CV_RegisterVar(&cv_netstat);
|
CV_RegisterVar(&cv_netstat);
|
||||||
CV_RegisterVar(&cv_netticbuffer);
|
CV_RegisterVar(&cv_netticbuffer);
|
||||||
|
CV_RegisterVar(&cv_mindelay);
|
||||||
|
|
||||||
#ifdef NETGAME_DEVMODE
|
#ifdef NETGAME_DEVMODE
|
||||||
CV_RegisterVar(&cv_fishcake);
|
CV_RegisterVar(&cv_fishcake);
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ typedef enum
|
||||||
patch_t *pinggfx[5]; // small ping graphic
|
patch_t *pinggfx[5]; // small ping graphic
|
||||||
patch_t *mping[5]; // smaller ping graphic
|
patch_t *mping[5]; // smaller ping graphic
|
||||||
patch_t *pingmeasure[2]; // ping measurement graphic
|
patch_t *pingmeasure[2]; // ping measurement graphic
|
||||||
|
patch_t *pinglocal[2]; // mindelay indecator
|
||||||
|
|
||||||
patch_t *framecounter;
|
patch_t *framecounter;
|
||||||
patch_t *frameslash; // framerate stuff. Used in screen.c
|
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[0], "PINGD");
|
||||||
HU_UpdatePatch(&pingmeasure[1], "PINGMS");
|
HU_UpdatePatch(&pingmeasure[1], "PINGMS");
|
||||||
|
|
||||||
|
HU_UpdatePatch(&pinglocal[0], "PINGGFXL");
|
||||||
|
HU_UpdatePatch(&pinglocal[1], "MPINGL");
|
||||||
|
|
||||||
// fps stuff
|
// fps stuff
|
||||||
HU_UpdatePatch(&framecounter, "FRAMER");
|
HU_UpdatePatch(&framecounter, "FRAMER");
|
||||||
HU_UpdatePatch(&frameslash, "FRAMESL");
|
HU_UpdatePatch(&frameslash, "FRAMESL");
|
||||||
|
|
@ -2334,37 +2338,65 @@ void HU_Erase(void)
|
||||||
static int
|
static int
|
||||||
Ping_gfx_num (int lag)
|
Ping_gfx_num (int lag)
|
||||||
{
|
{
|
||||||
if (lag < 2)
|
if (lag <= 2)
|
||||||
return 0;
|
return 0;
|
||||||
else if (lag < 4)
|
else if (lag <= 4)
|
||||||
return 1;
|
return 1;
|
||||||
else if (lag < 7)
|
else if (lag <= 7)
|
||||||
return 2;
|
return 2;
|
||||||
else if (lag < 10)
|
else if (lag <= 10)
|
||||||
return 3;
|
return 3;
|
||||||
else
|
else
|
||||||
return 4;
|
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
|
// 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;
|
UINT8 *colormap = NULL;
|
||||||
INT32 measureid = cv_pingmeasurement.value ? 1 : 0;
|
INT32 measureid = cv_pingmeasurement.value ? 1 : 0;
|
||||||
INT32 gfxnum; // gfx to draw
|
INT32 gfxnum; // gfx to draw
|
||||||
|
boolean drawlocal = (offline && cv_mindelay.value && lag <= (tic_t)cv_mindelay.value);
|
||||||
|
|
||||||
|
if (!server && lag <= (tic_t)cv_mindelay.value)
|
||||||
|
{
|
||||||
|
lag = cv_mindelay.value;
|
||||||
|
drawlocal = true;
|
||||||
|
}
|
||||||
|
|
||||||
gfxnum = Ping_gfx_num(lag);
|
gfxnum = Ping_gfx_num(lag);
|
||||||
|
|
||||||
if (measureid == 1)
|
if (measureid == 1)
|
||||||
V_DrawScaledPatch(x+11 - pingmeasure[measureid]->width, y+9, flags, pingmeasure[measureid]);
|
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)
|
if (servermaxping && lag > servermaxping && hu_tick < 4)
|
||||||
{
|
{
|
||||||
// flash ping red if too high
|
// 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)
|
if (cv_pingmeasurement.value)
|
||||||
|
|
@ -2389,7 +2421,16 @@ HU_drawMiniPing (INT32 x, INT32 y, UINT32 lag, INT32 flags)
|
||||||
w /= 2;
|
w /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
patch = mping[Ping_gfx_num(lag)];
|
// 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];
|
||||||
|
else
|
||||||
|
patch = mping[Ping_gfx_num(lag)];
|
||||||
|
|
||||||
if (( flags & V_SNAPTORIGHT ))
|
if (( flags & V_SNAPTORIGHT ))
|
||||||
x += ( w - SHORT (patch->width) );
|
x += ( w - SHORT (patch->width) );
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ void HU_Drawer(void);
|
||||||
char HU_dequeueChatChar(void);
|
char HU_dequeueChatChar(void);
|
||||||
void HU_Erase(void);
|
void HU_Erase(void);
|
||||||
void HU_clearChatChars(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);
|
void HU_drawMiniPing(INT32 x, INT32 y, UINT32 ping, INT32 flags);
|
||||||
|
|
||||||
INT32 HU_CreateTeamScoresTbl(playersort_t *tab, UINT32 dmtotals[]);
|
INT32 HU_CreateTeamScoresTbl(playersort_t *tab, UINT32 dmtotals[]);
|
||||||
|
|
|
||||||
|
|
@ -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)
|
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");
|
V_DrawCenteredString(BASEVIDWIDTH>>1, 176, V_REDMAP|V_SNAPTOBOTTOM, "WRONG WAY");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (netgame && r_splitscreen)
|
if ((netgame || cv_mindelay.value) && r_splitscreen && Playing())
|
||||||
{
|
{
|
||||||
K_drawMiniPing();
|
K_drawMiniPing();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1038,6 +1038,12 @@ menuitem_t OPTIONS_Gameplay[] =
|
||||||
{IT_SPACE | IT_NOTHING, NULL, NULL,
|
{IT_SPACE | IT_NOTHING, NULL, NULL,
|
||||||
NULL, {NULL}, 0, 0},
|
NULL, {NULL}, 0, 0},
|
||||||
|
|
||||||
|
{IT_STRING | IT_CVAR, "Minimum Input Delay", "Practice for online play! 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.",
|
{IT_STRING | IT_SUBMENU, "Random Item Toggles...", "Change which items to enable for your games.",
|
||||||
NULL, {.submenu = &OPTIONS_GameplayItemsDef}, 0, 0},
|
NULL, {.submenu = &OPTIONS_GameplayItemsDef}, 0, 0},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -628,11 +628,14 @@ void SCR_DisplayTicRate(void)
|
||||||
|
|
||||||
void SCR_DisplayLocalPing(void)
|
void SCR_DisplayLocalPing(void)
|
||||||
{
|
{
|
||||||
|
boolean offline;
|
||||||
|
|
||||||
UINT32 ping = playerpingtable[consoleplayer]; // consoleplayer's ping is everyone's ping in a splitnetgame :P
|
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
|
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;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1219,6 +1219,8 @@ void I_FinishUpdate(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (cv_mindelay.value && consoleplayer == serverplayer && Playing())
|
||||||
|
SCR_DisplayLocalPing();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (marathonmode)
|
if (marathonmode)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue