當前位置: 首頁>>代碼示例>>C++>>正文


C++ Cmd_ArgsFrom函數代碼示例

本文整理匯總了C++中Cmd_ArgsFrom函數的典型用法代碼示例。如果您正苦於以下問題:C++ Cmd_ArgsFrom函數的具體用法?C++ Cmd_ArgsFrom怎麽用?C++ Cmd_ArgsFrom使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Cmd_ArgsFrom函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: SVC_RemoteCommand

/*
===============
SVC_RemoteCommand

An rcon packet arrived from the network.
Shift down the remaining args
Redirect all printfs
===============
*/
static void SVC_RemoteCommand( netadr_t from, msg_t *msg ) {
	qboolean	valid;
	unsigned int time;
	char		remaining[1024];
	// TTimo - scaled down to accumulate, but not overflow anything network wise, print wise etc.
	// (OOB messages are the bottleneck here)
#define SV_OUTPUTBUF_LENGTH (1024 - 16)
	char		sv_outputbuf[SV_OUTPUTBUF_LENGTH];
	static unsigned int lasttime = 0;
	char *cmd_aux;

	// TTimo - https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=534
	time = Com_Milliseconds();
	if ( (unsigned)( time - lasttime ) < 500u ) {
		return;
	}
	lasttime = time;

	if ( !strlen( sv_rconPassword->string ) ||
		strcmp (Cmd_Argv(1), sv_rconPassword->string) ) {
		valid = qfalse;
		Com_Printf ("Bad rcon from %s: %s\n", NET_AdrToString (from), Cmd_ArgsFrom(2) );
	} else {
		valid = qtrue;
		Com_Printf ("Rcon from %s: %s\n", NET_AdrToString (from), Cmd_ArgsFrom(2) );
	}

	// start redirecting all print outputs to the packet
	svs.redirectAddress = from;
	Com_BeginRedirect (sv_outputbuf, SV_OUTPUTBUF_LENGTH, SV_FlushRedirect);

	if ( !strlen( sv_rconPassword->string ) ) {
		Com_Printf ("No rconpassword set on the server.\n");
	} else if ( !valid ) {
		Com_Printf ("Bad rconpassword.\n");
	} else {
		remaining[0] = 0;
		
		// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=543
		// get the command directly, "rcon <pass> <command>" to avoid quoting issues
		// extract the command by walking
		// since the cmd formatting can fuckup (amount of spaces), using a dumb step by step parsing
		cmd_aux = Cmd_Cmd();
		cmd_aux+=4;
		while(cmd_aux[0]==' ')
			cmd_aux++;
		while(cmd_aux[0] && cmd_aux[0]!=' ') // password
			cmd_aux++;
		while(cmd_aux[0]==' ')
			cmd_aux++;
		
		Q_strcat( remaining, sizeof(remaining), cmd_aux);
		
		Cmd_ExecuteString (remaining);

	}

	Com_EndRedirect ();
}
開發者ID:BrendanCoughran,項目名稱:ioquake3,代碼行數:68,代碼來源:sv_main.c

示例2: Key_Bind_f

/*
===================
Key_Bind_f
===================
*/
static void Key_Bind_f(void)
{
    int c, b;

    c = Cmd_Argc();

    if (c < 2) {
        Com_Printf("bind <key> [command] : attach a command to a key\n");
        return;
    }
    b = Key_StringToKeynum(Cmd_Argv(1));
    if (b == -1) {
        Com_Printf("\"%s\" isn't a valid key\n", Cmd_Argv(1));
        return;
    }

    if (c == 2) {
        if (keybindings[b])
            Com_Printf("\"%s\" = \"%s\"\n", Cmd_Argv(1), keybindings[b]);
        else
            Com_Printf("\"%s\" is not bound\n", Cmd_Argv(1));
        return;
    }

// copy the rest of the command line
    Key_SetBinding(b, Cmd_ArgsFrom(2));
}
開發者ID:jayschwa,項目名稱:q2pro,代碼行數:32,代碼來源:keys.c

示例3: SV_ConTell_f

