Esempio n. 1
0
/*
===================
Svcmd_LayoutSave_f

layoutsave <name>
===================
*/
static void Svcmd_LayoutSave_f( void )
{
	char str[ MAX_QPATH ];
	char str2[ MAX_QPATH - 4 ];
	char *s;
	int  i = 0;

	if ( trap_Argc() != 2 )
	{
		G_Printf( "usage: layoutsave <name>\n" );
		return;
	}

	trap_Argv( 1, str, sizeof( str ) );

	// sanitize name
	s = &str[ 0 ];
	str2[ 0 ] = 0;

	while ( *s && i < sizeof( str2 ) - 1 )
	{
		if ( isalnum( *s ) || *s == '-' || *s == '_' )
		{
			str2[ i++ ] = *s;
			str2[ i ] = '\0';
		}

		s++;
	}

	if ( !str2[ 0 ] )
	{
		G_Printf( "layoutsave: invalid name \"%s\"\n", str );
		return;
	}

	G_LayoutSave( str2 );
}
Esempio n. 2
0
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 )
	{
		G_Printf( "usage: dumpuser <player>\n" );
		return;
	}

	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 )
	{
		Info_NextPair( &info, key, value );

		if ( !*info )
		{
			return;
		}

		G_Printf( "%-20s%s\n", key, value );
	}
}
Esempio n. 3
0
/*
==================
ConcatArgs
==================
*/
char *ConcatArgs(int start) {
	int i, c, tlen;
	static char line[MAX_STRING_CHARS];
	int len;
	char arg[MAX_STRING_CHARS];
	len = 0;
	c = trap_Argc();
	for (i = start; i < c; i++) {
		trap_Argv(i, arg, sizeof(arg));
		tlen = strlen(arg);
		if (len + tlen >= MAX_STRING_CHARS - 1) {
			break;
		}
		memcpy(line + len, arg, tlen);
		len += tlen;
		if (i != c - 1) {
			line[len] = ' ';
			len++;
		}
	}
	line[len] = 0;
	return line;
}
Esempio n. 4
0
static void Svcmd_PrintQueue_f()
{
    team_t team;
    char teamName[ MAX_STRING_CHARS ];

    if ( trap_Argc() != 2 )
    {
        G_Printf( "usage: printqueue <team>\n" );
        return;
    }

    trap_Argv( 1, teamName, sizeof( teamName ) );

    team = G_TeamFromString(teamName);
    if ( TEAM_ALIENS == team || TEAM_HUMANS == team )
    {
        G_PrintSpawnQueue( &level.team[ team ].spawnQueue );
    }
    else
    {
        G_Printf( "unknown team\n" );
    }
}
Esempio n. 5
0
void NS_MenuSelect( gentity_t *ent ) {
	char arg[MAX_TOKEN_CHARS];
	int menuSlot = 0;
	int menu;

	// no Active Menu?
	if ( ent->client->pers.activeMenu == MENU_NONE ) {
		return;
	}

	// smaller then 1 command?
	if ( trap_Argc() < 1 ) {
		return;
	}

	trap_Argv( 1, arg, sizeof( arg ) );
	menuSlot = atoi( arg );
	menu = ent->client->pers.activeMenu;

	ent->client->pers.activeMenu = MENU_NONE;

	NS_CallMenu( ent, menu, menuSlot );
}
Esempio n. 6
0
static void Svcmd_Armageddon_f( void )
{
	char arg[ 4 ];
	int percent;

	if ( trap_Argc() != 2 )
	{
		G_Printf( "usage: armageddon <percent>\n" );
		return;
	}

	trap_Argv( 1, arg, sizeof( arg ) );
	percent = atoi( arg );


	if ( percent < 1 || percent > 100 )
	{
		G_Printf( "armageddon: Strength must be between 1 and 100\n" );
		return;
	}

	G_Armageddon( percent / 100.0f );
}
Esempio n. 7
0
void G_RemoveReferee()
{ 
	char	cmd[MAX_TOKEN_CHARS];
	int		cnum;

	trap_Argv( 1, cmd, sizeof( cmd ) );

	if(!*cmd) {
		G_Printf( "usage: RemoveReferee <clientname>." );
		return;
	}

	cnum = G_refClientnumForName(NULL, cmd);

	if (cnum != MAX_CLIENTS ) {
		if( level.clients[cnum].sess.referee == RL_REFEREE ) {
			level.clients[cnum].sess.referee = RL_NONE;
			G_Printf( "%s is no longer a referee.\n", cmd );
		} else {
			G_Printf( "User is not a referee.\n" );
		}
	}
}
Esempio n. 8
0
static void Svcmd_TeamMessage_f( void )
{
  char   teamNum[ 2 ];
  team_t team;

  if( trap_Argc( ) < 3 )
  {
    G_Printf( "usage: say_team <team> <message>\n" );
    return;
  }

  trap_Argv( 1, teamNum, sizeof( teamNum ) );
  team = G_TeamFromString( teamNum );

  if( team == NUM_TEAMS )
  {
    G_Printf( "say_team: invalid team \"%s\"\n", teamNum );
    return;
  }

  G_TeamCommand( team, va( "chat -1 %d \"%s\"", SAY_TEAM, ConcatArgs( 2 ) ) );
  G_LogPrintf( "SayTeam: -1 \"console\": %s\n", ConcatArgs( 2 ) );
}
Esempio n. 9
0
/*
================
G_refRemoveShoutcaster_cmd
================
*/
void G_refRemoveShoutcaster_cmd( gentity_t *ent )
{
	int			pid;
	char		name[MAX_NAME_LENGTH];
	gentity_t	*player;

	if( trap_Argc() != 3 ) {
		G_refPrintf( ent, "Usage: \\ref removeshoutcaster <pid>" );
		return;
	}

	if( !G_IsShoutcastPasswordSet() ) {
		G_refPrintf( ent,
			"Sorry, shoutcaster status disabled on this server." );
		return;
	}

	trap_Argv( 2, name, sizeof( name ) );
	
	if( ( pid = ClientNumberFromString( ent, name ) ) == -1 ) {
		return;
	}

	player = g_entities + pid;

	if( !player || !player->client ) {
		return;
	}

	if( !player->client->sess.shoutcaster ) {
		G_refPrintf( ent, "Sorry, %s^7 is not a shoutcaster.",
			player->client->pers.netname );
		return;
	}

	G_RemoveShoutcaster( player );
}
Esempio n. 10
0
/*
 * Cmd_Follow_f
 */
