31 Jan 2010
This commit is contained in:
parent
e809471a65
commit
4b471fac31
|
@ -223,7 +223,8 @@ void CL_Connect_f( void )
|
|||
}
|
||||
|
||||
server = Cmd_Argv( 1 );
|
||||
|
||||
NET_Config( true ); // allow remote
|
||||
|
||||
Msg( "server %s\n", server );
|
||||
CL_Disconnect();
|
||||
|
||||
|
@ -259,6 +260,8 @@ void CL_Rcon_f( void )
|
|||
message[3] = (char)255;
|
||||
message[4] = 0;
|
||||
|
||||
NET_Config( true ); // allow remote
|
||||
|
||||
com.strcat( message, "rcon " );
|
||||
com.strcat( message, rcon_client_password->string );
|
||||
com.strcat( message, " " );
|
||||
|
@ -356,6 +359,24 @@ void CL_Disconnect_f( void )
|
|||
Host_Error( "Disconnected from server\n" );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_LocalServers_f
|
||||
=================
|
||||
*/
|
||||
void CL_LocalServers_f( void )
|
||||
{
|
||||
netadr_t adr;
|
||||
|
||||
MsgDev( D_INFO, "Scanning for servers on the local network area...\n" );
|
||||
NET_Config( true ); // allow remote
|
||||
|
||||
// send a broadcast packet
|
||||
adr.type = NA_BROADCAST;
|
||||
adr.port = BigShort( PORT_SERVER );
|
||||
|
||||
Netchan_OutOfBandPrint( NS_CLIENT, adr, "info %i", PROTOCOL_VERSION );
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
|
@ -379,16 +400,18 @@ void CL_Packet_f( void )
|
|||
return;
|
||||
}
|
||||
|
||||
if (!NET_StringToAdr (Cmd_Argv(1), &adr))
|
||||
NET_Config( true ); // allow remote
|
||||
|
||||
if( !NET_StringToAdr( Cmd_Argv( 1 ), &adr ))
|
||||
{
|
||||
Msg ("Bad address\n");
|
||||
Msg( "Bad address\n" );
|
||||
return;
|
||||
}
|
||||
if (!adr.port)
|
||||
adr.port = BigShort (PORT_SERVER);
|
||||
|
||||
in = Cmd_Argv(2);
|
||||
out = send+4;
|
||||
if( !adr.port ) adr.port = BigShort( PORT_SERVER );
|
||||
|
||||
in = Cmd_Argv( 2 );
|
||||
out = send + 4;
|
||||
send[0] = send[1] = send[2] = send[3] = (char)0xff;
|
||||
|
||||
l = com.strlen (in);
|
||||
|
@ -471,174 +494,11 @@ void CL_Reconnect_f( void )
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===================
|
||||
CL_StatusLocal_f
|
||||
===================
|
||||
*/
|
||||
void CL_GetServerList_f( void )
|
||||
{
|
||||
netadr_t adr;
|
||||
|
||||
// send a broadcast packet
|
||||
MsgDev( D_INFO, "status pinging broadcast...\n" );
|
||||
cls.pingtime = cls.realtime;
|
||||
|
||||
adr.type = NA_BROADCAST;
|
||||
adr.port = BigShort( PORT_SERVER );
|
||||
Netchan_OutOfBandPrint( NS_CLIENT, adr, "status" );
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
CL_FreeServerInfo
|
||||
=============
|
||||
*/
|
||||
static void CL_FreeServerInfo( serverinfo_t *server )
|
||||
{
|
||||
if( server->mapname ) Mem_Free( server->mapname );
|
||||
if( server->hostname ) Mem_Free( server->hostname );
|
||||
if( server->shortname ) Mem_Free( server->shortname );
|
||||
if( server->gamename ) Mem_Free( server->gamename );
|
||||
if( server->netaddress ) Mem_Free( server->netaddress );
|
||||
if( server->playerstr ) Mem_Free( server->playerstr );
|
||||
if( server->pingstring ) Mem_Free( server->pingstring );
|
||||
memset( server, 0, sizeof(serverinfo_t));
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
CL_FreeServerList
|
||||
=============
|
||||
*/
|
||||
static void CL_FreeServerList_f( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < cls.numservers; i++ )
|
||||
CL_FreeServerInfo( &cls.serverlist[i] );
|
||||
cls.numservers = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
CL_DupeCheckServerList
|
||||
|
||||
Checks for duplicates and returns true if there is one...
|
||||
Since status has higher priority than info, if there is already an instance and
|
||||
it's not status, and the current one is status, the old one is removed.
|
||||
=============
|
||||
*/
|
||||
static bool CL_DupeCheckServerList( char *adr, bool status )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < cls.numservers; i++ )
|
||||
{
|
||||
if(!cls.serverlist[i].netaddress && !cls.serverlist[i].hostname )
|
||||
{
|
||||
CL_FreeServerInfo( &cls.serverlist[i] );
|
||||
continue;
|
||||
}
|
||||
if( cls.serverlist[i].netaddress && !com.strcmp( cls.serverlist[i].netaddress, adr ))
|
||||
{
|
||||
if( cls.serverlist[i].statusPacket && status )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if( status )
|
||||
{
|
||||
CL_FreeServerInfo( &cls.serverlist[i] );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
CL_ParseServerStatus
|
||||
|
||||
Parses a status packet from a server
|
||||
FIXME: check against a list of sent status requests so it's not attempting to parse things it shouldn't
|
||||
=============
|
||||
*/
|
||||
bool CL_ParseServerStatus( char *adr, char *info )
|
||||
{
|
||||
serverinfo_t *server;
|
||||
char *token;
|
||||
char shortName[32];
|
||||
|
||||
if( !info || !info[0] )return false;
|
||||
if( !adr || !adr[0] ) return false;
|
||||
if( !com.strchr( info, '\\')) return false;
|
||||
|
||||
if( cls.numservers >= MAX_SERVERS )
|
||||
return true;
|
||||
if( CL_DupeCheckServerList( adr, true ))
|
||||
return true;
|
||||
|
||||
server = &cls.serverlist[cls.numservers];
|
||||
CL_FreeServerInfo( server );
|
||||
cls.numservers++;
|
||||
|
||||
// add net address
|
||||
server->netaddress = copystring( adr );
|
||||
server->mapname = copystring(Info_ValueForKey( info, "mapname"));
|
||||
server->maxplayers = com.atoi(Info_ValueForKey( info, "maxclients"));
|
||||
server->gamename = copystring(Info_ValueForKey( info, "gamename"));
|
||||
server->hostname = copystring(Info_ValueForKey( info, "hostname"));
|
||||
if( server->hostname )
|
||||
{
|
||||
com.strncpy( shortName, server->hostname, sizeof(shortName));
|
||||
server->shortname = copystring( shortName );
|
||||
}
|
||||
|
||||
// Check the player count
|
||||
server->numplayers = com.atoi(Info_ValueForKey( info, "curplayers"));
|
||||
if( server->numplayers <= 0 )
|
||||
{
|
||||
server->numplayers = 0;
|
||||
|
||||
token = strtok( info, "\n" );
|
||||
if( token )
|
||||
{
|
||||
token = strtok( NULL, "\n" );
|
||||
while( token )
|
||||
{
|
||||
server->numplayers++;
|
||||
token = strtok( NULL, "\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if it's valid
|
||||
if( !server->mapname[0] && !server->maxplayers && !server->gamename[0] && !server->hostname[0] )
|
||||
{
|
||||
CL_FreeServerInfo( server );
|
||||
return false;
|
||||
}
|
||||
|
||||
server->playerstr = copystring( va("%i/%i", server->numplayers, server->maxplayers ));
|
||||
|
||||
// add the ping
|
||||
server->ping = cls.realtime - cls.pingtime;
|
||||
server->pingstring = copystring( va( "%ims", server->ping ));
|
||||
server->statusPacket = true;
|
||||
|
||||
// print information
|
||||
MsgDev( D_NOTE, "%s %s ", server->hostname, server->mapname );
|
||||
MsgDev( D_NOTE, "%i/%i %ims\n", server->numplayers, server->maxplayers, server->ping );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_ParseStatusMessage
|
||||
|
||||
Handle a reply from a ping
|
||||
Handle a reply from a info
|
||||
=================
|
||||
*/
|
||||
void CL_ParseStatusMessage( netadr_t from, sizebuf_t *msg )
|
||||
|
@ -648,7 +508,7 @@ void CL_ParseStatusMessage( netadr_t from, sizebuf_t *msg )
|
|||
s = MSG_ReadString( msg );
|
||||
|
||||
Msg( "%s\n", s );
|
||||
CL_ParseServerStatus( NET_AdrToString( from ), s );
|
||||
UI_AddServerToList( from, s );
|
||||
}
|
||||
|
||||
//===================================================================
|
||||
|
@ -796,8 +656,8 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
|||
ShowWindow( host.hWnd, SW_RESTORE );
|
||||
SetForegroundWindow ( host.hWnd );
|
||||
s = MSG_ReadString( msg );
|
||||
Cbuf_AddText(s);
|
||||
Cbuf_AddText("\n");
|
||||
Cbuf_AddText( s );
|
||||
Cbuf_AddText( "\n" );
|
||||
return;
|
||||
}
|
||||
// print command from somewhere
|
||||
|
@ -805,13 +665,12 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
|||
{
|
||||
// print command from somewhere
|
||||
s = MSG_ReadString( msg );
|
||||
if(!CL_ParseServerStatus( NET_AdrToString( from ), s ))
|
||||
Msg( s );
|
||||
Msg( s );
|
||||
return;
|
||||
}
|
||||
|
||||
// ping from somewhere
|
||||
if( !com.strcmp(c, "ping" ))
|
||||
if( !com.strcmp( c, "ping" ))
|
||||
{
|
||||
Netchan_OutOfBandPrint( NS_CLIENT, from, "ack" );
|
||||
return;
|
||||
|
@ -1106,8 +965,7 @@ void CL_InitLocal( void )
|
|||
// register our commands
|
||||
Cmd_AddCommand ("cmd", CL_ForwardToServer_f, "send a console commandline to the server" );
|
||||
Cmd_AddCommand ("pause", NULL, "pause the game (if the server allows pausing)" );
|
||||
Cmd_AddCommand ("getserverlist", CL_GetServerList_f, "get info about local servers" );
|
||||
Cmd_AddCommand ("freeserverlist", CL_FreeServerList_f, "clear info about local servers" );
|
||||
Cmd_AddCommand ("localservers", CL_LocalServers_f, "collect info about local servers" );
|
||||
|
||||
Cmd_AddCommand ("userinfo", CL_Userinfo_f, "print current client userinfo" );
|
||||
Cmd_AddCommand ("physinfo", CL_Physinfo_f, "print current client physinfo" );
|
||||
|
@ -1120,7 +978,8 @@ void CL_InitLocal( void )
|
|||
Cmd_AddCommand ("demos", CL_Demos_f, "restart looping demos defined by the last startdemos command" );
|
||||
Cmd_AddCommand ("movie", CL_PlayVideo_f, "playing a movie" );
|
||||
Cmd_AddCommand ("stop", CL_Stop_f, "stop playing or recording a demo" );
|
||||
|
||||
Cmd_AddCommand ("info", NULL, "collect info about local servers with specified protocol" );
|
||||
|
||||
Cmd_AddCommand ("quit", CL_Quit_f, "quit from game" );
|
||||
Cmd_AddCommand ("exit", CL_Quit_f, "quit from game" );
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#define MAX_DEMOS 32
|
||||
#define MAX_EDIT_LINE 256
|
||||
#define COMMAND_HISTORY 32
|
||||
#define MAX_SERVERS 64
|
||||
#define MAX_GAME_TITLES 1024
|
||||
#define ColorIndex(c) (((c) - '0') & 7)
|
||||
|
||||
|
@ -184,24 +183,6 @@ struct cl_priv_s
|
|||
mouth_t mouth; // shared mouth info
|
||||
};
|
||||
|
||||
typedef struct serverinfo_s
|
||||
{
|
||||
char *mapname;
|
||||
char *hostname;
|
||||
char *shortname;
|
||||
char *gamename;
|
||||
char *netaddress;
|
||||
|
||||
char *playerstr;
|
||||
int numplayers;
|
||||
int maxplayers;
|
||||
|
||||
char *pingstring;
|
||||
bool statusPacket;
|
||||
int ping;
|
||||
|
||||
} serverinfo_t;
|
||||
|
||||
typedef enum { key_console = 0, key_game, key_menu } keydest_t;
|
||||
|
||||
typedef struct
|
||||
|
@ -337,8 +318,6 @@ typedef struct
|
|||
string demoname; // for demo looping
|
||||
|
||||
file_t *demofile;
|
||||
serverinfo_t serverlist[MAX_SERVERS]; // servers to join
|
||||
int numservers;
|
||||
int pingtime; // servers timebase
|
||||
} client_static_t;
|
||||
|
||||
|
|
|
@ -102,6 +102,7 @@ int Host_CompareFileTime( long ft1, long ft2 );
|
|||
void Host_EndGame( const char *message, ... );
|
||||
void Host_AbortCurrentFrame( void );
|
||||
void Host_WriteDefaultConfig( void );
|
||||
void Host_WriteServerConfig( void );
|
||||
void Host_WriteConfig( void );
|
||||
void Host_ShutdownServer( void );
|
||||
void Host_CheckChanges( void );
|
||||
|
|
|
@ -758,6 +758,12 @@ static void Cmd_WriteCvar(const char *name, const char *string, const char *desc
|
|||
FS_Printf(f, "seta %s \"%s\"\n", name, string );
|
||||
}
|
||||
|
||||
static void Cmd_WriteServerCvar(const char *name, const char *string, const char *desc, void *f )
|
||||
{
|
||||
if( !desc ) return; // ignore cvars without description (fantom variables)
|
||||
FS_Printf(f, "sets %s \"%s\"\n", name, string );
|
||||
}
|
||||
|
||||
static void Cmd_WriteHelp(const char *name, const char *unused, const char *desc, void *f )
|
||||
{
|
||||
if( !desc ) return; // ignore fantom cmds
|
||||
|
@ -772,6 +778,11 @@ void Cmd_WriteVariables( file_t *f )
|
|||
Cvar_LookupVars( CVAR_ARCHIVE, NULL, f, Cmd_WriteCvar );
|
||||
}
|
||||
|
||||
void Cmd_WriteServerVariables( file_t *f )
|
||||
{
|
||||
Cvar_LookupVars( CVAR_SERVERINFO, NULL, f, Cmd_WriteServerCvar );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
Host_WriteConfig
|
||||
|
@ -858,9 +869,45 @@ void Host_WriteDefaultConfig( void )
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
Host_WriteServerConfig
|
||||
|
||||
save serverinfo variables into server.rc (using for dedicated server too)
|
||||
===============
|
||||
*/
|
||||
void Host_WriteServerConfig( void )
|
||||
{
|
||||
file_t *f = FS_Open( "config/server.rc", "w" );
|
||||
if( f )
|
||||
{
|
||||
FS_Printf( f, "//=======================================================================\n" );
|
||||
FS_Printf( f, "//\t\t\tCopyright XashXT Group %s ©\n", timestamp( TIME_YEAR_ONLY ));
|
||||
FS_Printf( f, "//\t\t\tserver.rc - server temporare config\n" );
|
||||
FS_Printf( f, "//=======================================================================\n" );
|
||||
Cmd_WriteServerVariables( f );
|
||||
|
||||
// add default map if exist
|
||||
if( com.strlen( Cvar_VariableString( "defaultmap" )) != 0 )
|
||||
FS_Printf( f, "map %s\n", Cvar_VariableString( "defaultmap" ));
|
||||
FS_Close( f );
|
||||
}
|
||||
else MsgDev( D_ERROR, "Couldn't write server.rc.\n" );
|
||||
}
|
||||
|
||||
void Key_EnumCmds_f( void )
|
||||
{
|
||||
file_t *f = FS_Open( "docs/help.txt", "w" );
|
||||
file_t *f;
|
||||
|
||||
FS_AllowDirectPaths( true );
|
||||
if( FS_FileExists( "../help.txt" ))
|
||||
{
|
||||
Msg( "help.txt already exist\n" );
|
||||
FS_AllowDirectPaths( false );
|
||||
return;
|
||||
}
|
||||
|
||||
f = FS_Open( "../help.txt", "w" );
|
||||
if( f )
|
||||
{
|
||||
FS_Printf( f, "//=======================================================================\n");
|
||||
|
@ -874,7 +921,8 @@ void Key_EnumCmds_f( void )
|
|||
Cmd_LookupCmds( NULL, f, Cmd_WriteHelp );
|
||||
FS_Printf( f, "\n\n");
|
||||
FS_Close( f );
|
||||
Msg( "help.txt created\n" );
|
||||
}
|
||||
else MsgDev( D_ERROR, "Couldn't write help.txt.\n");
|
||||
Msg( "write docs/help.txt\n" );
|
||||
FS_AllowDirectPaths( false );
|
||||
}
|
|
@ -830,6 +830,7 @@ void Host_Init( const int argc, const char **argv )
|
|||
{
|
||||
Cmd_AddCommand( "quit", Sys_Quit, "quit the game" );
|
||||
Cmd_AddCommand( "exit", Sys_Quit, "quit the game" );
|
||||
Cbuf_AddText( "exec server.rc\n" ); // dedicated servers using settings from server.rc file
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -842,6 +843,7 @@ void Host_Init( const int argc, const char **argv )
|
|||
Cmd_AddCommand( "game", Host_ChangeGame_f, "change game" ); // allow to change game from the console
|
||||
host.frametime = Host_Milliseconds();
|
||||
host.errorframe = 0;
|
||||
Cbuf_Execute();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -464,26 +464,36 @@ The second parameter should be the current protocol version number.
|
|||
*/
|
||||
void SV_Info( netadr_t from )
|
||||
{
|
||||
char string[64];
|
||||
char string[MAX_INFO_STRING];
|
||||
int i, count = 0;
|
||||
int version;
|
||||
|
||||
// ignore in single player
|
||||
if( sv_maxclients->integer == 1 ) return;
|
||||
if( sv_maxclients->integer == 1 )
|
||||
return;
|
||||
|
||||
version = com.atoi(Cmd_Argv( 1 ));
|
||||
version = com.atoi( Cmd_Argv( 1 ));
|
||||
string[0] = '\0';
|
||||
|
||||
if( version != PROTOCOL_VERSION )
|
||||
{
|
||||
com.sprintf( string, "%s: wrong version\n", hostname->string, sizeof( string ));
|
||||
com.snprintf( string, sizeof( string ), "%s: wrong version\n", hostname->string );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = 0; i < sv_maxclients->integer; i++ )
|
||||
if( svs.clients[i].state >= cs_connected )
|
||||
count++;
|
||||
com.sprintf( string, "%16s %8s %2i/%2i\n", hostname->string, sv.name, count, sv_maxclients->integer );
|
||||
|
||||
Info_SetValueForKey( string, "hostname", hostname->string );
|
||||
Info_SetValueForKey( string, "mapname", sv.name );
|
||||
Info_SetValueForKey( string, "deathmatch", va( "%i", svgame.globals->deathmatch ));
|
||||
Info_SetValueForKey( string, "teamplay", va( "%i", svgame.globals->teamplay ));
|
||||
Info_SetValueForKey( string, "coop", va( "%i", svgame.globals->coop ));
|
||||
Info_SetValueForKey( string, "maxclients", va( "%i", sv_maxclients->integer ));
|
||||
Info_SetValueForKey( string, "numclients", va( "%i", count ));
|
||||
}
|
||||
Msg( "server responce (string len %i)\n", com.strlen( string ));
|
||||
Netchan_OutOfBandPrint( NS_SERVER, from, "info\n%s", string );
|
||||
}
|
||||
|
||||
|
|
|
@ -610,11 +610,12 @@ SV_KillServer_f
|
|||
Kick everyone off, possibly in preparation for a new game
|
||||
===============
|
||||
*/
|
||||
void SV_KillServer_f (void)
|
||||
void SV_KillServer_f( void )
|
||||
{
|
||||
if( !svs.initialized ) return;
|
||||
com.strncpy( host.finalmsg, "Server was killed\n", MAX_STRING );
|
||||
SV_Shutdown( false );
|
||||
NET_Config ( false ); // close network sockets
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -419,6 +419,9 @@ void SV_InitGame( void )
|
|||
svs.client_entities = Z_Malloc( sizeof( entity_state_t ) * svs.num_client_entities );
|
||||
svs.baselines = Z_Malloc( sizeof( entity_state_t ) * GI->max_edicts );
|
||||
|
||||
// init network stuff
|
||||
NET_Config(( sv_maxclients->integer > 1 ));
|
||||
|
||||
// copy gamemode into svgame.globals
|
||||
svgame.globals->deathmatch = Cvar_VariableInteger( "deathmatch" );
|
||||
svgame.globals->teamplay = Cvar_VariableInteger( "teamplay" );
|
||||
|
|
|
@ -519,6 +519,7 @@ void SV_Init( void )
|
|||
Cvar_Get ("fraglimit", "0", CVAR_SERVERINFO, "multiplayer fraglimit" );
|
||||
Cvar_Get ("timelimit", "0", CVAR_SERVERINFO, "multiplayer timelimit" );
|
||||
Cvar_Get ("protocol", va("%i", PROTOCOL_VERSION), CVAR_SERVERINFO|CVAR_INIT, "displays server protocol version" );
|
||||
Cvar_Get ("defaultmap", "", 0, "holds the multiplayer mapname" );
|
||||
Cvar_Get ("sv_aim", "1", 0, "enable auto-aiming" );
|
||||
|
||||
sv_fps = Cvar_Get( "sv_fps", "72.1", CVAR_ARCHIVE, "running server physics at" );
|
||||
|
|
|
@ -30,8 +30,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define ID_ADVANCED 3
|
||||
#define ID_DONE 4
|
||||
#define ID_CANCEL 5
|
||||
#define ID_KEYLIST 5
|
||||
#define ID_TABLEHINT 6
|
||||
#define ID_KEYLIST 6
|
||||
#define ID_TABLEHINT 7
|
||||
|
||||
#define MAX_KEYS 256
|
||||
#define CMD_LENGTH 24
|
||||
|
@ -139,7 +139,7 @@ static void UI_Controls_Callback( void *self, int event )
|
|||
UI_PopMenu();
|
||||
break;
|
||||
case ID_DEFAULTS:
|
||||
Cbuf_ExecuteText( EXEC_NOW, "exec basekeys.rc\n" );
|
||||
Cbuf_ExecuteText( EXEC_NOW, "exec keys.def\n" );
|
||||
UI_Controls_GetKeysList (); // reload all buttons
|
||||
break;
|
||||
case ID_ADVANCED:
|
||||
|
|
|
@ -74,16 +74,17 @@ static void UI_CreateGame_Begin( void )
|
|||
{
|
||||
if( Host_ServerState())
|
||||
Cbuf_ExecuteText( EXEC_APPEND, "disconnect\n" );
|
||||
/*
|
||||
Cvar_SetValue( "deathmatch", !((int)uiStartServer.rules.curValue));
|
||||
Cvar_SetValue( "coop", ((int)uiStartServer.rules.curValue));
|
||||
Cvar_SetValue( "timelimit", atoi(uiStartServer.timeLimit.buffer));
|
||||
Cvar_SetValue( "fraglimit", atoi(uiStartServer.fragLimit.buffer));
|
||||
Cvar_SetValue( "sv_maxclients", atoi(uiStartServer.maxClients.buffer));
|
||||
Cvar_Set( "sv_hostname", uiStartServer.hostName.buffer );
|
||||
|
||||
Cbuf_ExecuteText( EXEC_APPEND, va( "map %s\n", uiCreateGame.mapsList[uiCreateGame.mapsList.curItem] ));
|
||||
*/
|
||||
Cvar_SetValue( "deathmatch", 1.0f ); // FIXME
|
||||
Cvar_SetValue( "sv_maxclients", com.atoi( uiCreateGame.maxClients.buffer ));
|
||||
Cvar_Set( "sv_hostname", uiCreateGame.hostName.buffer );
|
||||
Cvar_Set( "defaultmap", uiCreateGame.mapName[uiCreateGame.mapsList.curItem] );
|
||||
Host_WriteServerConfig ();
|
||||
|
||||
// all done, start server
|
||||
if( uiCreateGame.dedicatedServer.enabled )
|
||||
Sys_NewInstance( va("#%s", GI->gamefolder ), "Starting dedicated server...\n" );
|
||||
else Cbuf_ExecuteText( EXEC_APPEND, "exec server.rc\n" );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -76,7 +76,7 @@ static void UI_LanGame_GetGamesList( void )
|
|||
if( com.strlen( uiStatic.serverNames[i] ) == 0 ) break; // this should never happen
|
||||
info = uiStatic.serverNames[i];
|
||||
|
||||
com.strncat( uiLanGame.gameDescription[i], Info_ValueForKey( info, "sv_hostname" ), GAME_LENGTH );
|
||||
com.strncat( uiLanGame.gameDescription[i], Info_ValueForKey( info, "hostname" ), GAME_LENGTH );
|
||||
com.strncat( uiLanGame.gameDescription[i], uiEmptyString, GAME_LENGTH );
|
||||
com.strncat( uiLanGame.gameDescription[i], Info_ValueForKey( info, "mapname" ), MAPNAME_LENGTH );
|
||||
com.strncat( uiLanGame.gameDescription[i], uiEmptyString, MAPNAME_LENGTH );
|
||||
|
@ -87,7 +87,9 @@ static void UI_LanGame_GetGamesList( void )
|
|||
else if( !com.strcmp( Info_ValueForKey( info, "teamplay" ), "1" ))
|
||||
com.strncat( uiLanGame.gameDescription[i], "teamplay", TYPE_LENGTH );
|
||||
com.strncat( uiLanGame.gameDescription[i], uiEmptyString, TYPE_LENGTH );
|
||||
com.strncat( uiLanGame.gameDescription[i], Info_ValueForKey( info, "sv_maxclients" ), MAXCL_LENGTH );
|
||||
com.strncat( uiLanGame.gameDescription[i], Info_ValueForKey( info, "numclients" ), MAXCL_LENGTH );
|
||||
com.strncat( uiLanGame.gameDescription[i], "\\", MAXCL_LENGTH );
|
||||
com.strncat( uiLanGame.gameDescription[i], Info_ValueForKey( info, "maxclients" ), MAXCL_LENGTH );
|
||||
com.strncat( uiLanGame.gameDescription[i], uiEmptyString, MAXCL_LENGTH );
|
||||
uiLanGame.gameDescriptionPtr[i] = uiLanGame.gameDescription[i];
|
||||
}
|
||||
|
@ -96,6 +98,26 @@ static void UI_LanGame_GetGamesList( void )
|
|||
uiLanGame.gameList.itemNames = uiLanGame.gameDescriptionPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
UI_Background_Ownerdraw
|
||||
=================
|
||||
*/
|
||||
static void UI_Background_Ownerdraw( void *self )
|
||||
{
|
||||
menuCommon_s *item = (menuCommon_s *)self;
|
||||
|
||||
UI_DrawPic(item->x, item->y, item->width, item->height, uiColorWhite, ((menuBitmap_s *)self)->pic);
|
||||
|
||||
// serverinfo has been changed update display
|
||||
if( uiStatic.updateServers )
|
||||
{
|
||||
UI_LanGame_GetGamesList ();
|
||||
uiStatic.updateServers = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
UI_LanGame_Callback
|
||||
|
@ -160,6 +182,7 @@ static void UI_LanGame_Init( void )
|
|||
uiLanGame.background.generic.width = 1024;
|
||||
uiLanGame.background.generic.height = 768;
|
||||
uiLanGame.background.pic = ART_BACKGROUND;
|
||||
uiLanGame.background.generic.ownerdraw = UI_Background_Ownerdraw;
|
||||
|
||||
uiLanGame.banner.generic.id = ID_BANNER;
|
||||
uiLanGame.banner.generic.type = QMTYPE_BITMAP;
|
||||
|
@ -243,6 +266,8 @@ static void UI_LanGame_Init( void )
|
|||
UI_AddItem( &uiLanGame.menu, (void *)&uiLanGame.done );
|
||||
UI_AddItem( &uiLanGame.menu, (void *)&uiLanGame.hintMessage );
|
||||
UI_AddItem( &uiLanGame.menu, (void *)&uiLanGame.gameList );
|
||||
|
||||
UI_RefreshServerList();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -286,6 +286,7 @@ typedef struct
|
|||
netadr_t serverAddresses[UI_MAX_SERVERS];
|
||||
char serverNames[UI_MAX_SERVERS][80];
|
||||
int numServers;
|
||||
bool updateServers; // true is receive new info about servers
|
||||
|
||||
float scaleX;
|
||||
float scaleY;
|
||||
|
|
|
@ -987,7 +987,7 @@ void UI_AddServerToList( netadr_t adr, const char *info )
|
|||
return;
|
||||
|
||||
if( uiStatic.numServers == UI_MAX_SERVERS )
|
||||
return; // Full
|
||||
return; // full
|
||||
|
||||
while( *info == ' ' )
|
||||
info++;
|
||||
|
@ -1000,6 +1000,7 @@ void UI_AddServerToList( netadr_t adr, const char *info )
|
|||
}
|
||||
|
||||
// add it to the list
|
||||
uiStatic.updateServers = true; // info has been updated
|
||||
uiStatic.serverAddresses[uiStatic.numServers] = adr;
|
||||
com.strncpy( uiStatic.serverNames[uiStatic.numServers], info, sizeof( uiStatic.serverNames[uiStatic.numServers] ));
|
||||
uiStatic.numServers++;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "byteorder.h"
|
||||
|
||||
#define PORT_ANY -1
|
||||
#define PORT_SERVER 27911
|
||||
#define PORT_SERVER 27910
|
||||
#define MAX_LOOPBACK 4
|
||||
#define MASK_LOOPBACK (MAX_LOOPBACK - 1)
|
||||
|
||||
|
|
Reference in New Issue