Example #1
0
/*
=================
CG_ConsoleCommand

The string has been tokenized and can be retrieved with
Cmd_Argc() / Cmd_Argv()
=================
*/
qboolean CG_ConsoleCommand( connstate_t state, int realTime ) {
	char		buffer[BIG_INFO_STRING];
	const char	*cmd;
	int		i;
	int		localPlayerNum;
	const char	*baseCmd;

	cg.connState = state;

	// update UI frame time
	UI_ConsoleCommand( realTime );

	cmd = CG_Argv(0);

	localPlayerNum = Com_LocalPlayerForCvarName( cmd );
	baseCmd = Com_LocalPlayerBaseCvarName( cmd );

	for ( i = 0 ; i < numPlayerCommands ; i++ ) {
		if ( !Q_stricmp( baseCmd, playerCommands[i].cmd )) {
			if ( CG_CheckCmdFlags( cmd, playerCommands[i].flags ) ) {
				return qtrue;
			}
			playerCommands[i].function( localPlayerNum );
			return qtrue;
		}
	}

	if ( localPlayerNum == 0 ) {
		if ( CG_CheckCommands( cg_commands, cg_numCommands, cmd ) ) {
			return qtrue;
		}

		if ( CG_CheckCommands( ui_commands, ui_numCommands, cmd ) ) {
			return qtrue;
		}
	}

	if ( cg.connected && trap_GetDemoState() != DS_PLAYBACK ) {
		// the game server will interpret these commands
		trap_LiteralArgs( buffer, sizeof ( buffer ) );
		trap_SendClientCommand( buffer );
		return qtrue;
	}

	return qfalse;
}
Example #2
0
/*
=================
G_ConsoleCompleteArgument

=================
*/
qboolean	G_ConsoleCompleteArgument( int completeArgument ) {
	char	args[BIG_INFO_STRING];
	char	cmd[MAX_TOKEN_CHARS];
	struct	svcmd *command;

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

	command = bsearch( cmd, svcmds, numSvCmds, sizeof( struct svcmd ), cmdcmp );

	if( !command || !command->complete )
		return qfalse;

	if( command->dedicated && !g_dedicated.integer )
		return qfalse;

	trap_LiteralArgs( args, sizeof ( args ) );

	command->complete( args, completeArgument );
	return qtrue;
}
Example #3
0
/*
=================
CG_ConsoleCommand

The string has been tokenized and can be retrieved with
Cmd_Argc() / Cmd_Argv()
=================
*/
qboolean CG_ConsoleCommand( void )
{
	char buffer[BIG_INFO_STRING];
	consoleCommand_t *cmd;

	cmd = (consoleCommand_t*) bsearch( CG_Argv( 0 ), commands,
	               ARRAY_LEN( commands ), sizeof( commands[ 0 ] ),
	               cmdcmp );

	if ( !cmd || !cmd->function )
	{
		//This command was added to provide completion of server-side commands
		//forward it to the server
		// (see also CG_ServerCommands)
		trap_LiteralArgs( buffer, sizeof ( buffer ) );
		trap_SendClientCommand( buffer );
	}
	else
	{
		cmd->function();
	}
	return qtrue;
}