/* ============ Cmd_ExecuteString A complete command line has been parsed, so try to execute it ============ */ void Cmd_ExecuteString( char *text, cmd_source_t src ) { qboolean isServerCommand = false; qboolean isDLLCommand = false; cmd_function_t *cmd; cmdalias_t *a; // set cmd source cmd_source = src; // execute the command line Cmd_TokenizeString( text ); if( !Cmd_Argc()) return; // no tokens // check alias for( a = cmd_alias; a; a = a->next ) { if( !Q_stricmp( cmd_argv[0], a->name )) { Cbuf_InsertText( a->value ); return; } } // check functions for( cmd = cmd_functions; cmd; cmd = cmd->next ) { if( cmd && !Q_stricmp( cmd_argv[0], cmd->name ) && cmd->function ) { cmd->function(); return; } } // check cvars if( Cvar_Command( )) return; // forward the command line to the server, so the entity DLL can parse it if( cmd_source == src_command && host.type == HOST_NORMAL ) { if( cls.state >= ca_connected ) { Cmd_ForwardToServer(); return; } } else if( text[0] != '@' && host.type == HOST_NORMAL ) { // commands with leading '@' are hidden system commands MsgDev( D_INFO, "Unknown command \"%s\"\n", text ); } }
VISIBLE int Cmd_Command (cbuf_args_t *args) { cmd_function_t *cmd; cmd_args = args; //cmd_source = src; if (!args->argc) return 0; // no tokens // check functions cmd = (cmd_function_t *) Hash_Find (cmd_hash, args->argv[0]->str); if (cmd) { if (cmd->function) { cmd->function (); } return 0; } // check cvars if (Cvar_Command ()) return 0; if (cbuf_active->unknown_command && cbuf_active->unknown_command ()) return 0; if (cbuf_active->strict) return -1; else if (cmd_warncmd->int_val || developer->int_val & SYS_DEV) Sys_Printf ("Unknown command \"%s\"\n", Cmd_Argv (0)); return 0; }
/* =============== Cmd_Exec_f =============== */ void Cmd_Exec_f (void) { char *f; int mark; if (Cmd_Argc () != 2) { Con_Printf ("exec <filename> : execute a script file\n"); return; } // FIXME: is this safe freeing the hunk here??? mark = Hunk_LowMark (); f = (char *)COM_LoadHunkFile (Cmd_Argv(1)); if (!f) { Con_Printf ("couldn't exec %s\n",Cmd_Argv(1)); return; } if (!Cvar_Command () && (cl_warncmd.value || developer.value)) Con_Printf ("execing %s\n",Cmd_Argv(1)); Cbuf_InsertText (f); Hunk_FreeToLowMark (mark); }
/* * A complete command line has been parsed, so try to execute it */ void Cmd_ExecuteString(char *text) { cmd_function_t *cmd; cmdalias_t *a; Cmd_TokenizeString(text, true); /* execute the command line */ if (!Cmd_Argc()) { return; /* no tokens */ } /* check functions */ for (cmd = cmd_functions; cmd; cmd = cmd->next) { if (!Q_strcasecmp(cmd_argv[0], cmd->name)) { if (!cmd->function) { /* forward to server command */ Cmd_ExecuteString(va("cmd %s", text)); } else { cmd->function(); } return; } } /* check alias */ for (a = cmd_alias; a; a = a->next) { if (!Q_strcasecmp(cmd_argv[0], a->name)) { if (++alias_count == ALIAS_LOOP_COUNT) { Com_Printf("ALIAS_LOOP_COUNT\n"); return; } Cbuf_InsertText(a->value); return; } } /* check cvars */ if (Cvar_Command()) { return; } #ifndef DEDICATED_ONLY /* send it as a server command if we are connected */ Cmd_ForwardToServer(); #endif }
void CL_R_DrawViewModel_f (void) { extern cvar_t cl_filterdrawviewmodel; if (cl_filterdrawviewmodel.value) return; Cvar_Command (); }
/* ----------------------------------------------------------------------------- Function: Cmd_ExecuteString -Execute command string. Parameters: text -[in] text string to execute. Returns: Nothing. Notes: A complete command line has been parsed, so try to execute it FIXME: lookupnoadd the token to speed search? ----------------------------------------------------------------------------- */ PUBLIC void Cmd_ExecuteString( char *text ) { cmd_function_t *cmd; cmdalias_t *a; W32 hashid; Cmd_TokenizeString( text, true ); // execute the command line if( ! Cmd_Argc() ) { return; // no tokens } hashid = my_strhash( cmd_argv[ 0 ] ); // check functions for( cmd = cmd_functions ; cmd ; cmd = cmd->next ) { if( hashid == cmd->id ) { if( ! cmd->function ) { // forward to server command Cmd_ExecuteString( va( "cmd %s", text ) ); } else { cmd->function(); } return; } } // check alias for( a = cmd_alias ; a ; a = a->next ) { if( ! my_stricmp( cmd_argv[ 0 ], a->name ) ) { if( ++alias_count == ALIAS_LOOP_COUNT ) { Com_Printf( "ALIAS_LOOP_COUNT\n" ); return; } Cbuf_InsertText( a->value ); return; } } // check cvars if( Cvar_Command() ) { return; } // send it as a server command if we are connected // Cmd_ForwardToServer(); }
/* ============ 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 ); }
/* ============ 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 (); }
/** * @brief A complete command line has been parsed, so try to execute it * @todo lookupnoadd the token to speed search? */ void Cmd_ExecuteString (const char *text) { const cmd_function_t *cmd; const cmd_alias_t *a; const char *str; unsigned int hash; Com_DPrintf(DEBUG_COMMANDS, "ExecuteString: '%s'\n", text); Cmd_TokenizeString(text, qtrue); /* execute the command line */ if (!Cmd_Argc()) /* no tokens */ return; str = Cmd_Argv(0); /* check functions */ hash = Com_HashKey(str, CMD_HASH_SIZE); for (cmd = cmd_functions_hash[hash]; cmd; cmd = cmd->hash_next) { if (!Q_strcasecmp(str, cmd->name)) { if (!cmd->function) { /* forward to server command */ Cmd_ExecuteString(va("cmd %s", text)); } else { cmd_userdata = cmd->userdata; cmd->function(); } return; } } /* check alias */ hash = Com_HashKey(str, ALIAS_HASH_SIZE); for (a = cmd_alias_hash[hash]; a; a = a->hash_next) { if (!Q_strcasecmp(str, a->name)) { if (++alias_count == ALIAS_LOOP_COUNT) { Com_Printf("ALIAS_LOOP_COUNT\n"); return; } Cbuf_InsertText(a->value); return; } } /* check cvars */ if (Cvar_Command()) return; /* send it as a server command if we are connected */ Cmd_ForwardToServer(); }
void Cmd_ExecuteString (const char *text) { cmd_function_t *cmd; cmd_alias_t *a; int key; static char buf[1024]; Cmd_ExpandString (text, buf); Cmd_TokenizeString (buf); // execute the command line if (!Cmd_Argc()) return; // no tokens key = Com_HashKey (cmd_argv[0]); // check functions for (cmd=cmd_hash_array[key] ; cmd ; cmd=cmd->hash_next) { if (!strcasecmp (cmd_argv[0], cmd->name)) { if (cmd->function) cmd->function (); return; } } // check cvars if (Cvar_Command()) return; // check alias for (a=cmd_alias_hash[key] ; a ; a=a->hash_next) { if (!strcasecmp (cmd_argv[0], a->name)) { Cbuf_InsertText ("\n"); Cbuf_InsertText (a->value); return; } } if (PR_ConsoleCmd()) return; Con_Printf ("Unknown command \"%s\"\n", Cmd_Argv(0)); }
/* ============ Cmd_ExecuteString A complete command line has been parsed, so try to execute it FIXME: lookupnoadd the token to speed search? ============ */ void Cmd_ExecuteString (char *text) { cmd_function_t *cmd; cmdalias_t *a; Cmd_TokenizeString (text); // execute the command line if (!Cmd_Argc()) return; // no tokens // check functions for (cmd=cmd_functions ; cmd ; cmd=cmd->next) { if (!Q_strcasecmp (cmd_argv[0],cmd->name)) { if (!strcmp(cmd->name, "kill")) { if ((trace_state == read_trace || trace_state == write_trace)) { trace_state = stop_trace; printf("GAJA: command = kill\n"); } } if (!cmd->function) Cmd_ForwardToServer (); else cmd->function (); return; } } // check alias for (a=cmd_alias ; a ; a=a->next) { if (!Q_strcasecmp (cmd_argv[0], a->name)) { Cbuf_InsertText (a->value); return; } } // check cvars if (!Cvar_Command () && (cl_warncmd.value || developer.value)) Con_Printf ("Unknown command \"%s\"\n", Cmd_Argv(0)); }
void EXT_FUNC Cmd_ExecuteString_internal(const char* cmdName, cmd_source_t src, IGameClient* client) { // Search in functions cmd_function_t *cmd = cmd_functions; while (cmd) { if (!Q_stricmp(cmd_argv[0], cmd->name)) { cmd->function(); if (g_pcls.demorecording && (cmd->flags & FCMD_HUD_COMMAND) && !g_pcls.spectator) { CL_RecordHUDCommand(cmd->name); } return; } cmd = cmd->next; } // Search in aliases cmdalias_t *a = cmd_alias; while (a) { if (!Q_stricmp(cmd_argv[0], a->name)) { Cbuf_InsertText(a->value); return; } a = a->next; } // Search in cvars if (!Cvar_Command() && g_pcls.state >= ca_connected) { // Send to a server if nothing processed locally and connected Cmd_ForwardToServer(); } }
/* ============ Cmd_ExecuteString A complete command line has been parsed, so try to execute it FIXME: lookupnoadd the token to speed search? ============ */ void Cmd_ExecuteString (char *text, cmd_source_t src) { cmd_function_t *cmd; cmdalias_t *a; cmd_source = src; Cmd_TokenizeString (text); // execute the command line if (!Cmd_Argc()) return; // no tokens // check functions for (cmd=cmd_functions ; cmd ; cmd=cmd->next) { if (!Q_strcasecmp (cmd_argv[0],cmd->name)) { cmd->function (); return; } } // check alias for (a=cmd_alias ; a ; a=a->next) { if (!Q_strcasecmp (cmd_argv[0], a->name)) { Cbuf_InsertText (a->value); return; } } // check cvars if (!Cvar_Command ()) Con_Printf ("Unknown command \"%s\"\n", Cmd_Argv(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(!com.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 ) Cmd_ExecuteString( va( "cmd %s", text )); else cmd->function(); return; } } // check cvars if( Cvar_Command()) return; if( Sys.app_name == HOST_NORMAL && Sys.CmdFwd ) { // all unrecognized commands will be forwarded to a server Sys.CmdFwd(); } else Msg( "Unknown command \"%s\"\n", text ); }
static void Cmd_Exec_f (void) { char *f; int mark; if (Cmd_Argc () != 2) { Sys_Printf ("exec <filename> : execute a script file\n"); return; } mark = Hunk_LowMark (); f = (char *) QFS_LoadHunkFile (Cmd_Argv (1)); if (!f) { Sys_Printf ("couldn't exec %s\n", Cmd_Argv (1)); return; } if (!Cvar_Command () && (cmd_warncmd->int_val || (developer && developer->int_val & SYS_DEV))) Sys_Printf ("execing %s\n", Cmd_Argv (1)); Cbuf_InsertText (cbuf_active, f); Hunk_FreeToLowMark (mark); }
/* ============ Cmd_ExecuteString A complete command line has been parsed, so try to execute it FIXME: this function is getting really messy... ============ */ void Cmd_ExecuteString (char *text) { cmd_function_t *cmd; cmd_alias_t *a; int key; static char buf[1024]; cbuf_t *inserttarget; #ifndef SERVERONLY char **s; #endif Cmd_ExpandString (text, buf); Cmd_TokenizeString (buf); // execute the command line if (!Cmd_Argc()) return; // no tokens inserttarget = &cbuf_main; #ifndef SERVERONLY if (cbuf_current == &cbuf_safe) inserttarget = &cbuf_safe; if (cbuf_current == &cbuf_svc) { if (CL_CheckServerCommand()) return; } #endif key = Com_HashKey (cmd_argv[0]); // check functions for (cmd=cmd_hash_array[key] ; cmd ; cmd=cmd->hash_next) { if (!Q_stricmp (cmd_argv[0], cmd->name)) { #ifndef SERVERONLY // special check for msg_trigger commands if (cbuf_current == &cbuf_safe) { for (s = safe_commands; *s; s++) { if (!Q_stricmp(cmd_argv[0], *s)) break; } if (!*s) { if (cl_warncmd.value || developer.value) Com_Printf ("\"%s\" cannot be used in message triggers\n", cmd_argv[0]); return; } } #endif if (cmd->function) cmd->function (); else Cmd_ForwardToServer (); return; } } // some bright guy decided to use "skill" as a mod command in Custom TF, sigh if (!strcmp(Cmd_Argv(0), "skill") && Cmd_Argc() == 1 && Cmd_FindAlias("skill")) goto checkaliases; // check cvars if (Cvar_Command()) return; // check alias checkaliases: for (a=cmd_alias_hash[key] ; a ; a=a->hash_next) { if (!Q_stricmp (cmd_argv[0], a->name)) { #ifndef SERVERONLY if (cbuf_current == &cbuf_svc) { Cbuf_AddText (a->value); Cbuf_AddText ("\n"); } else #endif { Cbuf_InsertTextEx (inserttarget, "\n"); // if the alias value is a command or cvar and // the alias is called with parameters, add them if (Cmd_Argc() > 1 && !strchr(a->value, ' ') && !strchr(a->value, '\t') && (Cvar_FindVar(a->value) || (Cmd_FindCommand(a->value) && a->value[0] != '+' && a->value[0] != '-'))) { Cbuf_InsertTextEx (inserttarget, Cmd_Args()); Cbuf_InsertTextEx (inserttarget, " "); } Cbuf_InsertTextEx (inserttarget, a->value); } return; } } if (Cmd_LegacyCommand()) return; if (!host_initialized && Cmd_Argc() > 1) { if (Cvar_CreateTempVar()) return; } #ifndef SERVERONLY if (cbuf_current != &cbuf_svc) #endif if (cl_warncmd.value || developer.value) Com_Printf ("Unknown command \"%s\"\n", Cmd_Argv(0)); }
/* ============ Cmd_ExecuteString A complete command line has been parsed, so try to execute it FIXME: lookupnoadd the token to speed search? ============ */ void Cmd_ExecuteString (char *text) { cmd_function_t *cmd; cmdalias_t *a; void **data; Cmd_TokenizeString (text, true); // execute the command line if (!Cmd_Argc()) { //Com_DPrintf ("Cmd_ExecuteString: no tokens on '%s'\n", text); return; // no tokens } // check functions // FIXME CRASH: NULL in the rb tree! data = rbfind (cmd_argv[0], cmdtree); if (data) { cmd = *(cmd_function_t **)data; if (!cmd->function) { // forward to server command //Cmd_ExecuteString (va("cmd %s", text)); #ifndef DEDICATED_ONLY Cmd_ForwardToServer (); #endif //Com_DPrintf ("Cmd_ExecuteString: no function '%s' for '%s', using 'cmd'\n", cmd->name, text); } else { //Com_DPrintf ("Cmd_ExecuteString: function '%s' called for '%s'\n", cmd->name, text); cmd->function (); } return; } // check alias data = rbfind (cmd_argv[0], aliastree); if (data) { char expanded[MAX_STRING_CHARS]; a = *(cmdalias_t **)data; if (++alias_count == ALIAS_LOOP_COUNT) { Com_Printf ("ALIAS_LOOP_COUNT\n", LOG_GENERAL); return; } Cmd_Expand_Args (a->value, expanded, sizeof(expanded)); Cbuf_InsertText (expanded); return; } // check cvars if (Cvar_Command ()) { //Com_DPrintf ("Cmd_ExecuteString: '%s' : is cvar\n", text); return; } // send it as a server command if we are connected #ifndef DEDICATED_ONLY Cmd_ForwardToServer (); #else Com_Printf ("Unknown command \"%s\"\n", LOG_GENERAL, text); #endif }
/* ============ 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); }