diff options
author | M. Kristall <mkpdev@gmail.com> | 2009-10-03 12:25:16 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:15:56 +0000 |
commit | 128465097ee6fbba8670ccb27a40dc1074a3ea95 (patch) | |
tree | 8ab8bf47fd8ecbdc2451684930df81353805fc15 | |
parent | 788fdf35246001ba4178dcac7665954479871f48 (diff) |
* Move some server commands into game and refactor game commands
-rw-r--r-- | src/game/g_local.h | 3 | ||||
-rw-r--r-- | src/game/g_maprotation.c | 9 | ||||
-rw-r--r-- | src/game/g_svcmds.c | 393 | ||||
-rw-r--r-- | src/server/sv_ccmds.c | 354 |
4 files changed, 267 insertions, 492 deletions
diff --git a/src/game/g_local.h b/src/game/g_local.h index c9a01b1b..7d7dd725 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -677,6 +677,7 @@ void G_FollowLockView( gentity_t *ent ); qboolean G_FollowNewClient( gentity_t *ent, int dir ); void G_ToggleFollow( gentity_t *ent ); void G_MatchOnePlayer( int *plist, int num, char *err, int len ); +int G_ClientNumberFromString( char *s ); int G_ClientNumbersFromString( char *s, int *plist, int max ); int G_SayArgc( void ); qboolean G_SayArgv( int n, char *buffer, int bufferLength ); @@ -1057,7 +1058,7 @@ typedef struct mapRotations_s } mapRotations_t; void G_PrintRotations( void ); -qboolean G_AdvanceMapRotation( void ); +void G_AdvanceMapRotation( void ); qboolean G_StartMapRotation( char *name, qboolean changeMap ); void G_StopMapRotation( void ); qboolean G_MapRotationActive( void ); diff --git a/src/game/g_maprotation.c b/src/game/g_maprotation.c index 9ae4f209..a202d4be 100644 --- a/src/game/g_maprotation.c +++ b/src/game/g_maprotation.c @@ -651,7 +651,7 @@ G_AdvanceMapRotation Increment the current map rotation =============== */ -qboolean G_AdvanceMapRotation( void ) +void G_AdvanceMapRotation( void ) { mapRotation_t *mr; mapRotationEntry_t *mre; @@ -661,7 +661,7 @@ qboolean G_AdvanceMapRotation( void ) mapConditionType_t mct; if( ( currentRotation = g_currentMapRotation.integer ) == NOT_ROTATING ) - return qfalse; + return; currentMap = G_GetCurrentMap( currentRotation ); @@ -685,8 +685,7 @@ qboolean G_AdvanceMapRotation( void ) case MCT_ROTATION: G_StartMapRotation( mrc->dest, qtrue ); - return qtrue; - break; + return; default: case MCT_ERR: @@ -699,8 +698,6 @@ qboolean G_AdvanceMapRotation( void ) G_SetCurrentMap( nextMap, currentRotation ); G_IssueMapChange( currentRotation ); - - return qtrue; } /* diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c index 40dd6eb3..2faec6bf 100644 --- a/src/game/g_svcmds.c +++ b/src/game/g_svcmds.c @@ -85,8 +85,23 @@ void Svcmd_EntityList_f( void ) case ET_GRAPPLE: G_Printf( "ET_GRAPPLE " ); break; + case ET_CORPSE: + G_Printf( "ET_CORPSE " ); + break; + case ET_PARTICLE_SYSTEM: + G_Printf( "ET_PARTICLE_SYSTEM " ); + break; + case ET_ANIMMAPOBJ: + G_Printf( "ET_ANIMMAPOBJ " ); + break; + case ET_MODELDOOR: + G_Printf( "ET_MODELDOOR " ); + break; + case ET_LIGHTFLARE: + G_Printf( "ET_LIGHTFLARE " ); + break; default: - G_Printf( "%3i ", check->s.eType ); + G_Printf( "%-3i ", check->s.eType ); break; } @@ -97,48 +112,55 @@ void Svcmd_EntityList_f( void ) } } -gclient_t *ClientForString( const char *s ) +static gclient_t *ClientForString( char *s ) { - gclient_t *cl; - int i; - int idnum; + int idnum, count; + int pids[ MAX_CLIENTS ]; - // numeric values are just slot numbers - if( s[ 0 ] >= '0' && s[ 0 ] <= '9' ) + if( ( count = G_ClientNumbersFromString( s, pids, MAX_CLIENTS ) ) != 1 ) { - idnum = atoi( s ); + idnum = G_ClientNumberFromString( s ); - if( idnum < 0 || idnum >= level.maxclients ) + if( idnum == -1 ) { - Com_Printf( "Bad client slot: %i\n", idnum ); + char err[ MAX_STRING_CHARS ]; + G_MatchOnePlayer( pids, count, err, sizeof( err ) ); + G_Printf( "%s\n", err ); return NULL; } + } + else + idnum = pids[ 0 ]; - cl = &level.clients[ idnum ]; - - if( cl->pers.connected == CON_DISCONNECTED ) - { - G_Printf( "Client %i is not connected\n", idnum ); - return NULL; - } + return &level.clients[ idnum ]; +} - return cl; - } +static void Svcmd_Status_f( void ) +{ + int i; + gclient_t *cl; + char userinfo[ MAX_INFO_STRING ]; - // check for a name match - for( i = 0; i < level.maxclients; i++ ) + G_Printf( "slot score ping address rate name\n" ); + G_Printf( "---- ----- ---- ------- ---- ----\n" ); + for( i = 0, cl = level.clients; i < level.maxclients; i++, cl++ ) { - cl = &level.clients[ i ]; if( cl->pers.connected == CON_DISCONNECTED ) continue; - if( !Q_stricmp( cl->pers.netname, s ) ) - return cl; - } + G_Printf( "%-4d ", i ); + G_Printf( "%-5d ", cl->ps.persistant[ PERS_SCORE ] ); - G_Printf( "User %s is not on the server\n", s ); + if( cl->pers.connected == CON_CONNECTING ) + G_Printf( "CNCT " ); + else + G_Printf( "%-4d ", cl->ps.ping ); - return NULL; + trap_GetUserinfo( i, userinfo, sizeof( userinfo ) ); + G_Printf( "%-21s ", Info_ValueForKey( userinfo, "ip" ) ); + G_Printf( "%-8d ", Info_ValueForKey( userinfo, "rate" ) ); + G_Printf( "%s\n", cl->pers.netname ); // Info_ValueForKey( userinfo, "name" ) + } } /* @@ -148,22 +170,32 @@ Svcmd_ForceTeam_f forceteam <player> <team> =================== */ -void Svcmd_ForceTeam_f( void ) +static void Svcmd_ForceTeam_f( void ) { gclient_t *cl; char str[ MAX_TOKEN_CHARS ]; + team_t team; + + if( trap_Argc( ) != 3 ) + { + G_Printf( "usage: forceteam <player> <team>\n" ); + return; + } - // find the player trap_Argv( 1, str, sizeof( str ) ); cl = ClientForString( str ); if( !cl ) return; - // set the team trap_Argv( 2, str, sizeof( str ) ); - /*SetTeam( &g_entities[cl - level.clients], str );*/ - //FIXME: tremulise this + team = G_TeamFromString( str ); + if( team == NUM_TEAMS ) + { + G_Printf( "forceteam: invalid team \"%s\"\n", str ); + return; + } + G_ChangeTeam( &g_entities[ cl - level.clients ], team ); } /* @@ -173,7 +205,7 @@ Svcmd_LayoutSave_f layoutsave <name> =================== */ -void Svcmd_LayoutSave_f( void ) +static void Svcmd_LayoutSave_f( void ) { char str[ MAX_QPATH ]; char str2[ MAX_QPATH - 4 ]; @@ -182,7 +214,7 @@ void Svcmd_LayoutSave_f( void ) if( trap_Argc( ) != 2 ) { - G_Printf( "usage: layoutsave LAYOUTNAME\n" ); + G_Printf( "usage: layoutsave <name>\n" ); return; } trap_Argv( 1, str, sizeof( str ) ); @@ -191,9 +223,7 @@ void Svcmd_LayoutSave_f( void ) s = &str[ 0 ]; while( *s && i < sizeof( str2 ) - 1 ) { - if( ( *s >= '0' && *s <= '9' ) || - ( *s >= 'a' && *s <= 'z' ) || - ( *s >= 'A' && *s <= 'Z' ) || *s == '-' || *s == '_' ) + if( isalnum( *s ) || *s == '-' || *s == '_' ) { str2[ i++ ] = *s; str2[ i ] = '\0'; @@ -203,7 +233,7 @@ void Svcmd_LayoutSave_f( void ) if( !str2[ 0 ] ) { - G_Printf("layoutsave: invalid name \"%s\"\n", str ); + G_Printf( "layoutsave: invalid name \"%s\"\n", str ); return; } @@ -223,11 +253,17 @@ This is just a silly alias for doing: map_restart =================== */ -void Svcmd_LayoutLoad_f( void ) +static void Svcmd_LayoutLoad_f( void ) { char layouts[ MAX_CVAR_VALUE_STRING ]; char *s; + if( trap_Argc( ) < 2 ) + { + G_Printf( "usage: layoutload <name> ...\n" ); + return; + } + s = ConcatArgs( 1 ); Q_strncpyz( layouts, s, sizeof( layouts ) ); trap_Cvar_Set( "g_layouts", layouts ); @@ -246,151 +282,246 @@ static void Svcmd_AdmitDefeat_f( void ) return; } trap_Argv( 1, teamNum, sizeof( teamNum ) ); - team = atoi( teamNum ); - if( team == TEAM_ALIENS || teamNum[ 0 ] == 'a' ) + team = G_TeamFromString( teamNum ); + if( team == TEAM_ALIENS ) { - level.surrenderTeam = TEAM_ALIENS; - G_BaseSelfDestruct( TEAM_ALIENS ); G_TeamCommand( TEAM_ALIENS, "cp \"Hivemind Link Broken\" 1"); trap_SendServerCommand( -1, "print \"Alien team has admitted defeat\n\"" ); } - else if( team == TEAM_HUMANS || teamNum[ 0 ] == 'h' ) + else if( team == TEAM_HUMANS ) { - level.surrenderTeam = TEAM_HUMANS; - G_BaseSelfDestruct( TEAM_HUMANS ); G_TeamCommand( TEAM_HUMANS, "cp \"Life Support Terminated\" 1"); trap_SendServerCommand( -1, "print \"Human team has admitted defeat\n\"" ); } else { G_Printf("admitdefeat: invalid team\n"); - } + return; + } + level.surrenderTeam = team; + G_BaseSelfDestruct( team ); } -/* -================= -ConsoleCommand +static void Svcmd_TeamWin_f( void ) +{ + char cmd[ 6 ]; + trap_Argv( 0, cmd, sizeof( cmd ) ); + G_BaseSelfDestruct( G_TeamFromString( cmd ) ); +} -================= -*/ -qboolean ConsoleCommand( void ) +static void Svcmd_Evacuation_f( void ) { - char cmd[ MAX_TOKEN_CHARS ]; + trap_SendServerCommand( -1, "print \"Evacuation ordered\n\"" ); + level.lastWin = TEAM_NONE; + trap_SetConfigstring( CS_WINNER, "Evacuation" ); + LogExit( "Evacuation." ); +} - trap_Argv( 0, cmd, sizeof( cmd ) ); +static void Svcmd_MapRotation_f( void ) +{ + char rotationName[ MAX_QPATH ]; - if( Q_stricmp( cmd, "entitylist" ) == 0 ) + if( trap_Argc( ) != 2 ) { - Svcmd_EntityList_f( ); - return qtrue; + G_Printf( "usage: maprotation <name>\n" ); + return; } - if( Q_stricmp( cmd, "forceteam" ) == 0 ) - { - Svcmd_ForceTeam_f( ); - return qtrue; - } + trap_Argv( 1, rotationName, sizeof( rotationName ) ); + if( !G_StartMapRotation( rotationName, qfalse ) ) + G_Printf( "maprotation: invalid map rotation \"%s\"\n", rotationName ); +} + +static void Svcmd_TeamMessage_f( void ) +{ + char teamNum[ 2 ]; + team_t team; - if( Q_stricmp( cmd, "mapRotation" ) == 0 ) + if( trap_Argc( ) < 3 ) { - char *rotationName = ConcatArgs( 1 ); + G_Printf( "usage: say_team <team> <message>\n" ); + return; + } - if( !G_StartMapRotation( rotationName, qfalse ) ) - G_Printf( "Can't find map rotation %s\n", rotationName ); + trap_Argv( 1, teamNum, sizeof( teamNum ) ); + team = G_TeamFromString( teamNum ); - return qtrue; + if( team == NUM_TEAMS ) + { + G_Printf( "say_team: invalid team \"%s\"\n", teamNum ); + return; } - if( Q_stricmp( cmd, "stopMapRotation" ) == 0 ) - { - G_StopMapRotation( ); + G_TeamCommand( team, va( "tchat \"console: %s\"", ConcatArgs( 2 ) ) ); +} - return qtrue; - } +static void Svcmd_SendMessage( void ) +{ + char cmd[ 5 ]; + trap_Argv( 1, cmd, sizeof( cmd ) ); - if( Q_stricmp( cmd, "advanceMapRotation" ) == 0 ) + if( trap_Argc( ) < 2 ) { - G_AdvanceMapRotation( ); - - return qtrue; + G_Printf( "usage: %s <message>\n", cmd ); + return; } - if( Q_stricmp( cmd, "alienWin" ) == 0 ) + trap_SendServerCommand( -1, va( "chat \"console: %s\"", ConcatArgs( 1 ) ) ); +} + +static void Svcmd_CenterPrint_f( void ) +{ + if( trap_Argc( ) < 2 ) { - G_BaseSelfDestruct( TEAM_HUMANS ); - return qtrue; + G_Printf( "usage: cp <message>\n" ); + return; } - if( Q_stricmp( cmd, "humanWin" ) == 0 ) + trap_SendServerCommand( -1, va( "cp \"%s\"", ConcatArgs( 1 ) ) ); +} + +static void Svcmd_EjectClient_f( void ) +{ + char *reason, name[ MAX_STRING_CHARS ]; + + if( trap_Argc( ) < 2 ) { - G_BaseSelfDestruct( TEAM_ALIENS ); - return qtrue; + G_Printf( "usage: eject <player|-1> <reason>\n" ); + return; } - if( !Q_stricmp( cmd, "layoutsave" ) ) + trap_Argv( 1, name, sizeof( name ) ); + reason = ConcatArgs( 2 ); + + if( atoi( name ) == -1 ) { - Svcmd_LayoutSave_f( ); - return qtrue; + int i; + for( i = 0; i < level.maxclients; i++ ) + { + if( level.clients[ i ].pers.connected == CON_DISCONNECTED ) + continue; + if( level.clients[ i ].pers.localClient ) + continue; + trap_DropClient( i, reason ); + } } - - if( !Q_stricmp( cmd, "layoutload" ) ) + else { - Svcmd_LayoutLoad_f( ); - return qtrue; + gclient_t *cl = ClientForString( name ); + if( !cl ) + return; + if( cl->pers.localClient ) + { + G_Printf( "eject: cannot eject local clients\n" ); + return; + } + trap_DropClient( cl-level.clients, reason ); } - - if( !Q_stricmp( cmd, "admitdefeat" ) ) +} + +static void Svcmd_DumpUser_f( void ) +{ + char name[ MAX_STRING_CHARS ], userinfo[ MAX_INFO_STRING ]; + char key[ BIG_INFO_KEY ], value[ BIG_INFO_VALUE ]; + const char *info; + gclient_t *cl; + + if( trap_Argc( ) != 2 ) { - Svcmd_AdmitDefeat_f( ); - return qtrue; + G_Printf( "usage: dumpuser <player>\n" ); + return; } - if( !Q_stricmp( cmd, "evacuation" ) ) + trap_Argv( 1, name, sizeof( name ) ); + cl = ClientForString( name ); + if( !cl ) + return; + + trap_GetUserinfo( cl-level.clients, userinfo, sizeof( userinfo ) ); + info = &userinfo[ 0 ]; + G_Printf( "userinfo\n--------\n" ); + //Info_Print( userinfo ); + while( 1 ) { - trap_SendServerCommand( -1, "print \"Evacuation ordered\n\"" ); - level.lastWin = TEAM_NONE; - trap_SetConfigstring( CS_WINNER, "Evacuation" ); - LogExit( "Evacuation." ); - return qtrue; + Info_NextPair( &info, key, value ); + if( !*info ) + return; + + G_Printf( "%-20s%s\n", key, value ); } - - // see if this is a a admin command - if( G_admin_cmd_check( NULL, qfalse ) ) - return qtrue; +} - if( g_dedicated.integer ) +// dumb wrapper for "a" and "m" +static void Svcmd_MessageWrapper( void ) +{ + char cmd[ 2 ]; + trap_Argv( 0, cmd, sizeof( cmd ) ); + if( !Q_stricmp( cmd, "a" ) ) + Cmd_AdminMessage_f( NULL ); + else + Cmd_PrivateMessage_f( NULL ); +} + +struct +{ + char *cmd; + qboolean dedicated; + void ( *function )( void ); +} svcmds[ ] = { + { "entityList", qfalse, Svcmd_EntityList_f }, + { "status", qfalse, Svcmd_Status_f }, + { "forceTeam", qfalse, Svcmd_ForceTeam_f }, + { "mapRotation", qfalse, Svcmd_MapRotation_f }, + { "stopMapRotation", qfalse, G_StopMapRotation }, + { "advanceMapRotation", qfalse, G_AdvanceMapRotation }, + { "alienWin", qfalse, Svcmd_TeamWin_f }, + { "humanWin", qfalse, Svcmd_TeamWin_f }, + { "layoutSave", qfalse, Svcmd_LayoutSave_f }, + { "layoutLoad", qfalse, Svcmd_LayoutLoad_f }, + { "eject", qfalse, Svcmd_EjectClient_f }, + { "dumpuser", qfalse, Svcmd_DumpUser_f }, + { "admitDefeat", qfalse, Svcmd_AdmitDefeat_f }, + { "evacuation", qfalse, Svcmd_Evacuation_f }, + // don't handle communication commands unless dedicated + { "say_team", qtrue, Svcmd_TeamMessage_f }, + { "say", qtrue, Svcmd_SendMessage }, + { "chat", qtrue, Svcmd_SendMessage }, + { "cp", qtrue, Svcmd_CenterPrint_f }, + { "m", qtrue, Svcmd_MessageWrapper }, + { "a", qtrue, Svcmd_MessageWrapper } +}; + +/* +================= +ConsoleCommand + +================= +*/ +qboolean ConsoleCommand( void ) +{ + char cmd[ MAX_TOKEN_CHARS ]; + int i; + + trap_Argv( 0, cmd, sizeof( cmd ) ); + + for( i = 0; i < sizeof( svcmds ) / sizeof( svcmds[ 0 ] ); i++ ) { - if( Q_stricmp( cmd, "say" ) == 0 ) - { - trap_SendServerCommand( -1, va( "print \"server: %s\n\"", ConcatArgs( 1 ) ) ); - return qtrue; - } - else if( !Q_stricmp( cmd, "chat" ) ) - { - trap_SendServerCommand( -1, va( "chat \"%s\" -1 0", ConcatArgs( 1 ) ) ); - G_Printf( "chat: %s\n", ConcatArgs( 1 ) ); - return qtrue; - } - else if( !Q_stricmp( cmd, "cp" ) ) - { - trap_SendServerCommand( -1, va( "cp \"%s\"", ConcatArgs( 1 ) ) ); - G_Printf( "cp: %s\n", ConcatArgs( 1 ) ); - return qtrue; - } - else if( !Q_stricmp( cmd, "m" ) ) - { - Cmd_PrivateMessage_f( NULL ); - return qtrue; - } - else if( !Q_stricmp( cmd, "a" ) ) + if( !Q_stricmp( cmd, svcmds[ i ].cmd ) ) { - Cmd_AdminMessage_f( NULL ); + if( svcmds[ i ].dedicated && !g_dedicated.integer ) + return qfalse; + svcmds[ i ].function( ); return qtrue; } - G_Printf( "unknown command: %s\n", cmd ); - return qtrue; } + // see if this is an admin command + if( G_admin_cmd_check( NULL, qfalse ) ) + return qtrue; + + if( g_dedicated.integer ) + G_Printf( "unknown command: %s\n", cmd ); + return qfalse; } diff --git a/src/server/sv_ccmds.c b/src/server/sv_ccmds.c index 60de4275..367ca23d 100644 --- a/src/server/sv_ccmds.c +++ b/src/server/sv_ccmds.c @@ -32,118 +32,6 @@ These commands can only be entered from stdin or by a remote operator datagram =============================================================================== */ - -/* -================== -SV_GetPlayerByHandle - -Returns the player with player id or name from Cmd_Argv(1) -================== -*/ -static client_t *SV_GetPlayerByHandle( void ) { - client_t *cl; - int i; - char *s; - char cleanName[64]; - - // make sure server is running - if ( !com_sv_running->integer ) { - return NULL; - } - - if ( Cmd_Argc() < 2 ) { - Com_Printf( "No player specified.\n" ); - return NULL; - } - - s = Cmd_Argv(1); - - // Check whether this is a numeric player handle - for(i = 0; s[i] >= '0' && s[i] <= '9'; i++); - - if(!s[i]) - { - int plid = atoi(s); - - // Check for numeric playerid match - if(plid >= 0 && plid < sv_maxclients->integer) - { - cl = &svs.clients[plid]; - - if(cl->state) - return cl; - } - } - - // check for a name match - for ( i=0, cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++ ) { - if ( !cl->state ) { - continue; - } - if ( !Q_stricmp( cl->name, s ) ) { - return cl; - } - - Q_strncpyz( cleanName, cl->name, sizeof(cleanName) ); - Q_CleanStr( cleanName ); - if ( !Q_stricmp( cleanName, s ) ) { - return cl; - } - } - - Com_Printf( "Player %s is not on the server\n", s ); - - return NULL; -} - -/* -================== -SV_GetPlayerByNum - -Returns the player with idnum from Cmd_Argv(1) -================== -*/ -static client_t *SV_GetPlayerByNum( void ) { - client_t *cl; - int i; - int idnum; - char *s; - - // make sure server is running - if ( !com_sv_running->integer ) { - return NULL; - } - - if ( Cmd_Argc() < 2 ) { - Com_Printf( "No player specified.\n" ); - return NULL; - } - - s = Cmd_Argv(1); - - for (i = 0; s[i]; i++) { - if (s[i] < '0' || s[i] > '9') { - Com_Printf( "Bad slot number: %s\n", s); - return NULL; - } - } - idnum = atoi( s ); - if ( idnum < 0 || idnum >= sv_maxclients->integer ) { - Com_Printf( "Bad client slot: %i\n", idnum ); - return NULL; - } - - cl = &svs.clients[idnum]; - if ( !cl->state ) { - Com_Printf( "Client %i is not active\n", idnum ); - return NULL; - } - return cl; -} - -//========================================================= - - /* ================== SV_Map_f @@ -319,202 +207,6 @@ static void SV_MapRestart_f( void ) { svs.time += 100; } -//=============================================================== - -/* -================== -SV_KickAll_f - -Kick all users off of the server FIXME: move to game -================== -*/ -static void SV_KickAll_f( void ) { - client_t *cl; - int i; - - // make sure server is running - if ( !com_sv_running->integer ) { - Com_Printf( "Server is not running.\n" ); - return; - } - - for ( i=0, cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++ ) { - if ( !cl->state ) { - continue; - } - if( cl->netchan.remoteAddress.type == NA_LOOPBACK ) { - continue; - } - SV_DropClient( cl, "was kicked" ); - cl->lastPacketTime = svs.time; // in case there is a funny zombie - } -} - -/* -================== -SV_Kick_f - -Kick a user off of the server FIXME: move to game -================== -*/ -static void SV_Kick_f( void ) { - client_t *cl; - - // make sure server is running - if ( !com_sv_running->integer ) { - Com_Printf( "Server is not running.\n" ); - return; - } - - if ( Cmd_Argc() != 2 ) { - Com_Printf ("Usage: kick <player name>\n"); - return; - } - - cl = SV_GetPlayerByHandle(); - if ( !cl ) { - return; - } - if( cl->netchan.remoteAddress.type == NA_LOOPBACK ) { - SV_SendServerCommand(NULL, "print \"%s\"", "Cannot kick host player\n"); - return; - } - - SV_DropClient( cl, "was kicked" ); - cl->lastPacketTime = svs.time; // in case there is a funny zombie -} - -/* -================== -SV_KickNum_f - -Kick a user off of the server FIXME: move to game -================== -*/ -static void SV_KickNum_f( void ) { - client_t *cl; - - // make sure server is running - if ( !com_sv_running->integer ) { - Com_Printf( "Server is not running.\n" ); - return; - } - - if ( Cmd_Argc() != 2 ) { - Com_Printf ("Usage: kicknum <client number>\n"); - return; - } - - cl = SV_GetPlayerByNum(); - if ( !cl ) { - return; - } - if( cl->netchan.remoteAddress.type == NA_LOOPBACK ) { - SV_SendServerCommand(NULL, "print \"%s\"", "Cannot kick host player\n"); - return; - } - - SV_DropClient( cl, "was kicked" ); - cl->lastPacketTime = svs.time; // in case there is a funny zombie -} - -/* -================ -SV_Status_f -================ -*/ -static void SV_Status_f( void ) { - int i, j, l; - client_t *cl; - playerState_t *ps; - const char *s; - int ping; - - // make sure server is running - if ( !com_sv_running->integer ) { - Com_Printf( "Server is not running.\n" ); - return; - } - - Com_Printf ("map: %s\n", sv_mapname->string ); - - Com_Printf ("num score ping name lastmsg address qport rate\n"); - Com_Printf ("--- ----- ---- --------------- ------- --------------------- ----- -----\n"); - for (i=0,cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++) - { - if (!cl->state) - continue; - Com_Printf ("%3i ", i); - ps = SV_GameClientNum( i ); - Com_Printf ("%5i ", ps->persistant[PERS_SCORE]); - - if (cl->state == CS_CONNECTED) - Com_Printf ("CNCT "); - else if (cl->state == CS_ZOMBIE) - Com_Printf ("ZMBI "); - else - { - ping = cl->ping < 9999 ? cl->ping : 9999; - Com_Printf ("%4i ", ping); - } - - Com_Printf ("%s", cl->name); - // TTimo adding a ^7 to reset the color - // NOTE: colored names in status breaks the padding (WONTFIX) - Com_Printf ("^7"); - l = 16 - strlen(cl->name); - for (j=0 ; j<l ; j++) - Com_Printf (" "); - - Com_Printf ("%7i ", svs.time - cl->lastPacketTime ); - - s = NET_AdrToString( cl->netchan.remoteAddress ); - Com_Printf ("%s", s); - l = 22 - strlen(s); - for (j=0 ; j<l ; j++) - Com_Printf (" "); - - Com_Printf ("%5i", cl->netchan.qport); - - Com_Printf (" %5i", cl->rate); - - Com_Printf ("\n"); - } - Com_Printf ("\n"); -} - -/* -================== -SV_ConSay_f -================== -*/ -static void SV_ConSay_f(void) { - char *p; - char text[1024]; - - // make sure server is running - if ( !com_sv_running->integer ) { - Com_Printf( "Server is not running.\n" ); - return; - } - - if ( Cmd_Argc () < 2 ) { - return; - } - - strcpy (text, "console: ^2"); - p = Cmd_Args(); - - if ( *p == '"' ) { - p++; - p[strlen(p)-1] = 0; - } - - strcat(text, p); - - SV_SendServerCommand(NULL, "chat \"%s^7\"", text); -} - /* ================== @@ -555,38 +247,6 @@ static void SV_Systeminfo_f( void ) { /* -=========== -SV_DumpUser_f - -Examine all a users info strings FIXME: move to game -=========== -*/ -static void SV_DumpUser_f( void ) { - client_t *cl; - - // make sure server is running - if ( !com_sv_running->integer ) { - Com_Printf( "Server is not running.\n" ); - return; - } - - if ( Cmd_Argc() != 2 ) { - Com_Printf ("Usage: info <userid>\n"); - return; - } - - cl = SV_GetPlayerByHandle(); - if ( !cl ) { - return; - } - - Com_Printf( "userinfo\n" ); - Com_Printf( "--------\n" ); - Info_Print( cl->userinfo ); -} - - -/* ================= SV_KillServer ================= @@ -611,21 +271,13 @@ void SV_AddOperatorCommands( void ) { initialized = qtrue; Cmd_AddCommand ("heartbeat", SV_Heartbeat_f); - Cmd_AddCommand ("kick", SV_Kick_f); - Cmd_AddCommand ("kickAll", SV_KickAll_f); - Cmd_AddCommand ("clientkick", SV_KickNum_f); - Cmd_AddCommand ("status", SV_Status_f); Cmd_AddCommand ("serverinfo", SV_Serverinfo_f); Cmd_AddCommand ("systeminfo", SV_Systeminfo_f); - Cmd_AddCommand ("dumpuser", SV_DumpUser_f); Cmd_AddCommand ("map_restart", SV_MapRestart_f); Cmd_AddCommand ("sectorlist", SV_SectorList_f); Cmd_AddCommand ("map", SV_Map_f); Cmd_AddCommand ("devmap", SV_Map_f); Cmd_AddCommand ("killserver", SV_KillServer_f); - if( com_dedicated->integer ) { - Cmd_AddCommand ("say", SV_ConSay_f); - } } /* @@ -637,16 +289,10 @@ void SV_RemoveOperatorCommands( void ) { #if 0 // removing these won't let the server start again Cmd_RemoveCommand ("heartbeat"); - Cmd_RemoveCommand ("kick"); - Cmd_RemoveCommand ("banUser"); - Cmd_RemoveCommand ("banClient"); - Cmd_RemoveCommand ("status"); Cmd_RemoveCommand ("serverinfo"); Cmd_RemoveCommand ("systeminfo"); - Cmd_RemoveCommand ("dumpuser"); Cmd_RemoveCommand ("map_restart"); Cmd_RemoveCommand ("sectorlist"); - Cmd_RemoveCommand ("say"); #endif } |