diff options
author | Tim Angus <tim@ngus.net> | 2009-10-03 11:44:45 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:15:18 +0000 |
commit | f7e1f6ab256e2efa67d4e01dd15d45c1bcf6ce8f (patch) | |
tree | d9e5bcbacba8dad00b09a8281ee1969fb085007b | |
parent | b7723d58b1eac3cd7a542f55de8f361d84eaf45c (diff) |
* (bug 3517) connect.menu isn't properly opened on connection
* Partially revert 772
* Strip off trailing '\n' from server denial messages
-rw-r--r-- | src/client/cl_main.c | 5 | ||||
-rw-r--r-- | src/server/sv_client.c | 12 | ||||
-rw-r--r-- | src/ui/ui_atoms.c | 2 | ||||
-rw-r--r-- | src/ui/ui_main.c | 24 | ||||
-rw-r--r-- | src/ui/ui_shared.c | 38 | ||||
-rw-r--r-- | src/ui/ui_shared.h | 3 | ||||
-rw-r--r-- | ui/say.menu | 2 |
7 files changed, 36 insertions, 50 deletions
diff --git a/src/client/cl_main.c b/src/client/cl_main.c index ae1044e2..326bc5f6 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -2013,7 +2013,12 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) { // echo request from server if ( !Q_stricmp(c, "print") ) { s = MSG_ReadString( msg ); + Q_strncpyz( clc.serverMessage, s, sizeof( clc.serverMessage ) ); + + while( clc.serverMessage[ strlen( clc.serverMessage ) - 1 ] == '\n' ) + clc.serverMessage[ strlen( clc.serverMessage ) - 1 ] = '\0'; + Com_Printf( "%s", s ); return; } diff --git a/src/server/sv_client.c b/src/server/sv_client.c index 40a3a9f8..6aa7797b 100644 --- a/src/server/sv_client.c +++ b/src/server/sv_client.c @@ -111,7 +111,7 @@ void SV_DirectConnect( netadr_t from ) { version = atoi( Info_ValueForKey( userinfo, "protocol" ) ); if ( version != PROTOCOL_VERSION ) { - NET_OutOfBandPrint( NS_SERVER, from, "print\nServer uses protocol version %i", PROTOCOL_VERSION ); + NET_OutOfBandPrint( NS_SERVER, from, "print\nServer uses protocol version %i\n", PROTOCOL_VERSION ); Com_DPrintf (" rejected connect from version %i\n", version); return; } @@ -161,7 +161,7 @@ void SV_DirectConnect( netadr_t from ) { } } if (i == MAX_CHALLENGES) { - NET_OutOfBandPrint( NS_SERVER, from, "print\nNo or bad challenge for address" ); + NET_OutOfBandPrint( NS_SERVER, from, "print\nNo or bad challenge for address\n" ); return; } @@ -173,7 +173,7 @@ void SV_DirectConnect( netadr_t from ) { if ( !Sys_IsLANAddress( from ) ) { if ( sv_minPing->value && ping < sv_minPing->value ) { // don't let them keep trying until they get a big delay - NET_OutOfBandPrint( NS_SERVER, from, "print\nServer is for high pings only" ); + NET_OutOfBandPrint( NS_SERVER, from, "print\nServer is for high pings only\n" ); Com_DPrintf ("Client %i rejected on a too low ping\n", i); // reset the address otherwise their ping will keep increasing // with each connect message and they'd eventually be able to connect @@ -181,7 +181,7 @@ void SV_DirectConnect( netadr_t from ) { return; } if ( sv_maxPing->value && ping > sv_maxPing->value ) { - NET_OutOfBandPrint( NS_SERVER, from, "print\nServer is for low pings only" ); + NET_OutOfBandPrint( NS_SERVER, from, "print\nServer is for low pings only\n" ); Com_DPrintf ("Client %i rejected on a too high ping\n", i); return; } @@ -246,7 +246,7 @@ void SV_DirectConnect( netadr_t from ) { return; } else { - NET_OutOfBandPrint( NS_SERVER, from, "print\nServer is full" ); + NET_OutOfBandPrint( NS_SERVER, from, "print\nServer is full\n" ); Com_DPrintf ("Rejected a connection.\n"); return; } @@ -282,7 +282,7 @@ gotnewcl: // we can't just use VM_ArgPtr, because that is only valid inside a VM_Call char *str = VM_ExplicitArgPtr( gvm, denied ); - NET_OutOfBandPrint( NS_SERVER, from, "print\n%s", str ); + NET_OutOfBandPrint( NS_SERVER, from, "print\n%s\n", str ); Com_DPrintf ("Game rejected a connection: %s.\n", str); return; } diff --git a/src/ui/ui_atoms.c b/src/ui/ui_atoms.c index 65cfd0b1..71374ab3 100644 --- a/src/ui/ui_atoms.c +++ b/src/ui/ui_atoms.c @@ -201,7 +201,7 @@ qboolean UI_ConsoleCommand( int realTime ) { if( Menu_Count( ) > 0 ) { - Menus_CloseAll( qfalse ); + Menus_CloseAll( ); if( Menu_Count( ) == 0 ) { trap_Key_SetCatcher( trap_Key_GetCatcher( ) & ~KEYCATCH_UI ); diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c index a5168bdb..d8389c66 100644 --- a/src/ui/ui_main.c +++ b/src/ui/ui_main.c @@ -169,7 +169,7 @@ intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, return 0; case UI_IS_FULLSCREEN: - return UI_IsFullscreen(); + return UI_IsFullscreen( ); case UI_SET_ACTIVE_MENU: UI_SetActiveMenu( arg0 ); @@ -1479,7 +1479,7 @@ void UI_Load( void ) UI_LoadMenus( "ui/ingame.txt", qfalse ); UI_LoadMenus( "ui/tremulous.txt", qfalse ); UI_LoadHelp( "ui/help.txt" ); - Menus_CloseAll( qtrue ); + Menus_CloseAll( ); Menus_ActivateByName( lastName ); } @@ -2906,7 +2906,7 @@ static void UI_RunMenuScript( char **args ) //disallow the menu if it would be empty if( uiInfo.alienUpgradeCount <= 0 ) - Menus_CloseAll( qfalse ); + Menus_CloseAll( ); } else if( Q_stricmp( name, "UpgradeToNewClass" ) == 0 ) { @@ -3062,7 +3062,7 @@ static void UI_RunMenuScript( char **args ) { trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" ); trap_Key_SetCatcher( KEYCATCH_UI ); - Menus_CloseAll( qtrue ); + Menus_CloseAll( ); Menus_ActivateByName( "main" ); } else if( Q_stricmp( name, "ServerSort" ) == 0 ) @@ -3087,7 +3087,7 @@ static void UI_RunMenuScript( char **args ) trap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI ); trap_Key_ClearStates(); trap_Cvar_Set( "cl_paused", "0" ); - Menus_CloseAll( qfalse ); + Menus_CloseAll( ); } else if( Q_stricmp( name, "voteMap" ) == 0 ) { @@ -3928,7 +3928,7 @@ void UI_Init( qboolean inGameLoad ) UI_LoadMenus( "ui/tremulous.txt", qfalse ); UI_LoadHelp( "ui/help.txt" ); - Menus_CloseAll( qtrue ); + Menus_CloseAll( ); trap_LAN_LoadCachedServers(); @@ -3958,7 +3958,7 @@ void UI_KeyEvent( int key, qboolean down ) if( menu ) { if( key == K_ESCAPE && down && !Menus_AnyFullScreenVisible() ) - Menus_CloseAll( qtrue ); + Menus_CloseAll( ); else Menu_HandleKey( menu, key, down ); } @@ -4015,14 +4015,14 @@ void UI_SetActiveMenu( uiMenuCommand_t menu ) trap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI ); trap_Key_ClearStates(); trap_Cvar_Set( "cl_paused", "0" ); - Menus_CloseAll( qtrue ); + Menus_CloseAll( ); return; case UIMENU_MAIN: trap_Cvar_Set( "sv_killserver", "1" ); trap_Key_SetCatcher( KEYCATCH_UI ); - Menus_CloseAll( qtrue ); + Menus_CloseAll( ); Menus_ActivateByName( "main" ); trap_Cvar_VariableStringBuffer( "com_errorMessage", buf, sizeof( buf ) ); @@ -4040,7 +4040,7 @@ void UI_SetActiveMenu( uiMenuCommand_t menu ) trap_Cvar_Set( "cl_paused", "1" ); trap_Key_SetCatcher( KEYCATCH_UI ); UI_BuildPlayerList(); - Menus_CloseAll( qtrue ); + Menus_CloseAll( ); Menus_ActivateByName( "ingame" ); return; } @@ -4049,7 +4049,7 @@ void UI_SetActiveMenu( uiMenuCommand_t menu ) qboolean UI_IsFullscreen( void ) { - return Menus_AnyFullScreenVisible(); + return Menus_AnyFullScreenVisible( ); } @@ -4309,7 +4309,7 @@ void UI_DrawConnectScreen( qboolean overlay ) // print any server info (server full, bad version, etc) if( cstate.connState < CA_CONNECTED ) - Text_PaintCenter_AutoWrapped( centerPoint, yStart + 176, 630, 20, scale, colorWhite, cstate.messageString, 0 ); + Text_PaintCenter( centerPoint, yStart + 176, scale, colorWhite, cstate.messageString, 0 ); if( lastConnState > cstate.connState ) lastLoadingText[0] = '\0'; diff --git a/src/ui/ui_shared.c b/src/ui/ui_shared.c index 309b530d..84c31e4e 100644 --- a/src/ui/ui_shared.c +++ b/src/ui/ui_shared.c @@ -1543,7 +1543,8 @@ static void Menus_Close( menuDef_t *menu ) Menu_RunCloseScript( menu ); menu->window.flags &= ~( WINDOW_VISIBLE | WINDOW_HASFOCUS ); - openMenuCount--; + if( openMenuCount > 0 ) + openMenuCount--; if( openMenuCount > 0 ) Menus_Activate( menuStack[ openMenuCount - 1 ] ); @@ -1555,23 +1556,22 @@ void Menus_CloseByName( const char *p ) Menus_Close( Menus_FindByName( p ) ); } -void Menus_CloseAll( qboolean force ) +void Menus_CloseAll( void ) { int i; - for( i = 0; i < menuCount; i++ ) + // Close any menus on the stack first + if( openMenuCount > 0 ) { - if( !( Menus[i].window.flags & WINDOW_DONTCLOSEALL ) || force ) - Menus_Close( &Menus[i] ); - } + for( i = openMenuCount; i > 0; i-- ) + Menus_Close( menuStack[ i ] ); - if( force ) - { openMenuCount = 0; - g_editingField = qfalse; - g_waitingForKey = qfalse; - g_editItem = NULL; } + + // Close all other menus + for( i = 0; i < menuCount; i++ ) + Menus_Close( &Menus[ i ] ); } @@ -7675,20 +7675,6 @@ qboolean MenuParse_visible( itemDef_t *item, int handle ) return qtrue; } -qboolean MenuParse_dontCloseAll( itemDef_t *item, int handle ) -{ - int i; - menuDef_t *menu = ( menuDef_t* )item; - - if( !PC_Int_Parse( handle, &i ) ) - return qfalse; - - if( i ) - menu->window.flags |= WINDOW_DONTCLOSEALL; - - return qtrue; -} - qboolean MenuParse_onOpen( itemDef_t *item, int handle ) { menuDef_t *menu = ( menuDef_t* )item; @@ -7969,7 +7955,6 @@ keywordHash_t menuParseKeywords[] = { {"aspectBias", MenuParse_aspectBias, NULL}, {"style", MenuParse_style, NULL}, {"visible", MenuParse_visible, NULL}, - {"dontCloseAll", MenuParse_dontCloseAll, NULL}, {"onOpen", MenuParse_onOpen, NULL}, {"onClose", MenuParse_onClose, NULL}, {"onESC", MenuParse_onESC, NULL}, @@ -8281,4 +8266,3 @@ static qboolean Menu_OverActiveItem( menuDef_t *menu, float x, float y ) return qfalse; } - diff --git a/src/ui/ui_shared.h b/src/ui/ui_shared.h index 36d77bf8..a33d9ae6 100644 --- a/src/ui/ui_shared.h +++ b/src/ui/ui_shared.h @@ -64,7 +64,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define WINDOW_POPUP 0x00200000 // popup #define WINDOW_BACKCOLORSET 0x00400000 // backcolor was explicitly set #define WINDOW_TIMEDVISIBLE 0x00800000 // visibility timing ( NOT implemented ) -#define WINDOW_DONTCLOSEALL 0x01000000 // don't close during Menus_CloseAll() // CGAME cursor type bits @@ -464,7 +463,7 @@ menuDef_t *Menus_FindByName( const char *p ); void Menus_CloseByName( const char *p ); void Display_HandleKey( int key, qboolean down, int x, int y ); void LerpColor( vec4_t a, vec4_t b, vec4_t c, float t ); -void Menus_CloseAll( qboolean force ); +void Menus_CloseAll( void ); void Menu_Paint( menuDef_t *menu, qboolean forcePaint ); void Menu_SetFeederSelection( menuDef_t *menu, int feeder, int index, const char *name ); void Display_CacheAll( void ); diff --git a/ui/say.menu b/ui/say.menu index 51b7e681..7b804b45 100644 --- a/ui/say.menu +++ b/ui/say.menu @@ -15,7 +15,6 @@ name say fullScreen MENU_FALSE visible MENU_FALSE - dontCloseAll MENU_TRUE rect X Y W H aspectBias ALIGN_LEFT focusColor 1 1 1 1 @@ -54,7 +53,6 @@ name say_team fullScreen MENU_FALSE visible MENU_FALSE - dontCloseAll MENU_TRUE rect X Y W H aspectBias ALIGN_LEFT focusColor 1 1 1 1 |