/* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // ui_joinserver.c -- the join server menu // Copyright (C) 2001-2003 pat@aftermoon.net for modif flanked by #include #ifdef _WIN32 #include #endif #include "../client/client.h" #include "ui_local.h" /* ============================================================================= JOIN SERVER MENU ============================================================================= */ #define MAX_LOCAL_SERVERS 12 static menuframework_s s_joinserver_menu; static menuseparator_s s_joinserver_server_title; //Knightmare- client compatibility option static menulist_s s_joinserver_compatibility_box; static menuseparator_s s_joinserver_compat_title; static menuaction_s s_joinserver_search_action; static menuaction_s s_joinserver_address_book_action; static menuaction_s s_joinserver_server_actions[MAX_LOCAL_SERVERS]; static menuaction_s s_joinserver_back_action; int m_num_servers; #define NO_SERVER_STRING "" // user readable information static char local_server_names[MAX_LOCAL_SERVERS][80]; // network address static netadr_t local_server_netadr[MAX_LOCAL_SERVERS]; void SearchLocalGames( void ); //Knightmare- client compatibility option static void ClientCompatibilityFunc( void *unused ) { Cvar_SetValue( "cl_servertrick", s_joinserver_compatibility_box.curvalue ); } #if 1 // Added code for compute ping time of server broadcasted // The server is displayed like : // "protocol ping hostname mapname nb players/max players" // "udp 100ms Pat q2dm1 2/8" int global_udp_server_time; int global_ipx_server_time; int global_adr_server_time[16]; netadr_t global_adr_server_netadr[16]; void UI_AddToServerList (netadr_t adr, char *info) { int i; int iPing; char *pszProtocol; if (m_num_servers == MAX_LOCAL_SERVERS) return; while ( *info == ' ' ) info++; // Ignore if duplicated for (i=0 ; i 0 ) // udp server { iPing = Sys_Milliseconds() - global_udp_server_time ; pszProtocol = "UDP" ; } else // ipx server { iPing = Sys_Milliseconds() - global_ipx_server_time ; pszProtocol = "IPX" ; } } Com_sprintf( local_server_names[m_num_servers], sizeof(local_server_names[0]), "%s %4dms %s", pszProtocol, iPing, info ) ; local_server_netadr[m_num_servers] = adr; m_num_servers++; } // #else void UI_AddToServerList (netadr_t adr, char *info) { int i; if (m_num_servers == MAX_LOCAL_SERVERS) return; while ( *info == ' ' ) info++; // ignore if duplicated for (i=0 ; i= m_num_servers) return; Com_sprintf (buffer, sizeof(buffer), "connect %s\n", NET_AdrToString (local_server_netadr[index])); Cbuf_AddText (buffer); UI_ForceMenuOff (); cls.disable_screen = 1; // Knightmare- show loading screen } void AddressBookFunc( void *self ) { M_Menu_AddressBook_f(); } //Knightmare- init client compatibility menu option static void JoinserverSetMenuItemValues( void ) { Cvar_SetValue( "cl_servertrick", ClampCvar( 0, 1, Cvar_VariableValue("cl_servertrick") ) ); s_joinserver_compatibility_box.curvalue = Cvar_VariableValue("cl_servertrick"); } void NullCursorDraw( void *self ) { } void SearchLocalGames( void ) { int i; m_num_servers = 0; for (i=0 ; i