void
Cmd_Follow_f(Gentity *ent)
{
	int	i;
	char	arg[MAX_TOKEN_CHARS];

	if(trap_Argc() != 2){
		if(ent->client->sess.specstate == SPECTATOR_FOLLOW)
			StopFollowing(ent);
		return;
	}

	trap_Argv(1, arg, sizeof(arg));
	i = ClientNumberFromString(ent, arg);
	if(i == -1)
		return;

	/* can't follow self */
	if(&level.clients[ i ] == ent->client)
		return;

	/* can't follow another spectator */
	if(level.clients[ i ].sess.team == TEAM_SPECTATOR)
		return;

	/* if they are playing a tournement game, count as a loss */
	if((g_gametype.integer == GT_TOURNAMENT)
	   && ent->client->sess.team == TEAM_FREE)
		ent->client->sess.losses++;

	/* first set them to spectator */
	if(ent->client->sess.team != TEAM_SPECTATOR)
		SetTeam(ent, "spectator");

	ent->client->sess.specstate	= SPECTATOR_FOLLOW;
	ent->client->sess.specclient	= i;
}
Esempio n. 11
0
void Cmd_mShaderGroup_f( gentity_t *ent )
{
	int numArgs = trap_Argc();
	char arg[1024] = { 0 };
	gentity_t *target;
	RemapSettings *group;
	int num, groupCounter = 0;

	if(numArgs == 2)
	{
		target = SelectedEnt(ent);
		if(!target)
			return;
	}
	else
	{
		MM_SendMessage( ent-g_entities, va("print \"Command usage: mShaderGroup <group name/0>, if you set it to 0 it will choose the default group.\n\""));
		return;
	}

	trap_Argv( 1, arg, sizeof(arg) );
	if(isNumber(arg,&num))
		group = FindGroup(ent-g_entities, target, NULL, &groupCounter, NULL);
	else group = FindGroup(ent-g_entities, target, arg, &groupCounter, NULL);

	if(!group)
	{
		MM_SendMessage( ent-g_entities, va("print \"This group hasn't been created yet.\n\""));
		return; 
	}

	target->s.trickedentindex = 1;
	target->s.trickedentindex2 = ent - g_entities;
	target->s.trickedentindex3 = groupCounter;


}
Esempio n. 12
0
void Cmd_DelJail_f(gentity_t *ent)
{
	char buffer[MAX_TOKEN_CHARS];
	if (!HasPermission(ent, PERMISSION_JAIL))
		return;

	if (trap_Argc() != 2)
	{
		MM_SendMessage(ent - g_entities, va("print \"Command usage: mdeljail <id>\n\""));
		return;
	}

	trap_Argv(1, buffer, sizeof(buffer));

	int id = atoi(buffer);
	jail_t *root = jails.next;

	for (int i = 0; i < id; i++)
		if (root == NULL) break;
		else
			root = root->next;

	if (root)
	{
		if(root->prev) root->prev->next = root->next;
		if(root->next) root->next->prev = root->prev;
		free(root);
		jails.count--;
		MM_SendMessage(ent - g_entities, va("print \"Jail spot removed.\n\""));
	}
	else
		MM_SendMessage(ent - g_entities, va("print \"Error removing jail spot.\n\""));

	vmCvar_t mapname;
	trap_Cvar_Register(&mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM);
	MM_WriteData(va("jails\\%s.json", mapname.string), MM_WriteJails);
}
Esempio n. 13
0
static void CG_BuddyVoiceChat_f(void)
{
	char chatCmd[64];

	if (trap_Argc() != 2)
	{
		return;
	}

	// don't let spectators voice chat
	// NOTE - This cg.snap will be the person you are following, but its just for intermission test
	if (cg.snap && (cg.snap->ps.pm_type != PM_INTERMISSION))
	{
		if (cgs.clientinfo[cg.clientNum].team == TEAM_SPECTATOR || cgs.clientinfo[cg.clientNum].team == TEAM_FREE)
		{
			CG_Printf("%s", CG_TranslateString("Can't buddy voice chat as a spectator.\n"));
			return;
		}
	}

	trap_Argv(1, chatCmd, 64);

	trap_SendConsoleCommand(va("cmd vsay_buddy -1 %s %s\n", CG_BuildSelectedFirteamString(), chatCmd));
}
Esempio n. 14
0
int G_BotAddNames( team_t team, int arg, int last )
{
	int  i = botNames[team].count;
	int  added = 0;
	char name[MAX_NAME_LENGTH];

	while ( arg < last && i < MAX_CLIENTS )
	{
		int j, t;

		trap_Argv( arg++, name, sizeof( name ) );

		// name already in the list? (quick check, including colours & invalid)
		for ( t = 1; t < NUM_TEAMS; ++t )
		{
			for ( j = 0; j < botNames[t].count; ++j )
			{
				if ( !Q_stricmp( botNames[t].name[j].name, name ) )
				{
					goto next;
				}
			}
		}

		botNames[team].name[i].name = ( char * )BG_Alloc( strlen( name ) + 1 );
		strcpy( botNames[team].name[i].name, name );

		botNames[team].count = ++i;
		++added;

		next:
		;
	}

	return added;
}
Esempio n. 15
0
void Svcmd_Campaign_f(void) {
	char	str[MAX_TOKEN_CHARS];
	int		i;
	g_campaignInfo_t *campaign = NULL;

	// find the campaign
	trap_Argv( 1, str, sizeof( str ) );
	
	for( i = 0; i < level.campaignCount; i++ ) {
		campaign = &g_campaigns[i];

		if( !Q_stricmp( campaign->shortname, str ) ) {
			break;
		}
	}

	if( i == level.campaignCount || !(campaign->typeBits & (1 << GT_WOLF) ) ) {
		G_Printf( "Can't find campaign '%s'\n", str );
		return;
	}

	trap_Cvar_Set( "g_oldCampaign", g_currentCampaign.string );
	trap_Cvar_Set( "g_currentCampaign", campaign->shortname );
	trap_Cvar_Set( "g_currentCampaignMap", "0" );

	level.newCampaign = qtrue;

	// we got a campaign, start it
	trap_Cvar_Set( "g_gametype", va( "%i", GT_WOLF_CAMPAIGN ) );
#if 0
	if( g_developer.integer )
		trap_SendConsoleCommand( EXEC_APPEND, va( "devmap %s\n", campaign->mapnames[0] ) );
	else
#endif
		trap_SendConsoleCommand( EXEC_APPEND, va( "map %s\n", campaign->mapnames[0] ) );
}
Esempio n. 16
0
/*
=================
Svcmd_DeleteID_f
=================
*/
void Svcmd_RemoveID_f ( void )
{
	char str[MAX_TOKEN_CHARS];
	idFilter_t	*id;

	if ( trap_Argc() < 2 )
	{
		G_Printf( "Usage: removeID <Ban ID>\n" );
		return;
	}

	trap_Argv( 1, str, sizeof( str ) );

	id = &idFilters[atoi(str)];
	if ( !id )
	{
		G_Printf( "Specified ID not found.\n" );
		return;
	}

	memset( id, 0, sizeof( idFilter_t ) );

	UpdateIDBans();
}
Esempio n. 17
0
void G_MakeReferee()
{
	char	cmd[MAX_TOKEN_CHARS];
	int		cnum;

	trap_Argv( 1, cmd, sizeof( cmd ) );

	if(!*cmd) {
		G_Printf( "usage: MakeReferee <clientname>." );
		return;
	}

	cnum = G_refClientnumForName(NULL, cmd);

	if (cnum != MAX_CLIENTS ) {
		if(level.clients[cnum].sess.referee == RL_NONE) {
			level.clients[cnum].sess.referee = RL_REFEREE;
			AP(va("cp \"%s\n^3has been made a referee\n\"", cmd));
			G_Printf("%s has been made a referee.\n", cmd);
		} else {
			G_Printf("User is already authed.\n");
		}
	}
}
Esempio n. 18
0
/**
 * @brief Sends an class setup message. Enables etpro like classscripts
 */
