From a85a856215204d42e6125cea7f58ea4030e22d9e Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 12 Jul 2019 22:41:57 +0300 Subject: [PATCH] engine: implement connection warning dialog showing up, update menu --- engine/client/cl_main.c | 25 ++++++++++++++++++++++++- engine/client/client.h | 4 ++++ engine/common/common.h | 1 + engine/common/dedicated.c | 5 +++++ engine/common/net_chan.c | 2 +- mainui | 2 +- 6 files changed, 36 insertions(+), 3 deletions(-) diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index e1c4565b..8c36cb49 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -2088,7 +2088,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) if( cls.internetservers_pending ) { - Cbuf_AddText( "menu_resetping\n" ); // TODO: New Menu API + UI_ResetPing(); cls.internetservers_pending = false; } } @@ -2713,6 +2713,29 @@ void CL_Escape_f( void ) else UI_SetActiveMenu( true ); } +/* +================= +CL_WarnLostSplitPacket + +================= +*/ +void CL_WarnLostSplitPacket( void ) +{ + if( cls.state != ca_connected ) + return; + + if( Host_IsLocalClient() ) + return; + + if( ++cl.lostpackets == 8 ) + { + CL_Disconnect(); + UI_ShowConnectionWarning(); + MsgDev( D_WARN, "Too many lost packets! Showing Network options menu\n" ); + + } +} + /* ================= CL_InitLocal diff --git a/engine/client/client.h b/engine/client/client.h index 89b0d2aa..d5bb44f9 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -265,6 +265,8 @@ typedef struct short decal_index[MAX_DECALS]; model_t *worldmodel; // pointer to world + + int lostpackets; // count lost packets and show dialog in menu } client_t; /* @@ -490,6 +492,7 @@ typedef struct { void *hInstance; // pointer to client.dll UI_FUNCTIONS dllFuncs; // dll exported funcs + UI_EXTENDED_FUNCTIONS dllFuncs2; // fwgs extension byte *mempool; // client edicts pool cl_entity_t playermodel; // uiPlayerSetup drawing model @@ -1071,6 +1074,7 @@ qboolean UI_CreditsActive( void ); void UI_CharEvent( int key ); qboolean UI_MouseInRect( void ); qboolean UI_IsVisible( void ); +void UI_ResetPing( void ); void UI_AddTouchButtonToList( const char *name, const char *texture, const char *command, unsigned char *color, int flags ); void pfnPIC_Set( HIMAGE hPic, int r, int g, int b, int a ); void pfnPIC_Draw( int x, int y, int width, int height, const wrect_t *prc ); diff --git a/engine/common/common.h b/engine/common/common.h index c65a78f3..5d8b1af8 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -851,6 +851,7 @@ qboolean CL_IsInConsole( void ); qboolean CL_IsThirdPerson( void ); qboolean CL_IsIntermission( void ); qboolean CL_Initialized( void ); +void CL_WarnLostSplitPacket( void ); char *CL_Userinfo( void ); void CL_LegacyUpdateInfo( void ); void CL_CharEvent( int key ); diff --git a/engine/common/dedicated.c b/engine/common/dedicated.c index d1c9773b..49922cd1 100644 --- a/engine/common/dedicated.c +++ b/engine/common/dedicated.c @@ -327,4 +327,9 @@ void CL_ClearStaticEntities( void ) } +void CL_WarnLostSplitPacket( void ) +{ + +} + #endif // XASH_DEDICATED diff --git a/engine/common/net_chan.c b/engine/common/net_chan.c index 3e16efbb..31558823 100644 --- a/engine/common/net_chan.c +++ b/engine/common/net_chan.c @@ -140,7 +140,7 @@ qboolean NetSplit_GetLong( netsplit_t *ns, netadr_t *from, byte *data, size_t *l // warn if previous packet not received if( p->received < p->count ) { - //CL_WarnLostSplitPacket(); + CL_WarnLostSplitPacket(); Con_Reportf( S_WARN "NetSplit_GetLong: lost packet %d\n", p->id ); } diff --git a/mainui b/mainui index 155a1d80..f43379a4 160000 --- a/mainui +++ b/mainui @@ -1 +1 @@ -Subproject commit 155a1d80ddffd6696c965853e2f97167d9b4da59 +Subproject commit f43379a48cb0b9d1fa076a0fbb6eee8b73b47775