2007-02-03 19:37:19 +00:00
//-----------------------------------------------------------------------------
//
// $Id$
//
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.41 2007/02/03 19:37:19 jbravo
// Adding CVS headers to new files in CVS.
//
//
//-----------------------------------------------------------------------------
2002-01-31 23:55:05 +00:00
# include "g_local.h"
2002-03-31 03:31:24 +00:00
// JBravo: for warnings
2002-06-16 20:06:15 +00:00
int ClientNumberFromString ( gentity_t * to , char * s ) ;
2002-01-31 23:55:05 +00:00
2002-08-23 14:25:05 +00:00
gentity_t * refVotes [ 2 ] ; // refVotes[0] is the clientnumber red team voted
2002-05-12 12:15:05 +00:00
2002-06-16 20:06:15 +00:00
// refVotes[1] is the clientnumber blue team voted
2002-06-23 19:12:17 +00:00
2009-07-04 03:37:41 +00:00
void SendEndMessage ( void )
2002-06-16 20:06:15 +00:00
{
2002-06-08 10:51:42 +00:00
int mins , secs ;
2002-06-16 20:06:15 +00:00
mins = ( int ) floor ( level . matchTime / 60.0f ) ;
secs = level . matchTime - ( mins * 60 ) ;
2002-06-08 10:51:42 +00:00
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( - 1 , " cp \" Match is Over! \n \" " ) ;
trap_SendServerCommand ( - 1 ,
va ( " print \" Scores: Team1 [%d] - Team2 [%d] \n \" " , level . teamScores [ TEAM_RED ] ,
level . teamScores [ TEAM_BLUE ] ) ) ;
trap_SendServerCommand ( - 1 , va ( " print \" Total Match Time: %d:%02d \n \" " , mins , secs ) ) ;
2002-06-08 10:51:42 +00:00
}
2002-08-23 14:25:05 +00:00
2009-07-04 03:37:41 +00:00
int getNumberOfRefs ( void ) {
2002-08-23 14:25:05 +00:00
gentity_t * ent ;
int i , count ;
count = 0 ;
for ( i = 0 ; i < level . maxclients ; i + + ) {
2002-09-24 05:06:17 +00:00
//Blaze: Prit out some Debug info
if ( & g_entities [ i ] = = NULL ) G_Printf ( " Ln 0030 \n " ) ;
2002-08-23 14:25:05 +00:00
ent = & g_entities [ i ] ;
if ( ! ent - > inuse )
continue ;
if ( ent - > client - > sess . referee )
+ + count ;
}
return count ;
}
2002-06-16 20:06:15 +00:00
gentity_t * getEntByName ( char * name )
{
2002-05-12 12:15:05 +00:00
gentity_t * ent ;
int i ;
2002-06-16 20:06:15 +00:00
2002-05-12 12:15:05 +00:00
for ( i = 0 ; i < level . maxclients ; i + + ) {
2002-09-24 05:06:17 +00:00
//Blaze: Prit out some Debug info
if ( & g_entities [ i ] = = NULL ) G_Printf ( " Ln 0047 \n " ) ;
2002-05-12 12:15:05 +00:00
ent = & g_entities [ i ] ;
if ( ! ent - > inuse )
continue ;
2002-06-16 20:06:15 +00:00
if ( ! Q_stricmp ( ent - > client - > pers . netname , name ) )
2002-05-12 12:15:05 +00:00
return ent ;
}
return NULL ;
2002-06-16 20:06:15 +00:00
}
qboolean checkCaptain ( team_t team )
{
gentity_t * ent ;
int i ;
2002-05-12 12:15:05 +00:00
2002-02-02 16:34:02 +00:00
for ( i = 0 ; i < level . maxclients ; i + + ) {
2002-09-24 05:06:17 +00:00
//Blaze: Prit out some Debug info
if ( & g_entities [ i ] = = NULL ) G_Printf ( " Ln 0059 \n " ) ;
2002-02-02 16:34:02 +00:00
ent = & g_entities [ i ] ;
2009-07-04 16:39:39 +00:00
if ( ! ent - > client )
2002-02-02 16:34:02 +00:00
continue ;
2002-06-16 20:06:15 +00:00
if ( ent - > client - > sess . savedTeam = = team & & ent - > client - > sess . captain = = team )
return qtrue ;
2002-02-02 16:34:02 +00:00
}
return qfalse ;
}
2002-03-07 00:00:54 +00:00
2002-06-16 20:06:15 +00:00
void MM_RunFrame ( void )
{
2002-01-31 23:55:05 +00:00
int fps ;
2002-06-16 20:06:15 +00:00
fps = trap_Cvar_VariableIntegerValue ( " sv_fps " ) ;
2002-05-05 04:23:00 +00:00
switch ( g_gametype . integer ) {
2002-06-16 20:06:15 +00:00
//Each Type has different ways of dealing things..
2002-05-05 04:23:00 +00:00
case ( GT_TEAMPLAY ) :
2002-09-29 16:06:45 +00:00
case ( GT_CTF ) :
2002-10-26 22:03:43 +00:00
case ( GT_TEAM ) :
2002-05-05 04:23:00 +00:00
if ( level . team_game_going & & level . inGame )
2002-06-16 20:06:15 +00:00
level . matchTime + = 1.0f / ( float ) fps ;
2002-01-31 23:55:05 +00:00
break ;
}
2002-02-02 16:34:02 +00:00
}
2002-03-07 00:00:54 +00:00
2002-06-16 20:06:15 +00:00
void MM_Sub_f ( gentity_t * ent )
{
2002-05-05 04:23:00 +00:00
if ( ! g_RQ3_matchmode . integer )
2002-02-02 21:57:58 +00:00
return ;
2002-05-05 04:23:00 +00:00
if ( ent - > client - > sess . savedTeam = = TEAM_SPECTATOR | | ent - > client - > sess . savedTeam = = TEAM_FREE ) {
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " You need to be on a team for that \n \" " ) ) ;
2002-02-02 21:57:58 +00:00
return ;
}
2002-05-05 15:51:16 +00:00
if ( ent - > client - > sess . sub = = TEAM_FREE ) {
2002-06-16 20:06:15 +00:00
// if (ent->client->ps.pm_type == PM_NORMAL) {
if ( ent - > client - > sess . sessionTeam ! = TEAM_SPECTATOR ) {
ent - > flags & = ~ FL_GODMODE ;
ent - > client - > ps . stats [ STAT_HEALTH ] = ent - > health = 0 ;
player_die ( ent , ent , ent , 100000 , MOD_SUICIDE ) ;
}
ent - > client - > sess . sub = ent - > client - > sess . savedTeam ;
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" %s " MM_OK_COLOR " is now a Substitute for %s. \n \" " ,
2002-06-16 20:06:15 +00:00
ent - > client - > pers . netname ,
ent - > client - > sess . savedTeam = =
TEAM_BLUE ? g_RQ3_team2name . string : g_RQ3_team1name . string ) ) ;
2002-05-05 04:23:00 +00:00
} else {
2002-06-23 15:22:53 +00:00
if ( g_RQ3_maxplayers . integer > 0 & & ( RQ3TeamCount ( - 1 , ent - > client - > sess . savedTeam ) > = g_RQ3_maxplayers . integer ) ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " Your team is full. \n \" " ) ) ;
return ;
}
else {
2002-06-16 20:06:15 +00:00
ent - > client - > sess . sub = TEAM_FREE ;
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" %s " MM_OK_COLOR " is no longer a Substitute for %s. \n \" " ,
2002-06-16 20:06:15 +00:00
ent - > client - > pers . netname ,
ent - > client - > sess . savedTeam = =
TEAM_BLUE ? g_RQ3_team2name . string : g_RQ3_team1name . string ) ) ;
2002-06-23 15:22:53 +00:00
}
2002-02-02 21:57:58 +00:00
}
}
2002-03-07 00:00:54 +00:00
2002-06-16 20:06:15 +00:00
void MM_Captain_f ( gentity_t * ent )
{
2002-05-05 04:23:00 +00:00
if ( ! g_RQ3_matchmode . integer )
2002-02-02 20:39:09 +00:00
return ;
2002-05-05 04:23:00 +00:00
if ( ent - > client - > sess . savedTeam = = TEAM_SPECTATOR | | ent - > client - > sess . savedTeam = = TEAM_FREE ) {
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " You need to be on a team for that \n \" " ) ) ;
2002-02-02 16:34:02 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( ent - > client - > sess . captain = = TEAM_RED ) {
level . team1ready = qfalse ;
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" %s " MM_OK_COLOR " is no longer %s's Captain. \n \" " ,
2002-06-16 20:06:15 +00:00
ent - > client - > pers . netname , g_RQ3_team1name . string ) ) ;
ent - > client - > sess . captain = TEAM_FREE ;
2002-05-05 15:51:16 +00:00
} else if ( ent - > client - > sess . captain = = TEAM_BLUE ) {
2002-06-16 20:06:15 +00:00
level . team2ready = qfalse ;
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" %s " MM_OK_COLOR " is no longer %s's Captain. \n \" " ,
2002-06-16 20:06:15 +00:00
ent - > client - > pers . netname , g_RQ3_team2name . string ) ) ;
ent - > client - > sess . captain = TEAM_FREE ;
2002-05-05 04:23:00 +00:00
} else {
if ( ! checkCaptain ( ent - > client - > sess . savedTeam ) ) {
2002-05-05 15:51:16 +00:00
ent - > client - > sess . captain = ent - > client - > sess . savedTeam ;
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" %s " MM_OK_COLOR " is now %s's Captain. \n \" " ,
2002-06-16 20:06:15 +00:00
ent - > client - > pers . netname ,
ent - > client - > sess . savedTeam = =
TEAM_BLUE ? g_RQ3_team2name . string : g_RQ3_team1name . string ) ) ;
2002-05-05 04:23:00 +00:00
} else
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " Your team already has a Captain \n \" " ) ) ;
2002-02-02 21:57:58 +00:00
}
}
2002-03-07 00:00:54 +00:00
2002-06-16 20:06:15 +00:00
void MM_Ready_f ( gentity_t * ent )
{
2002-05-05 04:23:00 +00:00
if ( ! g_RQ3_matchmode . integer )
2002-02-02 21:57:58 +00:00
return ;
2002-09-29 16:06:45 +00:00
if ( level . inGame & & ( g_RQ3_mmflags . integer & MMF_UNREADY ) ! = MMF_UNREADY ) {
2002-06-23 19:12:17 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " This server does not allow you to un-ready your team after the match started \n \" " ) ) ;
return ;
}
2002-10-26 22:03:43 +00:00
if ( level . inGame & & ( g_gametype . integer = = GT_CTF | | g_gametype . integer = = GT_TEAM ) ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " This gametype does not yet support un-readying your team after the match started \n \" " ) ) ;
2002-09-29 16:06:45 +00:00
return ;
}
2002-05-05 15:51:16 +00:00
if ( ent - > client - > sess . captain ! = TEAM_FREE ) {
2002-05-05 04:23:00 +00:00
if ( ent - > client - > sess . savedTeam = = TEAM_RED ) {
2002-09-29 16:06:45 +00:00
trap_SendServerCommand ( - 1 , va ( " cp \" %s is%s Ready. \n \" " ,
2002-06-16 20:06:15 +00:00
g_RQ3_team1name . string , level . team1ready ? " no longer " : " " ) ) ;
2002-05-05 04:23:00 +00:00
2002-06-07 19:07:08 +00:00
if ( level . team1ready )
level . team1ready = qfalse ;
2002-02-02 21:57:58 +00:00
else
2002-06-07 19:07:08 +00:00
level . team1ready = qtrue ;
2002-05-05 04:23:00 +00:00
} else {
2002-09-29 16:06:45 +00:00
trap_SendServerCommand ( - 1 , va ( " cp \" %s is%s Ready. \n \" " ,
2002-06-16 20:06:15 +00:00
g_RQ3_team2name . string , level . team2ready ? " no longer " : " " ) ) ;
2002-02-04 00:11:12 +00:00
2002-06-07 19:07:08 +00:00
if ( level . team2ready )
level . team2ready = qfalse ;
2002-02-02 21:57:58 +00:00
else
2002-06-07 19:07:08 +00:00
level . team2ready = qtrue ;
2002-02-02 21:57:58 +00:00
}
2002-05-05 04:23:00 +00:00
} else
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " You need to be a captain for that \n \" " ) ) ;
2002-02-08 18:00:34 +00:00
}
2002-04-28 11:03:46 +00:00
2002-06-16 20:06:15 +00:00
void MM_TeamModel_f ( gentity_t * ent )
{
int args ;
team_t team ;
char buff [ MAX_TOKEN_CHARS ] ;
2002-05-05 04:23:00 +00:00
2002-06-16 20:06:15 +00:00
team = ent - > client - > sess . savedTeam ;
if ( ! g_RQ3_matchmode . integer )
2002-05-05 04:23:00 +00:00
return ;
if ( team = = TEAM_SPECTATOR ) {
return ;
}
args = trap_Argc ( ) ;
2002-04-28 11:03:46 +00:00
2002-05-05 04:23:00 +00:00
if ( args < 2 ) {
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" Your current team model is: " MM_OK_COLOR " %s \n \" " ,
2002-06-16 20:06:15 +00:00
ent - > client - > sess . savedTeam = =
TEAM_RED ? g_RQ3_team1model . string : g_RQ3_team2model .
string ) ) ;
2002-05-05 04:23:00 +00:00
return ;
} else {
2002-06-23 19:12:17 +00:00
if ( ( g_RQ3_mmflags . integer & MMF_TEAMMODEL ) ! = MMF_TEAMMODEL ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " This server does not allow you to change team model \n \" " ) ) ;
return ;
}
2002-05-05 15:51:16 +00:00
if ( ent - > client - > sess . captain = = TEAM_FREE ) {
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " You need to be a captain for that \n \" " ) ) ;
2002-04-28 11:03:46 +00:00
return ;
}
2002-05-05 04:23:00 +00:00
if ( level . team_game_going | | level . team_round_going ) {
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities ,
2002-06-23 15:22:53 +00:00
va ( " print \" " MM_DENY_COLOR " You cannot change your team's model while playing or ready. \n \" " ) ) ;
2002-10-21 21:00:39 +00:00
return ;
2002-05-05 04:23:00 +00:00
}
2002-04-28 11:03:46 +00:00
2002-05-05 04:23:00 +00:00
trap_Argv ( 1 , buff , sizeof ( buff ) ) ;
2002-04-28 11:03:46 +00:00
2002-05-05 04:23:00 +00:00
if ( team = = TEAM_RED ) {
2002-06-07 19:07:08 +00:00
if ( level . team1ready ) {
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities ,
2002-06-23 15:22:53 +00:00
va ( " print \" You need to un-ready your team for that.. \n \" " ) ) ;
2002-05-05 04:23:00 +00:00
return ;
2002-04-28 11:03:46 +00:00
}
2002-05-05 04:23:00 +00:00
trap_Cvar_Set ( " g_RQ3_team1model " , buff ) ;
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" New Team 1 Model: " MM_OK_COLOR " %s \n \" " , buff ) ) ;
2002-05-05 04:23:00 +00:00
} else {
2002-06-07 19:07:08 +00:00
if ( level . team2ready ) {
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities ,
2002-06-23 15:22:53 +00:00
va ( " print \" " MM_DENY_COLOR " You need to un-ready your team for that.. \n \" " ) ) ;
2002-05-05 04:23:00 +00:00
return ;
2002-04-28 11:03:46 +00:00
}
2002-06-16 20:06:15 +00:00
trap_Cvar_Set ( " g_RQ3_team2model " , buff ) ;
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" New Team 2 Model: " MM_OK_COLOR " %s \n \" " , buff ) ) ;
2002-05-05 04:23:00 +00:00
}
}
2002-04-28 11:03:46 +00:00
}
2002-02-08 18:00:34 +00:00
2002-06-16 20:06:15 +00:00
void MM_TeamName_f ( gentity_t * ent )
{
int args ;
team_t team ;
char * buff ;
2002-05-05 04:23:00 +00:00
2002-06-16 20:06:15 +00:00
team = ent - > client - > sess . savedTeam ;
if ( ! g_RQ3_matchmode . integer )
2002-05-05 04:23:00 +00:00
return ;
if ( team = = TEAM_SPECTATOR ) {
return ;
}
2002-04-07 12:49:53 +00:00
2002-05-05 04:23:00 +00:00
args = trap_Argc ( ) ;
2002-04-07 12:49:53 +00:00
2002-05-05 04:23:00 +00:00
if ( args < 2 ) {
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" Your Team Name: " MM_OK_COLOR " %s \n \" " ,
2002-06-16 20:06:15 +00:00
ent - > client - > sess . savedTeam = =
TEAM_RED ? g_RQ3_team1name . string : g_RQ3_team2name .
string ) ) ;
2002-05-05 04:23:00 +00:00
return ;
} else {
2002-06-23 19:12:17 +00:00
if ( ( g_RQ3_mmflags . integer & MMF_TEAMNAME ) ! = MMF_TEAMNAME ) {
2002-10-21 21:00:39 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " This server does not allow you to change team name \n \" " ) ) ;
return ;
2002-06-23 19:12:17 +00:00
}
2002-05-05 15:51:16 +00:00
if ( ent - > client - > sess . captain = = TEAM_FREE ) {
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " You need to be a captain for that \n \" " ) ) ;
2002-04-07 12:49:53 +00:00
return ;
}
2002-05-05 04:23:00 +00:00
if ( level . team_game_going | | level . team_round_going ) {
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities ,
2002-06-23 15:22:53 +00:00
va ( " print \" " MM_DENY_COLOR " You cannot change your team's name while playing or ready. \n \" " ) ) ;
2002-10-21 21:00:39 +00:00
return ;
2002-05-05 04:23:00 +00:00
}
2002-04-07 12:49:53 +00:00
2002-05-05 04:23:00 +00:00
buff = ConcatArgs ( 1 ) ;
2002-04-07 12:49:53 +00:00
2002-05-05 04:23:00 +00:00
if ( strlen ( buff ) > TEAM_NAME_SIZE )
buff [ TEAM_NAME_SIZE ] = 0 ;
2002-04-07 12:49:53 +00:00
2002-05-05 04:23:00 +00:00
if ( team = = TEAM_RED ) {
2002-06-07 19:07:08 +00:00
if ( level . team1ready ) {
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities ,
2002-06-23 15:22:53 +00:00
va ( " print \" " MM_DENY_COLOR " You need to un-ready your team for that.. \n \" " ) ) ;
2002-05-05 04:23:00 +00:00
return ;
2002-04-07 12:49:53 +00:00
}
2002-05-05 04:23:00 +00:00
trap_Cvar_Set ( " g_RQ3_team1name " , buff ) ;
2002-07-26 06:21:43 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" New Team 1 Name: %s \n \" " , buff ) ) ;
2002-05-05 04:23:00 +00:00
} else {
2002-06-07 19:07:08 +00:00
if ( level . team2ready ) {
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities ,
2002-06-23 15:22:53 +00:00
va ( " print \" " MM_DENY_COLOR " You need to un-ready your team for that.. \n \" " ) ) ;
2002-05-05 04:23:00 +00:00
return ;
2002-04-07 12:49:53 +00:00
}
2002-06-16 20:06:15 +00:00
trap_Cvar_Set ( " g_RQ3_team2name " , buff ) ;
2002-07-26 06:21:43 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" New Team 2 Name: %s \n \" " , buff ) ) ;
2002-05-05 04:23:00 +00:00
}
}
2002-04-07 12:49:53 +00:00
}
2002-03-07 00:00:54 +00:00
//
2002-06-16 20:06:15 +00:00
// aasimon: Referee Functions Definition, with some aid functions first
2002-03-07 00:00:54 +00:00
//
2009-07-04 03:37:41 +00:00
void checkRefVotes ( void )
2002-06-16 20:06:15 +00:00
{
2002-08-23 14:25:05 +00:00
// gentity_t *ent;
// char nr[4];
2002-06-16 20:06:15 +00:00
2002-08-23 14:25:05 +00:00
//G_Printf("Vote Red: %i Vote Blue %i \n", refVotes[0], refVotes[1]);
2002-06-16 20:06:15 +00:00
if ( refVotes [ 0 ] = = refVotes [ 1 ] ) {
2002-08-23 14:25:05 +00:00
// ent = g_entities + refVotes[0];
refVotes [ 0 ] - > client - > sess . referee = 1 ;
2002-08-29 22:28:45 +00:00
trap_SendServerCommand ( - 1 , va ( " cp \" %s " MM_OK_COLOR " is now a Referee. \n \" " , refVotes [ 0 ] - > client - > pers . netname ) ) ;
2002-08-23 14:25:05 +00:00
refVotes [ 0 ] = refVotes [ 1 ] = NULL ;
2002-05-12 12:15:05 +00:00
}
}
2002-03-07 00:00:54 +00:00
2002-05-12 12:15:05 +00:00
/* Slicer - MM_Referee_f
For captains to vote a referee */
2002-06-16 20:06:15 +00:00
void MM_Referee_f ( gentity_t * ent )
{
2002-05-12 12:15:05 +00:00
gentity_t * ref ;
2002-08-29 22:28:45 +00:00
char cmd [ MAX_TOKEN_CHARS ] ;
int clientNr ;
2002-05-12 12:15:05 +00:00
team_t captain ;
2002-06-16 20:06:15 +00:00
if ( ! g_RQ3_matchmode . integer )
2002-05-12 12:15:05 +00:00
return ;
2002-03-07 00:00:54 +00:00
2002-05-12 12:15:05 +00:00
captain = ent - > client - > sess . captain ;
2002-06-16 20:06:15 +00:00
if ( ! g_RQ3_AllowRef . integer ) {
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " No Referee Allowed on this server \n \" " ) ) ;
2002-05-12 12:15:05 +00:00
return ;
}
2002-08-23 14:25:05 +00:00
if ( captain = = TEAM_FREE ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " Only captains can vote a referee \n \" " ) ) ;
return ;
}
2002-06-16 20:06:15 +00:00
if ( trap_Argc ( ) < 2 ) {
2002-08-23 14:25:05 +00:00
trap_SendServerCommand ( ent - g_entities ,
2002-08-29 22:28:45 +00:00
va ( " print \" " MM_DENY_COLOR " Use referee <player number> to vote a referee \n \" " ) ) ;
return ;
}
trap_Argv ( 1 , cmd , sizeof ( cmd ) ) ;
clientNr = atoi ( cmd ) ;
if ( clientNr < 0 | | clientNr > level . maxclients ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " Invalid Player Number - use <playerlist> \n \" " ) ) ;
return ;
}
ref = & g_entities [ clientNr ] ;
if ( ! ref - > inuse | | ! ref - > client ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " Invalid Player Number - use <playerlist> \n \" " ) ) ;
2002-05-12 12:15:05 +00:00
return ;
}
2002-08-29 22:28:45 +00:00
2002-06-23 19:12:17 +00:00
if ( ( g_RQ3_mmflags . integer & MMF_VOTEREF ) ! = MMF_VOTEREF ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " This server does not allow captains to vote for a Referee \n \" " ) ) ;
return ;
}
2002-08-23 14:25:05 +00:00
if ( getNumberOfRefs ( ) = = g_RQ3_maxRefs . integer ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " Too many referees already on the server \n \" " ) ) ;
return ;
}
2002-08-29 22:28:45 +00:00
refVotes [ captain - 1 ] = ref ;
trap_SendServerCommand ( - 1 , va ( " print \" %s " MM_OK_COLOR " has voted %s " MM_OK_COLOR " for referee \n \" " ,
ent - > client - > pers . netname , ref - > client - > pers . netname ) ) ;
checkRefVotes ( ) ;
2002-06-16 20:06:15 +00:00
2002-05-12 12:15:05 +00:00
}
2002-08-02 22:44:37 +00:00
void MM_ClearScores ( qboolean clearTeamFlags )
2002-06-16 20:06:15 +00:00
{
gentity_t * ent ;
int i ;
2002-05-05 04:23:00 +00:00
2002-03-07 00:00:54 +00:00
for ( i = 0 ; i < level . maxclients ; i + + ) {
2002-09-24 05:06:17 +00:00
//Blaze: Prit out some Debug info
if ( & g_entities [ i ] = = NULL ) G_Printf ( " Ln 1241 \n " ) ;
2002-03-07 00:00:54 +00:00
ent = & g_entities [ i ] ;
if ( ! ent - > inuse )
continue ;
2002-08-02 22:44:37 +00:00
if ( clearTeamFlags ) {
ent - > client - > sess . captain = TEAM_FREE ;
ent - > client - > sess . sub = TEAM_FREE ;
}
2002-03-07 00:00:54 +00:00
// aasimon: Clear only PERS info. Lata clear all REC information. See if more info is needed to be clean
ent - > client - > ps . persistant [ PERS_SCORE ] = 0 ;
ent - > client - > ps . persistant [ PERS_KILLED ] = 0 ;
2002-05-12 12:15:05 +00:00
ent - > client - > ps . persistant [ PERS_DAMAGE_DELT ] = 0 ;
}
2002-10-26 22:03:43 +00:00
if ( g_gametype . integer > = GT_TEAM ) {
2002-05-12 12:15:05 +00:00
level . teamScores [ TEAM_RED ] = 0 ;
level . teamScores [ TEAM_BLUE ] = 0 ;
2002-03-07 00:00:54 +00:00
}
2002-06-16 20:06:15 +00:00
}
2002-03-07 00:00:54 +00:00
// aasimon: checks for a ref
2002-08-23 14:25:05 +00:00
/*qboolean Ref_Exists(void)
2002-06-16 20:06:15 +00:00
{
2002-03-07 01:38:36 +00:00
if ( g_RQ3_RefID . integer = = - 1 )
return qfalse ;
else
return qtrue ;
2002-05-05 04:23:00 +00:00
}
2002-08-23 14:25:05 +00:00
*/
2002-03-07 00:00:54 +00:00
//
2002-06-16 20:06:15 +00:00
// aasimon: Ref Auth. Do some kind of logging (ip's etc)
2002-03-07 00:00:54 +00:00
//
2002-06-16 20:06:15 +00:00
qboolean Ref_Auth ( gentity_t * ent )
{
char pass [ MAX_TOKEN_CHARS ] ;
2002-08-23 14:25:05 +00:00
// int cn;
// char teste[2];
2002-03-07 00:00:54 +00:00
2002-05-05 04:23:00 +00:00
if ( ! g_RQ3_AllowRef . integer ) {
2002-03-07 00:00:54 +00:00
// No ref allowed on the server - HELLO!!!!! FIREMAN CARS????
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " No Referee Allowed on this server \n \" " ) ) ;
2002-03-07 00:00:54 +00:00
return qfalse ;
}
2002-08-23 14:25:05 +00:00
if ( ! g_RQ3_matchmode . integer ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " This server is not running match mode \n \" " ) ) ;
return qfalse ;
}
2002-03-07 00:00:54 +00:00
2002-10-21 21:00:39 +00:00
if ( Q_stricmp ( g_RQ3_RefPassword . string , " " ) = = 0 ) {
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " No Referee Password Set on this server \n \" " ) ) ;
2002-03-07 00:00:54 +00:00
return qfalse ;
2002-06-16 20:06:15 +00:00
}
2002-08-23 14:25:05 +00:00
if ( getNumberOfRefs ( ) = = g_RQ3_maxRefs . integer ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " Too many referees already on the server \n \" " ) ) ;
return qfalse ;
}
if ( ent - > client - > sess . referee ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " You are already the referee \n \" " ) ) ;
return qfalse ;
2002-03-07 00:00:54 +00:00
}
2002-08-29 22:28:45 +00:00
if ( trap_Argc ( ) < 2 ) {
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_DENY_COLOR " Use reflogin <password> to become a referee \n \" " ) ) ;
return qfalse ;
}
2002-05-05 04:23:00 +00:00
trap_Argv ( 1 , pass , sizeof ( pass ) ) ;
2002-08-23 14:25:05 +00:00
2002-03-07 00:00:54 +00:00
// Does a simple plain text auth
2002-10-21 21:00:39 +00:00
if ( Q_stricmp ( pass , g_RQ3_RefPassword . string ) = = 0 ) {
2002-08-23 14:25:05 +00:00
ent - > client - > sess . referee = 1 ;
2002-10-21 21:00:39 +00:00
+ + level . refAmmount ;
2002-08-23 14:25:05 +00:00
trap_SendServerCommand ( - 1 ,
va ( " print \" %s " MM_OK_COLOR " is now a Referee \n \" " ,
ent - > client - > pers . netname ) ) ;
return qtrue ;
}
2002-10-21 21:00:39 +00:00
/* if (Q_stricmp(pass, g_RQ3_RefPassword.string) == 0) {
2002-06-16 20:06:15 +00:00
cn = ent - g_entities ;
2002-03-07 01:38:36 +00:00
Com_sprintf ( teste , 3 , " %i " , cn ) ;
trap_Cvar_Set ( " g_RQ3_RefID " , teste ) ;
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( - 1 ,
2002-07-26 06:21:43 +00:00
va ( " print \" %s " MM_OK_COLOR " is the new Referee \n \" " ,
2002-06-16 20:06:15 +00:00
ent - > client - > pers . netname ) ) ;
2002-03-07 00:00:54 +00:00
return qtrue ;
2002-06-16 20:06:15 +00:00
}
2002-08-23 14:25:05 +00:00
*/
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " Invalid Referee Password \n \" " ) ) ;
2002-05-05 04:23:00 +00:00
2002-03-07 00:00:54 +00:00
return qfalse ;
}
2002-08-02 22:44:37 +00:00
// MM_ResetMatch by Slicer
// Used by admin or rcon to reset Match settings, that is subs, captains, scores, teams's status and game status
//
2009-07-04 03:37:41 +00:00
void MM_ResetMatch ( void ) {
2002-08-02 22:44:37 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" " MM_OK_COLOR " Reseting Server Match Status... \n \" " ) ) ;
// CleanUp Scores and Team Status
MM_ClearScores ( qtrue ) ;
// Just in case
MakeAllLivePlayersObservers ( ) ;
level . team1ready = qfalse ;
level . team2ready = qfalse ;
level . inGame = qfalse ;
level . team_game_going = 0 ;
level . team_round_going = 0 ;
level . team_round_countdown = 0 ;
level . matchTime = 0 ;
}
2002-03-07 00:00:54 +00:00
2009-07-04 03:37:41 +00:00
void refReadyStatus ( void ) {
2002-10-21 21:00:39 +00:00
gentity_t * ent ;
int i ;
for ( i = 0 ; i < level . maxclients ; i + + ) {
ent = & g_entities [ i ] ;
if ( ! ent | | ! ent - > inuse )
continue ;
if ( ent - > client - > sess . refReady ) {
level . refStatus = 1 ;
return ;
}
}
}
2002-03-07 00:00:54 +00:00
//
2002-06-16 20:06:15 +00:00
// aasimon: processes comands sent from the referee
2002-03-07 00:00:54 +00:00
//
2002-06-16 20:06:15 +00:00
void Ref_Command ( gentity_t * ent )
{
char com [ MAX_TOKEN_CHARS ] ;
2002-06-23 03:04:09 +00:00
char param [ MAX_TOKEN_CHARS ] ;
2002-08-27 04:48:13 +00:00
char arg2 [ MAX_STRING_CHARS ] ;
2002-10-21 21:00:39 +00:00
int cn , i , args ;
2002-08-29 22:28:45 +00:00
gentity_t * p ;
2002-10-21 21:00:39 +00:00
char * buff ;
2002-03-07 00:00:54 +00:00
2002-10-21 21:00:39 +00:00
args = trap_Argc ( ) ;
2002-08-23 14:25:05 +00:00
//cn = ent - g_entities;
if ( ! ent - > client - > sess . referee ) {
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " You are not a referee \n \" " ) ) ;
2002-03-07 00:00:54 +00:00
return ;
}
2002-10-21 21:00:39 +00:00
if ( args < 2 ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " You need to specify a command. Use \" ref help \" to list available commands \n \" " ) ) ;
return ;
}
2002-03-07 00:00:54 +00:00
2002-06-16 20:06:15 +00:00
trap_Argv ( 1 , com , sizeof ( com ) ) ;
2002-03-07 00:00:54 +00:00
// nice strcmp for each comand (borring, wheres my beer?)
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( com , " help " ) = = 0 ) {
2002-10-21 21:00:39 +00:00
/* // Theres a clean way to do this - add more help here (this is for example only)
2002-08-29 22:28:45 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" kick <player number> \n \" " ) ;
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" map_restart \n \" " ) ;
trap_SendServerCommand ( ent - g_entities , " print \" clearscores \n \" " ) ;
trap_SendServerCommand ( ent - g_entities , " print \" pause \n \" " ) ;
2002-06-18 03:57:38 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" cyclemap \n \" " ) ;
2002-06-20 18:40:17 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" lockSettings \n \" " ) ;
2002-08-02 22:44:37 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" resetMatch \n \" " ) ;
2002-06-23 03:04:09 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" map <map_to_go> \n \" " ) ;
2002-08-27 04:48:13 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" say <text> \n \" " ) ;
2002-10-21 21:00:39 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" hearAll \n \" " ) ;
trap_SendServerCommand ( ent - g_entities , " print \" ready \n \" " ) ;
trap_SendServerCommand ( ent - g_entities , " print \" forceReady \n \" " ) ; */
trap_SendServerCommand ( ent - g_entities , " print \" kick <player number> \t \t \" " ) ;
trap_SendServerCommand ( ent - g_entities , " print \" map_restart \n \" " ) ;
trap_SendServerCommand ( ent - g_entities , " print \" clearscores \t \t \" " ) ;
trap_SendServerCommand ( ent - g_entities , " print \" pause \n \" " ) ;
trap_SendServerCommand ( ent - g_entities , " print \" cyclemap \t \t \" " ) ;
trap_SendServerCommand ( ent - g_entities , " print \" lockSettings \n \" " ) ;
trap_SendServerCommand ( ent - g_entities , " print \" resetMatch \t \t \" " ) ;
trap_SendServerCommand ( ent - g_entities , " print \" map <map_to_go> \n \" " ) ;
trap_SendServerCommand ( ent - g_entities , " print \" say <text> \t \t \" " ) ;
trap_SendServerCommand ( ent - g_entities , " print \" hearAll \n \" " ) ;
trap_SendServerCommand ( ent - g_entities , " print \" ready \t \t \" " ) ;
trap_SendServerCommand ( ent - g_entities , " print \" teamReady <team1/team2> \n \" " ) ;
trap_SendServerCommand ( ent - g_entities , " print \" teamName <team1/team2> <name> \t \t \" " ) ;
trap_SendServerCommand ( ent - g_entities , " print \" teamModel <team1/team2> <model> \t \t \" " ) ;
return ;
} else if ( Q_stricmp ( com , " teamModel " ) = = 0 ) {
if ( args < 3 ) {
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_DENY_COLOR " Please specify which Team and Model Name: ref <team1 / team2> <model> \n \" " ) ) ;
return ;
}
if ( level . team_game_going | | level . team_round_going ) {
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_DENY_COLOR " You cannot change Models while game is occuring. \n \" " ) ) ;
return ;
}
trap_Argv ( 2 , com , sizeof ( com ) ) ;
if ( Q_stricmp ( com , " team1 " ) = = 0 ) {
buff = ConcatArgs ( 2 ) ;
trap_Cvar_Set ( " g_RQ3_team1model " , buff ) ;
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_OK_COLOR " New Team1 Model: %s \n \" " , g_RQ3_team1model . string ) ) ;
}
else if ( Q_stricmp ( com , " team2 " ) = = 0 ) {
buff = ConcatArgs ( 2 ) ;
trap_Cvar_Set ( " g_RQ3_team2model " , buff ) ;
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_OK_COLOR " New Team2 Model: %s \n \" " , g_RQ3_team2model . string ) ) ;
}
else {
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_DENY_COLOR " Invalid Team. Available teams are: \" team1 \" or \" team2 \" \n \" " ) ) ;
}
return ;
} else if ( Q_stricmp ( com , " teamName " ) = = 0 ) {
if ( args < 3 ) {
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_DENY_COLOR " Please specify which Team and Name: ref <team1 / team2> <name> \n \" " ) ) ;
return ;
}
trap_Argv ( 2 , com , sizeof ( com ) ) ;
if ( Q_stricmp ( com , " team1 " ) = = 0 ) {
buff = ConcatArgs ( 2 ) ;
if ( strlen ( buff ) > TEAM_NAME_SIZE )
buff [ TEAM_NAME_SIZE ] = 0 ;
trap_Cvar_Set ( " g_RQ3_team1name " , buff ) ;
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_OK_COLOR " New Team1 Name: %s \n \" " , g_RQ3_team1name . string ) ) ;
}
else if ( Q_stricmp ( com , " team2 " ) = = 0 ) {
buff = ConcatArgs ( 2 ) ;
if ( strlen ( buff ) > TEAM_NAME_SIZE )
buff [ TEAM_NAME_SIZE ] = 0 ;
trap_Cvar_Set ( " g_RQ3_team2name " , buff ) ;
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_OK_COLOR " New Team2 Name: %s \n \" " , g_RQ3_team2name . string ) ) ;
}
else {
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_DENY_COLOR " Invalid Team. Available teams are: \" team1 \" or \" team2 \" \n \" " ) ) ;
}
return ;
} else if ( Q_stricmp ( com , " teamReady " ) = = 0 ) {
if ( args < 2 ) {
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_DENY_COLOR " Please specify which team: ref <team1 / team2> \n \" " ) ) ;
return ;
}
trap_Argv ( 2 , com , sizeof ( com ) ) ;
if ( Q_stricmp ( com , " team1 " ) = = 0 ) {
trap_SendServerCommand ( - 1 , va ( " cp \" %s forced %s to be%s Ready. \n \" " ,
ent - > client - > pers . netname , g_RQ3_team1name . string , level . team1ready ? " no longer " : " " ) ) ;
if ( level . team1ready )
level . team1ready = qfalse ;
else
level . team1ready = qtrue ;
}
else if ( Q_stricmp ( com , " team2 " ) = = 0 ) {
trap_SendServerCommand ( - 1 , va ( " cp \" %s forced %s to be%s Ready. \n \" " ,
ent - > client - > pers . netname , g_RQ3_team2name . string , level . team2ready ? " no longer " : " " ) ) ;
if ( level . team2ready )
level . team2ready = qfalse ;
else
level . team2ready = qtrue ;
}
else {
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_DENY_COLOR " Invalid Team. Available teams are: \" team1 \" or \" team2 \" \n \" " ) ) ;
}
return ;
} else if ( Q_stricmp ( com , " ready " ) = = 0 ) {
if ( ent - > client - > sess . refReady ) {
ent - > client - > sess . refReady = 0 ;
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_OK_COLOR " You are no longer Ready \n \" " ) ) ;
}
else {
ent - > client - > sess . refReady = 1 ;
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_OK_COLOR " You are now Ready \n \" " ) ) ;
}
refReadyStatus ( ) ;
return ;
} else if ( Q_stricmp ( com , " hearall " ) = = 0 ) {
if ( ent - > client - > sess . refHear ) {
ent - > client - > sess . refHear = qfalse ;
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_OK_COLOR " Hear All Disabled \n \" " ) ) ;
}
else {
if ( ent - > client - > sess . savedTeam ! = TEAM_SPECTATOR ) {
ent - > client - > sess . refHear = qtrue ;
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_OK_COLOR " Hear All Enabled \n \" " ) ) ;
}
else
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_DENY_COLOR " You cannot use hear all when on a team \n \" " ) ) ;
}
2002-06-20 18:40:17 +00:00
return ;
2002-08-02 22:44:37 +00:00
} else if ( Q_stricmp ( com , " resetMatch " ) = = 0 ) {
MM_ResetMatch ( ) ;
return ;
2002-06-20 18:40:17 +00:00
} else if ( Q_stricmp ( com , " lockSettings " ) = = 0 ) {
2002-07-07 21:12:52 +00:00
if ( level . settingsLocked ) {
2002-06-20 18:40:17 +00:00
level . settingsLocked = qfalse ;
2002-07-07 21:12:52 +00:00
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_OK_COLOR " Settings are now unLocked \n \" " ) ) ;
}
else {
2002-06-20 18:40:17 +00:00
level . settingsLocked = qtrue ;
2002-07-07 21:12:52 +00:00
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" " MM_OK_COLOR " Settings are now Locked \n \" " ) ) ;
}
2002-03-07 00:00:54 +00:00
return ;
2002-06-16 20:06:15 +00:00
} else if ( Q_stricmp ( com , " kick " ) = = 0 ) { // kick kick kick
trap_Argv ( 2 , com , sizeof ( com ) ) ;
if ( Q_stricmp ( com , " " ) = = 0 ) {
trap_SendServerCommand ( ent - g_entities ,
2002-08-29 22:28:45 +00:00
va ( " print \" " MM_DENY_COLOR " You must specify a player number - use <playerlist> \n \" " ) ) ;
2002-03-07 00:00:54 +00:00
return ;
}
2002-05-05 04:23:00 +00:00
2002-08-29 22:28:45 +00:00
/*cn = ClientNumberFromString(ent, com);
2002-05-05 04:23:00 +00:00
if ( cn = = - 1 ) {
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities ,
2002-07-26 06:21:43 +00:00
va ( " print \" %s " MM_DENY_COLOR " is not on the server \n \" " , com ) ) ;
2002-03-07 00:00:54 +00:00
return ;
}
2002-08-29 22:28:45 +00:00
trap_DropClient ( cn , " was kicked by the referee " ) ; */
cn = atoi ( com ) ;
if ( cn < 0 | | cn > level . maxclients ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " Invalid Player Number - use <playerlist> \n \" " ) ) ;
return ;
}
p = & g_entities [ cn ] ;
if ( ! p - > inuse | | ! p - > client ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " Invalid Player Number - use <playerlist> \n \" " ) ) ;
return ;
}
trap_DropClient ( p - g_entities , " was kicked by the referee " ) ;
2002-06-16 20:06:15 +00:00
} else if ( Q_stricmp ( com , " clearscores " ) = = 0 ) {
2002-08-02 22:44:37 +00:00
MM_ClearScores ( qfalse ) ;
2002-03-07 00:00:54 +00:00
return ;
2002-06-16 20:06:15 +00:00
} else if ( Q_stricmp ( com , " map_restart " ) = = 0 ) {
2002-03-07 00:00:54 +00:00
// this is having problems, namely diference from rcon map_restart or using this trap
// Ok here it goes: doing map_restart with players IN THE GAME forces them to specs but
// the scoreboard still shows the players in the team.
// Second thing is: remove the stupid 5-4-3-2-1 if doing map_restart i (with i > 0)
2002-05-05 04:23:00 +00:00
trap_SendConsoleCommand ( EXEC_APPEND , " map_restart 0 \n " ) ;
2002-03-07 00:00:54 +00:00
return ;
2002-06-16 20:06:15 +00:00
} else if ( Q_stricmp ( com , " pause " ) = = 0 ) {
2002-05-05 04:23:00 +00:00
if ( level . paused ) {
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( - 1 , " cp \" Game resumed by Referee. \n \" " ) ;
2002-04-28 17:28:27 +00:00
level . paused = qfalse ;
2002-05-05 04:23:00 +00:00
} else {
if ( level . team_game_going ) {
if ( level . inGame )
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities ,
2002-06-23 15:22:53 +00:00
va ( " print \" " MM_OK_COLOR " Game will be paused at the end of the round " ) ) ;
2002-04-28 11:03:46 +00:00
else
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( - 1 , va ( " cp \" Game is now paused by the Referee \" " ) ) ;
2002-04-28 17:28:27 +00:00
level . paused = qtrue ;
2002-05-05 04:23:00 +00:00
} else
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " No game is going.. " ) ) ;
2002-04-28 11:03:46 +00:00
}
2002-06-18 03:57:38 +00:00
} else if ( Q_stricmp ( com , " cyclemap " ) = = 0 ) {
BeginIntermission ( ) ;
2002-06-23 03:04:09 +00:00
} else if ( Q_stricmp ( com , " map " ) = = 0 ) {
// get map name
trap_Argv ( 2 , param , sizeof ( param ) ) ;
if ( ! G_FileExists ( va ( " maps/%s.bsp " , param ) ) ) {
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " The map %s does not exist. \n \" " , param ) ) ;
2002-06-23 03:04:09 +00:00
return ;
}
else {
trap_Cvar_Set ( " g_RQ3_ValidIniFile " , " 3 " ) ;
g_RQ3_ValidIniFile . integer = 3 ;
2002-07-26 06:21:43 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" " MM_OK_COLOR " Referee changed next map to: %s \n \" " , param ) ) ;
2002-06-23 03:04:09 +00:00
Com_sprintf ( level . voteMap , sizeof ( level . voteMap ) , " map %s " , param ) ;
BeginIntermission ( ) ;
}
}
2002-08-27 04:48:13 +00:00
else if ( Q_stricmp ( com , " say " ) = = 0 ) {
arg2 [ 0 ] = ' \0 ' ;
for ( i = 2 ; i < trap_Argc ( ) ; i + + ) {
if ( i > 2 )
strcat ( arg2 , " " ) ;
trap_Argv ( i , & arg2 [ strlen ( arg2 ) ] , sizeof ( arg2 ) - strlen ( arg2 ) ) ;
}
G_Say ( ent , NULL , SAY_REF , arg2 ) ;
}
2002-06-23 03:04:09 +00:00
else
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities ,
2002-06-23 15:22:53 +00:00
va ( " print \" " MM_DENY_COLOR " Invalid Referee comand. Type ref help to see a list of available commands \n \" " ) ) ;
2002-03-07 00:00:54 +00:00
}
2002-06-16 20:06:15 +00:00
void Ref_Resign ( gentity_t * ent )
{
2002-08-23 14:25:05 +00:00
if ( ent - > client - > sess . referee ) {
2002-10-21 21:00:39 +00:00
- - level . refAmmount ;
2002-08-23 14:25:05 +00:00
ent - > client - > sess . referee = 0 ;
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_OK_COLOR " You resign from your referee status \n \" " ) ) ;
2002-03-07 00:00:54 +00:00
}
}
2002-06-20 18:40:17 +00:00
/*
Timelimit
RoundLimit
RoundTimeLimit
Fraglimit
2002-06-23 15:22:53 +00:00
Max Players
2002-06-20 18:40:17 +00:00
Friendly Fire
Chase Cam
Team Grenades
- - - > Irvision Doesnt Exist .
Force Team Talk
*/
# define NR_SETTVARS 9
2002-07-26 06:21:43 +00:00
const char * settings [ ] = { " timelimit " , " g_RQ3_roundlimit " , " g_RQ3_roundtimelimit " , " fraglimit " , " g_RQ3_maxplayers " ,
" g_RQ3_forceteamtalk " , " g_RQ3_limchasecam " , " g_RQ3_tgren " , " g_friendlyFire " } ;
// JBravo: adding settings2 for cvars to set in the client for the MM ingame menu.
2003-02-16 21:39:10 +00:00
//Makro - changed cg_RQ3_timelimit/fraglimit cvars - they were causing problems on local servers
const char * settings2 [ ] = { " timelimit " , " cg_RQ3_roundlimit " , " cg_RQ3_roundtimelimit " , " fraglimit " ,
2002-07-26 06:21:43 +00:00
" cg_RQ3_maxplayers " , " cg_RQ3_forceteamtalk " , " cg_RQ3_limchasecam " , " cg_RQ3_tgren " , " cg_RQ3_friendlyFire " } ;
2002-06-20 18:40:17 +00:00
void MM_Settings_f ( gentity_t * ent ) {
int i ;
char str [ MAX_TOKEN_CHARS ] ;
if ( ! g_RQ3_matchmode . integer )
return ;
//Invalid Data SENT
2002-07-26 06:21:43 +00:00
if ( trap_Argc ( ) - 1 ! = NR_SETTVARS ) {
2002-06-20 18:40:17 +00:00
return ;
2002-07-04 16:05:32 +00:00
}
2002-06-23 19:12:17 +00:00
2002-10-21 21:00:39 +00:00
if ( ( g_RQ3_mmflags . integer & MMF_SETTINGS ) ! = MMF_SETTINGS & & ! ent - > client - > sess . referee ) {
2002-06-23 19:12:17 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " This server does not allow you to change settings \n \" " ) ) ;
return ;
}
2002-08-23 14:25:05 +00:00
if ( ent - > client - > sess . captain = = TEAM_FREE & & ! ent - > client - > sess . referee ) {
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " Only Captains and Referees can change match Settings \n \" " ) ) ;
2002-06-20 18:40:17 +00:00
return ;
}
//Game has begun
2002-07-26 06:21:43 +00:00
if ( level . inGame ) {
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " Settings can only be changed before a game starts \n \" " ) ) ;
2002-06-20 18:40:17 +00:00
return ;
}
//Referee locked settings
2002-10-21 21:00:39 +00:00
if ( level . settingsLocked & & ! ent - > client - > sess . referee ) {
2002-06-23 15:22:53 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" " MM_DENY_COLOR " Settings are currently locked, only Referee can unlock them \n \" " ) ) ;
2002-06-20 18:40:17 +00:00
return ;
}
2002-07-26 06:21:43 +00:00
for ( i = 0 ; i < NR_SETTVARS ; + + i ) {
2002-06-20 18:40:17 +00:00
trap_Argv ( i + 1 , str , sizeof ( str ) ) ;
trap_Cvar_Set ( settings [ i ] , str ) ;
2002-07-26 06:21:43 +00:00
// JBravo: setting the cvars in cgame now.
trap_SendServerCommand ( - 1 , va ( " rq3_cmd %i %s %s " , CVARSET , settings2 [ i ] , str ) ) ;
2002-06-20 18:40:17 +00:00
}
2002-07-26 06:21:43 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" " MM_OK_COLOR " Match Settings have been changed by %s \n \" " , ent - > client - > pers . netname ) ) ;
2002-06-20 18:40:17 +00:00
}