Exemplo n.º 1
0
/*
============
Cmd_ExecuteString

A complete command line has been parsed, so try to execute it
============
*/
void	Cmd_ExecuteString( const char *text ) {	
	cmd_function_t	*cmd, **prev;

	// execute the command line
	Cmd_TokenizeString( text );		
	if ( !Cmd_Argc() ) {
		return;		// no tokens
	}

	// check registered command functions	
	for ( prev = &cmd_functions ; *prev ; prev = &cmd->next ) {
		cmd = *prev;
		if ( !Q_stricmp( Cmd_Argv(0), cmd->name ) ) {
			// rearrange the links so that the command will be
			// near the head of the list next time it is used
			*prev = cmd->next;
			cmd->next = cmd_functions;
			cmd_functions = cmd;

			// perform the action
			if ( !cmd->function ) {
				// let the cgame or game handle it
				break;
			} else {
				cmd->function ();
			}
			return;
		}
	}
	
	// check cvars
	if ( Cvar_Command() ) {
		return;
	}

	// check client game commands
	if ( com_cl_running && com_cl_running->integer && CL_GameCommand() ) {
		return;
	}

	// check server game commands
	if ( com_sv_running && com_sv_running->integer && SV_GameCommand() ) {
		return;
	}

	// check ui commands
	if ( com_cl_running && com_cl_running->integer && UI_GameCommand() ) {
		return;
	}

	// send it as a server command if we are connected
	// this will usually result in a chat message
	//CL_ForwardCommandToServer ( text );
	CL_ForwardCommandToServer ( text );
}
Exemplo n.º 2
0
/*
============
Cmd_ExecuteString

A complete command line has been parsed, so try to execute it
============
*/
void	Cmd_ExecuteString( const char *text ) {	

	// execute the command line
	Cmd_TokenizeString( text );		
	if ( !Cmd_Argc() ) {
		return;		// no tokens
	}

	// check registered command functions	
	for ( int c = 0; c < CMD_MAX_NUM; ++c )
	{
		if ( !Q_stricmp( cmd_argv[0],cmd_functions[c].name ) ) {
			// rearrange the links so that the command will be
			// near the head of the list next time it is used
			cmd_function_t temp = cmd_functions[c];
			cmd_functions[c] = cmd_functions[0];
			cmd_functions[0] = temp;

			// perform the action
			if ( !temp.function ) {
				// let the cgame or game handle it
				break;
			} else {
				temp.function ();
			}
			return;
		}
	}
	
	// check cvars
	if ( Cvar_Command() ) {
		return;
	}

	// check client game commands
	if ( com_cl_running && com_cl_running->integer && CL_GameCommand() ) {
		return;
	}

	// check server game commands
	if ( com_sv_running && com_sv_running->integer && SV_GameCommand() ) {
		return;
	}

	// check ui commands
	if ( com_cl_running && com_cl_running->integer && UI_GameCommand() ) {
		return;
	}

	// send it as a server command if we are connected
	// this will usually result in a chat message
	CL_ForwardCommandToServer ();
}
Exemplo n.º 3
0
/*
============
Cmd_ExecuteString

A complete command line has been parsed, so try to execute it
============
*/
void	Cmd_ExecuteString( const char *text )
{
	cmd_function_t	*cmd, **prev;
	char arg0[MAX_TOKEN_CHARS];
#ifdef PUNKBUSTER
	/* Trap commands going to PunkBuster here */
	if(!Q_stricmpn(text, "pb_sv_", 6))
	{
		if(gamebinary_initialized == qtrue)
			PbSvAddEvent(14, -1, strlen(text), (char*)text);
		
		return;
	}
#endif
	// execute the command line
	Cmd_TokenizeString( text );		
	if ( !Cmd_Argc() ) {
		Cmd_EndTokenizedString( );
		return;		// no tokens
	}

	Q_strncpyz(arg0, Cmd_Argv(0), sizeof(arg0));
	
	//Legacy fallback
	if(!Q_stricmpn(arg0, "dvar", 4))
	{
		arg0[0] = 'c';
	}else if(!Q_stricmpn(arg0, "auth", 4)){
		if(!Q_stricmp(arg0, "authChangePassword"))
		{
			Q_strncpyz(arg0, "changePassword", sizeof(arg0));
			Com_PrintWarning("\"authchangePassword\" is deprecated and will be removed soon. Use \"changePassword\" instead\n");
		}
		else if(!Q_stricmp(arg0, "authSetAdmin"))
		{
			Q_strncpyz(arg0, "AdminAddAdminWithPassword", sizeof(arg0));
			Com_PrintWarning("\"authSetAdmin\" is deprecated and will be removed soon. Use \"AdminAddAdminWithPassword\" instead\n");
		}
		else if(!Q_stricmp(arg0, "authUnsetAdmin"))
		{
			Q_strncpyz(arg0, "AdminRemoveAdmin", sizeof(arg0));
			Com_PrintWarning("\"authUnsetAdmin\" is deprecated and will be removed soon. Use \"AdminRemoveAdmin\" instead\n");
		}
		else if(!Q_stricmp(arg0, "authListAdmins"))
		{
			Q_strncpyz(arg0, "adminListAdmins", sizeof(arg0));
			Com_PrintWarning("\"authListAdmins\" is deprecated and will be removed soon. Use \"adminListAdmins\" instead\n");
		}
	}else if(!Q_stricmp(arg0, "cmdpowerlist")){
		Q_strncpyz(arg0, "AdminListCommands", sizeof(arg0));
		Com_PrintWarning("\"cmdpowerlist\" is deprecated and will be removed soon. Use \"AdminListCommands\" instead\n");
	}
	else if(!Q_stricmp(arg0, "setCmdMinPower")){
		Q_strncpyz(arg0, "AdminChangeCommandPower", sizeof(arg0));
		Com_PrintWarning("\"setCmdMinPower\" is deprecated and will be removed soon. Use \"AdminChangeCommandPower\" instead\n");
	}
	// check registered command functions	
	for ( prev = &cmd_functions ; *prev ; prev = &cmd->next ) {
		cmd = *prev;
		if ( !Q_stricmp( arg0, cmd->name ) ) {
			// rearrange the links so that the command will be
			// near the head of the list next time it is used
			*prev = cmd->next;
			cmd->next = cmd_functions;
			cmd_functions = cmd;

			// perform the action
			if ( !cmd->function ) {
				// let the cgame or game handle it
				break;
			} else {
				cmd->function ();
			}
			Cmd_EndTokenizedString( );
			return;
		}
	}
	
	// check cvars
	if ( Cvar_Command() ) {
		Cmd_EndTokenizedString( );
		return;
	}

	// check server game commands
	if ( com_sv_running && com_sv_running->boolean && SV_GameCommand() ) {
		Cmd_EndTokenizedString( );
		return;
	}

	Cmd_EndTokenizedString( );

	if(!Q_stricmpn(arg0, "bind", 4))
		return;

	if(!Q_stricmpn(arg0, "unbindall", 9))
		return;

	if(!Q_stricmpn(arg0, "con_showchannel", 15))
		return;

	Com_Printf("Bad command or cvar: %s\n", arg0);
}