From 6054901c62e3e0b472d5b8e80d6708ada15d15f9 Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Fri, 15 Feb 2019 20:51:44 -0600 Subject: [PATCH 01/20] Ping kick changes + other quality of life improvements [REDO] --- src/d_clisrv.c | 43 +++++++++++++++++++++++++++++++++++++------ src/d_clisrv.h | 1 + src/d_netcmd.c | 10 ++++++++++ src/d_netcmd.h | 2 ++ src/hu_stuff.c | 28 ++++++++++++++++++++++++++-- src/m_menu.c | 20 ++++++++++++-------- 6 files changed, 88 insertions(+), 16 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 961c1e59..04816fd1 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -93,6 +93,7 @@ static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the UINT16 pingmeasurecount = 1; UINT32 realpingtable[MAXPLAYERS]; //the base table of ping where an average will be sent to everyone. UINT32 playerpingtable[MAXPLAYERS]; //table of player latency values. +tic_t servermaxping = 800; // server's max ping. Defaults to 800 #endif SINT8 nodetoplayer[MAXNETNODES]; SINT8 nodetoplayer2[MAXNETNODES]; // say the numplayer for this node if any (splitscreen) @@ -4355,6 +4356,9 @@ FILESTAMP for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i]) playerpingtable[i] = (tic_t)netbuffer->u.pingtable[i]; + + servermaxping = (tic_t)netbuffer->u.pingtable[i++]; + CONS_Printf("got server maxping: %d\n", servermaxping); } break; @@ -4997,6 +5001,18 @@ void TryRunTics(tic_t realtics) } #ifdef NEWPING + +/* Ping Update except better: + We call this once per second and check for people's pings. If their ping happens to be too high, we increment some timer and kick them out. + If they're not lagging, decrement the timer by 1. Of course, reset all of this if they leave. + + Why do we do that? Well, I'm a person with unfortunately sometimes unstable internet and happen to keep getting kicked very unconveniently for very short high spikes. (700+ ms) + Because my spikes are so high, the average ping is exponentially higher too (700s really add up...!) which leads me to getting kicked for a short burst of spiking. + With this change here, this doesn't happen anymore as it checks if my ping has been CONSISTENTLY bad for long enough before killing me. +*/ + +static INT32 pingtimeout[MAXPLAYERS]; + static inline void PingUpdate(void) { INT32 i; @@ -5017,6 +5033,9 @@ static inline void PingUpdate(void) laggers[i] = true; numlaggers++; } + else + pingtimeout[i] = 0; + } //kick lagging players... unless everyone but the server's ping sucks. @@ -5027,12 +5046,21 @@ static inline void PingUpdate(void) { if (playeringame[i] && laggers[i]) { - XBOXSTATIC char buf[2]; + pingtimeout[i]++; + CONS_Printf("Player %d is lagging, incrementing timeout... %d/%d\n", i, pingtimeout[i], cv_pingtimeout.value); // debug print, don't forget to remove this... - buf[0] = (char)i; - buf[1] = KICK_MSG_PING_HIGH; - SendNetXCmd(XD_KICK, &buf, 2); + if (pingtimeout[i] > cv_pingtimeout.value) // ok your net has been bad for too long, you deserve to die. + { + pingtimeout[i] = 0; + XBOXSTATIC char buf[2]; + + buf[0] = (char)i; + buf[1] = KICK_MSG_PING_HIGH; + SendNetXCmd(XD_KICK, &buf, 2); + } } + else // you aren't lagging, but you aren't free yet. In case you'll keep spiking, we just make the timer go back down. (Very unstable net must still get kicked). + pingtimeout[i] = (pingtimeout[i] == 0 ? 0 : pingtimeout[i]-1); } } } @@ -5047,10 +5075,13 @@ static inline void PingUpdate(void) realpingtable[i] = 0; //Reset each as we go. } + // send the server's maxping as last element of our ping table. This is useful to let us know when we're about to get kicked. + netbuffer->u.pingtable[i++] = cv_maxping.value; + //send out our ping packets for (i = 0; i < MAXNETNODES; i++) if (nodeingame[i]) - HSendPacket(i, true, 0, sizeof(INT32) * MAXPLAYERS); + HSendPacket(i, true, 0, sizeof(INT32) * (MAXPLAYERS+1)); pingmeasurecount = 1; //Reset count } @@ -5064,7 +5095,7 @@ static void UpdatePingTable(void) INT32 i; if (server) { - if (netgame && !(gametime % 255)) + if (netgame && !(gametime % 35)) // update once per second. PingUpdate(); // update node latency values so we can take an average later. for (i = 0; i < MAXPLAYERS; i++) diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 62bd8bc1..04569198 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -519,6 +519,7 @@ extern tic_t jointimeout; extern UINT16 pingmeasurecount; extern UINT32 realpingtable[MAXPLAYERS]; extern UINT32 playerpingtable[MAXPLAYERS]; +extern tic_t servermaxping; #endif extern consvar_t diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 438cdcd5..ce54960d 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -435,6 +435,14 @@ consvar_t cv_jointimeout = {"jointimeout", "105", CV_CALL|CV_SAVE, nettimeout_co #ifdef NEWPING static CV_PossibleValue_t maxping_cons_t[] = {{0, "MIN"}, {1000, "MAX"}, {0, NULL}}; consvar_t cv_maxping = {"maxping", "800", CV_SAVE, maxping_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +static CV_PossibleValue_t pingtimeout_cons_t[] = {{8, "MIN"}, {120, "MAX"}, {0, NULL}}; +consvar_t cv_pingtimeout = {"pingtimeout", "15", CV_SAVE, pingtimeout_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +// show your ping on the HUD next to framerate. Defaults to warning only (shows up if your ping is > maxping) +static CV_PossibleValue_t showping_cons_t[] = {{0, "Off"}, {1, "Always"}, {2, "Warning"}, {0, NULL}}; +consvar_t cv_showping = {"showping", "Warning", CV_SAVE, showping_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + #endif // Intermission time Tails 04-19-2002 static CV_PossibleValue_t inttime_cons_t[] = {{0, "MIN"}, {3600, "MAX"}, {0, NULL}}; @@ -664,6 +672,8 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_sleep); #ifdef NEWPING CV_RegisterVar(&cv_maxping); + CV_RegisterVar(&cv_pingtimeout); + CV_RegisterVar(&cv_showping); #endif #ifdef SEENAMES diff --git a/src/d_netcmd.h b/src/d_netcmd.h index c590eee6..54c00484 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -145,6 +145,8 @@ extern consvar_t cv_specialrings, cv_powerstones, cv_matchboxes, cv_competitionb #ifdef NEWPING extern consvar_t cv_maxping; +extern consvar_t cv_pingtimeout; +extern consvar_t cv_showping; #endif extern consvar_t cv_skipmapcheck; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 3d8f2383..216d14b0 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2178,6 +2178,22 @@ static void HU_DrawSongCredits(void) V_DrawRightAlignedThinString(cursongcredit.x, y, V_ALLOWLOWERCASE|V_6WIDTHSPACE|V_SNAPTOLEFT|(cursongcredit.trans< servermaxping)) // only show 2 (warning) if our ping is at a bad level + { + INT32 dispx = cv_ticrate.value ? 260 : 290; + HU_drawPing(dispx, 190, ping, false); + } +} + // Heads up displays drawer, call each frame // void HU_Drawer(void) @@ -2290,6 +2306,9 @@ void HU_Drawer(void) V_DrawCenteredString(BASEVIDWIDTH/2, 180, V_YELLOWMAP | V_ALLOWLOWERCASE, resynch_text); } + + // draw the ping if the user wishes to + HU_drawLocalPing(); } //====================================================================== @@ -2376,6 +2395,7 @@ void HU_drawPing(INT32 x, INT32 y, INT32 ping, boolean notext) SINT8 i = 0; SINT8 yoffset = 6; INT32 dx = x+1 - (V_SmallStringWidth(va("%dms", ping), V_ALLOWLOWERCASE)/2); + boolean highping = (servermaxping && ping > servermaxping) ? true : false; if (ping < 128) { @@ -2387,13 +2407,17 @@ void HU_drawPing(INT32 x, INT32 y, INT32 ping, boolean notext) numbars = 2; // Apparently ternaries w/ multiple statements don't look good in C so I decided against it. barcolor = 103; } + else if (highping) // yikes...! + { + numbars = 0; + } if (!notext || vid.width >= 640) // how sad, we're using a shit resolution. - V_DrawSmallString(dx, y+4, V_ALLOWLOWERCASE, va("%dms", ping)); + V_DrawSmallString(dx, y+4, V_ALLOWLOWERCASE|((highping && hu_tick < 4) ? V_REDMAP : 0), va("%dms", ping)); for (i=0; (i<3); i++) // Draw the ping bar { - V_DrawFill(x+2 *(i-1), y+yoffset-4, 2, 8-yoffset, 31); + V_DrawFill(x+2 *(i-1), y+yoffset-4, 2, 8-yoffset, (highping && hu_tick < 4) ? 128 : 31); if (i < numbars) V_DrawFill(x+2 *(i-1), y+yoffset-3, 1, 8-yoffset-1, barcolor); diff --git a/src/m_menu.c b/src/m_menu.c index d8b1c2d7..966f4fa7 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1390,7 +1390,7 @@ static menuitem_t OP_HUDOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "HUD Visibility", &cv_translucenthud, 20}, - {IT_STRING | IT_SUBMENU, NULL, "Online chat options...",&OP_ChatOptionsDef, 35}, + {IT_STRING | IT_SUBMENU, NULL, "Online HUD options...",&OP_ChatOptionsDef, 35}, {IT_STRING | IT_CVAR, NULL, "Background Glass", &cons_backcolor, 45}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, @@ -1404,6 +1404,7 @@ static menuitem_t OP_HUDOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Console Text Size", &cv_constextsize, 120}, }; +// Ok it's still called chatoptions but we'll put ping display in here to be clean static menuitem_t OP_ChatOptionsMenu[] = { // will ANYONE who doesn't know how to use the console want to touch this one? @@ -1417,6 +1418,8 @@ static menuitem_t OP_ChatOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Chat Background Tint", &cv_chatbacktint, 50}, {IT_STRING | IT_CVAR, NULL, "Message Fadeout Time", &cv_chattime, 60}, {IT_STRING | IT_CVAR, NULL, "Spam Protection", &cv_chatspamprotection, 70}, + + {IT_STRING | IT_CVAR, NULL, "Local ping display", &cv_showping, 90}, // shows ping next to framerate if we want to. }; static menuitem_t OP_GameOptionsMenu[] = @@ -1469,15 +1472,16 @@ static menuitem_t OP_AdvServerOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 40}, {IT_STRING | IT_CVAR, NULL, "Ping limit (ms)", &cv_maxping, 50}, - {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 60}, - {IT_STRING | IT_CVAR, NULL, "Join timeout (tics)", &cv_jointimeout, 70}, + {IT_STRING | IT_CVAR, NULL, "Ping timeout (s)", &cv_pingtimeout, 60}, + {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 70}, + {IT_STRING | IT_CVAR, NULL, "Join timeout (tics)", &cv_jointimeout, 80}, - {IT_STRING | IT_CVAR, NULL, "Max. file transfer send (KB)", &cv_maxsend, 90}, - {IT_STRING | IT_CVAR, NULL, "File transfer packet rate", &cv_downloadspeed, 100}, + {IT_STRING | IT_CVAR, NULL, "Max. file transfer send (KB)", &cv_maxsend, 100}, + {IT_STRING | IT_CVAR, NULL, "File transfer packet rate", &cv_downloadspeed, 110}, - {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 120}, - {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 130}, - {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 140}, + {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 130}, + {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 140}, + {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 150}, }; #endif From 3349b9b196b6612c388ce65d11a1b1c4681bcaf4 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Fri, 15 Feb 2019 03:12:08 +0100 Subject: [PATCH 02/20] forgot to remove this print --- src/d_clisrv.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 04816fd1..cb02bf83 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4358,7 +4358,6 @@ FILESTAMP playerpingtable[i] = (tic_t)netbuffer->u.pingtable[i]; servermaxping = (tic_t)netbuffer->u.pingtable[i++]; - CONS_Printf("got server maxping: %d\n", servermaxping); } break; From 07e56e550e9f203998d02d5a59906337de8ec01f Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Fri, 15 Feb 2019 21:08:08 -0600 Subject: [PATCH 03/20] New visuals for ping and fps display alike [REDO] --- src/d_main.c | 2 +- src/hu_stuff.c | 73 ++++++++++++++++++++++++++---------------------- src/hu_stuff.h | 6 +++- src/k_kart.c | 3 +- src/lua_hudlib.c | 19 +++++++++++++ src/screen.c | 20 +++++++++---- src/v_video.c | 22 +++++++++++++++ src/v_video.h | 4 +++ 8 files changed, 107 insertions(+), 42 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 5cf95f4b..b35296aa 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -932,7 +932,7 @@ static void IdentifyVersion(void) D_AddFile(va(pandf,srb2waddir,"chars.kart")); D_AddFile(va(pandf,srb2waddir,"maps.kart")); #ifdef USE_PATCH_KART - D_AddFile(va(pandf,srb2waddir,"patch.kart")); + D_AddFile(va(pandf,srb2waddir,"patchping.kart")); // also don't forget to change that, this is to avoid conflicting with our regular patch.kart #endif #if !defined (HAVE_SDL) || defined (HAVE_MIXER) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 216d14b0..7e9f703d 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -74,6 +74,14 @@ patch_t *nightsnum[10]; // 0-9 patch_t *lt_font[LT_FONTSIZE]; patch_t *cred_font[CRED_FONTSIZE]; +// ping font +// Note: I'd like to adress that at this point we might *REALLY* want to work towards a common drawString function that can take any font we want because this is really turning into a MESS. :V -Lat' +patch_t *pingnum[10]; +patch_t *pinggfx[5]; // small ping graphic + +patch_t *framecounter; +patch_t *frameslash; // framerate stuff. Used in screen.c + static player_t *plr; boolean chat_on; // entering a chat message? static char w_chat[HU_MAXMSGLEN]; @@ -263,6 +271,8 @@ void HU_LoadGraphics(void) tallnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); sprintf(buffer, "NGTNUM%d", i); nightsnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + sprintf(buffer, "PINGN%d", i); + pingnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); } // minus for negative tallnums @@ -295,6 +305,17 @@ void HU_LoadGraphics(void) tinyemeraldpics[6] = W_CachePatchName("TEMER7", PU_HUDGFX); songcreditbg = W_CachePatchName("K_SONGCR", PU_HUDGFX); + + // cache ping gfx: + for (i = 0; i < 5; i++) + { + sprintf(buffer, "PINGGFX%d", i+1); + pinggfx[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + + // fps stuff + framecounter = W_CachePatchName("FRAMER", PU_HUDGFX); + frameslash = W_CachePatchName("FRAMESL", PU_HUDGFX);; } // Initialise Heads up @@ -2183,14 +2204,14 @@ static void HU_DrawSongCredits(void) void HU_drawLocalPing(void) { - if (!cv_showping.value || !netgame || consoleplayer == serverplayer) // we don't want to see it or aren't in a netgame, or are the server + if (!cv_showping.value || !netgame || consoleplayer != serverplayer) // we don't want to see it or aren't in a netgame, or are the server return; INT32 ping = playerpingtable[consoleplayer]; // consoleplayer's ping is everyone's ping in a splitnetgame :P if (cv_showping.value == 1 || (cv_showping.value == 2 && ping > servermaxping)) // only show 2 (warning) if our ping is at a bad level { - INT32 dispx = cv_ticrate.value ? 260 : 290; - HU_drawPing(dispx, 190, ping, false); + INT32 dispy = cv_ticrate.value ? 160 : 181; + HU_drawPing(307, dispy, ping, V_SNAPTORIGHT|V_SNAPTOBOTTOM); } } @@ -2388,41 +2409,25 @@ void HU_Erase(void) // // HU_drawPing // -void HU_drawPing(INT32 x, INT32 y, INT32 ping, boolean notext) +void HU_drawPing(INT32 x, INT32 y, INT32 ping, INT32 flags) { - UINT8 numbars = 1; // how many ping bars do we draw? - UINT8 barcolor = 128; // color we use for the bars (green, yellow or red) - SINT8 i = 0; - SINT8 yoffset = 6; - INT32 dx = x+1 - (V_SmallStringWidth(va("%dms", ping), V_ALLOWLOWERCASE)/2); - boolean highping = (servermaxping && ping > servermaxping) ? true : false; + INT32 gfxnum = 4; // gfx to draw + UINT8 const *colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_SALMON, GTC_CACHE); - if (ping < 128) - { - numbars = 3; - barcolor = 184; - } + if (ping < 76) + gfxnum = 0; + else if (ping < 137) + gfxnum = 1; else if (ping < 256) - { - numbars = 2; // Apparently ternaries w/ multiple statements don't look good in C so I decided against it. - barcolor = 103; - } - else if (highping) // yikes...! - { - numbars = 0; - } + gfxnum = 2; + else if (ping < 500) + gfxnum = 3; - if (!notext || vid.width >= 640) // how sad, we're using a shit resolution. - V_DrawSmallString(dx, y+4, V_ALLOWLOWERCASE|((highping && hu_tick < 4) ? V_REDMAP : 0), va("%dms", ping)); - - for (i=0; (i<3); i++) // Draw the ping bar - { - V_DrawFill(x+2 *(i-1), y+yoffset-4, 2, 8-yoffset, (highping && hu_tick < 4) ? 128 : 31); - if (i < numbars) - V_DrawFill(x+2 *(i-1), y+yoffset-3, 1, 8-yoffset-1, barcolor); - - yoffset -= 2; - } + V_DrawScaledPatch(x, y, flags, pinggfx[gfxnum]); + if (servermaxping && ping > servermaxping && hu_tick < 4) // flash ping red if too high + V_DrawPingNum(x, y+9, flags, ping, colormap); + else + V_DrawPingNum(x, y+9, flags, ping, NULL); } // diff --git a/src/hu_stuff.h b/src/hu_stuff.h index f1ecb2ff..0c94034d 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -80,7 +80,11 @@ extern boolean chat_on; extern patch_t *hu_font[HU_FONTSIZE], *kart_font[KART_FONTSIZE], *tny_font[HU_FONTSIZE]; // SRB2kart extern patch_t *tallnum[10]; +extern patch_t *pingnum[10]; +extern patch_t *pinggfx[5]; extern patch_t *nightsnum[10]; +extern patch_t *framecounter; +extern patch_t *frameslash; extern patch_t *lt_font[LT_FONTSIZE]; extern patch_t *cred_font[CRED_FONTSIZE]; extern patch_t *emeraldpics[7]; @@ -109,7 +113,7 @@ void HU_Drawer(void); char HU_dequeueChatChar(void); void HU_Erase(void); void HU_clearChatChars(void); -void HU_drawPing(INT32 x, INT32 y, INT32 ping, boolean notext); // Lat': Ping drawer for scoreboard. +void HU_drawPing(INT32 x, INT32 y, INT32 ping, INT32 flags); // Lat': Ping drawer for scoreboard. //void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer); //void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer); void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol); diff --git a/src/k_kart.c b/src/k_kart.c index 8d2936d3..ad6da417 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4682,6 +4682,7 @@ static void K_KartDrift(player_t *player, boolean onground) player->kartstuff[k_driftend] = 0; } + // Incease/decrease the drift value to continue drifting in that direction if (player->kartstuff[k_spinouttimer] == 0 && player->kartstuff[k_jmp] == 1 && onground && player->kartstuff[k_drift] != 0) { @@ -7168,7 +7169,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I if (netgame // don't draw it offline && tab[i].num != serverplayer) - HU_drawPing(x + ((i < 8) ? -19 : rightoffset + 13), y+2, playerpingtable[tab[i].num], false); + HU_drawPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, playerpingtable[tab[i].num], 0); STRBUFCPY(strtime, tab[i].name); diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index cd8e0392..fb6814b2 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -410,6 +410,24 @@ static int libd_drawPaddedNum(lua_State *L) return 0; } + +static int libd_drawPingNum(lua_State *L) +{ + INT32 x, y, flags, num; + const UINT8 *colormap = NULL; + HUDONLY + x = luaL_checkinteger(L, 1); + y = luaL_checkinteger(L, 2); + num = luaL_checkinteger(L, 3); + flags = luaL_optinteger(L, 4, 0); + flags &= ~V_PARAMMASK; // Don't let crashes happen. + if (!lua_isnoneornil(L, 5)) + colormap = *((UINT8 **)luaL_checkudata(L, 5, META_COLORMAP)); + + V_DrawPingNum(x, y, flags, num, colormap); + return 0; +} + static int libd_drawFill(lua_State *L) { INT32 x = luaL_optinteger(L, 1, 0); @@ -613,6 +631,7 @@ static luaL_Reg lib_draw[] = { {"drawScaled", libd_drawScaled}, {"drawNum", libd_drawNum}, {"drawPaddedNum", libd_drawPaddedNum}, + {"drawPingNum", libd_drawPingNum}, {"drawFill", libd_drawFill}, {"fadeScreen", libd_fadeScreen}, {"drawString", libd_drawString}, diff --git a/src/screen.c b/src/screen.c index af6aed03..937d6caa 100644 --- a/src/screen.c +++ b/src/screen.c @@ -403,7 +403,7 @@ void SCR_DisplayTicRate(void) tic_t i; tic_t ontic = I_GetTime(); tic_t totaltics = 0; - INT32 ticcntcolor = 0; + const UINT8 *ticcntcolor = NULL; for (i = lasttic + 1; i < TICRATE+lasttic && i < ontic; ++i) fpsgraph[i % TICRATE] = false; @@ -414,13 +414,23 @@ void SCR_DisplayTicRate(void) if (fpsgraph[i]) ++totaltics; - if (totaltics <= TICRATE/2) ticcntcolor = V_REDMAP; - else if (totaltics == TICRATE) ticcntcolor = V_GREENMAP; + if (totaltics <= TICRATE/2) ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_SALMON, GTC_CACHE); + else if (totaltics == TICRATE) ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_MINT, GTC_CACHE); - V_DrawString(vid.width-(24*vid.dupx), vid.height-(16*vid.dupy), + /*V_DrawString(vid.width-(24*vid.dupx), vid.height-(16*vid.dupy), V_YELLOWMAP|V_NOSCALESTART, "FPS"); V_DrawString(vid.width-(40*vid.dupx), vid.height-( 8*vid.dupy), - ticcntcolor|V_NOSCALESTART, va("%02d/%02u", totaltics, TICRATE)); + ticcntcolor|V_NOSCALESTART, va("%02d/%02u", totaltics, TICRATE));*/ + + // draw "FPS" + V_DrawFixedPatch(306<width); // this SHOULD always be 5 but I guess custom graphics exist. + + if (flags & V_NOSCALESTART) + w *= vid.dupx; + + if (num < 0) + num = -num; + + // draw the number + do + { + x -= (w-1); // Oni wanted their outline to intersect. + V_DrawFixedPatch(x< Date: Fri, 15 Feb 2019 22:30:13 +0100 Subject: [PATCH 04/20] Forgot to change this back from testing --- src/hu_stuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 7e9f703d..63673740 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2204,7 +2204,7 @@ static void HU_DrawSongCredits(void) void HU_drawLocalPing(void) { - if (!cv_showping.value || !netgame || consoleplayer != serverplayer) // we don't want to see it or aren't in a netgame, or are the server + if (!cv_showping.value || !netgame || consoleplayer == serverplayer) // we don't want to see it or aren't in a netgame, or are the server return; INT32 ping = playerpingtable[consoleplayer]; // consoleplayer's ping is everyone's ping in a splitnetgame :P From 95bbb0d833002dce797779a15fe3998c7ef4dd99 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sat, 16 Feb 2019 02:40:55 +0100 Subject: [PATCH 05/20] Remove debug stuff --- src/d_clisrv.c | 2 -- src/d_main.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index cb02bf83..b5de6896 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5046,8 +5046,6 @@ static inline void PingUpdate(void) if (playeringame[i] && laggers[i]) { pingtimeout[i]++; - CONS_Printf("Player %d is lagging, incrementing timeout... %d/%d\n", i, pingtimeout[i], cv_pingtimeout.value); // debug print, don't forget to remove this... - if (pingtimeout[i] > cv_pingtimeout.value) // ok your net has been bad for too long, you deserve to die. { pingtimeout[i] = 0; diff --git a/src/d_main.c b/src/d_main.c index b35296aa..5cf95f4b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -932,7 +932,7 @@ static void IdentifyVersion(void) D_AddFile(va(pandf,srb2waddir,"chars.kart")); D_AddFile(va(pandf,srb2waddir,"maps.kart")); #ifdef USE_PATCH_KART - D_AddFile(va(pandf,srb2waddir,"patchping.kart")); // also don't forget to change that, this is to avoid conflicting with our regular patch.kart + D_AddFile(va(pandf,srb2waddir,"patch.kart")); #endif #if !defined (HAVE_SDL) || defined (HAVE_MIXER) From a119d1cddd24215148575773fc06bb5b5bf1af02 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sat, 16 Feb 2019 12:19:03 +0100 Subject: [PATCH 06/20] Lower default ping timeout + Fix chat arrows being missing while we're at it --- src/d_netcmd.c | 2 +- src/hu_stuff.c | 4 ++-- src/v_video.c | 10 ++++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index ce54960d..53d88f2f 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -437,7 +437,7 @@ static CV_PossibleValue_t maxping_cons_t[] = {{0, "MIN"}, {1000, "MAX"}, {0, NUL consvar_t cv_maxping = {"maxping", "800", CV_SAVE, maxping_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t pingtimeout_cons_t[] = {{8, "MIN"}, {120, "MAX"}, {0, NULL}}; -consvar_t cv_pingtimeout = {"pingtimeout", "15", CV_SAVE, pingtimeout_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_pingtimeout = {"pingtimeout", "10", CV_SAVE, pingtimeout_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // show your ping on the HUD next to framerate. Defaults to warning only (shows up if your ping is > maxping) static CV_PossibleValue_t showping_cons_t[] = {{0, "Off"}, {1, "Always"}, {2, "Warning"}, {0, NULL}}; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 63673740..3bc28c17 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1633,9 +1633,9 @@ static void HU_drawChatLog(INT32 offset) // draw arrows to indicate that we can (or not) scroll. if (chat_scroll > 0) - V_DrawThinString(chatx-9, ((justscrolledup) ? (chat_topy-1) : (chat_topy)), V_SNAPTOBOTTOM | V_SNAPTOLEFT | highlight, "\x1A"); // up arrow + V_DrawCharacter(chatx-9, ((justscrolledup) ? (chat_topy-1) : (chat_topy)), V_SNAPTOBOTTOM | V_SNAPTOLEFT | highlight | '\x1A', false); // up arrow if (chat_scroll < chat_maxscroll) - V_DrawThinString(chatx-9, chat_bottomy-((justscrolleddown) ? 5 : 6), V_SNAPTOBOTTOM | V_SNAPTOLEFT | highlight, "\x1B"); // down arrow + V_DrawCharacter(chatx-9, chat_bottomy-((justscrolleddown) ? 5 : 6), V_SNAPTOBOTTOM | V_SNAPTOLEFT | highlight | '\x1B', false); // down arrow justscrolleddown = false; justscrolledup = false; diff --git a/src/v_video.c b/src/v_video.c index 7cbcd99a..473adeed 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1342,8 +1342,8 @@ void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed) V_DrawScaledPatch(x, y, flags, hu_font[c]); } -// Writes a single character for the chat. (draw WHITE if bit 7 set) -// Essentially the same as the above but it's small or big depending on what resolution you've chosen to huge.. +// Writes a single character for the chat (half scaled). (draw WHITE if bit 7 set) +// 16/02/19: Scratch the scaling thing, chat doesn't work anymore under 2x res -Lat' // void V_DrawChatCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed, UINT8 *colormap) { @@ -1359,13 +1359,11 @@ void V_DrawChatCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed, UI if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) return; - w = (vid.width < 640 ) ? (SHORT(hu_font[c]->width)/2) : (SHORT(hu_font[c]->width)); // use normal sized characters if we're using a terribly low resolution. + w = SHORT(hu_font[c]->width)/2; if (x + w > vid.width) return; - V_DrawFixedPatch(x*FRACUNIT, y*FRACUNIT, (vid.width < 640) ? (FRACUNIT) : (FRACUNIT/2), flags, hu_font[c], colormap); - - + V_DrawFixedPatch(x*FRACUNIT, y*FRACUNIT, FRACUNIT/2, flags, hu_font[c], colormap); } // Precompile a wordwrapped string to any given width. From 24516cbf8440b7534602292073a2093997be7910 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sat, 16 Feb 2019 13:38:50 +0100 Subject: [PATCH 07/20] Move ping display in i_video for consistency with showfps display --- src/djgppdos/i_video.c | 5 +++++ src/hu_stuff.c | 3 ++- src/sdl/i_video.c | 7 ++++++- src/sdl12/i_video.c | 5 +++++ src/win32/win_vid.c | 5 +++++ src/win32ce/win_vid.c | 5 +++++ 6 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/djgppdos/i_video.c b/src/djgppdos/i_video.c index 612c7221..69addfb0 100644 --- a/src/djgppdos/i_video.c +++ b/src/djgppdos/i_video.c @@ -41,6 +41,7 @@ #include "../m_argv.h" #include "vid_vesa.h" #include "../i_video.h" +#include "../hu_stuff.h" //dosstuff -newly added @@ -93,6 +94,10 @@ void I_FinishUpdate (void) // draw FPS if enabled if (cv_ticrate.value) SCR_DisplayTicRate(); + + // this is now handled here so that wipes and other things don't overlap it for the sake of consistency. + // no additional checks are needed here, this function does them all so no need to worry. :) + HU_drawLocalPing(); //blast it to the screen // this code sucks diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 3bc28c17..404b4509 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2329,7 +2329,8 @@ void HU_Drawer(void) } // draw the ping if the user wishes to - HU_drawLocalPing(); + // THIS IS NOW HANDLED IN I_VIDEO + //HU_drawLocalPing(); } //====================================================================== diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 2a77604d..9e5e4b60 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -64,9 +64,10 @@ #include "../m_menu.h" #include "../d_main.h" #include "../s_sound.h" -#include "../i_sound.h" // midi pause/unpause +#include "../i_sound.h" // midi pause/unpause #include "../i_joy.h" #include "../st_stuff.h" +#include "../hu_stuff.h" // ping drawer #include "../g_game.h" #include "../i_video.h" #include "../console.h" @@ -1360,6 +1361,10 @@ void I_FinishUpdate(void) if (cv_ticrate.value) SCR_DisplayTicRate(); + + // this is now handled here so that wipes and other things don't overlap it for the sake of consistency. + // no additional checks are needed here, this function does them all so no need to worry. :) + HU_drawLocalPing(); if (rendermode == render_soft && screens[0]) { diff --git a/src/sdl12/i_video.c b/src/sdl12/i_video.c index 69cf5ca9..08e6bd94 100644 --- a/src/sdl12/i_video.c +++ b/src/sdl12/i_video.c @@ -99,6 +99,7 @@ #include "../i_sound.h" // midi pause/unpause #include "../i_joy.h" #include "../st_stuff.h" +#include "../hu_stuff.h" #include "../g_game.h" #include "../i_video.h" #include "../console.h" @@ -1342,6 +1343,10 @@ void I_FinishUpdate(void) if (cv_ticrate.value) SCR_DisplayTicRate(); + + // this is now handled here so that wipes and other things don't overlap it for the sake of consistency. + // no additional checks are needed here, this function does them all so no need to worry. :) + HU_drawLocalPing(); if (render_soft == rendermode && screens[0]) { diff --git a/src/win32/win_vid.c b/src/win32/win_vid.c index 9f3d13f8..cba0c209 100644 --- a/src/win32/win_vid.c +++ b/src/win32/win_vid.c @@ -28,6 +28,7 @@ #include "../m_argv.h" #include "../v_video.h" #include "../st_stuff.h" +#include "../hu_stuff.h" #include "../i_video.h" #include "../z_zone.h" #include "fabdxlib.h" @@ -365,6 +366,10 @@ void I_FinishUpdate(void) // display a graph of ticrate if (cv_ticrate.value) SCR_DisplayTicRate(); + + // this is now handled here so that wipes and other things don't overlap it for the sake of consistency. + // no additional checks are needed here, this function does them all so no need to worry. :) + HU_drawLocalPing(); // if (bDIBMode) diff --git a/src/win32ce/win_vid.c b/src/win32ce/win_vid.c index 5e8e7e1f..c6610fa0 100644 --- a/src/win32ce/win_vid.c +++ b/src/win32ce/win_vid.c @@ -26,6 +26,7 @@ #include "../m_argv.h" #include "../v_video.h" #include "../st_stuff.h" +#include "../hu_stuff.h" #include "../i_video.h" #include "../z_zone.h" #include "fabdxlib.h" @@ -198,6 +199,10 @@ void I_FinishUpdate(void) if (cv_ticrate.value) SCR_DisplayTicRate(); + // this is now handled here so that wipes and other things don't overlap it for the sake of consistency. + // no additional checks are needed here, this function does them all so no need to worry. :) + HU_drawLocalPing(); + // if (bDIBMode) { From 82dbf45fa489881a5a0c6ff506bd7c9581efdbce Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Sat, 16 Feb 2019 08:29:48 -0600 Subject: [PATCH 08/20] Fix compiler warnings --- src/hu_stuff.c | 4 ++-- src/hu_stuff.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 404b4509..175c8bf3 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2207,7 +2207,7 @@ void HU_drawLocalPing(void) if (!cv_showping.value || !netgame || consoleplayer == serverplayer) // we don't want to see it or aren't in a netgame, or are the server return; - INT32 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 (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; @@ -2410,7 +2410,7 @@ void HU_Erase(void) // // HU_drawPing // -void HU_drawPing(INT32 x, INT32 y, INT32 ping, INT32 flags) +void HU_drawPing(INT32 x, INT32 y, UINT32 ping, INT32 flags) { INT32 gfxnum = 4; // gfx to draw UINT8 const *colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_SALMON, GTC_CACHE); diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 0c94034d..6788c701 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -109,11 +109,12 @@ void HU_Start(void); boolean HU_Responder(event_t *ev); void HU_Ticker(void); +void HU_drawLocalPing(void); void HU_Drawer(void); char HU_dequeueChatChar(void); void HU_Erase(void); void HU_clearChatChars(void); -void HU_drawPing(INT32 x, INT32 y, INT32 ping, INT32 flags); // Lat': Ping drawer for scoreboard. +void HU_drawPing(INT32 x, INT32 y, UINT32 ping, INT32 flags); // Lat': Ping drawer for scoreboard. //void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer); //void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer); void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol); From 1fb65c72ff0b1db2546830bf825b19da75b42d9e Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Tue, 19 Feb 2019 18:52:57 -0600 Subject: [PATCH 09/20] Reorganization + kill old interfaces --- src/djgppdos/i_video.c | 5 ----- src/hu_stuff.c | 15 --------------- src/hu_stuff.h | 1 - src/screen.c | 13 +++++++++++++ src/screen.h | 1 + src/sdl/i_video.c | 8 +++----- src/sdl12/i_video.c | 5 ----- src/win32/win_vid.c | 5 ----- src/win32ce/win_vid.c | 5 ----- 9 files changed, 17 insertions(+), 41 deletions(-) diff --git a/src/djgppdos/i_video.c b/src/djgppdos/i_video.c index 69addfb0..612c7221 100644 --- a/src/djgppdos/i_video.c +++ b/src/djgppdos/i_video.c @@ -41,7 +41,6 @@ #include "../m_argv.h" #include "vid_vesa.h" #include "../i_video.h" -#include "../hu_stuff.h" //dosstuff -newly added @@ -94,10 +93,6 @@ void I_FinishUpdate (void) // draw FPS if enabled if (cv_ticrate.value) SCR_DisplayTicRate(); - - // this is now handled here so that wipes and other things don't overlap it for the sake of consistency. - // no additional checks are needed here, this function does them all so no need to worry. :) - HU_drawLocalPing(); //blast it to the screen // this code sucks diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 175c8bf3..1ae48886 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2199,21 +2199,6 @@ static void HU_DrawSongCredits(void) V_DrawRightAlignedThinString(cursongcredit.x, y, V_ALLOWLOWERCASE|V_6WIDTHSPACE|V_SNAPTOLEFT|(cursongcredit.trans< 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); - } -} // Heads up displays drawer, call each frame // diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 6788c701..0f316bc7 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -109,7 +109,6 @@ void HU_Start(void); boolean HU_Responder(event_t *ev); void HU_Ticker(void); -void HU_drawLocalPing(void); void HU_Drawer(void); char HU_dequeueChatChar(void); void HU_Erase(void); diff --git a/src/screen.c b/src/screen.c index 937d6caa..4de2abd0 100644 --- a/src/screen.c +++ b/src/screen.c @@ -434,3 +434,16 @@ void SCR_DisplayTicRate(void) lasttic = ontic; } + +// SCR_DisplayLocalPing +// Used to draw the user's local ping next to the framerate for a quick check without having to hold TAB for instance. By default, it only shows up if your ping is too high and risks getting you kicked. + +void SCR_DisplayLocalPing(void) +{ + UINT32 ping = playerpingtable[consoleplayer]; // consoleplayer's ping is everyone's ping in a splitnetgame :P + if (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); + } +} diff --git a/src/screen.h b/src/screen.h index 9ad254d3..5b4a8e58 100644 --- a/src/screen.h +++ b/src/screen.h @@ -180,5 +180,6 @@ FUNCMATH boolean SCR_IsAspectCorrect(INT32 width, INT32 height); // move out to main code for consistency void SCR_DisplayTicRate(void); +void SCR_DisplayLocalPing(void); #undef DNWH #endif //__SCREEN_H__ diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 9e5e4b60..39a2c5ef 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -67,7 +67,6 @@ #include "../i_sound.h" // midi pause/unpause #include "../i_joy.h" #include "../st_stuff.h" -#include "../hu_stuff.h" // ping drawer #include "../g_game.h" #include "../i_video.h" #include "../console.h" @@ -1361,10 +1360,9 @@ void I_FinishUpdate(void) if (cv_ticrate.value) SCR_DisplayTicRate(); - - // this is now handled here so that wipes and other things don't overlap it for the sake of consistency. - // no additional checks are needed here, this function does them all so no need to worry. :) - HU_drawLocalPing(); + + if (cv_showping.value && netgame && consoleplayer != serverplayer) + SCR_DisplayLocalPing(); if (rendermode == render_soft && screens[0]) { diff --git a/src/sdl12/i_video.c b/src/sdl12/i_video.c index 08e6bd94..69cf5ca9 100644 --- a/src/sdl12/i_video.c +++ b/src/sdl12/i_video.c @@ -99,7 +99,6 @@ #include "../i_sound.h" // midi pause/unpause #include "../i_joy.h" #include "../st_stuff.h" -#include "../hu_stuff.h" #include "../g_game.h" #include "../i_video.h" #include "../console.h" @@ -1343,10 +1342,6 @@ void I_FinishUpdate(void) if (cv_ticrate.value) SCR_DisplayTicRate(); - - // this is now handled here so that wipes and other things don't overlap it for the sake of consistency. - // no additional checks are needed here, this function does them all so no need to worry. :) - HU_drawLocalPing(); if (render_soft == rendermode && screens[0]) { diff --git a/src/win32/win_vid.c b/src/win32/win_vid.c index cba0c209..9f3d13f8 100644 --- a/src/win32/win_vid.c +++ b/src/win32/win_vid.c @@ -28,7 +28,6 @@ #include "../m_argv.h" #include "../v_video.h" #include "../st_stuff.h" -#include "../hu_stuff.h" #include "../i_video.h" #include "../z_zone.h" #include "fabdxlib.h" @@ -366,10 +365,6 @@ void I_FinishUpdate(void) // display a graph of ticrate if (cv_ticrate.value) SCR_DisplayTicRate(); - - // this is now handled here so that wipes and other things don't overlap it for the sake of consistency. - // no additional checks are needed here, this function does them all so no need to worry. :) - HU_drawLocalPing(); // if (bDIBMode) diff --git a/src/win32ce/win_vid.c b/src/win32ce/win_vid.c index c6610fa0..5e8e7e1f 100644 --- a/src/win32ce/win_vid.c +++ b/src/win32ce/win_vid.c @@ -26,7 +26,6 @@ #include "../m_argv.h" #include "../v_video.h" #include "../st_stuff.h" -#include "../hu_stuff.h" #include "../i_video.h" #include "../z_zone.h" #include "fabdxlib.h" @@ -199,10 +198,6 @@ void I_FinishUpdate(void) if (cv_ticrate.value) SCR_DisplayTicRate(); - // this is now handled here so that wipes and other things don't overlap it for the sake of consistency. - // no additional checks are needed here, this function does them all so no need to worry. :) - HU_drawLocalPing(); - // if (bDIBMode) { From 30d37ce4cadcd2b09084ce677a5c68a896be0868 Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Tue, 19 Feb 2019 18:54:24 -0600 Subject: [PATCH 10/20] ...remove this forgotten comment too while I'm at it. --- src/hu_stuff.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 1ae48886..a9aa7c56 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2312,10 +2312,6 @@ void HU_Drawer(void) V_DrawCenteredString(BASEVIDWIDTH/2, 180, V_YELLOWMAP | V_ALLOWLOWERCASE, resynch_text); } - - // draw the ping if the user wishes to - // THIS IS NOW HANDLED IN I_VIDEO - //HU_drawLocalPing(); } //====================================================================== From ca87cfbf01302d398bf5970c3b5980be3262e9b4 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 19 Feb 2019 21:57:56 -0500 Subject: [PATCH 11/20] Water skipping speed requirements are stricter --- src/p_mobj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 746fc1af..fd42a1d7 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3399,8 +3399,8 @@ void P_MobjCheckWater(mobj_t *mobj) // skipping stone! if (p && p->kartstuff[k_waterskip] < 2 - && ((p->speed/2 > abs(mobj->momz)) // Going more forward than horizontal, so you can skip across the water. - || (p->speed > K_GetKartSpeed(p,false)/4 && p->kartstuff[k_waterskip])) // Already skipped once, so you can skip once more! + && ((p->speed/3 > abs(mobj->momz)) // Going more forward than horizontal, so you can skip across the water. + || (p->speed > K_GetKartSpeed(p,false)/3 && p->kartstuff[k_waterskip])) // Already skipped once, so you can skip once more! && ((!(mobj->eflags & MFE_VERTICALFLIP) && thingtop - mobj->momz > mobj->watertop) || ((mobj->eflags & MFE_VERTICALFLIP) && mobj->z - mobj->momz < mobj->waterbottom))) { From 68b8ec81626a9023f638e7e22e9bb01489637ea6 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 19 Feb 2019 23:01:19 -0500 Subject: [PATCH 12/20] Wipeout particles come from back wheels --- src/k_kart.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 468f5438..5ccc969b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2771,11 +2771,24 @@ void K_SpawnSparkleTrail(mobj_t *mo) void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent) { mobj_t *dust; + angle_t aoff; I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); - dust = P_SpawnMobj(mo->x + (P_RandomRange(-25,25) * mo->scale), mo->y + (P_RandomRange(-25,25) * mo->scale), mo->z, MT_WIPEOUTTRAIL); + if (mo->player) + aoff = (mo->player->frameangle + ANGLE_180); + else + aoff = (mo->angle + ANGLE_180); + + if ((leveltime / 2) & 1) + aoff -= ANGLE_45; + else + aoff += ANGLE_45; + + dust = P_SpawnMobj(mo->x + FixedMul(24*mo->scale, FINECOSINE(aoff>>ANGLETOFINESHIFT)) + (P_RandomRange(-8,8) << FRACBITS), + mo->y + FixedMul(24*mo->scale, FINESINE(aoff>>ANGLETOFINESHIFT)) + (P_RandomRange(-8,8) << FRACBITS), + mo->z, MT_WIPEOUTTRAIL); P_SetTarget(&dust->target, mo); dust->angle = R_PointToAngle2(0,0,mo->momx,mo->momy); From 38ad726e55eb443702b3a76676ce14054fdae71e Mon Sep 17 00:00:00 2001 From: James Date: Tue, 19 Feb 2019 23:38:16 -0500 Subject: [PATCH 13/20] Modify momz underwater for lots of things in k_kart.c --- src/k_kart.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 468f5438..81877a64 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1399,7 +1399,7 @@ void K_RespawnChecker(player_t *player) mo->eflags |= MFE_VERTICALFLIP; P_SetTarget(&mo->target, player->mo); mo->angle = newangle+ANGLE_90; - mo->momz = (8*FRACUNIT)*P_MobjFlip(player->mo); + mo->momz = (8<mo); P_SetScale(mo, (mo->destscale = FRACUNIT)); } } @@ -2212,6 +2212,9 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b player->mo->momz *= 2; } + if (player->mo->eflags & MFE_UNDERWATER) + player->mo->momz = (117 * player->mo->momz) / 200; + if (player->mo->state != &states[S_KART_SPIN]) P_SetPlayerMobjState(player->mo, S_KART_SPIN); @@ -2421,6 +2424,8 @@ void K_SpawnMineExplosion(mobj_t *source, UINT8 color) truc->momy = P_RandomRange(-speed, speed)*FRACUNIT; speed = FixedMul(20*FRACUNIT, source->scale)>>FRACBITS; truc->momz = P_RandomRange(-speed, speed)*FRACUNIT; + if (truc->eflags & MFE_UNDERWATER) + truc->momz = (117 * truc->momz) / 200; truc->color = color; } @@ -2449,6 +2454,8 @@ void K_SpawnMineExplosion(mobj_t *source, UINT8 color) truc->momz = P_RandomRange(speed, speed2)*FRACUNIT; if (P_RandomChance(FRACUNIT/2)) truc->momz = -truc->momz; + if (truc->eflags & MFE_UNDERWATER) + truc->momz = (117 * truc->momz) / 200; truc->tics = TICRATE*2; truc->color = color; } @@ -3006,6 +3013,9 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map mo->momy = player->mo->momy + FixedMul(FINESINE(fa), (altthrow == 2 ? 2*PROJSPEED/3 : PROJSPEED)); mo->momz = P_MobjFlip(player->mo) * HEIGHT; + if (mo->eflags & MFE_UNDERWATER) + mo->momz = (117 * mo->momz) / 200; + if (player->mo->eflags & MFE_VERTICALFLIP) mo->eflags |= MFE_VERTICALFLIP; } @@ -3364,6 +3374,9 @@ void K_DoPogoSpring(mobj_t *mo, fixed_t vertispeed, UINT8 sound) else mo->momz = FixedMul(vertispeed, vscale); + if (mo->eflags & MFE_UNDERWATER) + mo->momz = (117 * mo->momz) / 200; + if (sound) S_StartSound(mo, (sound == 1 ? sfx_kc2f : sfx_kpogos)); } @@ -3513,6 +3526,8 @@ void K_DropHnextList(player_t *player) dropwork->momx = player->mo->momx>>1; dropwork->momy = player->mo->momy>>1; dropwork->momz = 3*flip*mapobjectscale; + if (dropwork->eflags & MFE_UNDERWATER) + dropwork->momz = (117 * dropwork->momz) / 200; P_Thrust(dropwork, work->angle - ANGLE_90, 6*mapobjectscale); dropwork->movecount = 2; dropwork->movedir = work->angle - ANGLE_90; @@ -3571,6 +3586,8 @@ void K_DropItems(player_t *player) FixedAngle(P_RandomFixed()*180) + player->mo->angle + ANGLE_90, 16*mapobjectscale); drop->momz = P_MobjFlip(player->mo)*3*mapobjectscale; + if (drop->eflags & MFE_UNDERWATER) + drop->momz = (117 * drop->momz) / 200; drop->threshold = (thunderhack ? KITEM_THUNDERSHIELD : player->kartstuff[k_itemtype]); drop->movecount = player->kartstuff[k_itemamount]; From d9759df874608e97a1ea5708b95916f224f3d18d Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Fri, 22 Feb 2019 18:13:22 -0600 Subject: [PATCH 14/20] I don't think these old interfaces even compile but let's not kill them off --- src/djgppdos/i_video.c | 3 +++ src/sdl12/i_video.c | 3 +++ src/win32/win_vid.c | 3 +++ src/win32ce/win_vid.c | 3 +++ 4 files changed, 12 insertions(+) diff --git a/src/djgppdos/i_video.c b/src/djgppdos/i_video.c index 612c7221..7829acbb 100644 --- a/src/djgppdos/i_video.c +++ b/src/djgppdos/i_video.c @@ -94,6 +94,9 @@ void I_FinishUpdate (void) if (cv_ticrate.value) SCR_DisplayTicRate(); + if (cv_showping.value && netgame && consoleplayer != serverplayer) + SCR_DisplayLocalPing(); + //blast it to the screen // this code sucks //memcpy(dascreen,screens[0],screenwidth*screenheight); diff --git a/src/sdl12/i_video.c b/src/sdl12/i_video.c index 69cf5ca9..a2a20c61 100644 --- a/src/sdl12/i_video.c +++ b/src/sdl12/i_video.c @@ -1343,6 +1343,9 @@ void I_FinishUpdate(void) if (cv_ticrate.value) SCR_DisplayTicRate(); + if (cv_showping.value && netgame && consoleplayer != serverplayer) + SCR_DisplayLocalPing(); + if (render_soft == rendermode && screens[0]) { SDL_Rect *dstrect = NULL; diff --git a/src/win32/win_vid.c b/src/win32/win_vid.c index 9f3d13f8..45f96e9d 100644 --- a/src/win32/win_vid.c +++ b/src/win32/win_vid.c @@ -366,6 +366,9 @@ void I_FinishUpdate(void) if (cv_ticrate.value) SCR_DisplayTicRate(); + if (cv_showping.value && netgame && consoleplayer != serverplayer) + SCR_DisplayLocalPing(); + // if (bDIBMode) { diff --git a/src/win32ce/win_vid.c b/src/win32ce/win_vid.c index 5e8e7e1f..244dfaf3 100644 --- a/src/win32ce/win_vid.c +++ b/src/win32ce/win_vid.c @@ -198,6 +198,9 @@ void I_FinishUpdate(void) if (cv_ticrate.value) SCR_DisplayTicRate(); + if (cv_showping.value && netgame && consoleplayer != serverplayer) + SCR_DisplayLocalPing(); + // if (bDIBMode) { From cec79dee87128b0d9f48f6a6c0a87a6b31e596e4 Mon Sep 17 00:00:00 2001 From: Alam Arias Date: Fri, 22 Feb 2019 21:04:53 -0500 Subject: [PATCH 15/20] if you going to use abs(), you need to work in signed types --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 0a19ec8f..842ac1a7 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4896,7 +4896,7 @@ void G_WriteGhostTic(mobj_t *ghost) void G_ConsGhostTic(void) { UINT8 ziptic; - UINT32 px,py,pz,gx,gy,gz; + fixed_t px,py,pz,gx,gy,gz; mobj_t *testmo; UINT32 syncleeway; boolean nightsfail = false; From d5a4759121b89340016b22f332bdc174dc4a56a7 Mon Sep 17 00:00:00 2001 From: Alam Arias Date: Fri, 22 Feb 2019 21:13:00 -0500 Subject: [PATCH 16/20] signed and unsigned compare --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 842ac1a7..003c11e9 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4898,7 +4898,7 @@ void G_ConsGhostTic(void) UINT8 ziptic; fixed_t px,py,pz,gx,gy,gz; mobj_t *testmo; - UINT32 syncleeway; + fixed_t syncleeway; boolean nightsfail = false; if (!demo_p || !demo_start) From f91eb68b709c660f319c6546a3a27dd1ce4100f1 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Fri, 22 Feb 2019 22:49:27 -0500 Subject: [PATCH 17/20] Update item table Not looking forward to testing... --- src/k_kart.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index c8c1e1e5..93ef33db 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -496,20 +496,20 @@ boolean K_IsPlayerWanted(player_t *player) static INT32 K_KartItemOddsRace[NUMKARTRESULTS][10] = { //P-Odds 0 1 2 3 4 5 6 7 8 9 - /*Sneaker*/ {20, 0, 0, 4, 6, 6, 0, 0, 0, 0 }, // Sneaker - /*Rocket Sneaker*/ { 0, 0, 0, 0, 0, 1, 3, 5, 3, 0 }, // Rocket Sneaker - /*Invincibility*/ { 0, 0, 0, 0, 0, 1, 4, 6,14, 0 }, // Invincibility - /*Banana*/ { 0,10, 4, 2, 1, 0, 0, 0, 0, 0 }, // Banana + /*Sneaker*/ {20, 0, 0, 4, 7, 7, 0, 0, 0, 0 }, // Sneaker + /*Rocket Sneaker*/ { 0, 0, 0, 0, 0, 1, 4, 5, 3, 0 }, // Rocket Sneaker + /*Invincibility*/ { 0, 0, 0, 0, 0, 1, 4, 6,10, 0 }, // Invincibility + /*Banana*/ { 0, 9, 4, 2, 1, 0, 0, 0, 0, 0 }, // Banana /*Eggman Monitor*/ { 0, 3, 2, 1, 0, 0, 0, 0, 0, 0 }, // Eggman Monitor - /*Orbinaut*/ { 0, 8, 6, 4, 2, 0, 0, 0, 0, 0 }, // Orbinaut + /*Orbinaut*/ { 0, 7, 6, 4, 2, 0, 0, 0, 0, 0 }, // Orbinaut /*Jawz*/ { 0, 0, 3, 2, 1, 1, 0, 0, 0, 0 }, // Jawz /*Mine*/ { 0, 0, 2, 2, 1, 0, 0, 0, 0, 0 }, // Mine /*Ballhog*/ { 0, 0, 0, 2, 1, 0, 0, 0, 0, 0 }, // Ballhog /*Self-Propelled Bomb*/ { 0, 0, 1, 2, 3, 4, 2, 2, 0,20 }, // Self-Propelled Bomb - /*Grow*/ { 0, 0, 0, 0, 0, 1, 3, 5, 3, 0 }, // Grow + /*Grow*/ { 0, 0, 0, 0, 0, 0, 2, 5, 7, 0 }, // Grow /*Shrink*/ { 0, 0, 0, 0, 0, 0, 0, 2, 0, 0 }, // Shrink /*Thunder Shield*/ { 0, 1, 2, 0, 0, 0, 0, 0, 0, 0 }, // Thunder Shield - /*Hyudoro*/ { 0, 0, 0, 0, 1, 2, 1, 0, 0, 0 }, // Hyudoro + /*Hyudoro*/ { 0, 0, 0, 0, 0, 2, 1, 0, 0, 0 }, // Hyudoro /*Pogo Spring*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Pogo Spring /*Kitchen Sink*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Kitchen Sink /*Sneaker x3*/ { 0, 0, 0, 0, 3, 7, 9, 2, 0, 0 }, // Sneaker x3 From c543c35b91cb217faaa9c2b2a9b9e4d57eb9d4a3 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Fri, 22 Feb 2019 22:50:13 -0500 Subject: [PATCH 18/20] Revert this minor change --- src/k_kart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 93ef33db..d49b4f4d 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -496,7 +496,7 @@ boolean K_IsPlayerWanted(player_t *player) static INT32 K_KartItemOddsRace[NUMKARTRESULTS][10] = { //P-Odds 0 1 2 3 4 5 6 7 8 9 - /*Sneaker*/ {20, 0, 0, 4, 7, 7, 0, 0, 0, 0 }, // Sneaker + /*Sneaker*/ {20, 0, 0, 4, 6, 7, 0, 0, 0, 0 }, // Sneaker /*Rocket Sneaker*/ { 0, 0, 0, 0, 0, 1, 4, 5, 3, 0 }, // Rocket Sneaker /*Invincibility*/ { 0, 0, 0, 0, 0, 1, 4, 6,10, 0 }, // Invincibility /*Banana*/ { 0, 9, 4, 2, 1, 0, 0, 0, 0, 0 }, // Banana @@ -509,7 +509,7 @@ static INT32 K_KartItemOddsRace[NUMKARTRESULTS][10] = /*Grow*/ { 0, 0, 0, 0, 0, 0, 2, 5, 7, 0 }, // Grow /*Shrink*/ { 0, 0, 0, 0, 0, 0, 0, 2, 0, 0 }, // Shrink /*Thunder Shield*/ { 0, 1, 2, 0, 0, 0, 0, 0, 0, 0 }, // Thunder Shield - /*Hyudoro*/ { 0, 0, 0, 0, 0, 2, 1, 0, 0, 0 }, // Hyudoro + /*Hyudoro*/ { 0, 0, 0, 0, 1, 2, 1, 0, 0, 0 }, // Hyudoro /*Pogo Spring*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Pogo Spring /*Kitchen Sink*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Kitchen Sink /*Sneaker x3*/ { 0, 0, 0, 0, 3, 7, 9, 2, 0, 0 }, // Sneaker x3 From 1d3adb04911702f13b0a89d101b589d5ef2cf9d3 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Tue, 26 Feb 2019 17:33:10 -0500 Subject: [PATCH 19/20] Remove mixed declaration that triggers ERRORMODE on my setup --- src/d_clisrv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 6eda1445..e8700cd0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5096,9 +5096,10 @@ static inline void PingUpdate(void) pingtimeout[i]++; if (pingtimeout[i] > cv_pingtimeout.value) // ok your net has been bad for too long, you deserve to die. { - pingtimeout[i] = 0; XBOXSTATIC char buf[2]; + pingtimeout[i] = 0; + buf[0] = (char)i; buf[1] = KICK_MSG_PING_HIGH; SendNetXCmd(XD_KICK, &buf, 2); From 22434949e52afd5cf0c87a1622426974668d2e35 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Tue, 26 Feb 2019 17:44:35 -0500 Subject: [PATCH 20/20] Extend pingtable by 1 for the servermaxping entry --- src/d_clisrv.c | 6 +++--- src/d_clisrv.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e8700cd0..f8938d6c 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4400,12 +4400,12 @@ FILESTAMP //Update client ping table from the server. if (client) { - INT32 i; + UINT8 i; for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i]) playerpingtable[i] = (tic_t)netbuffer->u.pingtable[i]; - servermaxping = (tic_t)netbuffer->u.pingtable[i++]; + servermaxping = (tic_t)netbuffer->u.pingtable[MAXPLAYERS]; } break; @@ -5122,7 +5122,7 @@ static inline void PingUpdate(void) } // send the server's maxping as last element of our ping table. This is useful to let us know when we're about to get kicked. - netbuffer->u.pingtable[i++] = cv_maxping.value; + netbuffer->u.pingtable[MAXPLAYERS] = cv_maxping.value; //send out our ping packets for (i = 0; i < MAXNETNODES; i++) diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 21fe7c38..6615d67d 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -452,10 +452,10 @@ typedef struct serverrefuse_pak serverrefuse; // 65025 bytes (somehow I feel like those values are garbage...) askinfo_pak askinfo; // 61 bytes msaskinfo_pak msaskinfo; // 22 bytes - plrinfo playerinfo[MAXPLAYERS]; // 1152 bytes (I'd say 36~38) - plrconfig playerconfig[MAXPLAYERS]; // (up to) 896 bytes (welp they ARE) + plrinfo playerinfo[MAXPLAYERS]; // 576 bytes(?) + plrconfig playerconfig[MAXPLAYERS]; // (up to) 528 bytes(?) #ifdef NEWPING - UINT32 pingtable[MAXPLAYERS]; // 128 bytes + UINT32 pingtable[MAXPLAYERS+1]; // 68 bytes #endif } u; // This is needed to pack diff packet types data together } ATTRPACK doomdata_t;