/*
==================
SV_ConTell_f
==================
*/
static void SV_ConTell_f(void) {
	char	*p;
	char	text[1024];
	client_t	*cl;

	// make sure server is running
	if ( !com_sv_running->integer ) {
		Com_Printf( "Server is not running.\n" );
		return;
	}

	if ( Cmd_Argc() < 3 ) {
		Com_Printf ("Usage: tell <client number> <text>\n");
		return;
	}

	cl = SV_GetPlayerByNum();
	if ( !cl ) {
		return;
	}

	strcpy (text, "console_tell: ");
	p = Cmd_ArgsFrom(2);

	if ( *p == '"' ) {
		p++;
		p[strlen(p)-1] = 0;
	}

	strcat(text, p);

	SV_SendServerCommand(cl, "chat \"%s\"", text);
}
開發者ID:Lrns123,項目名稱:jkaq3,代碼行數:38,代碼來源:sv_ccmds.c

示例4: reason

/*
==================
SV_StartServerDemo_f

Record a server-side demo for given player/slot. The demo
will be called "YYYY-MM-DD_hh-mm-ss_playername_id.urtdemo",
in the "demos" directory under your game directory. Note
that "startserverdemo all" will start demos for all players
currently in the server. Players who join later require a
new "startserverdemo" command. If you are already recording
demos for some players, another "startserverdemo all" will
start new demos only for players not already recording. Note
that bots will never be recorded, not even if "all" is given.
The server-side demos will stop when "stopserverdemo" is issued
or when the server restarts for any reason (such as a new map
loading).
==================
*/
static void SV_StartServerDemo_f(void)
{
	client_t *client;

	Com_DPrintf("SV_StartServerDemo_f\n");

	if (!com_sv_running->integer) {
		Com_Printf("startserverdemo: Server not running\n");
		return;
	}

	if (Cmd_Argc() < 2) {
		Com_Printf("Usage: startserverdemo <player-or-all> <optional demo name>\n");
		return;
	}

	client = SV_BetterGetPlayerByHandle(Cmd_Argv(1));
	if (!Q_stricmp(Cmd_Argv(1), "all")) {
		if (client) {
			Com_Printf("startserverdemo: Player 'all' ignored, starting all demos instead\n");
		}
		SV_StartRecordAll();
	}
	else if (client) {
		if (Cmd_Argc() > 2) {
      		SV_StartRecordOne(client, Cmd_ArgsFrom(2));
    	} else {
      		SV_StartRecordOne(client, NULL);
		}
	}
	else {
		Com_Printf("startserverdemo: No player with that handle/in that slot\n");
	}
}
開發者ID:slackin,項目名稱:ioq3-for-UrbanTerror-4,代碼行數:52,代碼來源:sv_ccmds.c

示例5: SV_ForceName_f

/*
==================
SV_ForceName_f

Sets a user's name
==================
*/
static void SV_ForceName_f( void ) {
	client_t	*cl;
	const char	*name;

	// make sure server is running
	if ( !com_sv_running->integer ) {
		Com_Printf( "Server is not running.\n" );
		return;
	}

	if ( Cmd_Argc() >= 2 ) {
		cl = SV_GetPlayerByNum();
		if ( !cl ) {
			return;
		}
		if ( Cmd_Argc() == 2 ) {
			Com_Printf ("forcename: %s: %s\n",Cmd_Argv(1),cl->name);
			return;
		} else {
			name = Cmd_ArgsFrom(2);
			cl->forcename = 2;
			Q_strncpyz( cl->name, name, sizeof(cl->name) );
			SV_UserinfoChanged( cl );
			VM_Call( gvm, GAME_CLIENT_USERINFO_CHANGED, cl - svs.clients );
			Com_Printf ("forcename: %s: %s\n",Cmd_Argv(1),cl->name);
			return;
		}
	}
	Com_Printf ("Usage: forcename <client number> [<name>]\n");
	return;
}
開發者ID:OADoctor,項目名稱:SmokinGuns,代碼行數:38,代碼來源:sv_ccmds.c

示例6: reason

