本文整理汇总了C++中Cbuf_InsertText函数的典型用法代码示例。如果您正苦于以下问题:C++ Cbuf_InsertText函数的具体用法?C++ Cbuf_InsertText怎么用?C++ Cbuf_InsertText使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Cbuf_InsertText函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Cmd_Vstr_f
/*
===============
Cmd_Vstr_f
Inserts the current value of a variable as command text
===============
*/
void Cmd_Vstr_f( void ) {
char *v;
if (Cmd_Argc () != 2) {
Com_Printf ("vstr <variablename> : execute a variable command\n");
return;
}
v = Cvar_VariableString( Cmd_Argv( 1 ) );
Cbuf_InsertText( va("%s\n", v ) );
}
示例2: Cmd_ExecuteString
/*
============
Cmd_ExecuteString
A complete command line has been parsed, so try to execute it
FIXME: lookupnoadd the token to speed search?
============
*/
void Cmd_ExecuteString(const char * text)
{
extern void Cmd_ForwardToServer(void);
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;
// send it as a server command if we are connected
Cmd_ForwardToServer();
}
示例3: Cmd_ExecuteString
/*
============
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 );
}
}
示例4: Cmd_ExecuteString
/**
* @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();
}
示例5: Cmd_Vstr_f
/*
===============
Cmd_Vstr_f
Inserts the current value of a variable as command text
===============
*/
void Cmd_Vstr_f( void ) {
char *v;
char buf[MAX_STRING_CHARS];
if (Cmd_Argc () != 2) {
Com_Printf ("vstr <variablename> : execute a variable command\n");
return;
}
v = Cvar_VariableString( Cmd_Argv( 1 ) );
Com_sprintf(buf, sizeof(buf), "%s", v);
Cbuf_InsertText( buf );
}
示例6: Cmd_If_f
/*
===============
Cmd_If_f
Compares two values, if true executes the third argument, if false executes the forth
===============
*/
void Cmd_If_f( void ) {
char *v;
int v1;
int v2;
char *vt;
char *vf;
char *op;
if ( (Cmd_Argc () == 6 ) || (Cmd_Argc () == 5) ) {
v1 = atoi( Cmd_Argv( 1 ) );
op = Cmd_Argv( 2 );
v2 = atoi( Cmd_Argv( 3 ) );
vt = Cmd_Argv( 4 );
if ( ( !strcmp( op, "=" ) && v1 == v2 ) ||
( !strcmp( op, "!=" ) && v1 != v2 ) ||
( !strcmp( op, "<" ) && v1 < v2 ) ||
( !strcmp( op, "<=" ) && v1 <= v2 ) ||
( !strcmp( op, ">" ) && v1 > v2 ) ||
( !strcmp( op, ">=" ) && v1 >= v2 ) )
{
v = vt;
}
else if ( ( !strcmp( op, "=" ) && v1 != v2 ) ||
( !strcmp( op, "!=" ) && v1 == v2 ) ||
( !strcmp( op, "<" ) && v1 >= v2 ) ||
( !strcmp( op, "<=" ) && v1 > v2 ) ||
( !strcmp( op, ">" ) && v1 <= v2 ) ||
( !strcmp( op, ">=" ) && v1 < v2 ) )
{
if ( Cmd_Argc () == 6 )
{
vf = Cmd_Argv( 5 );
v = vf;
}
else
{
return;
}
}
else
{
Com_Printf ("invalid operator in if command. valid operators are = != < > >= <=\n");
return;
}
}
else {
Com_Printf ("if <value1> <operator> <value2> <cmdthen> (<cmdelse>) : compares the first two values and executes <cmdthen> if true, <cmdelse> if false\n");
return;
}
Cbuf_InsertText( va("vstr %s\n", v ) );
}
示例7: Cmd_Vstr_f
/*
===============
Cmd_Vstr_f
Inserts the current value of a variable as command text
===============
*/
void Cmd_Vstr_f( void ) {
const char *v;
char buf[MAX_CMD_LINE];
char c_str[1024];
if (Cmd_Argc () != 2) {
Com_Printf ("vstr <variablename> : execute a variable command\n");
return;
}
v = Cvar_VariableStringBuffer( Cmd_Argv( 1 ), c_str, sizeof(c_str) );
Com_sprintf(buf, sizeof(buf), "%s", v);
Cbuf_InsertText( buf );
}
示例8: Host_Exec_f
/*
===============
Host_Exec_f
===============
*/
void Host_Exec_f( void )
{
string cfgpath;
char *f;
if( Cmd_Argc() != 2 )
{
Msg( "Usage: exec <filename>\n" );
return;
}
// HACKHACK: don't execute listenserver.cfg in singleplayer
if( !Q_stricmp( Cvar_VariableString( "lservercfgfile" ), Cmd_Argv( 1 )))
{
if( Cvar_VariableValue( "maxplayers" ) == 1.0f )
return;
}
Q_strncpy( cfgpath, Cmd_Argv( 1 ), sizeof( cfgpath ));
FS_DefaultExtension( cfgpath, ".cfg" ); // append as default
f = (char *)FS_LoadFile( cfgpath, NULL, false );
if( !f )
{
MsgDev( D_NOTE, "couldn't exec %s\n", Cmd_Argv( 1 ));
return;
}
MsgDev( D_INFO, "execing %s\n", Cmd_Argv( 1 ));
// terminate the string with newline just in case it's missing
// insertion order is backwards from execution order
Cbuf_InsertText( "\n" );
Cbuf_InsertText( f );
Mem_Free( f );
}
示例9: Cmd_Runalias_f
static void
Cmd_Runalias_f (void)
{
cmdalias_t *a;
a = (cmdalias_t *) Hash_Find (cmd_alias_hash, Cmd_Argv (0));
if (a) {
Cbuf_InsertText (cbuf_active, a->value);
return;
} else {
Sys_Printf
("BUG: No alias found for registered command. Please report this to the QuakeForge development team.");
}
}
示例10: Cmd_ExecuteString
/*
============
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));
}
示例11: Cmd_StuffCmds_f
/*
===============
Cmd_StuffCmds_f
Adds command line parameters as script statements
Commands lead with a +, and continue until a - or another +
xash +prog jctest.qp +cmd amlev1
xash -nosound +cmd amlev1
===============
*/
void Cmd_StuffCmds_f( void )
{
int i, j, l = 0;
char build[MAX_MSGLEN]; // this is for all commandline options combined (and is bounds checked)
if(Cmd_Argc() != 1)
{
Msg( "stuffcmds : execute command line parameters\n");
return;
}
// no reason to run the commandline arguments twice
if(Sys.stuffcmdsrun) return;
Sys.stuffcmdsrun = true;
build[0] = 0;
for (i = 0; i < fs_argc; i++)
{
if (fs_argv[i] && fs_argv[i][0] == '+' && (fs_argv[i][1] < '0' || fs_argv[i][1] > '9') && l + strlen(fs_argv[i]) - 1 <= sizeof(build) - 1)
{
j = 1;
while (fs_argv[i][j]) build[l++] = fs_argv[i][j++];
i++;
for ( ; i < fs_argc; i++)
{
if (!fs_argv[i]) continue;
if ((fs_argv[i][0] == '+' || fs_argv[i][0] == '-') && (fs_argv[i][1] < '0' || fs_argv[i][1] > '9'))
break;
if (l + strlen(fs_argv[i]) + 4 > sizeof(build) - 1)
break;
build[l++] = ' ';
if (strchr(fs_argv[i], ' ')) build[l++] = '\"';
for (j = 0; fs_argv[i][j]; j++) build[l++] = fs_argv[i][j];
if (strchr(fs_argv[i], ' ')) build[l++] = '\"';
}
build[l++] = '\n';
i--;
}
}
// now terminate the combined string and prepend it to the command buffer
// we already reserved space for the terminator
build[l++] = 0;
Cbuf_InsertText( build );
}
示例12: Cbuf_ExecuteText
/*
============
Cbuf_ExecuteText
============
*/
void Cbuf_ExecuteText (int exec_when, char *text)
{
switch (exec_when)
{
case EXEC_NOW:
Cmd_ExecuteString (text);
break;
case EXEC_INSERT:
Cbuf_InsertText (text);
break;
case EXEC_APPEND:
Cbuf_AddText (text);
break;
default:
Com_Error (ERR_FATAL, "Cbuf_ExecuteText: bad exec_when");
}
}
示例13: Cmd_RunAlias_f
/*
============
Cmd_RunAlias_f
============
*/
void Cmd_RunAlias_f(void)
{
cmd_alias_t *alias;
char *name = Cmd_Argv(0);
char *args = Cmd_ArgsFrom(1);
// Find existing alias
for (alias = cmd_aliases; alias; alias=alias->next)
{
if (!Q_stricmp( name, alias->name ))
break;
}
if (!alias)
Com_Error(ERR_FATAL, "Alias: Alias %s doesn't exist", name);
Cbuf_InsertText(va("%s %s", alias->exec, args));
}
示例14: Menu_ItemAtCursor
static const char *Keys_MenuKey( int key )
{
menuaction_s *item = ( menuaction_s * ) Menu_ItemAtCursor( &s_keys_menu );
//pressing mouse1 to pick a new bind wont force bind/unbind itself - spaz
if ( bind_grab && !(cursor.buttonused[MOUSEBUTTON1]&&key==K_MOUSE1))
{
if ( key != K_ESCAPE && key != '`' )
{
char cmd[1024];
Com_sprintf (cmd, sizeof(cmd), "bind \"%s\" \"%s\"\n", Key_KeynumToString(key), bindnames[item->generic.localdata[0]][0]);
Cbuf_InsertText (cmd);
}
// Knightmare- added Psychospaz's mouse support
//dont let selecting with mouse buttons screw everything up
UI_RefreshCursorButtons();
if (key==K_MOUSE1)
cursor.buttonclicks[MOUSEBUTTON1] = -1;
//Menu_SetStatusBar( &s_keys_menu, "enter to change, backspace to clear" );
Menu_SetStatusBar( &s_keys_menu, "Press ENTER or LEFT CLICK to change the key. Press BACKSPACE to clear." );
bind_grab = false;
return menu_out_sound;
}
switch ( key )
{
case K_KP_ENTER:
case K_ENTER:
if (item == &s_keys_back_action) { // back action hack
UI_BackMenu(item); return NULL; }
KeyBindingFunc( item );
return menu_in_sound;
case K_BACKSPACE: // delete bindings
case K_DEL: // delete bindings
case K_KP_DEL:
M_UnbindCommand( bindnames[item->generic.localdata[0]][0] );
return menu_out_sound;
default:
return Default_MenuKey( &s_keys_menu, key );
}
}
示例15: Cmd_ExecFile
/*
===============
Cmd_ExecFile
===============
*/
static void Cmd_ExecFile( char *f )
{
int i;
COM_Compress (f);
Cvar_Get( "arg_all", Cmd_ArgsFrom(2), CVAR_TEMP | CVAR_ROM | CVAR_USER_CREATED, "" );
Cvar_Set( "arg_all", Cmd_ArgsFrom(2) );
Cvar_Get( "arg_count", va( "%i", Cmd_Argc() - 2 ), CVAR_TEMP | CVAR_ROM | CVAR_USER_CREATED, "" );
Cvar_Set( "arg_count", va( "%i", Cmd_Argc() - 2 ) );
for (i = Cmd_Argc() - 2; i; i--)
{
Cvar_Get( va("arg_%i", i), Cmd_Argv( i + 1 ), CVAR_TEMP | CVAR_ROM | CVAR_USER_CREATED, "" );
Cvar_Set( va("arg_%i", i), Cmd_Argv( i + 1 ) );
}
Cbuf_InsertText (f);
}