void CG_Class_f(void)
{
	char             cls[64];
	const char       *classtype, *teamstring;
	int              weapon1, weapon2, playerclass;
	bg_playerclass_t *classinfo;
	team_t           team;

	if (cg.demoPlayback)
	{
		return;
	}

	team = cgs.clientinfo[cg.clientNum].team;

	if (team == TEAM_SPECTATOR)
	{
		return;
	}

	if (trap_Argc() < 2)
	{
		CG_Printf("Invalid command format.\n");
		return;
	}

	switch (team)
	{
	case TEAM_AXIS:
		classtype  = "r";
		teamstring = CG_TranslateString("Axis");
		break;
	case TEAM_ALLIES:
		classtype  = "b";
		teamstring = CG_TranslateString("Allies");
		break;
	default:
		CG_Printf("Invalid team.\n");
		return;
	}

	trap_Argv(1, cls, 64);

	if (!Q_stricmp(cls, "s") || !Q_stricmp(cls, "0"))
	{
		playerclass = PC_SOLDIER;
	}
	else if (!Q_stricmp(cls, "m") || !Q_stricmp(cls, "1"))
	{
		playerclass = PC_MEDIC;
	}
	else if (!Q_stricmp(cls, "e") || !Q_stricmp(cls, "2"))
	{
		playerclass = PC_ENGINEER;
	}
	else if (!Q_stricmp(cls, "f") || !Q_stricmp(cls, "3"))
	{
		playerclass = PC_FIELDOPS;
	}
	else if (!Q_stricmp(cls, "c") || !Q_stricmp(cls, "4"))
	{
		playerclass = PC_COVERTOPS;
	}
	else
	{
		CG_Printf("Invalid class format.\n");
		return;
	}

	classinfo = BG_GetPlayerClassInfo(team, playerclass);

	if (trap_Argc() > 2)
	{
		trap_Argv(2, cls, 64);
		weapon1 = atoi(cls);
		if (weapon1 <= 0 || weapon1 > MAX_WEAPS_PER_CLASS)
		{
			weapon1 = classinfo->classWeapons[0];
		}
		else if (!classinfo->classWeapons[weapon1 - 1])
		{
			CG_Printf("Invalid command format for weapon.\n");
			return;
		}
		else
		{
			weapon1 = classinfo->classWeapons[weapon1 - 1];
		}
	}
	else
	{
		weapon1 = classinfo->classWeapons[0];
	}

	if (trap_Argc() > 3)
	{
		trap_Argv(3, cls, 64);
		weapon2 = atoi(cls);
		weapon2 = CG_GetSecondaryWeapon(weapon2, team, playerclass);
	}
	else
	{
		weapon2 = CG_GetSecondaryWeapon(-1, team, playerclass);
	}

	// Print out the selected class and weapon info
	if (cgs.clientinfo[cg.clientNum].skill[SK_HEAVY_WEAPONS] >= 4 && playerclass == PC_SOLDIER && !Q_stricmp(weaponTable[weapon1].desc, weaponTable[weapon2].desc))
	{
		CG_PriorityCenterPrint(va(CG_TranslateString("You will spawn as an %s %s with a %s."), teamstring, BG_ClassnameForNumber(playerclass), weaponTable[weapon1].desc), 400, cg_fontScaleCP.value, -1);
	}
	else
	{
		switch (weapon2)
		{
		case WP_AKIMBO_COLT:
		case WP_AKIMBO_LUGER:
		case WP_AKIMBO_SILENCEDCOLT:
		case WP_AKIMBO_SILENCEDLUGER:
			CG_PriorityCenterPrint(va(CG_TranslateString("You will spawn as an %s %s with a %s and %s."), teamstring, BG_ClassnameForNumber(playerclass), weaponTable[weapon1].desc, weaponTable[weapon2].desc), 400, cg_fontScaleCP.value, -1);
			break;
		default:
			CG_PriorityCenterPrint(va(CG_TranslateString("You will spawn as an %s %s with a %s and a %s."), teamstring, BG_ClassnameForNumber(playerclass), weaponTable[weapon1].desc, weaponTable[weapon2].desc), 400, cg_fontScaleCP.value, -1);
			break;
		}
	}
	// Send the switch command to the server
	trap_SendClientCommand(va("team %s %i %i %i\n", classtype, playerclass, weapon1, weapon2));
}
Esempio n. 19
0
// Command handler
void Cmd_FireTeam_MP_f( gentity_t* ent ) {
	char command[32];
	int i;

	if ( trap_Argc() < 2 ) {
		G_ClientPrintAndReturn( ent - g_entities, "usage: fireteam <create|leave|apply|invite>" );
	}

	trap_Argv( 1, command, 32 );

	if ( !Q_stricmp( command, "create" ) ) {
		G_RegisterFireteam( ent - g_entities );
	} else if ( !Q_stricmp( command, "disband" ) ) {
		G_DestroyFireteam( ent - g_entities );
	} else if ( !Q_stricmp( command, "leave" ) ) {
		G_RemoveClientFromFireteams( ent - g_entities, qtrue, qtrue );
	} else if ( !Q_stricmp( command, "apply" ) ) {
		char namebuffer[32];
		int fireteam;

		if ( trap_Argc() < 3 ) {
			G_ClientPrintAndReturn( ent - g_entities, "usage: fireteam apply <fireteamname|fireteamnumber>" );
		}

		trap_Argv( 2, namebuffer, 32 );
		fireteam = G_FireteamNumberForString( namebuffer, ent->client->sess.sessionTeam );

		if ( fireteam <= 0 ) {
			G_ClientPrintAndReturn( ent - g_entities, "usage: fireteam apply <fireteamname|fireteamnumber>" );
		}

		G_ApplyToFireTeam( ent - g_entities, fireteam - 1 );
	} else if ( !Q_stricmp( command, "invite" ) ) {
		char namebuffer[32];
		int clientnum = 0;

		if ( trap_Argc() < 3 ) {
			G_ClientPrintAndReturn( ent - g_entities, "usage: fireteam invite <clientname|clientnumber>" );
		}

		trap_Argv( 2, namebuffer, 32 );
		for ( i = 0; i < MAX_CLIENTS; i++ ) {
			if ( !g_entities[i].inuse || !g_entities[i].client ) {
				continue;
			}

			if ( !Q_stricmp( g_entities[i].client->pers.netname, namebuffer ) ) {
				clientnum = i + 1;
			}
		}

		if ( clientnum <= 0 ) {
			clientnum = atoi( namebuffer );

			if ( ( clientnum <= 0 || clientnum > MAX_CLIENTS ) || !g_entities[clientnum - 1].inuse || !g_entities[clientnum - 1].client ) {
				G_ClientPrintAndReturn( ent - g_entities, "Invalid client selected" );
			}
		}

		if ( clientnum <= 0 ) {
			G_ClientPrintAndReturn( ent - g_entities, "usage: fireteam invite <clientname|clientnumber>" );
		}

		G_InviteToFireTeam( ent - g_entities, clientnum - 1 );
	} else if ( !Q_stricmp( command, "warn" ) ) {
		char namebuffer[32];
		int clientnum = 0;

		if ( trap_Argc() < 3 ) {
			G_ClientPrintAndReturn( ent - g_entities, "usage: fireteam warn <clientname|clientnumber>" );
		}

		trap_Argv( 2, namebuffer, 32 );
		for ( i = 0; i < MAX_CLIENTS; i++ ) {
			if ( !g_entities[i].inuse || !g_entities[i].client ) {
				continue;
			}

			if ( !Q_stricmp( g_entities[i].client->pers.netname, namebuffer ) ) {
				clientnum = i + 1;
			}
		}

		if ( clientnum <= 0 ) {
			clientnum = atoi( namebuffer );

			if ( ( clientnum <= 0 || clientnum > MAX_CLIENTS ) || !g_entities[clientnum - 1].inuse || !g_entities[clientnum - 1].client ) {
				G_ClientPrintAndReturn( ent - g_entities, "Invalid client selected" );
			}
		}

		if ( clientnum <= 0 ) {
			G_ClientPrintAndReturn( ent - g_entities, "usage: fireteam warn <clientname|clientnumber>" );
		}

		G_WarnFireTeamPlayer( ent - g_entities, clientnum - 1 );
	} else if ( !Q_stricmp( command, "kick" ) ) {
		char namebuffer[32];
		int clientnum = 0;

		if ( trap_Argc() < 3 ) {
			G_ClientPrintAndReturn( ent - g_entities, "usage: fireteam kick <clientname|clientnumber>" );
		}

		trap_Argv( 2, namebuffer, 32 );
		for ( i = 0; i < MAX_CLIENTS; i++ ) {
			if ( !g_entities[i].inuse || !g_entities[i].client ) {
				continue;
			}

			if ( !Q_stricmp( g_entities[i].client->pers.netname, namebuffer ) ) {
				clientnum = i + 1;
			}
		}

		if ( clientnum <= 0 ) {
			clientnum = atoi( namebuffer );

			if ( ( clientnum <= 0 || clientnum > MAX_CLIENTS ) || !g_entities[clientnum - 1].inuse || !g_entities[clientnum - 1].client ) {
				G_ClientPrintAndReturn( ent - g_entities, "Invalid client selected" );
			}
		}

		if ( clientnum <= 0 ) {
			G_ClientPrintAndReturn( ent - g_entities, "usage: fireteam kick <clientname|clientnumber>" );
		}

		G_KickFireTeamPlayer( ent - g_entities, clientnum - 1 );
	} else if ( !Q_stricmp( command, "propose" ) ) {
		char namebuffer[32];
		int clientnum = 0;

		if ( trap_Argc() < 3 ) {
			G_ClientPrintAndReturn( ent - g_entities, "usage: fireteam propose <clientname|clientnumber>" );
		}

		trap_Argv( 2, namebuffer, 32 );
		for ( i = 0; i < MAX_CLIENTS; i++ ) {
			if ( !g_entities[i].inuse || !g_entities[i].client ) {
				continue;
			}

			if ( !Q_stricmp( g_entities[i].client->pers.netname, namebuffer ) ) {
				clientnum = i + 1;
			}
		}

		if ( clientnum <= 0 ) {
			clientnum = atoi( namebuffer );

			if ( ( clientnum <= 0 || clientnum > MAX_CLIENTS ) || !g_entities[clientnum - 1].inuse || !g_entities[clientnum - 1].client ) {
				G_ClientPrintAndReturn( ent - g_entities, "Invalid client selected" );
			}
		}

		if ( clientnum <= 0 ) {
			G_ClientPrintAndReturn( ent - g_entities, "usage: fireteam propose <clientname|clientnumber>" );
		}

		G_ProposeFireTeamPlayer( ent - g_entities, clientnum - 1 );
	}
}
Esempio n. 20
0
void G_ParseCampaigns( void ) {
	int numdirs;
	char filename[128];
	char dirlist[1024];
	char*       dirptr;
	int i;
	int dirlen;
	qboolean mapFound = qfalse;

	level.campaignCount = 0;
	level.currentCampaign = -1;
	memset( &g_campaigns, 0, sizeof( g_campaignInfo_t ) * MAX_CAMPAIGNS );

	// get all campaigns from .campaign files
	numdirs = trap_FS_GetFileList( "scripts", ".campaign", dirlist, 1024 );
	dirptr  = dirlist;
	for ( i = 0; i < numdirs && level.campaignCount < MAX_CAMPAIGNS; i++, dirptr += dirlen + 1 ) {
		dirlen = strlen( dirptr );
		strcpy( filename, "scripts/" );
		strcat( filename, dirptr );

		if ( G_LoadCampaignsFromFile( filename ) ) {
			mapFound = qtrue;
		}
	}

	if ( g_gametype.integer != GT_WOLF_CAMPAIGN ) {
		trap_Cvar_Set( "g_oldCampaign", "" );
		trap_Cvar_Set( "g_currentCampaign", "" );
		trap_Cvar_Set( "g_currentCampaignMap", "0" );
	} else if ( !mapFound ) {
		// map isn't found in the current campaign, see if it's the first map in another campaign
		for ( i = 0; i < level.campaignCount; i++ ) {
			if ( !Q_stricmp( g_campaigns[i].mapnames[0], level.rawmapname ) ) {
				// someone manually specified a /map command, and it's the first map in a campaign
				trap_Cvar_Set( "g_oldCampaign", g_currentCampaign.string );
				trap_Cvar_Set( "g_currentCampaign", g_campaigns[i].shortname );
				trap_Cvar_Set( "g_currentCampaignMap", "0" );

				level.newCampaign = qtrue;

				g_campaigns[level.campaignCount].current = 0;
				level.currentCampaign = i;

				break;
			}
		}

		if ( i == level.campaignCount ) {
			char buf[MAX_STRING_CHARS]; // fretn

			if ( trap_Argc() < 1 ) { // command not found, throw error
				G_Error( "Usage 'map <mapname>\n'" );
			}

			trap_Argv( 0, buf, sizeof( buf ) );

			if ( !buf ) { // command not found, throw error
				G_Error( "Usage 'map <mapname>\n'" );
			}

			// no campaign found, fallback to GT_WOLF
			// and reload the map
			trap_Cvar_Set( "g_gametype", "2" );
			trap_SendConsoleCommand( EXEC_APPEND, va( "%s %s", buf, level.rawmapname ) );
		}
	}
}
/*
=================
ConsoleCommand

=================
*/
qboolean	ConsoleCommand( void ) {
    char	cmd[MAX_TOKEN_CHARS];

    trap_Argv( 0, cmd, sizeof( cmd ) );

    if ( Q_stricmp (cmd, "entitylist") == 0 ) {
        Svcmd_EntityList_f();
        return qtrue;
    }

    if ( Q_stricmp (cmd, "forceteam") == 0 ) {
        Svcmd_ForceTeam_f();
        return qtrue;
    }

    if (Q_stricmp (cmd, "game_memory") == 0) {
        Svcmd_GameMem_f();
        return qtrue;
    }

    if (Q_stricmp (cmd, "addbot") == 0) {
        Svcmd_AddBot_f();
        return qtrue;
    }

    if (Q_stricmp (cmd, "botlist") == 0) {
        Svcmd_BotList_f();
        return qtrue;
    }

    if (Q_stricmp (cmd, "abort_podium") == 0) {
        Svcmd_AbortPodium_f();
        return qtrue;
    }

    if (Q_stricmp (cmd, "addip") == 0) {
        Svcmd_AddIP_f();
        return qtrue;
    }

    if (Q_stricmp (cmd, "removeip") == 0) {
        Svcmd_RemoveIP_f();
        return qtrue;
    }

    if (Q_stricmp (cmd, "listip") == 0) {
        trap_SendConsoleCommand( EXEC_NOW, "g_banIPs\n" );
        return qtrue;
    }

    if(Q_stricmp (cmd, "setGametype") == 0)
    {
        Svcmd_SetGameType_f();
        return qtrue;
    }
    if(Q_stricmp (cmd, "startcam") == 0) {
        Svcmd_StartCam();
        return qtrue;
    }
    if(Q_stricmp (cmd, "stopcam") == 0) {
        Svcmd_StopCam();
        return qtrue;
    }
    if(Q_stricmp (cmd, "camcmd") == 0) {
        Svcmd_CamCmd();
        return qtrue;
    }
    if( !Q_stricmp( cmd, "initwp") ) {
        WaypointInit();
        return qtrue;
    }

    if ( Q_stricmp( cmd, "blibset") == 0 ) {
        char key[MAX_TOKEN_CHARS];
        char value[MAX_TOKEN_CHARS];

        trap_Argv(1, key, sizeof(key) );
        trap_Argv(2, value, sizeof(value) );
        if(!strlen(key))
        {
            G_Printf("missing key\n");
            return qtrue;
        }

        if( !strlen(value) )	// use "1" as default
            strcpy( value, "1" );

        trap_BotLibVarSet( key, value );
        return qtrue;
    }

    if(wopSP_cmdCheck(cmd))
        return qtrue;

    if (g_dedicated.integer) {
        if ( Q_stricmp( cmd, "ssay" ) == 0 ) {
            Svcmd_Say_f();
            return qtrue;
        }
        if ( Q_stricmp( cmd, "stell" ) == 0 ) {
            Svcmd_Tell_f();
            return qtrue;
        }

        if ( Q_stricmp( cmd, "scp" ) == 0 ) {
            Svcmd_ClientCommand_f( CCMD_CP );
            return qtrue;
        }
        if ( Q_stricmp( cmd, "smp" ) == 0 ) {
            Svcmd_ClientCommand_f( CCMD_MP );
            return qtrue;
        }
        if ( Q_stricmp( cmd, "sprint" ) == 0 ) {
            Svcmd_ClientCommand_f( CCMD_PRINT );
            return qtrue;
        }

        // everything else will also be printed to clients
        trap_SendServerCommand( -1, va("print \"server: %s\n\"", ConcatArgs(0) ) );
        return qtrue;
    }

    return qfalse;
}
Esempio n. 22
0
/*
=================
ConsoleCommand

=================
*/
qboolean    ConsoleCommand( void ) {
	char cmd[MAX_TOKEN_CHARS];

	trap_Argv( 0, cmd, sizeof( cmd ) );

	if ( Q_stricmp( cmd, "entitylist" ) == 0 ) {
		Svcmd_EntityList_f();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "forceteam" ) == 0 ) {
		Svcmd_ForceTeam_f();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "game_memory" ) == 0 ) {
		Svcmd_GameMem_f();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "addbot" ) == 0 ) {
		Svcmd_AddBot_f();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "addip" ) == 0 ) {
		Svcmd_AddIP_f();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "removeip" ) == 0 ) {
		Svcmd_RemoveIP_f();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "listip" ) == 0 ) {
		trap_SendConsoleCommand( EXEC_INSERT, "g_banIPs\n" );
		return qtrue;
	}

	if ( Q_stricmp( cmd, "listmaxlivesip" ) == 0 ) {
		PrintMaxLivesGUID();
		return qtrue;
	}


	// NERVE - SMF
	if ( Q_stricmp( cmd, "start_match" ) == 0 ) {
		Svcmd_StartMatch_f();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "reset_match" ) == 0 ) {
		Svcmd_ResetMatch_f();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "swap_teams" ) == 0 ) {
		Svcmd_SwapTeams_f();
		return qtrue;
	}
	// -NERVE - SMF

	if ( g_dedicated.integer ) {
		if ( Q_stricmp( cmd, "say" ) == 0 ) {
			trap_SendServerCommand( -1, va( "print \"server:[lof] %s\"", ConcatArgs( 1 ) ) );
			return qtrue;
		}
		// everything else will also be printed as a say command
		trap_SendServerCommand( -1, va( "print \"server:[lof] %s\"", ConcatArgs( 0 ) ) );
		return qtrue;
	}

	return qfalse;
}
Esempio n. 23
0
void Cmd_Powerup_f( gentity_t * ent ) 
{
    int i = 0;
    int argc = trap_Argc();
    char arg[MAX_TOKEN_CHARS] = "\0";
	char arg2[MAX_TOKEN_CHARS] = "\0";

    if( !ent->client->sess.routeMaker )
    {
        CP("cp \"^7You need to be a route maker to create powerups.\n\"");
        return;
    }

    if(argc < 2)
    {
        CP("print \"usage: ^7powerup [type]\n\"");
        return;
    }
	
    trap_Argv(1, arg, sizeof(arg));

    if(!Q_stricmp(arg, "help"))
    {
        PrintPowerupHelp(ent);
        return;
    }
	
	
	if(!Q_stricmp(arg, "info"))
	{
		trap_Argv(2, arg, sizeof(arg));
		PrintPowerupInfo(ent, arg);
		return;
	}

    // Special case, spawn random pwup
    if(!Q_stricmp(arg, "random"))
    {
        int index = rand() % numPowerups;

        if(powerups[index].spawn && powerups[index].think)
        {
            if(level.numPowerups == MAX_POWERUPS)
            {
                CP("print \"^1error: ^7too many powerups spawned.\n\"");
                return;
            }
            level.powerups[level.numPowerups] = powerups[index].spawn(ent, powerups[index].think);
            level.powerups[level.numPowerups]->powerupType = powerups[index].pw;
            level.powerups[level.numPowerups]->powerupModelType = powerups[index].modelIndex;
            level.numPowerups++;
            CP("cp \"^5Spawned a random powerup\n\"");
        }
        return;
    }

    if(!Q_stricmp(arg, "any"))
    {
        if(level.numPowerups == MAX_POWERUPS)
        {
            CP("print \"^1error: ^7too many powerups spawned.\n\"");
            return;
        }
        level.powerups[level.numPowerups] = SpawnRandomPowerupSpawner( ent );
        level.powerups[level.numPowerups]->powerupType = PW_RANDOM;
        level.powerups[level.numPowerups]->powerupModelType = PW_RANDOM;
        level.numPowerups++;
        CP("cp \"^5Spawned a random powerup\n\"");
        return;
    }

    for(; i < numPowerups; i++)
    {
        if(!Q_stricmp(arg, powerups[i].name))
        {
            if(powerups[i].spawn && powerups[i].think)
            {
                if(level.numPowerups == MAX_POWERUPS)
                {
                    CP("print \"^1error: ^7too many powerups spawned.\n\"");
                    return;
                }
                level.powerups[level.numPowerups] = powerups[i].spawn(ent, powerups[i].think);
                level.powerups[level.numPowerups]->powerupType = powerups[i].pw;
                level.powerups[level.numPowerups]->powerupModelType = powerups[i].modelIndex;
                level.numPowerups++;
                CP(va("cp \"^5Spawned a %s powerup\n\"", powerups[i].text));
            } else
            {
                G_LogPrintf("Undefined powerup: %s\n", arg);
            }
            break;
        }
    }
}
Esempio n. 24
0
// MAPVOTE
void G_IntermissionMapVote(gentity_t *ent)
{
	char arg[MAX_TOKEN_CHARS];

	if (g_gametype.integer != GT_WOLF_MAPVOTE)
	{
		CP(va("print \"^3Map voting not enabled!\n\""));
		return;
	}

	if (g_gamestate.integer != GS_INTERMISSION)
	{
		CP(va("print \"^3Can't vote until intermission\n\""));
		return;
	}

	if (!level.intermissiontime)
	{
		CP(va("print \"^3You can only vote during intermission\n\""));
		return;
	}

	trap_Argv(1, arg, sizeof(arg));
	// normal one-map vote
	if (trap_Argc() == 2)
	{
		if (ent->client->ps.eFlags & EF_VOTED)
		{
			level.mapvoteinfo[ent->client->sess.mapVotedFor[0]].numVotes--;
			level.mapvoteinfo[ent->client->sess.mapVotedFor[0]].totalVotes--;
		}
		ent->client->ps.eFlags |= EF_VOTED;
		level.mapvoteinfo[atoi(arg)].numVotes++;
		level.mapvoteinfo[atoi(arg)].totalVotes++;
		ent->client->sess.mapVotedFor[0] = atoi(arg);
	}
	else if (trap_Argc() == 3)
	{
		char arg2[MAX_TOKEN_CHARS];
		int  voteRank = 0, i;

		trap_Argv(2, arg2, sizeof(arg2));
		voteRank = atoi(arg2);
		if (voteRank < 1 || voteRank > 3)
		{
			return;
		}

		for (i = 0; i < 3; i++)
		{
			if (voteRank - 1 == i)
			{
				continue;
			}
			if (ent->client->sess.mapVotedFor[i] == atoi(arg))
			{
				CP(va("print \"^3Can't vote for the same map twice\n\""));
				return;
			}
		}
		if (ent->client->sess.mapVotedFor[voteRank - 1] != -1)
		{
			level.mapvoteinfo[ent->client->sess.mapVotedFor[voteRank - 1]].numVotes   -= voteRank;
			level.mapvoteinfo[ent->client->sess.mapVotedFor[voteRank - 1]].totalVotes -= voteRank;
		}
		level.mapvoteinfo[atoi(arg)].numVotes      += voteRank;
		level.mapvoteinfo[atoi(arg)].totalVotes    += voteRank;
		ent->client->sess.mapVotedFor[voteRank - 1] = atoi(arg);
		ent->client->ps.eFlags                     |= EF_VOTED;
	}

	// Someone has voted. Send the votetally to all ...
	// Doing it now, so there is no need for players to keep polling for this.
	G_IntermissionVoteTally(NULL);
}
Esempio n. 25
0
static void CG_SetWeaponCrosshair_f( void ) {
	char crosshair[64];

	trap_Argv( 1, crosshair, 64 );
	cg.newCrosshairIndex = atoi( crosshair ) + 1;
}
Esempio n. 26
0
qboolean ProcessFormula(int *values)
{
	int		i, j;
	char	buffer[MAX_TOKEN_CHARS];

	for (i = 0; i < 3 ; i++ )
	{
		int result, len;
		char *exp_p;
		int num_operators[6] = { 0 };
		MathOp root;
		MathOp *cur_pos = &root;


		trap_Argv( i+1, buffer, sizeof( buffer ) );

		// If it's just a plain number use it.
		if(isNumber(buffer,&result))
		{
			values[i] = result;
			continue;
		}

		// Otherwise check if it's a valid expression
		// And let's count supported operators first.
		//len = strlen(buffer);
		//for(j = 0; j < len; j++)
		//{
		//	if(buffer[j] == '+')
		//		num_operators[0]++;
		//	else if(buffer[j] == '-')
		//		num_operators[1]++;
		//	else if(buffer[j] == '*')
		//		num_operators[2]++;
		//	else if(buffer[j] == '/')
		//		num_operators[3]++;
		//	else if(buffer[j] == '(')
		//		num_operators[4]++;
		//	else if(buffer[j] == ')')
		//		num_operators[5]++;
		//}

		// Check if we have a valid starting point
		if(!(VALID_START & FormulaType(buffer[0])) && buffer[0] != '-')
			return qfalse;

		// Initialize the root node.
		root.pos = 0;
		root.left = root.right = root.back = NULL;
		root.value = -1;


		len = strlen(buffer);
		for(j = 0; j < len; j++)
		{
			// Check for value.
			if(FormulaType(buffer[j]) == VALUE || buffer[j] == '-')		// [FIXME]
			{
				// Read the full value.
				char full_value[256] = { 0 };
				int pos = 0;
				while((buffer[j] >= '0' && buffer[j] <= '9') || buffer[j] == '-' )
					full_value[pos++] = buffer[j++];

				cur_pos->type = VALUE;
				cur_pos->value = atoi(full_value);
			}
			// Check for parenthesis.
			else if(FormulaType(buffer[j]) == BRACK_LEFT)
			{
				cur_pos->type = BRACK_LEFT;
				if(!cur_pos->pos)
				{
					cur_pos->left = (MathOp*)malloc(sizeof(MathOp));
					cur_pos->left->back = cur_pos;
					cur_pos->pos++;
					cur_pos = cur_pos->left;
				}
				else
				{
					cur_pos->right = (MathOp*)malloc(sizeof(MathOp));
					cur_pos->right->back = cur_pos;
					cur_pos->pos++;
					cur_pos = cur_pos->right;
				}
			}
			else if(FormulaType(buffer[j]) == BRACK_RIGHT)
			{
				if(cur_pos->back->pos != 2)	// This means the expression is malformed: 5 + (5 *) for example.
					return qfalse;

				cur_pos = cur_pos->back;
			}
			else if(FormulaType(buffer[j]) == ADD)
			{
				// 5+5
				if(!cur_pos)				// Malformed: (+5
					return qfalse;

			}
		}

		exp_p = buffer;
		while(1)
		{
			// 5+5
			// 5+(5*4)
			
		}

	}
	return qtrue;
}
void Svcmd_CamCmd( void ) {
    char buf[MAX_TOKEN_CHARS];
    char cmd[MAX_TOKEN_CHARS];
    char name[MAX_TOKEN_CHARS];
    int i;
    gclient_t* cl;

    if( !level.cammode ) {
        return;
    }

    if( trap_Argc() < 2 ) {
        return;
    }

    trap_Argv( 1, cmd, sizeof(cmd) );

    if ( !Q_stricmp (cmd, "print")  )
    {
        trap_Argv( 2, buf, sizeof(buf) );
        trap_SendServerCommand( -1, va("cp \"%s\n\"", buf ) );
    }
    else if( !Q_stricmp (cmd, "setclientpos") ) {
        vec3_t	newOrigin;

        if( trap_Argc() != 8 && trap_Argc() != 6 ) {
            Com_Printf("usage: camcmd setclientpos name/id x y z (a b) \na = PITCH-angle, b = YAW-angle\n");
            return;
        }

        trap_Argv( 2, name, sizeof( name ) );

        cl = ClientForString( name ) ;
        if(!cl)
            return;

        for( i=0; i<3; i++) {
            trap_Argv( i+3, buf, sizeof( buf) );
            newOrigin[i] = atof( buf );
        }

        G_SetOrigin( &g_entities[cl->ps.clientNum], newOrigin );
        VectorCopy( newOrigin, cl->ps.origin );

        if(trap_Argc() == 8) {
            vec3_t	newAngles;

            memset(newAngles,0,sizeof(newAngles));
            trap_Argv( 6, buf, sizeof( buf ) );
            newAngles[PITCH] = atoi(buf);
            trap_Argv( 7, buf, sizeof( buf ) );
            newAngles[YAW] = atoi(buf);

            SetClientViewAngle( &g_entities[cl->ps.clientNum], newAngles );
        }
    }
    else if( !Q_stricmp (cmd, "setspawn")  )
    {
        if( trap_Argc() != 8 ) {
            Com_Printf("usage: camcmd setspawn x y z a b c \n");
            return;
        }

        for( i=0; i<3; i++) {
            trap_Argv( i+2, buf, sizeof(buf) );
            level.cam_spawnpos[i] = atof(buf);
        }
        for( i=0; i<3; i++) {
            trap_Argv( i+5, buf, sizeof(buf) );
            level.cam_spawnangles[i] = atof(buf);
        }
    }
    else if( !Q_stricmp (cmd, "botmove")  )
    {
        vec3_t pos;

        if( trap_Argc() != 6 ) {
            Com_Printf("usage: camcmd botmove name x y z \n");
            return;
        }

        trap_Argv( 2, name, sizeof( name ) );

        for( i=0; i<3; i++) {
            trap_Argv( i+3, buf, sizeof( buf) );
            pos[i] = atof( buf );
        }

        cl = ClientForString( name ) ;
        if(!cl)
            return;
        BotCamMoveTo( cl->ps.clientNum, pos );
    }
    else if( !Q_stricmp (cmd, "botviewangles")  )
    {
        vec3_t angles;

        if( trap_Argc() != 5 ) {
            Com_Printf("usage: camcmd botviewangles name x y \n");
            return;
        }

        trap_Argv( 2, name, sizeof( name ) );
        cl = ClientForString( name ) ;
        if(!cl)
            return;
        trap_Argv( 3, buf, sizeof( buf ) );
        angles[PITCH] = atoi(buf);
        trap_Argv( 4, buf, sizeof( buf ) );
        angles[YAW] = atoi(buf);

        BotCamViewangles( cl->ps.clientNum, angles );
    }
    else if( !Q_stricmp (cmd, "botviewtarget")  )
    {
        vec3_t target;

        if( trap_Argc() != 6 ) {
            Com_Printf("usage: camcmd botviewtarget name x y z \n");
            return;
        }

        trap_Argv( 2, name, sizeof( name ) );
        cl = ClientForString( name ) ;
        if(!cl)
            return;
        trap_Argv( 3, buf, sizeof( buf ) );
        target[0] = atoi(buf);
        trap_Argv( 4, buf, sizeof( buf ) );
        target[1] = atoi(buf);
        trap_Argv( 5, buf, sizeof( buf ) );
        target[2] = atoi(buf);

        BotCamViewTarget( cl->ps.clientNum, target );
    }
    else if( !Q_stricmp (cmd, "botviewentity")  )
    {
//		int target_bot;
        gclient_t* target_cl;
        if( trap_Argc() != 4 ) {
            Com_Printf("usage: camcmd botviewentity name targetname \n");
            return;
        }

        trap_Argv( 2, name, sizeof( name ) );
        cl = ClientForString( name ) ;
        if(!cl)
            return;

        trap_Argv( 3, buf, sizeof( buf ) );
        target_cl = ClientForString( buf );
        if(!target_cl)
            return;
        BotCamViewEntitiy( cl->ps.clientNum, target_cl->ps.clientNum );

    }
    else if( !Q_stricmp (cmd, "boteditinv")  )
    {
        if( trap_Argc() < 3)
            return;
        trap_Argv( 2, name, sizeof(name) );
        cl = ClientForString( name );
        if( !cl ) return;
        EditPlayerInventory( &g_entities[cl->ps.clientNum], 3 );
    }
    else if( !Q_stricmp (cmd, "botchooseweap")  )
    {
        if( trap_Argc() != 4 ) {
            Com_Printf("usage: camcmd botchooseweap name weapID \n");
            return;
        }
        trap_Argv( 2, name, sizeof( name ) );
        cl = ClientForString( name ) ;
        if(!cl)
            return;
        trap_Argv( 3, buf, sizeof( buf ) );
        BotChooseWeap( cl->ps.clientNum, atoi(buf) );
    }
    else if( !Q_stricmp (cmd, "bottaunt")  )
    {
        if( trap_Argc() != 3 ) {
            Com_Printf("usage: camcmd bottaunt name \n");
            return;
        }
        trap_Argv( 2, name, sizeof( name ) );
        cl = ClientForString( name ) ;
        if(!cl)
            return;

        BotCamTaunt( cl->ps.clientNum );
    }
    else if( !Q_stricmp(cmd, "botfire") )
    {
        if( trap_Argc() != 3 ) {
            Com_Printf("usage: camcmd botfire name \n");
            return;
        }
        trap_Argv( 2, name, sizeof( name ) );
        cl = ClientForString( name ) ;
        if(!cl)
            return;

        BotCamFire( cl->ps.clientNum );
    }
    else if( !Q_stricmp(cmd, "freeze") ) {
        int on;


        if( trap_Argc() != 3 ) {
            Com_Printf("usage: camcmd freeze [0|1] \n");
            return;
        }
        trap_Argv( 2, name, sizeof( name ) );

        on = atoi( name );
        FreezePlayers( on );
    }

}
Esempio n. 28
0
/*
=================
ConsoleCommand

=================
*/
qboolean	ConsoleCommand( void ) {
	char	cmd[MAX_TOKEN_CHARS];

	trap_Argv( 0, cmd, sizeof( cmd ) );

	if ( Q_stricmp (cmd, "entitylist") == 0 ) {
		Svcmd_EntityList_f();
		return qtrue;
	}

	if ( Q_stricmp (cmd, "forceteam") == 0 ) {
		Svcmd_ForceTeam_f();
		return qtrue;
	}

	if (Q_stricmp (cmd, "game_memory") == 0) {
		Svcmd_GameMem_f();
		return qtrue;
	}

	if (Q_stricmp (cmd, "addbot") == 0) {
		Svcmd_AddBot_f();
		return qtrue;
	}

	if (Q_stricmp (cmd, "botlist") == 0) {
		Svcmd_BotList_f();
		return qtrue;
	}

/*	if (Q_stricmp (cmd, "abort_podium") == 0) {
		Svcmd_AbortPodium_f();
		return qtrue;
	}
*/
	if (Q_stricmp (cmd, "addip") == 0) {
		Svcmd_AddIP_f();
		return qtrue;
	}

	if (Q_stricmp (cmd, "removeip") == 0) {
		Svcmd_RemoveIP_f();
		return qtrue;
	}

	if (Q_stricmp (cmd, "listip") == 0) {
		trap_SendConsoleCommand( EXEC_NOW, "g_banIPs\n" );
		return qtrue;
	}

	if (g_dedicated.integer) {
		if (Q_stricmp (cmd, "say") == 0) {
			trap_SendServerCommand( -1, va("print \"server: %s\n\"", ConcatArgs(1) ) );
			return qtrue;
		}
		// everything else will also be printed as a say command
		trap_SendServerCommand( -1, va("print \"server: %s\n\"", ConcatArgs(0) ) );
		return qtrue;
	}

	return qfalse;
}
Esempio n. 29
0
void G_ParseCampaigns(void)
{
	int      i;
	qboolean mapFound = qfalse;

	level.campaignCount   = 0;
	level.currentCampaign = -1;
	memset(&g_campaigns, 0, sizeof(g_campaignInfo_t) * MAX_CAMPAIGNS);

	if (g_gametype.integer != GT_WOLF_CAMPAIGN)
	{
		trap_Cvar_Set("g_oldCampaign", "");
		trap_Cvar_Set("g_currentCampaign", "");
		trap_Cvar_Set("g_currentCampaignMap", "0");
		return;
	}

	if (g_campaignFile.string[0])
	{
		if (G_LoadCampaignsFromFile(g_campaignFile.string))
		{
			mapFound = qtrue;
		}
	}

	if (!mapFound)
	{
		// get all campaigns from .campaign files
		int  dirlen;
		int  numdirs = trap_FS_GetFileList("scripts", ".campaign", bigTextBuffer, sizeof(bigTextBuffer));
		char filename[MAX_QPATH]; // was 128
		char *dirptr = bigTextBuffer;

		for (i = 0; i < numdirs; i++, dirptr += dirlen + 1)
		{
			// log a warning if server has more than MAX_CAMPAIGNS
			if (level.campaignCount >= MAX_CAMPAIGNS)
			{
				G_LogPrintf("WARNING G_ParseCampaigns: number of campaigns larger then MAX_CAMPAIGNS\n");
				break;
			}

			dirlen = strlen(dirptr);
			strcpy(filename, "scripts/");
			strcat(filename, dirptr);

			if (G_LoadCampaignsFromFile(filename))
			{
				mapFound = qtrue;
			}
		}
	}

	if (!mapFound)
	{
		// map isn't found in the current campaign, see if it's the first map in another campaign
		for (i = 0; i < level.campaignCount; i++)
		{
			if (!Q_stricmp(g_campaigns[i].mapnames[0], level.rawmapname))
			{
				// someone manually specified a /map command, and it's the first map in a campaign
				trap_Cvar_Set("g_currentCampaign", g_campaigns[i].shortname);
				trap_Cvar_Set("g_currentCampaignMap", "0");

				level.newCampaign = qtrue;

				g_campaigns[level.campaignCount].current = 0;
				level.currentCampaign                    = i;

				break;
			}
		}

		if (i == level.campaignCount)
		{
			char buf[MAX_STRING_CHARS];

			if (trap_Argc() < 1) // command not found, throw error
			{
				G_Error("Usage 'map <mapname>\n'");
			}

			trap_Argv(0, buf, sizeof(buf));

			if (!(*buf)) // command not found, throw error
			{
				G_Error("Usage 'map <mapname>\n'");
			}

			// no campaign found, fallback to GT_WOLF
			// and reload the map
			trap_Cvar_Set("g_gametype", "2");
			trap_SendConsoleCommand(EXEC_APPEND, va("%s %s\n", buf, level.rawmapname));
		}
	}
}
Esempio n. 30
0
/*
=================
ConsoleCommand

=================
*/
qboolean	ConsoleCommand( void ) {
	char	cmd[MAX_TOKEN_CHARS];

	trap_Argv( 0, cmd, sizeof( cmd ) );

	//	all commands prefixed with st_ are destined for the rules engine.
	if (	cmd[ 0 ] == 's' &&
			cmd[ 1 ] == 't' &&
			cmd[ 2 ] == '_' )
	{
		if ( G_ST_exec( ST_CONSOLECOMMAND, cmd+3 ) )
			return qtrue;
	}

	switch( SWITCHSTRING( cmd ) )
	{
#ifdef DEVELOPER
	case CS('b','u','y',0):
	case CS('s','e','l','l'):
	case CS('v','i','s','i'):
	case CS('b','e','g','i'):
	case CS('a','s','s','e'):
	case CS('i','n','t','e'):
	case CS('e','n','d','i'):
	case CS('l','o','o','k'):
	case CS('p','l','a','n'):
		G_ST_exec( ST_CLIENTCOMMAND, 0, cmd );
		trap_SendConsoleCommand( EXEC_INSERT, "wait 50 ;" );
		return qtrue;

		//	cl0_
	case CS('c','l','0','_'):
		ClientCommand( 0, cmd + 4 );
		return 0;
#endif

		//	entitylist
	case CS('e','n','t','i'):
		Svcmd_EntityList_f();
		return qtrue;

		//	forceteam
	case CS('f','o','r','c'):
		Svcmd_ForceTeam_f();
		return qtrue;

		//	game_memory
	case CS('g','a','m','e'):
		Svcmd_GameMem_f();
		return qtrue;

		//	addbot
	case CS('a','d','d','b'):
		Svcmd_AddBot_f();
		return qtrue;

		//	botlist
	case CS('b','o','t','l'):
		Svcmd_BotList_f();
		return qtrue;

		//	addip
	case CS('a','d','d','i'):
		Svcmd_AddIP_f();
		return qtrue;

		//	removeip
	case CS('r','e','m','o'):
		Svcmd_RemoveIP_f();
		return qtrue;

		//	listip
	case CS('l','i','s','t'):
		trap_SendConsoleCommand( EXEC_NOW, "g_banIPs\n" );
		return qtrue;

		//	abort
	case CS('a','b','o','r'):
		G_ST_exec( ST_CONSOLECOMMAND, cmd );
		return qtrue;
	}

	if (g_dedicated.integer) {
		if (Q_stricmp (cmd, "say") == 0) {

			trap_SendServerCommand( -1, va("print \"server: %s\"", ConcatArgs(1) ) );
			return qtrue;
		}
		// everything else will also be printed as a say command
		trap_SendServerCommand( -1, va("print \"server: %s\"", ConcatArgs(0) ) );
		return qtrue;
	}

	return qfalse;
}