/*
==================
SV_StartServerDemo_f

Record a server-side demo for given player/slot. The demo
will be called "YYYY-MM-DD_hh-mm-ss_playername_id.urtdemo",
in the "demos" directory under your game directory. Note
that "startserverdemo all" will start demos for all players
currently in the server. Players who join later require a
new "startserverdemo" command. If you are already recording
demos for some players, another "startserverdemo all" will
start new demos only for players not already recording. Note
that bots will never be recorded, not even if "all" is given.
The server-side demos will stop when "stopserverdemo" is issued
or when the server restarts for any reason (such as a new map
loading).
==================
*/
static void SV_StartServerDemo_f(void) {

    client_t *client;

    Com_DPrintf("SV_StartServerDemo_f\n");

    if (!com_sv_running->integer) {
        Com_Printf("startserverdemo: Server not running\n");
        return;
    }

    if (Cmd_Argc() < 2) {
        Com_Printf("Usage: startserverdemo <client-or-all> [<optional-demo-name>]\n");
        return;
    }

    if (!Q_stricmp(Cmd_Argv(1), "all")) {

        SV_StartRecordAll();

    } else {

        client = SV_GetPlayerByHandle();
        if (!client) {
            return;
        }

        if (Cmd_Argc() > 2) {
            SV_StartRecordOne(client, Cmd_ArgsFrom(2));
        } else {
            SV_StartRecordOne(client, NULL);
        }

    }
}
開發者ID:CoolOppo,項目名稱:ioq3-for-UrbanTerror-4,代碼行數:53,代碼來源:sv_ccmds.c

示例7: SV_ConTell_f

/*
==================
SV_ConTell_f

Based on Urban Terror implementation
==================
*/
static void SV_ConTell_f(void) {
	char	*p;
	char	text[MAX_STRING_CHARS-18];// OK?
	client_t	*cl;

	// make sure server is running
	if ( !com_sv_running->integer ) {
		Com_Printf( "Server is not running.\n" );
		return;
	}

	if ( Cmd_Argc() < 3 ) {
		Com_Printf ("Usage: tell <client number> <text>\n");
		return;
	}

	cl = SV_GetPlayerByNum();
	if ( !cl ) {
		return;
	}

	strcpy (text, "^3private:^7 ");
	p = Cmd_ArgsFrom(2);

	if ( *p == '"' ) {
		p++;
		p[strlen(p)-1] = 0;
	}

	strcat(text, p);

	SV_SendServerCommand(cl, "print \"%s\n\"", SV_ConvertNewlines((char *)text));
}
開發者ID:OADoctor,項目名稱:SmokinGuns,代碼行數:40,代碼來源:sv_ccmds.c

示例8: CL_ConfigstringModified

/*
=====================
CL_ConfigstringModified
=====================
*/
void CL_ConfigstringModified( void ) {
	char        *old, *s;
	int i, index;
	char        *dup;
	gameState_t oldGs;
	int len;

	index = atoi( Cmd_Argv( 1 ) );
	if ( index < 0 || index >= MAX_CONFIGSTRINGS ) {
		Com_Error( ERR_DROP, "CL_ConfigstringModified: bad index %i", index );
	}
//	s = Cmd_Argv(2);
	// get everything after "cs <num>"
	s = Cmd_ArgsFrom( 2 );

	old = cl.gameState.stringData + cl.gameState.stringOffsets[ index ];
	if ( !strcmp( old, s ) ) {
		return;     // unchanged
	}

	// build the new gameState_t
	oldGs = cl.gameState;

	memset( &cl.gameState, 0, sizeof( cl.gameState ) );

	// leave the first 0 for uninitialized strings
	cl.gameState.dataCount = 1;

	for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) {
		if ( i == index ) {
			dup = s;
		} else {
			dup = oldGs.stringData + oldGs.stringOffsets[ i ];
		}
		if ( !dup[0] ) {
			continue;       // leave with the default empty string
		}

		len = strlen( dup );

		if ( len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS ) {
			Com_Error( ERR_DROP, "MAX_GAMESTATE_CHARS exceeded" );
		}

		// append it to the gameState string buffer
		cl.gameState.stringOffsets[ i ] = cl.gameState.dataCount;
		memcpy( cl.gameState.stringData + cl.gameState.dataCount, dup, len + 1 );
		cl.gameState.dataCount += len + 1;
	}

	if ( index == CS_SYSTEMINFO ) {
		// parse serverId and other cvars
		CL_SystemInfoChanged();
	}

}
開發者ID:MAN-AT-ARMS,項目名稱:iortcw-archive,代碼行數:61,代碼來源:cl_cgame.c

