2007-11-17 22:00:00 +01:00
|
|
|
|
//=======================================================================
|
|
|
|
|
// Copyright XashXT Group 2007 <20>
|
|
|
|
|
// sv_cmds.c - server console commands
|
|
|
|
|
//=======================================================================
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2008-06-09 22:00:00 +02:00
|
|
|
|
#include "common.h"
|
2007-06-21 22:00:00 +02:00
|
|
|
|
#include "server.h"
|
2008-07-23 22:00:00 +02:00
|
|
|
|
#include "byteorder.h"
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2008-07-12 22:00:00 +02:00
|
|
|
|
sv_client_t *sv_client; // current client
|
|
|
|
|
|
2008-07-16 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
=================
|
|
|
|
|
SV_ClientPrintf
|
|
|
|
|
|
|
|
|
|
Sends text across to be displayed if the level passes
|
|
|
|
|
=================
|
|
|
|
|
*/
|
2009-06-24 22:00:00 +02:00
|
|
|
|
void SV_ClientPrintf( sv_client_t *cl, int level, char *fmt, ... )
|
2008-07-16 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
va_list argptr;
|
2008-07-23 22:00:00 +02:00
|
|
|
|
char string[MAX_SYSPATH];
|
2009-06-24 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( level < cl->messagelevel )
|
|
|
|
|
return;
|
|
|
|
|
if( cl->edict && (cl->edict->v.flags & FL_FAKECLIENT ))
|
|
|
|
|
return;
|
2008-07-16 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
va_start( argptr, fmt );
|
|
|
|
|
com.vsprintf( string, fmt, argptr );
|
|
|
|
|
va_end( argptr );
|
|
|
|
|
|
|
|
|
|
MSG_WriteByte( &cl->netchan.message, svc_print );
|
2009-11-23 22:00:00 +01:00
|
|
|
|
MSG_WriteByte( &cl->netchan.message, level );
|
2008-07-16 22:00:00 +02:00
|
|
|
|
MSG_WriteString( &cl->netchan.message, string );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=================
|
|
|
|
|
SV_BroadcastPrintf
|
|
|
|
|
|
|
|
|
|
Sends text to all active clients
|
|
|
|
|
=================
|
|
|
|
|
*/
|
2009-06-24 22:00:00 +02:00
|
|
|
|
void SV_BroadcastPrintf( int level, char *fmt, ... )
|
2008-07-16 22:00:00 +02:00
|
|
|
|
{
|
2008-07-23 22:00:00 +02:00
|
|
|
|
char string[MAX_SYSPATH];
|
2008-07-16 22:00:00 +02:00
|
|
|
|
va_list argptr;
|
|
|
|
|
sv_client_t *cl;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
va_start( argptr, fmt );
|
|
|
|
|
com.vsprintf( string, fmt, argptr );
|
|
|
|
|
va_end( argptr );
|
|
|
|
|
|
|
|
|
|
// echo to console
|
2008-07-31 22:00:00 +02:00
|
|
|
|
if( host.type == HOST_DEDICATED ) Msg( "%s", string );
|
2009-09-25 22:00:00 +02:00
|
|
|
|
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
|
2008-07-16 22:00:00 +02:00
|
|
|
|
{
|
2009-06-24 22:00:00 +02:00
|
|
|
|
if( level < cl->messagelevel ) continue;
|
2008-07-16 22:00:00 +02:00
|
|
|
|
if( cl->state != cs_spawned ) continue;
|
2009-06-24 22:00:00 +02:00
|
|
|
|
if( cl->edict && (cl->edict->v.flags & FL_FAKECLIENT ))
|
|
|
|
|
continue;
|
2008-07-16 22:00:00 +02:00
|
|
|
|
MSG_WriteByte( &cl->netchan.message, svc_print );
|
2009-11-23 22:00:00 +01:00
|
|
|
|
MSG_WriteByte( &cl->netchan.message, level );
|
2008-07-16 22:00:00 +02:00
|
|
|
|
MSG_WriteString( &cl->netchan.message, string );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=================
|
|
|
|
|
SV_BroadcastCommand
|
|
|
|
|
|
|
|
|
|
Sends text to all active clients
|
|
|
|
|
=================
|
|
|
|
|
*/
|
|
|
|
|
void SV_BroadcastCommand( char *fmt, ... )
|
|
|
|
|
{
|
|
|
|
|
va_list argptr;
|
2008-07-23 22:00:00 +02:00
|
|
|
|
char string[MAX_SYSPATH];
|
2008-07-16 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
if( !sv.state ) return;
|
|
|
|
|
va_start( argptr, fmt );
|
|
|
|
|
com.vsprintf( string, fmt, argptr );
|
|
|
|
|
va_end( argptr );
|
|
|
|
|
|
|
|
|
|
MSG_Begin( svc_stufftext );
|
|
|
|
|
MSG_WriteString( &sv.multicast, string );
|
2009-11-25 22:00:00 +01:00
|
|
|
|
MSG_Send( MSG_ALL, NULL, NULL );
|
2008-07-16 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-06-21 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
====================
|
|
|
|
|
SV_SetMaster_f
|
|
|
|
|
|
|
|
|
|
Specify a list of master servers
|
|
|
|
|
====================
|
|
|
|
|
*/
|
2007-11-17 22:00:00 +01:00
|
|
|
|
void SV_SetMaster_f( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
int i, slot;
|
|
|
|
|
|
|
|
|
|
// only dedicated servers send heartbeats
|
2008-07-11 22:00:00 +02:00
|
|
|
|
if( host.type != HOST_DEDICATED )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2007-11-17 22:00:00 +01:00
|
|
|
|
Msg("Only dedicated servers use masters.\n");
|
2007-06-21 22:00:00 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// make sure the server is listed public
|
|
|
|
|
Cvar_Set ("public", "1");
|
|
|
|
|
|
2008-07-31 22:00:00 +02:00
|
|
|
|
for( i = 1; i < MAX_MASTERS; i++ )
|
2007-11-17 22:00:00 +01:00
|
|
|
|
{
|
2009-09-17 22:00:00 +02:00
|
|
|
|
Mem_Set( &master_adr[i], 0, sizeof( master_adr[i] ));
|
2007-11-17 22:00:00 +01:00
|
|
|
|
}
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2007-11-17 22:00:00 +01:00
|
|
|
|
// slot 0 will always contain the id master
|
2008-07-31 22:00:00 +02:00
|
|
|
|
for( i = 1, slot = 1; i < Cmd_Argc(); i++ )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2008-07-31 22:00:00 +02:00
|
|
|
|
if( slot == MAX_MASTERS ) break;
|
|
|
|
|
if(!NET_StringToAdr(Cmd_Argv(i), &master_adr[i]))
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2008-07-31 22:00:00 +02:00
|
|
|
|
Msg( "Bad address: %s\n", Cmd_Argv(i));
|
2007-06-21 22:00:00 +02:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-17 22:00:00 +01:00
|
|
|
|
if(!master_adr[slot].port) master_adr[slot].port = BigShort (PORT_MASTER);
|
2008-07-31 22:00:00 +02:00
|
|
|
|
Msg( "Master server at %s\n", NET_AdrToString (master_adr[slot]));
|
|
|
|
|
Msg( "Sending a ping.\n");
|
|
|
|
|
Netchan_OutOfBandPrint( NS_SERVER, master_adr[slot], "ping" );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
slot++;
|
|
|
|
|
}
|
2008-06-30 22:00:00 +02:00
|
|
|
|
svs.last_heartbeat = MAX_HEARTBEAT;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==================
|
|
|
|
|
SV_SetPlayer
|
|
|
|
|
|
|
|
|
|
Sets sv_client and sv_player to the player with idnum Cmd_Argv(1)
|
|
|
|
|
==================
|
|
|
|
|
*/
|
2007-11-17 22:00:00 +01:00
|
|
|
|
bool SV_SetPlayer( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
char *s;
|
2008-07-09 22:00:00 +02:00
|
|
|
|
sv_client_t *cl;
|
2007-11-17 22:00:00 +01:00
|
|
|
|
int i, idnum;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2009-11-25 22:00:00 +01:00
|
|
|
|
if( sv_maxclients->integer == 1 )
|
|
|
|
|
{
|
|
|
|
|
// sepcial case for singleplayer
|
|
|
|
|
sv_client = svs.clients;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( Cmd_Argc() < 2 ) return false;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2009-11-25 22:00:00 +01:00
|
|
|
|
s = Cmd_Argv( 1 );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
// numeric values are just slot numbers
|
2008-07-31 22:00:00 +02:00
|
|
|
|
if( s[0] >= '0' && s[0] <= '9' )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2009-09-25 22:00:00 +02:00
|
|
|
|
idnum = com.atoi( Cmd_Argv( 1 ));
|
|
|
|
|
if( idnum < 0 || idnum >= sv_maxclients->integer )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2009-09-25 22:00:00 +02:00
|
|
|
|
Msg( "Bad client slot: %i\n", idnum );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
sv_client = &svs.clients[idnum];
|
2008-07-31 22:00:00 +02:00
|
|
|
|
if( !sv_client->state )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2009-09-25 22:00:00 +02:00
|
|
|
|
Msg( "Client %i is not active\n", idnum );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// check for a name match
|
2009-09-25 22:00:00 +02:00
|
|
|
|
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2008-07-31 22:00:00 +02:00
|
|
|
|
if( !cl->state ) continue;
|
2009-09-25 22:00:00 +02:00
|
|
|
|
if( !com.strcmp( cl->name, s ))
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
sv_client = cl;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-07-31 22:00:00 +02:00
|
|
|
|
Msg( "Userid %s is not on the server\n", s );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==================
|
2007-11-17 22:00:00 +01:00
|
|
|
|
SV_Map_f
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2007-11-17 22:00:00 +01:00
|
|
|
|
Goes directly to a given map without any savegame archiving.
|
|
|
|
|
For development work
|
2007-06-21 22:00:00 +02:00
|
|
|
|
==================
|
|
|
|
|
*/
|
2007-11-17 22:00:00 +01:00
|
|
|
|
void SV_Map_f( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2008-10-27 22:00:00 +01:00
|
|
|
|
string filename;
|
2009-09-28 22:00:00 +02:00
|
|
|
|
char *spawn_entity;
|
2007-11-17 22:00:00 +01:00
|
|
|
|
|
2008-07-31 22:00:00 +02:00
|
|
|
|
if( Cmd_Argc() != 2 )
|
2007-10-19 22:00:00 +02:00
|
|
|
|
{
|
2009-11-03 22:00:00 +01:00
|
|
|
|
Msg( "Usage: map <filename>\n" );
|
2007-10-19 22:00:00 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-28 22:00:00 +02:00
|
|
|
|
// determine spawn entity classname
|
|
|
|
|
if( Cvar_VariableInteger( "deathmatch" ))
|
|
|
|
|
spawn_entity = GI->dm_entity;
|
|
|
|
|
else if( Cvar_VariableInteger( "coop" ))
|
|
|
|
|
spawn_entity = GI->coop_entity;
|
|
|
|
|
else if( Cvar_VariableInteger( "teamplay" ))
|
|
|
|
|
spawn_entity = GI->team_entity;
|
|
|
|
|
else spawn_entity = GI->sp_entity;
|
|
|
|
|
|
|
|
|
|
com.strncpy( filename, Cmd_Argv( 1 ), sizeof( filename ));
|
2009-11-03 22:00:00 +01:00
|
|
|
|
if( !SV_MapIsValid( filename, spawn_entity ))
|
2007-11-17 22:00:00 +01:00
|
|
|
|
{
|
2009-09-28 22:00:00 +02:00
|
|
|
|
Msg( "SV_NewMap: invalid map %s\n", filename );
|
2007-11-17 22:00:00 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2009-09-28 22:00:00 +02:00
|
|
|
|
sv.loadgame = false; // set right state
|
|
|
|
|
sv.changelevel = false;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2009-09-28 22:00:00 +02:00
|
|
|
|
if( com.strcmp( sv.name, filename ))
|
|
|
|
|
SV_InitGame ();
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2009-09-28 22:00:00 +02:00
|
|
|
|
SV_SpawnServer( filename, NULL );
|
|
|
|
|
SV_LevelInit( filename, NULL, NULL );
|
|
|
|
|
SV_ActivateServer ();
|
2007-11-17 22:00:00 +01:00
|
|
|
|
}
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2008-01-20 22:00:00 +01:00
|
|
|
|
void SV_Newgame_f( void )
|
|
|
|
|
{
|
2009-09-28 22:00:00 +02:00
|
|
|
|
// FIXME: parse newgame script or somewhat
|
|
|
|
|
Cbuf_ExecuteText( EXEC_APPEND, va( "map %s\n", GI->startmap ));
|
2008-01-20 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 22:00:00 +02:00
|
|
|
|
void SV_Endgame_f( void )
|
|
|
|
|
{
|
|
|
|
|
Host_EndGame( "end game" );
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-21 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
==============
|
2007-11-17 22:00:00 +01:00
|
|
|
|
SV_Load_f
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
==============
|
|
|
|
|
*/
|
2007-11-17 22:00:00 +01:00
|
|
|
|
void SV_Load_f( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2008-10-27 22:00:00 +01:00
|
|
|
|
string filename;
|
2007-11-17 22:00:00 +01:00
|
|
|
|
|
2009-09-25 22:00:00 +02:00
|
|
|
|
if( Cmd_Argc() != 2 )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2009-09-25 22:00:00 +02:00
|
|
|
|
Msg( "Usage: load <filename>\n" );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-28 22:00:00 +02:00
|
|
|
|
com.strncpy( filename, Cmd_Argv( 1 ), sizeof( filename ));
|
2009-12-11 22:00:00 +01:00
|
|
|
|
if(WAD_Check( va( "save/%s.sav", filename )) != 1 )
|
2007-11-17 22:00:00 +01:00
|
|
|
|
{
|
2009-09-28 22:00:00 +02:00
|
|
|
|
Msg( "Can't loading %s\n", filename );
|
2007-11-17 22:00:00 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2009-09-28 22:00:00 +02:00
|
|
|
|
sv.loadgame = true; // set right state
|
|
|
|
|
sv.changelevel = false;
|
|
|
|
|
|
2007-11-17 22:00:00 +01:00
|
|
|
|
SV_ReadSaveFile( filename );
|
2009-09-28 22:00:00 +02:00
|
|
|
|
SV_SpawnServer( svs.mapname, NULL );
|
|
|
|
|
SV_LevelInit( svs.mapname, NULL, filename );
|
|
|
|
|
SV_ActivateServer();
|
2007-06-21 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
==============
|
|
|
|
|
SV_QuickLoad_f
|
|
|
|
|
|
|
|
|
|
==============
|
|
|
|
|
*/
|
|
|
|
|
void SV_QuickLoad_f( void )
|
|
|
|
|
{
|
|
|
|
|
Cbuf_ExecuteText( EXEC_APPEND, "echo Quick Loading...; wait; load quick" );
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-21 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
==============
|
2007-11-17 22:00:00 +01:00
|
|
|
|
SV_Save_f
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
==============
|
|
|
|
|
*/
|
2007-11-17 22:00:00 +01:00
|
|
|
|
void SV_Save_f( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2009-12-11 22:00:00 +01:00
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
|
|
if( Cmd_Argc() == 1 )
|
2010-01-07 22:00:00 +01:00
|
|
|
|
name = "new";
|
|
|
|
|
else if( Cmd_Argc() == 2 )
|
|
|
|
|
name = Cmd_Argv( 1 );
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Msg( "Usage: save <savename>\n" );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-11 22:00:00 +01:00
|
|
|
|
SV_WriteSaveFile( name, false, true );
|
2009-09-10 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
==============
|
|
|
|
|
SV_QuickSave_f
|
|
|
|
|
|
|
|
|
|
==============
|
|
|
|
|
*/
|
|
|
|
|
void SV_QuickSave_f( void )
|
|
|
|
|
{
|
|
|
|
|
Cbuf_ExecuteText( EXEC_APPEND, "echo Quick Saving...; wait; save quick" );
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-10 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
==============
|
2010-01-07 22:00:00 +01:00
|
|
|
|
SV_DeleteSave_f
|
2009-09-10 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
==============
|
|
|
|
|
*/
|
2010-01-07 22:00:00 +01:00
|
|
|
|
void SV_DeleteSave_f( void )
|
2009-09-10 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
if( Cmd_Argc() != 2 )
|
|
|
|
|
{
|
2010-01-07 22:00:00 +01:00
|
|
|
|
Msg( "Usage: delsave <name>\n" );
|
2009-09-10 22:00:00 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2009-09-10 22:00:00 +02:00
|
|
|
|
// delete save and saveshot
|
2009-12-11 22:00:00 +01:00
|
|
|
|
FS_Delete( va( "%s/save/%s.sav", GI->gamedir, Cmd_Argv( 1 )));
|
2009-09-23 22:00:00 +02:00
|
|
|
|
FS_Delete( va( "%s/save/%s.jpg", GI->gamedir, Cmd_Argv( 1 )));
|
2009-01-09 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==============
|
|
|
|
|
SV_AutoSave_f
|
|
|
|
|
|
|
|
|
|
==============
|
|
|
|
|
*/
|
|
|
|
|
void SV_AutoSave_f( void )
|
|
|
|
|
{
|
2009-09-28 22:00:00 +02:00
|
|
|
|
SV_WriteSaveFile( "autosave", true, true );
|
2007-11-17 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==================
|
|
|
|
|
SV_ChangeLevel_f
|
|
|
|
|
|
|
|
|
|
Saves the state of the map just being exited and goes to a new map.
|
|
|
|
|
==================
|
|
|
|
|
*/
|
|
|
|
|
void SV_ChangeLevel_f( void )
|
|
|
|
|
{
|
2009-09-28 22:00:00 +02:00
|
|
|
|
char *spawn_entity;
|
2008-06-09 22:00:00 +02:00
|
|
|
|
int c = Cmd_Argc();
|
2007-11-17 22:00:00 +01:00
|
|
|
|
|
2009-09-28 22:00:00 +02:00
|
|
|
|
// determine spawn entity classname
|
|
|
|
|
if( Cvar_VariableInteger( "deathmatch" ))
|
|
|
|
|
spawn_entity = GI->dm_entity;
|
|
|
|
|
else if( Cvar_VariableInteger( "coop" ))
|
|
|
|
|
spawn_entity = GI->coop_entity;
|
|
|
|
|
else if( Cvar_VariableInteger( "teamplay" ))
|
|
|
|
|
spawn_entity = GI->team_entity;
|
|
|
|
|
else spawn_entity = GI->sp_entity;
|
|
|
|
|
|
|
|
|
|
if( !SV_MapIsValid( Cmd_Argv( 1 ), spawn_entity ))
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2009-09-28 22:00:00 +02:00
|
|
|
|
Msg( "SV_ChangeLevel: invalid map %s\n", Cmd_Argv( 1 ));
|
2007-06-21 22:00:00 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-28 22:00:00 +02:00
|
|
|
|
if( sv.state != ss_active )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2009-09-28 22:00:00 +02:00
|
|
|
|
// just load map
|
|
|
|
|
Cbuf_AddText( va( "map %s\n", Cmd_Argv( 1 )));
|
2007-06-21 22:00:00 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-28 22:00:00 +02:00
|
|
|
|
switch( c )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2009-09-28 22:00:00 +02:00
|
|
|
|
case 2: SV_ChangeLevel( false, Cmd_Argv( 1 ), NULL ); break;
|
|
|
|
|
case 3: SV_ChangeLevel( true, Cmd_Argv( 1 ), Cmd_Argv( 2 )); break;
|
|
|
|
|
default: Msg( "Usage: changelevel <map> [landmark]\n" ); break;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-17 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
==================
|
|
|
|
|
SV_Restart_f
|
|
|
|
|
|
|
|
|
|
restarts current level
|
|
|
|
|
==================
|
|
|
|
|
*/
|
|
|
|
|
void SV_Restart_f( void )
|
|
|
|
|
{
|
2008-10-27 22:00:00 +01:00
|
|
|
|
string filename;
|
2007-11-17 22:00:00 +01:00
|
|
|
|
|
2009-01-09 22:00:00 +01:00
|
|
|
|
if( sv.state != ss_active ) return;
|
|
|
|
|
com.strncpy( filename, svs.mapname, MAX_STRING );
|
2007-11-17 22:00:00 +01:00
|
|
|
|
FS_StripExtension( filename );
|
|
|
|
|
|
|
|
|
|
// just sending console command
|
2009-01-09 22:00:00 +01:00
|
|
|
|
Cbuf_AddText( va( "map %s\n", filename ));
|
2007-11-17 22:00:00 +01:00
|
|
|
|
}
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2009-09-28 22:00:00 +02:00
|
|
|
|
void SV_Reload_f( void )
|
|
|
|
|
{
|
|
|
|
|
const char *save;
|
|
|
|
|
string loadname;
|
|
|
|
|
|
|
|
|
|
if( sv.state != ss_active ) return;
|
|
|
|
|
save = SV_GetLatestSave();
|
|
|
|
|
if( save )
|
|
|
|
|
{
|
|
|
|
|
FS_FileBase( save, loadname );
|
|
|
|
|
Cbuf_AddText( va( "load %s\n", loadname ));
|
|
|
|
|
}
|
|
|
|
|
else Cbuf_AddText( "newgame\n" ); // begin new game
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-21 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
==================
|
|
|
|
|
SV_Kick_f
|
|
|
|
|
|
|
|
|
|
Kick a user off of the server
|
|
|
|
|
==================
|
|
|
|
|
*/
|
2007-11-17 22:00:00 +01:00
|
|
|
|
void SV_Kick_f( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2009-09-17 22:00:00 +02:00
|
|
|
|
if( Cmd_Argc() != 2 )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2009-09-17 22:00:00 +02:00
|
|
|
|
Msg( "Usage: kick <userid>\n" );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-17 22:00:00 +02:00
|
|
|
|
if( !svs.clients )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2009-09-17 22:00:00 +02:00
|
|
|
|
Msg( "^3no server running.\n" );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2009-09-17 22:00:00 +02:00
|
|
|
|
if( !SV_SetPlayer()) return;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2009-06-24 22:00:00 +02:00
|
|
|
|
SV_BroadcastPrintf( PRINT_HIGH, "%s was kicked\n", sv_client->name );
|
|
|
|
|
SV_ClientPrintf( sv_client, PRINT_HIGH, "You were kicked from the game\n" );
|
2008-12-25 22:00:00 +01:00
|
|
|
|
SV_DropClient( sv_client );
|
2009-06-24 22:00:00 +02:00
|
|
|
|
sv_client->lastmessage = svs.realtime; // min case there is a funny zombie
|
2007-06-21 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-11-25 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
==================
|
|
|
|
|
SV_Kill_f
|
|
|
|
|
==================
|
|
|
|
|
*/
|
|
|
|
|
void SV_Kill_f( void )
|
|
|
|
|
{
|
|
|
|
|
if( !SV_SetPlayer()) return;
|
|
|
|
|
if( sv_client->edict->v.health <= 0.0f )
|
|
|
|
|
{
|
|
|
|
|
SV_ClientPrintf( sv_client, PRINT_HIGH, "Can't suicide -- allready dead!\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
svgame.dllFuncs.pfnClientKill( sv_client->edict );
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-21 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
================
|
|
|
|
|
SV_Status_f
|
|
|
|
|
================
|
|
|
|
|
*/
|
2007-11-17 22:00:00 +01:00
|
|
|
|
void SV_Status_f( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2007-11-17 22:00:00 +01:00
|
|
|
|
int i;
|
2008-07-09 22:00:00 +02:00
|
|
|
|
sv_client_t *cl;
|
2007-11-17 22:00:00 +01:00
|
|
|
|
|
2009-09-14 22:00:00 +02:00
|
|
|
|
if( !svs.clients )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2009-09-14 22:00:00 +02:00
|
|
|
|
Msg ( "^3no server running.\n" );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-14 22:00:00 +02:00
|
|
|
|
Msg( "map: %s\n", sv.name );
|
|
|
|
|
Msg( "num score ping name lastmsg address port \n" );
|
|
|
|
|
Msg( "--- ----- ------- --------------- ------- --------------------- ------\n" );
|
2007-11-17 22:00:00 +01:00
|
|
|
|
|
2009-09-25 22:00:00 +02:00
|
|
|
|
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2007-11-17 22:00:00 +01:00
|
|
|
|
int j, l, ping;
|
|
|
|
|
char *s;
|
|
|
|
|
|
2008-07-12 22:00:00 +02:00
|
|
|
|
if( !cl->state ) continue;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2009-09-16 22:00:00 +02:00
|
|
|
|
Msg( "%3i ", i );
|
2009-09-17 22:00:00 +02:00
|
|
|
|
Msg( "%5i ", (int)cl->edict->v.frags );
|
2007-11-17 22:00:00 +01:00
|
|
|
|
|
2009-09-14 22:00:00 +02:00
|
|
|
|
if( cl->state == cs_connected ) Msg( "Connect" );
|
|
|
|
|
else if( cl->state == cs_zombie ) Msg( "Zombie " );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ping = cl->ping < 9999 ? cl->ping : 9999;
|
2009-09-14 22:00:00 +02:00
|
|
|
|
Msg( "%7i ", ping );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-09-14 22:00:00 +02:00
|
|
|
|
Msg( "%s", cl->name );
|
|
|
|
|
l = 24 - com.strlen( cl->name );
|
2009-09-16 22:00:00 +02:00
|
|
|
|
for( j = 0; j < l; j++ ) Msg( " " );
|
2009-09-17 22:00:00 +02:00
|
|
|
|
Msg( "%g ", (svs.realtime - cl->lastmessage) * 0.001f );
|
2009-09-14 22:00:00 +02:00
|
|
|
|
s = NET_AdrToString( cl->netchan.remote_address );
|
|
|
|
|
Msg( "%s", s );
|
|
|
|
|
l = 22 - com.strlen( s );
|
|
|
|
|
for( j = 0; j < l; j++ ) Msg( " " );
|
|
|
|
|
Msg( "%5i", cl->netchan.qport );
|
|
|
|
|
Msg( "\n" );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
}
|
2009-09-14 22:00:00 +02:00
|
|
|
|
Msg( "\n" );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==================
|
|
|
|
|
SV_ConSay_f
|
|
|
|
|
==================
|
|
|
|
|
*/
|
2007-11-17 22:00:00 +01:00
|
|
|
|
void SV_ConSay_f( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2007-11-17 22:00:00 +01:00
|
|
|
|
char *p, text[MAX_SYSPATH];
|
2008-07-09 22:00:00 +02:00
|
|
|
|
sv_client_t *client;
|
2007-11-17 22:00:00 +01:00
|
|
|
|
int i;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2009-09-16 22:00:00 +02:00
|
|
|
|
if(Cmd_Argc() < 2) return;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2009-06-24 22:00:00 +02:00
|
|
|
|
com.strncpy( text, "console: ", MAX_SYSPATH );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
p = Cmd_Args();
|
|
|
|
|
|
2009-06-24 22:00:00 +02:00
|
|
|
|
if( *p == '"' )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
p++;
|
2007-11-30 22:00:00 +01:00
|
|
|
|
p[com.strlen(p) - 1] = 0;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
}
|
2009-06-24 22:00:00 +02:00
|
|
|
|
com.strncat( text, p, MAX_SYSPATH );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2009-09-25 22:00:00 +02:00
|
|
|
|
for( i = 0, client = svs.clients; i < sv_maxclients->integer; i++, client++ )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2008-07-31 22:00:00 +02:00
|
|
|
|
if( client->state != cs_spawned ) continue;
|
2009-06-24 22:00:00 +02:00
|
|
|
|
SV_ClientPrintf( client, PRINT_CHAT, "%s\n", text );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==================
|
|
|
|
|
SV_Heartbeat_f
|
|
|
|
|
==================
|
|
|
|
|
*/
|
2009-09-16 22:00:00 +02:00
|
|
|
|
void SV_Heartbeat_f (void)
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2008-06-30 22:00:00 +02:00
|
|
|
|
svs.last_heartbeat = MAX_HEARTBEAT;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
===========
|
2007-11-17 22:00:00 +01:00
|
|
|
|
SV_ServerInfo_f
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2007-11-17 22:00:00 +01:00
|
|
|
|
Examine serverinfo string
|
2007-06-21 22:00:00 +02:00
|
|
|
|
===========
|
|
|
|
|
*/
|
2007-11-17 22:00:00 +01:00
|
|
|
|
void SV_ServerInfo_f( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2009-11-10 22:00:00 +01:00
|
|
|
|
Msg( "Server info settings:\n" );
|
|
|
|
|
Info_Print( Cvar_Serverinfo( ));
|
2007-06-21 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
===========
|
2007-11-17 22:00:00 +01:00
|
|
|
|
SV_ClientInfo_f
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
Examine all a users info strings
|
|
|
|
|
===========
|
|
|
|
|
*/
|
2007-11-17 22:00:00 +01:00
|
|
|
|
void SV_ClientInfo_f( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2007-11-17 22:00:00 +01:00
|
|
|
|
if(Cmd_Argc() != 2)
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2007-11-17 22:00:00 +01:00
|
|
|
|
Msg("Usage: clientinfo <userid>\n" );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-17 22:00:00 +01:00
|
|
|
|
if(!SV_SetPlayer()) return;
|
|
|
|
|
Msg("userinfo\n");
|
|
|
|
|
Msg("--------\n");
|
|
|
|
|
Info_Print( sv_client->userinfo );
|
2007-07-21 22:00:00 +02:00
|
|
|
|
|
2007-06-21 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
===============
|
|
|
|
|
SV_KillServer_f
|
|
|
|
|
|
|
|
|
|
Kick everyone off, possibly in preparation for a new game
|
|
|
|
|
===============
|
|
|
|
|
*/
|
|
|
|
|
void SV_KillServer_f (void)
|
|
|
|
|
{
|
2008-08-02 22:00:00 +02:00
|
|
|
|
if( !svs.initialized ) return;
|
2007-11-30 22:00:00 +01:00
|
|
|
|
com.strncpy( host.finalmsg, "Server was killed\n", MAX_STRING );
|
2007-11-21 22:00:00 +01:00
|
|
|
|
SV_Shutdown( false );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==================
|
|
|
|
|
SV_InitOperatorCommands
|
|
|
|
|
==================
|
|
|
|
|
*/
|
2007-11-17 22:00:00 +01:00
|
|
|
|
void SV_InitOperatorCommands( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2008-11-14 22:00:00 +01:00
|
|
|
|
Cmd_AddCommand( "heartbeat", SV_Heartbeat_f, "send a heartbeat to the master server" );
|
|
|
|
|
Cmd_AddCommand( "kick", SV_Kick_f, "kick a player off the server by number or name" );
|
2009-11-25 22:00:00 +01:00
|
|
|
|
Cmd_AddCommand( "kill", SV_Kill_f, "die instantly" );
|
2008-11-14 22:00:00 +01:00
|
|
|
|
Cmd_AddCommand( "status", SV_Status_f, "print server status information" );
|
|
|
|
|
Cmd_AddCommand( "serverinfo", SV_ServerInfo_f, "print server settings" );
|
|
|
|
|
Cmd_AddCommand( "clientinfo", SV_ClientInfo_f, "print user infostring (player num required)" );
|
|
|
|
|
|
|
|
|
|
Cmd_AddCommand( "map", SV_Map_f, "start new level" );
|
2009-08-17 22:00:00 +02:00
|
|
|
|
Cmd_AddCommand( "devmap", SV_Map_f, "start new level" );
|
2008-11-14 22:00:00 +01:00
|
|
|
|
Cmd_AddCommand( "newgame", SV_Newgame_f, "begin new game" );
|
2009-10-16 22:00:00 +02:00
|
|
|
|
Cmd_AddCommand( "endgame", SV_Endgame_f, "end current game" );
|
2008-11-14 22:00:00 +01:00
|
|
|
|
Cmd_AddCommand( "changelevel", SV_ChangeLevel_f, "changing level" );
|
|
|
|
|
Cmd_AddCommand( "restart", SV_Restart_f, "restarting current level" );
|
2009-09-28 22:00:00 +02:00
|
|
|
|
Cmd_AddCommand( "reload", SV_Reload_f, "continue from latest save or restart level" );
|
2008-07-17 22:00:00 +02:00
|
|
|
|
|
2008-07-11 22:00:00 +02:00
|
|
|
|
if( host.type == HOST_DEDICATED )
|
2007-11-17 22:00:00 +01:00
|
|
|
|
{
|
2008-11-14 22:00:00 +01:00
|
|
|
|
Cmd_AddCommand( "say", SV_ConSay_f, "send a chat message to everyone on the server" );
|
|
|
|
|
Cmd_AddCommand( "setmaster", SV_SetMaster_f, "set ip address for dedicated server" );
|
2007-11-17 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2008-11-14 22:00:00 +01:00
|
|
|
|
Cmd_AddCommand( "save", SV_Save_f, "save the game to a file" );
|
|
|
|
|
Cmd_AddCommand( "load", SV_Load_f, "load a saved game file" );
|
2009-10-22 22:00:00 +02:00
|
|
|
|
Cmd_AddCommand( "savequick", SV_QuickSave_f, "save the game to the quicksave" );
|
|
|
|
|
Cmd_AddCommand( "loadquick", SV_QuickLoad_f, "load a quick-saved game file" );
|
2010-01-07 22:00:00 +01:00
|
|
|
|
Cmd_AddCommand( "delsave", SV_DeleteSave_f, "delete a saved game file and saveshot" );
|
2009-01-09 22:00:00 +01:00
|
|
|
|
Cmd_AddCommand( "autosave", SV_AutoSave_f, "save the game to 'autosave' file" );
|
2008-11-14 22:00:00 +01:00
|
|
|
|
Cmd_AddCommand( "killserver", SV_KillServer_f, "shutdown current server" );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-11-17 22:00:00 +01:00
|
|
|
|
void SV_KillOperatorCommands( void )
|
|
|
|
|
{
|
2009-01-09 22:00:00 +01:00
|
|
|
|
Cmd_RemoveCommand( "heartbeat" );
|
|
|
|
|
Cmd_RemoveCommand( "kick" );
|
2009-11-25 22:00:00 +01:00
|
|
|
|
Cmd_RemoveCommand( "kill" );
|
2009-01-09 22:00:00 +01:00
|
|
|
|
Cmd_RemoveCommand( "status" );
|
|
|
|
|
Cmd_RemoveCommand( "serverinfo" );
|
|
|
|
|
Cmd_RemoveCommand( "clientinfo" );
|
|
|
|
|
|
|
|
|
|
Cmd_RemoveCommand( "map" );
|
|
|
|
|
Cmd_RemoveCommand( "movie" );
|
|
|
|
|
Cmd_RemoveCommand( "newgame" );
|
2009-10-16 22:00:00 +02:00
|
|
|
|
Cmd_RemoveCommand( "endgame" );
|
2009-01-09 22:00:00 +01:00
|
|
|
|
Cmd_RemoveCommand( "changelevel" );
|
|
|
|
|
Cmd_RemoveCommand( "restart" );
|
2009-09-28 22:00:00 +02:00
|
|
|
|
Cmd_RemoveCommand( "reload" );
|
2009-01-09 22:00:00 +01:00
|
|
|
|
Cmd_RemoveCommand( "sectorlist" );
|
2007-11-17 22:00:00 +01:00
|
|
|
|
|
2008-07-11 22:00:00 +02:00
|
|
|
|
if( host.type == HOST_DEDICATED )
|
2007-11-17 22:00:00 +01:00
|
|
|
|
{
|
2009-01-09 22:00:00 +01:00
|
|
|
|
Cmd_RemoveCommand( "say" );
|
|
|
|
|
Cmd_RemoveCommand( "setmaster" );
|
2007-11-17 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2009-01-09 22:00:00 +01:00
|
|
|
|
Cmd_RemoveCommand( "save" );
|
|
|
|
|
Cmd_RemoveCommand( "load" );
|
2010-01-07 22:00:00 +01:00
|
|
|
|
Cmd_RemoveCommand( "delsave" );
|
2009-01-09 22:00:00 +01:00
|
|
|
|
Cmd_RemoveCommand( "autosave" );
|
|
|
|
|
Cmd_RemoveCommand( "killserver" );
|
2007-11-17 22:00:00 +01:00
|
|
|
|
}
|