summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2006-04-24 21:05:06 +0000
committerTim Angus <tim@ngus.net>2006-04-24 21:05:06 +0000
commitf7b88a4ed5a8c9347d9e40e0aee22c5a7011f60e (patch)
tree336304b3b0476b92fb11bc6f68d5c93aa261dd46 /src/game
parent523411fb188b851ed46e72acfd9bd981abf432fc (diff)
* Removed some \n from server connection messages
* Removed nextmap cvar and associated code, replaced with "advanceMapRotation" command * Rework the text displayed during votes to be more verbose * "destroy" command now only works when cheats are enabled * Voting UI is now a frontend for "clientkick" instead of plain "kick"
Diffstat (limited to 'src/game')
-rw-r--r--src/game/g_cmds.c164
-rw-r--r--src/game/g_local.h1
-rw-r--r--src/game/g_main.c16
-rw-r--r--src/game/g_svcmds.c7
4 files changed, 133 insertions, 55 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 875a922a..f8bbeb86 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -750,19 +750,6 @@ void Cmd_CallVote_f( gentity_t *ent )
return;
}
- if( !Q_stricmp( arg1, "map_restart" ) ) { }
- else if( !Q_stricmp( arg1, "nextmap" ) ) { }
- else if( !Q_stricmp( arg1, "map" ) ) { }
- else if( !Q_stricmp( arg1, "kick" ) ) { }
- else if( !Q_stricmp( arg1, "clientkick" ) ) { }
- else
- {
- trap_SendServerCommand( ent-g_entities, "print \"Invalid vote string\n\"" );
- trap_SendServerCommand( ent-g_entities, "print \"Vote commands are: map_restart, nextmap, map <mapname>, "
- "kick <player>, clientkick <clientnum>\n\"" );
- return;
- }
-
// if there is still a vote to be executed
if( level.voteExecuteTime )
{
@@ -770,40 +757,77 @@ void Cmd_CallVote_f( gentity_t *ent )
trap_SendConsoleCommand( EXEC_APPEND, va( "%s\n", level.voteString ) );
}
- if( !Q_stricmp( arg1, "map" ) )
+ if( !Q_stricmp( arg1, "kick" ) )
{
- // special case for map changes, we want to reset the nextmap setting
- // this allows a player to change maps, but not upset the map rotation
- char s[ MAX_STRING_CHARS ];
-
- trap_Cvar_VariableStringBuffer( "nextmap", s, sizeof( s ) );
+ char kickee[ MAX_NETNAME ];
- if( *s )
- Com_sprintf( level.voteString, sizeof( level.voteString ), "%s %s; set nextmap \"%s\"", arg1, arg2, s );
- else
- Com_sprintf( level.voteString, sizeof( level.voteString ), "%s %s", arg1, arg2 );
+ Q_strncpyz( kickee, arg2, sizeof( kickee ) );
+ Q_CleanStr( kickee );
- Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString );
+ Com_sprintf( level.voteString, sizeof( level.voteString ),
+ "%s \"%s\"", arg1, kickee );
+ Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ),
+ "Kick player \'%s\'", kickee );
}
- else if( !Q_stricmp( arg1, "nextmap" ) )
+ else if( !Q_stricmp( arg1, "clientkick" ) )
{
- char s[ MAX_STRING_CHARS ];
+ char kickee[ MAX_NETNAME ];
+ int clientNum = 0;
- trap_Cvar_VariableStringBuffer( "nextmap", s, sizeof( s ) );
-
- if( !*s )
+ //check arg2 is a number
+ for( i = 0; arg2[ i ]; i++ )
{
- trap_SendServerCommand( ent-g_entities, "print \"nextmap not set\n\"" );
- return;
+ if( arg2[ i ] < '0' || arg2[ i ] > '9' )
+ {
+ clientNum = -1;
+ break;
+ }
}
- Com_sprintf( level.voteString, sizeof( level.voteString ), "vstr nextmap" );
- Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString );
+ if( clientNum >= 0 )
+ {
+ clientNum = atoi( arg2 );
+
+ if( level.clients[ clientNum ].pers.connected != CON_DISCONNECTED )
+ {
+ Q_strncpyz( kickee, level.clients[ clientNum ].pers.netname, sizeof( kickee ) );
+ Q_CleanStr( kickee );
+
+ Com_sprintf( level.voteString, sizeof( level.voteString ),
+ "clientkick %d", clientNum );
+ Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ),
+ "Kick player \'%s\'", kickee );
+ }
+ else
+ return;
+ }
+ else
+ return;
+ }
+ else if( !Q_stricmp( arg1, "map_restart" ) )
+ {
+ Com_sprintf( level.voteString, sizeof( level.voteString ), "%s", arg1 );
+ Com_sprintf( level.voteDisplayString,
+ sizeof( level.voteDisplayString ), "Restart current map" );
+ }
+ else if( !Q_stricmp( arg1, "map" ) )
+ {
+ Com_sprintf( level.voteString, sizeof( level.voteString ), "%s %s", arg1, arg2 );
+ Com_sprintf( level.voteDisplayString,
+ sizeof( level.voteDisplayString ), "Change to map \'%s\'", arg2 );
+ }
+ else if( !Q_stricmp( arg1, "nextmap" ) )
+ {
+ Com_sprintf( level.voteString, sizeof( level.voteString ), "advanceMapRotation" );
+ Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ),
+ "Skip to next map in rotation" );
}
else
{
- Com_sprintf( level.voteString, sizeof( level.voteString ), "%s \"%s\"", arg1, arg2 );
- Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString );
+ trap_SendServerCommand( ent-g_entities, "print \"Invalid vote string\n\"" );
+ trap_SendServerCommand( ent-g_entities, "print \"Valid vote commands are: map_restart, nextmap, "
+ "map <mapname>, kick <player>, clientkick <clientnum>\n\"" );
+ return;
}
trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE
@@ -951,28 +975,82 @@ void Cmd_CallTeamVote_f( gentity_t *ent )
if( i >= level.maxclients )
{
- trap_SendServerCommand( ent-g_entities, va( "print \"%s "
+ trap_SendServerCommand( ent-g_entities, va( "print \"\'%s\' "
+ S_COLOR_WHITE "is not a valid player on your team\n\"", arg2 ) );
+ return;
+ }
+
+ Com_sprintf( level.teamVoteString[ cs_offset ],
+ sizeof( level.teamVoteString[ cs_offset ] ), "kick \"%s\"", kickee );
+ Com_sprintf( level.teamVoteDisplayString[ cs_offset ],
+ sizeof( level.teamVoteDisplayString[ cs_offset ] ), "Kick player \'%s\'", kickee );
+ }
+ else if( !Q_stricmp( arg1, "teamclientkick" ) )
+ {
+ int clientNum = 0;
+ char kickee[ MAX_NETNAME ];
+
+ //check arg2 is a number
+ for( i = 0; arg2[ i ]; i++ )
+ {
+ if( arg2[ i ] < '0' || arg2[ i ] > '9' )
+ {
+ clientNum = -1;
+ break;
+ }
+ }
+
+ if( clientNum >= 0 )
+ {
+ clientNum = atoi( arg2 );
+
+ for( i = 0; i < level.maxclients; i++ )
+ {
+ if( level.clients[ i ].pers.connected == CON_DISCONNECTED )
+ continue;
+
+ if( level.clients[ i ].ps.stats[ STAT_PTEAM ] != team )
+ continue;
+
+ if( level.clients[ i ].ps.clientNum == clientNum )
+ break;
+ }
+
+ if( i >= level.maxclients )
+ clientNum = -1;
+ }
+
+ if( clientNum < 0 )
+ {
+ trap_SendServerCommand( ent-g_entities, va( "print \"client %s "
S_COLOR_WHITE "is not a valid player on your team\n\"", arg2 ) );
return;
}
+
+ Q_strncpyz( kickee, level.clients[ clientNum ].pers.netname, sizeof( kickee ) );
+ Q_CleanStr( kickee );
+
+ Com_sprintf( level.teamVoteString[ cs_offset ],
+ sizeof( level.teamVoteString[ cs_offset ] ), "clientkick %d", clientNum );
+ Com_sprintf( level.teamVoteDisplayString[ cs_offset ],
+ sizeof( level.teamVoteDisplayString[ cs_offset ] ), "Kick player \'%s\'", kickee );
}
else
{
trap_SendServerCommand( ent-g_entities, "print \"Invalid vote string\n\"" );
- trap_SendServerCommand( ent-g_entities, "print \"Team vote commands are: teamkick <player>\n\"" );
+ trap_SendServerCommand( ent-g_entities, "print \"Valid team vote commands are: teamkick <player>, "
+ "teamclientkick <client>\n\"" );
return;
}
- Com_sprintf( level.teamVoteString[ cs_offset ],
- sizeof( level.teamVoteString[ cs_offset ] ), "kick \"%s\"", arg2 );
-
for( i = 0 ; i < level.maxclients ; i++ )
{
if( level.clients[ i ].pers.connected == CON_DISCONNECTED )
continue;
if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == team )
- trap_SendServerCommand( i, va("print \"%s called a team vote\n\"", ent->client->pers.netname ) );
+ trap_SendServerCommand( i, va("print \"%s " S_COLOR_WHITE
+ "called a team vote\n\"", ent->client->pers.netname ) );
}
// start the voting, the caller autoamtically votes yes
@@ -989,7 +1067,7 @@ void Cmd_CallTeamVote_f( gentity_t *ent )
ent->client->ps.eFlags |= EF_TEAMVOTED;
trap_SetConfigstring( CS_TEAMVOTE_TIME + cs_offset, va( "%i", level.teamVoteTime[ cs_offset ] ) );
- trap_SetConfigstring( CS_TEAMVOTE_STRING + cs_offset, level.teamVoteString[ cs_offset ] );
+ trap_SetConfigstring( CS_TEAMVOTE_STRING + cs_offset, level.teamVoteDisplayString[ cs_offset ] );
trap_SetConfigstring( CS_TEAMVOTE_YES + cs_offset, va( "%i", level.teamVoteYes[ cs_offset ] ) );
trap_SetConfigstring( CS_TEAMVOTE_NO + cs_offset, va( "%i", level.teamVoteNo[ cs_offset ] ) );
}
@@ -1356,7 +1434,7 @@ void Cmd_Destroy_f( gentity_t *ent, qboolean deconstruct )
return;
}
- if( !deconstruct )
+ if( !deconstruct && CheatsOk( ent ) )
G_Damage( traceEnt, ent, ent, forward, tr.endpos, 10000, 0, MOD_SUICIDE );
else
G_FreeEntity( traceEnt );
diff --git a/src/game/g_local.h b/src/game/g_local.h
index c528c4fb..5d35e5fb 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -542,6 +542,7 @@ typedef struct
// team voting state
char teamVoteString[ 2 ][ MAX_STRING_CHARS ];
+ char teamVoteDisplayString[ 2 ][ MAX_STRING_CHARS ];
int teamVoteTime[ 2 ]; // level.time vote was called
int teamVoteYes[ 2 ];
int teamVoteNo[ 2 ];
diff --git a/src/game/g_main.c b/src/game/g_main.c
index 4a4fa2ca..98978b0a 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -1388,9 +1388,8 @@ void BeginIntermission( void )
=============
ExitLevel
-When the intermission has been exited, the server is either killed
-or moved to a new level based on the "nextmap" cvar
-
+When the intermission has been exited, the server is either moved
+to a new map based on the map rotation or the current map restarted
=============
*/
void ExitLevel( void )
@@ -1401,7 +1400,7 @@ void ExitLevel( void )
if( G_MapRotationActive( ) )
G_AdvanceMapRotation( );
else
- trap_SendConsoleCommand( EXEC_APPEND, "vstr nextmap\n" );
+ trap_SendConsoleCommand( EXEC_APPEND, "map_restart\n" );
level.changemap = NULL;
level.intermissiontime = 0;
@@ -1810,14 +1809,7 @@ void CheckVote( void )
{
level.voteExecuteTime = 0;
- //SUPAR HAK
- if( !Q_stricmp( level.voteString, "vstr nextmap" ) )
- {
- level.lastWin = PTE_NONE;
- LogExit( "Vote for next map." );
- }
- else
- trap_SendConsoleCommand( EXEC_APPEND, va( "%s\n", level.voteString ) );
+ trap_SendConsoleCommand( EXEC_APPEND, va( "%s\n", level.voteString ) );
}
if( !level.voteTime )
diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c
index 30caab0d..63234aba 100644
--- a/src/game/g_svcmds.c
+++ b/src/game/g_svcmds.c
@@ -542,6 +542,13 @@ qboolean ConsoleCommand( void )
return qtrue;
}
+ if( Q_stricmp( cmd, "advanceMapRotation" ) == 0 )
+ {
+ G_AdvanceMapRotation( );
+
+ return qtrue;
+ }
+
if( Q_stricmp( cmd, "alienWin" ) == 0 )
{
int i;