示例9: 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);
}
開發者ID:TheDushan,項目名稱:OpenWolf,代碼行數:24,代碼來源:cmd.cpp

示例10: Cmd_Delay_f

/*
===============
Cmd_Delay_f

Delays a comand
===============
*/
void Cmd_Delay_f (void)
{
        int i, delay, type;
        char *raw_delay;
        qboolean availiable_cmd = qfalse;
        
        // Check if the call is valid
        if(Cmd_Argc () < 2)
        {
                Com_Printf ("delay <delay in milliseconds> <command>\ndelay <delay in frames>f <command>\nexecutes <command> after the delay\n");
                return;
        }
        
        raw_delay = Cmd_Argv(1);
        delay = atoi(raw_delay);
        
        if(delay < 1)
        {
                Com_Printf ("delay: the delay must be a positive integer");
                return;
        }
        
        //search for an unused slot
        for(i=0; (i<MAX_DELAYED_COMMANDS); i++)
        {
                if(delayed_cmd[i].delay == CMD_DELAY_UNUSED)
                {
                        availiable_cmd = qtrue;
                        break;
                }
        }
        
        if(!availiable_cmd)
        {
                Com_Printf ("WARNING: Maximum amount of delayed commands reached.");
                return;
        }

        int lastchar = strlen( raw_delay ) - 1;
        
        if(raw_delay[ lastchar ] == 'f' )
        {
                delay += CMD_DELAY_FRAME_FIRE;
                type = CMD_DELAY_FRAME;
        }else{
                type = CMD_DELAY_MSEC;
                delay += Sys_Milliseconds();
        }
        
        delayed_cmd[i].delay = delay;
        delayed_cmd[i].type = type;
        Q_strncpyz(delayed_cmd[i].text, Cmd_ArgsFrom(2), MAX_CMD_LINE);
}
開發者ID:b1naryth1ef,項目名稱:B1nUrT,代碼行數:60,代碼來源:cmd.c

示例11: SV_Map_f

/*
==================
SV_Map_f

Restart the server on a different map
==================
*/
static void SV_Map_f( void )
{
	char     *cmd;
	char     *map;
	const char *layouts;
	char     mapname[ MAX_QPATH ];
	qboolean cheat;
	char     expanded[ MAX_QPATH ];
	char     layout[ MAX_CVAR_VALUE_STRING ];

	map = Cmd_Argv( 1 );

	if ( !map )
	{
		return;
	}

	// make sure the level exists before trying to change, so that
	// a typo at the server console won't end the game
	Com_sprintf( expanded, sizeof( expanded ), "maps/%s.bsp", map );

	if ( FS_ReadFile( expanded, NULL ) == -1 )
	{
		Com_Printf(_( "Can't find map %s\n"), expanded );

		return;
	}

	// layout(s) - note that ArgsFrom adds quoting which we don't want here
	// Also, if empty, don't override
	layouts = Cmd_UnquoteString( Cmd_ArgsFrom( 2 ) );
	if ( *layouts )
	{
		Cvar_Set( "g_layouts", layouts );
	}

	cheat = !Q_stricmp( Cmd_Argv( 0 ), "devmap" );

	// save the map name here cause on a map restart we reload the q3config.cfg
	// and thus nuke the arguments of the map command
	Q_strncpyz( mapname, map, sizeof( mapname ) );

	// start up the map
	SV_SpawnServer( mapname );

	// set the cheat value
	// if the level was started with "map <levelname>", then
	// cheats will not be allowed.  If started with "devmap <levelname>"
	// then cheats will be allowed
	Cvar_Set( "sv_cheats", cheat ? "1" : "0" );
}
開發者ID:Gallaecio,項目名稱:Unvanquished,代碼行數:58,代碼來源:sv_ccmds.c

