示例#1
0
/*
=================
ConsoleCommand

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

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

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

  if( !command )
  {
    // see if this is an admin command
    if( G_admin_cmd_check( NULL ) )
      return qtrue;

    if( g_dedicated.integer )
      G_Printf( "unknown command: %s\n", cmd );

    return qfalse;
  }

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

  command->function( );
  return qtrue;
}
示例#2
0
/*
=================
ConsoleCommand

=================
*/
bool  ConsoleCommand()
{
    char         cmd[ MAX_TOKEN_CHARS ];
    struct svcmd *command;

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

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

    if ( !command )
    {
        // see if this is an admin command
        if ( G_admin_cmd_check( nullptr ) )
        {
            return true;
        }

        if ( level.inClient )
        {
            G_Printf( "unknown command server console command: %s\n", cmd );
        }

        return false;
    }

    if ( command->conflicts && level.inClient )
    {
        return false;
    }

    command->function();
    return true;
}