示例12: Cvar_Set_f

/*
=======================================================================================================================================
Cvar_Set_f

Allows setting and defining of arbitrary cvars from console, even if they weren't declared in C code.
=======================================================================================================================================
*/
void Cvar_Set_f(void) {
	int c;
	char *cmd;
	cvar_t *v;

	c = Cmd_Argc();
	cmd = Cmd_Argv(0);

	if (c < 2) {
		Com_Printf("usage: %s <variable> <value>\n", cmd);
		return;
	}

	if (c == 2) {
		Cvar_Print_f();
		return;
	}

	v = Cvar_Set2(Cmd_Argv(1), Cmd_ArgsFrom(2), qfalse);

	if (!v) {
		return;
	}

	switch (cmd[3]) {
		case 'a':
			if (!(v->flags & CVAR_ARCHIVE)) {
				v->flags |= CVAR_ARCHIVE;
				cvar_modifiedFlags |= CVAR_ARCHIVE;
			}

			break;
		case 'u':
			if (!(v->flags & CVAR_USERINFO)) {
				v->flags |= CVAR_USERINFO;
				cvar_modifiedFlags |= CVAR_USERINFO;
			}

			break;
		case 's':
			if (!(v->flags & CVAR_SERVERINFO)) {
				v->flags |= CVAR_SERVERINFO;
				cvar_modifiedFlags |= CVAR_SERVERINFO;
			}

			break;
	}
}
開發者ID:KuehnhammerTobias,項目名稱:ioqw,代碼行數:55,代碼來源:cvar.c

示例13: SV_ConBig_f

static void SV_ConBig_f(void) {
	char	*p;
	char	text[1024];
	client_t	*cl;

	// make sure server is running
	if ( !com_sv_running->integer ) {
		Com_Printf( "Server is not running.\n" );
		return;
	}

	if ( Cmd_Argc() < 3 ) {
		Com_Printf ("Usage: big <clientid> <text>\n");
		return;
	}

	cl = SV_GetPlayerByNum();
	if (atoi(Cmd_Argv(1)) < 0) {
		cl = NULL;
	}


//	if (atoi(Cmd_Argv(1))) {
//	    Com_Printf ("Hi1 -1\n");

////	    Com_Printf ("Hi2 -1\n");
//	    if ( !cl ) {
//		    return;
//	    }
////	    Com_Printf ("Hi3 -1\n");
//	}


	strcpy (text, "^3");
	p = Cmd_ArgsFrom(2);

	if ( *p == '"' ) {
		p++;
		p[strlen(p)-1] = 0;
	}

	strcat(text, p);

	SV_SendServerCommand(cl, "cp \"" S_COLOR_WHITE "%s\n\"", text);
}
開發者ID:OADoctor,項目名稱:SmokinGuns,代碼行數:45,代碼來源:sv_ccmds.c

示例14: 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));
}
開發者ID:TheDushan,項目名稱:OpenWolf,代碼行數:23,代碼來源:cmd.cpp

示例15: Com_Setenv_f

static void Com_Setenv_f(void)
{
    int argc = Cmd_Argc();

    if (argc > 2) {
        Q_setenv(Cmd_Argv(1), Cmd_ArgsFrom(2));
    } else if (argc == 2) {
        char *env = getenv(Cmd_Argv(1));

        if (env) {
            Com_Printf("%s=%s\n", Cmd_Argv(1), env);
        } else {
            Com_Printf("%s undefined\n", Cmd_Argv(1));
        }
    } else {
        Com_Printf("Usage: %s <name> [value]\n", Cmd_Argv(0));
    }
}
開發者ID:jayschwa,項目名稱:q2pro,代碼行數:18,代碼來源:common.c


注:本文中的Cmd_ArgsFrom函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。