当前位置: 首页>>代码示例>>C++>>正文


C++ Cmd_TokenizeString函数代码示例

本文整理汇总了C++中Cmd_TokenizeString函数的典型用法代码示例。如果您正苦于以下问题:C++ Cmd_TokenizeString函数的具体用法?C++ Cmd_TokenizeString怎么用?C++ Cmd_TokenizeString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Cmd_TokenizeString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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 );
	}
}
开发者ID:bmk10,项目名称:sing-engine,代码行数:60,代码来源:cmd.c

示例2: CL_TableDeleteRow

/*
=====================
CL_TableDeleteRow
=====================
*/
static void CL_TableDeleteRow( void ) {

	tableInfo_t * table = find_table( &cl.db, Cmd_Argv( 1 ) );
	if ( table && table->rows ) {
		const int i = atoi( Cmd_Argv( 2 ) );
		cellInfo_t * row = table->rows + (i*table->column_count);
		const int lastrow = table->row_count-1;
		
		if ( cl.db.delete_trigger ) {
			cl.db.delete_trigger( &cl.db, table, i );
		}

		if ( i == -1 ) {
			table->row_count = 0;
			table->last_changed++;
		} else {
			
			memmove( row, row + table->column_count, (lastrow-i) * table->column_count * sizeof(cellInfo_t) );
			table->row_count--;
			table->last_changed++;
		}

		if ( uivm ) {
			Cmd_TokenizeString( va("st_table %s", table->name) );
			VM_Call( uivm, UI_CONSOLE_COMMAND, cls.realtime );
		}
	}
}
开发者ID:ballju,项目名称:SpaceTrader-GPL-1.1.14,代码行数:33,代码来源:cl_cgame.c

示例3: SV_ConnectionlessPacket

/*
* SV_ConnectionlessPacket
* 
* A connectionless packet has four leading 0xff
* characters to distinguish it from a game channel.
* Clients that are in the game can still send
* connectionless packets.
*/
void SV_ConnectionlessPacket( const socket_t *socket, const netadr_t *address, msg_t *msg )
{
	connectionless_cmd_t *cmd;
	char *s, *c;

	MSG_BeginReading( msg );
	MSG_ReadLong( msg );    // skip the -1 marker

	s = MSG_ReadStringLine( msg );

	Cmd_TokenizeString( s );

	c = Cmd_Argv( 0 );
	Com_DPrintf( "Packet %s : %s\n", NET_AddressToString( address ), c );

	for( cmd = connectionless_cmds; cmd->name; cmd++ )
	{
		if( !strcmp( c, cmd->name ) )
		{
			cmd->func( socket, address );
			return;
		}
	}

	Com_DPrintf( "Bad connectionless packet from %s:\n%s\n", NET_AddressToString( address ), s );
}
开发者ID:Kaperstone,项目名称:warsow,代码行数:34,代码来源:sv_oob.c

示例4: Cmd_ExecuteString

/*
 * 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
}
开发者ID:smcv,项目名称:yquake2,代码行数:63,代码来源:cmdparser.c

示例5: SV_ConnectionlessPacket

/*
=================
SV_ConnectionlessPacket

A connectionless packet has four leading 0xff
characters to distinguish it from a game channel.
Clients that are in the game can still send
connectionless packets.
=================
*/
void SV_ConnectionlessPacket( netadr_t from, msg_t *msg ) {
	char	*s;
	char	*c;
	#ifdef USE_AUTH
	netadr_t	authServerIP;
	#endif

	MSG_BeginReadingOOB( msg );
	MSG_ReadLong( msg );		// skip the -1 marker

	if (!Q_strncmp("connect", (char *) &msg->data[4], 7)) {
		Huff_Decompress(msg, 12);
	}

	s = MSG_ReadStringLine( msg );
	Cmd_TokenizeString( s );

	c = Cmd_Argv(0);
	Com_DPrintf ("SV packet %s : %s\n", NET_AdrToString(from), c);

	if (!Q_stricmp(c, "getstatus")) {
		if (SV_CheckDRDoS(from)) { return; }
		SVC_Status( from  );
  } else if (!Q_stricmp(c, "getinfo")) {
		if (SV_CheckDRDoS(from)) { return; }
		SVC_Info( from );
	} else if (!Q_stricmp(c, "getchallenge")) {
		SV_GetChallenge( from );
	} else if (!Q_stricmp(c, "connect")) {
		SV_DirectConnect( from );
	} else if (!Q_stricmp(c, "ipAuthorize")) {
		SV_AuthorizeIpPacket( from );
	}
	#ifdef USE_AUTH
	// @Barbatos @Kalish
	else if ( (!Q_stricmp(c, "AUTH:SV")))
	{
		NET_StringToAdr(sv_authServerIP->string, &authServerIP);
		
		if ( !NET_CompareBaseAdr( from, authServerIP ) ) {
			Com_Printf( "AUTH not from the Auth Server\n" );
			return;
		}
		VM_Call(gvm, GAME_AUTHSERVER_PACKET);
	}
	#endif
	
	else if (!Q_stricmp(c, "rcon")) {
		SVC_RemoteCommand( from, msg );
	}else if (!Q_stricmp(c, "rconRecovery")) {
		SVC_RconRecoveryRemoteCommand( from, msg );
	} else if (!Q_stricmp(c, "disconnect")) {
		// if a client starts up a local server, we may see some spurious
		// server disconnect messages when their new server sees our final
		// sequenced messages to the old client
	} else {
		Com_DPrintf ("bad connectionless packet from %s:\n%s\n"
		, NET_AdrToString (from), s);
	}
}
开发者ID:pedrxd,项目名称:MinModUrT,代码行数:70,代码来源:sv_main.c

示例6: CL_ParseServerCommand

/*
* CL_ParseServerCommand
*/
static void CL_ParseServerCommand( msg_t *msg )
{
	const char *s;
	char *text;
	svcmd_t *cmd;

	text = MSG_ReadString( msg );

	Cmd_TokenizeString( text );
	s = Cmd_Argv( 0 );

	if( cl_debug_serverCmd->integer && ( cls.state < CA_ACTIVE || cls.demo.playing ) )
		Com_Printf( "CL_ParseServerCommand: \"%s\"\n", text );

	// filter out these server commands to be called from the client
	for( cmd = svcmds; cmd->name; cmd++ )
	{
		if( !strcmp( s, cmd->name ) )
		{
			cmd->func();
			return;
		}
	}

	Com_Printf( "Unknown server command: %s\n", s );
}
开发者ID:ShaitanShootout,项目名称:BM,代码行数:29,代码来源:cl_parse.c

示例7: SV_ExecuteClientCommand

/*
==================
SV_ExecuteClientCommand

Also called by bot code
==================
*/
void SV_ExecuteClientCommand(client_t *cl, const char *s, qboolean clientOK)
{
	ucmd_t  *u;

	Cmd_TokenizeString(s);

	// see if it is a server level command
	for(u = ucmds ; u->name ; u++)
	{
		if(!strcmp(Cmd_Argv(0), u->name))
		{
			u->func(cl);
			break;
		}
	}

	if(clientOK)
	{
		// pass unknown strings to the game
		if(!u->name && sv.state == SS_GAME)
		{
			VM_Call(gvm, GAME_CLIENT_COMMAND, cl - svs.clients);
		}
	}
}
开发者ID:Diskutant,项目名称:RTCW-SP,代码行数:32,代码来源:sv_client.c

示例8: Cmd_ExecuteString

void	Cmd_ExecuteString( const char *str ) {	
	int l = strlen( str );
	if ( str[l-1] == '\n' ) {
		char *stripped = alloca( l+1 );
		strcpy( stripped, str );
		str = stripped;
		stripped[l-1] = 0;
	}
	
	Com_Printf( "%s\n", str );
	Cmd_TokenizeString( str );
		 
	const char *arg0 = Cmd_Argv( 0 );
	int hashid = HashString( arg0 );
	
	// check commands first
	for( cmd_function_t *cmd = cmd_functions ; cmd ; cmd = cmd->next ) {
		if( hashid == cmd->hashid && !strcmp( arg0, cmd->name ) ) {
			cmd->function();
			return;
		}
	}
	
	// then check cvars
	cvar_t *cvar = Cvar_FindVar( arg0 );
	if ( cvar ) {
		Cvar_Set( arg0, Cmd_Argv( 1 ) );
		return;
	}
	Com_Printf( "Unknown command: %s\n", arg0 );
}
开发者ID:TermiT,项目名称:Doomsday--Hellraiser,代码行数:31,代码来源:cmd.c

示例9: ParseFloats

int ParseFloats(char *s, float *f, int *f_size)
{
	int i, argc;

	if (!s || !f || !f_size)
	{
		Sys_Error("ParseFloats() wrong params");
	}

	if (f_size[0] <= 0)
	{
		return (f_size[0] = 0);    // array have no size, unusual but no crime
	}

	Cmd_TokenizeString(s);
	argc = min(Cmd_Argc(), f_size[0]);

	for (i = 0; i < argc; i++)
	{
		f[i] = Q_atof(Cmd_Argv(i));
	}

	for (; i < f_size[0]; i++)
	{
		f[i] = 0;    // zeroing unused elements
	}

	return (f_size[0] = argc);
}
开发者ID:carriercomm,项目名称:Doodle,代码行数:29,代码来源:mathlib.c

示例10: SV_ExecuteClientCommand

/*
==================
SV_ExecuteClientCommand

Also called by bot code
==================
*/
void SV_ExecuteClientCommand( client_t *cl, const char *s, qboolean clientOK ) {
	ucmd_t	*u;
	qboolean bProcessed = qfalse;

	Cmd_TokenizeString( s );

	// see if it is a server level command
	for (u=ucmds ; u->name ; u++) {
		if (!strcmp (Cmd_Argv(0), u->name) ) {
			u->func( cl );
			bProcessed = qtrue;
			break;
		}
	}

	if (clientOK) {
		// pass unknown strings to the game
		if (!u->name && sv.state == SS_GAME && (cl->state == CS_ACTIVE || cl->state == CS_PRIMED)) {
			// strip \r \n and ;
			if ( sv_filterCommands->integer )
				Cmd_Args_Sanitize();
			GVM_ClientCommand( cl - svs.clients );
		}
	}
	else if (!bProcessed)
		Com_DPrintf( "client text ignored for %s: %s\n", cl->name, Cmd_Argv(0) );
}
开发者ID:Ben2917,项目名称:OpenJK,代码行数:34,代码来源:sv_client.cpp

示例11: Sv_UserStringCommand

/*
 * Sv_UserStringCommand
 *
 * Invoke the specified user string command.  If we don't have a function for
 * it, pass it off to the game module.
 */
static void Sv_UserStringCommand(const char *s) {
	sv_user_string_cmd_t *c;

	Cmd_TokenizeString(s);

	if (strchr(s, '\xFF')) { // catch end of message exploit
		Com_Warn("Sv_ExecuteUserCommand: Illegal command from %s\n",
				Sv_NetaddrToString(sv_client));
		Sv_KickClient(sv_client, NULL);
		return;
	}

	for (c = sv_user_string_cmds; c->name; c++) {

		if (!strcmp(Cmd_Argv(0), c->name)) {
			c->func();
			break;
		}
	}

	if (!c->name) { // unmatched command

		if (sv.state == SV_ACTIVE_GAME) // maybe the game knows what to do with it
			svs.game->ClientCommand(sv_player);
	}
}
开发者ID:darkshade9,项目名称:aq2w,代码行数:32,代码来源:sv_client.c

示例12: SV_NocPacket

void SV_NocPacket(netadr_t from, msg_t *msg) { //Not connected packet (Server is not running)
	char* s;
	char* c;
	if(msg->cursize >= 4) {
		if(*(int*)msg->data == -1) {
			#if 1
			int CSteamServer_HandleIncomingPacket(const void* pData, int cbData, unsigned int srcIP, unsigned short srcPort);
			if(!CSteamServer_HandleIncomingPacket((const void*)msg->data, msg->cursize, from._ip, from.port));
			#endif
		} else if(*(int*)msg->data == -2) {	
			MSG_BeginReading(msg);
			MSG_ReadLong(msg);
			
			s = MSG_ReadStringLine(msg);
			
			Cmd_TokenizeString(s);
			
			c = Cmd_Argv(0);
			
			if(!Q_stricmp(c, "serverversionresponse")) {
				if(!NET_CompareBaseAdr(from, x_master))
					return;
			} else if(!Q_stricmp(c, "clientversionresponse")) {
				if(!NET_CompareBaseAdr(from, x_master))
					return;
				clientversion = atoi( Cmd_Argv(1) );
			}
		}
	}
}
开发者ID:EndlessClan,项目名称:CoDExtended,代码行数:30,代码来源:sv_main.c

示例13: SV_ConnectionlessPacket

/**
 * @brief Handles a connectionless message from a client
 * @sa NET_OOB_Printf
 * @param[out] stream The stream to write to
 * @param msg The message buffer to read the connectionless data from
 */
static void SV_ConnectionlessPacket (struct net_stream *stream, struct dbuffer *msg)
{
	const char *c;
	char s[512];
	char buf[256];

	NET_ReadStringLine(msg, s, sizeof(s));

	Cmd_TokenizeString(s, qfalse);

	c = Cmd_Argv(0);
	Com_DPrintf(DEBUG_SERVER, "Packet : %s\n", c);

	if (Q_streq(c, "teaminfo"))
		SVC_TeamInfo(stream);
	else if (Q_streq(c, "info"))
		SVC_Info(stream);
	else if (Q_streq(c, "status"))
		SVC_Status(stream);
	else if (Q_streq(c, "connect"))
		SVC_DirectConnect(stream);
	else if (Q_streq(c, "rcon"))
		SVC_RemoteCommand(stream);
	else
		Com_Printf("Bad connectionless packet from %s:\n%s\n", NET_StreamPeerToName(stream, buf, sizeof(buf), qtrue), s);
}
开发者ID:chrisglass,项目名称:ufoai,代码行数:32,代码来源:sv_main.c

示例14: SV_ConnectionlessPacket

/*
=================
SV_ConnectionlessPacket

A connectionless packet has four leading 0xff
characters to distinguish it from a game channel.
Clients that are in the game can still send
connectionless packets.
=================
*/
static void SV_ConnectionlessPacket( netadr_t from, msg_t *msg ) {
	char	*s;
	const char	*c;

	MSG_BeginReading( msg );
	MSG_ReadLong( msg );		// skip the -1 marker

	s = MSG_ReadStringLine( msg );

	Cmd_TokenizeString( s );

	c = Cmd_Argv(0);
	Com_DPrintf ("SV packet %s : %s\n", NET_AdrToString(from), c);

	if (!strcmp(c,"getstatus")) {
		SVC_Status( from  );
	} else if (!strcmp(c,"getinfo")) {
		SVC_Info( from );
	} else if (!strcmp(c,"connect")) {
		SV_DirectConnect( from );
	} else if (!strcmp(c,"disconnect")) {
		// if a client starts up a local server, we may see some spurious
		// server disconnect messages when their new server sees our final
		// sequenced messages to the old client
	} else {
		Com_DPrintf ("bad connectionless packet from %s:\n%s\n"
		, NET_AdrToString (from), s);
	}
}
开发者ID:BSzili,项目名称:OpenJK,代码行数:39,代码来源:sv_main.cpp

示例15: Sv_ConnectionlessPacket

/*
 * @brief A connection-less packet has four leading 0xff bytes to distinguish
 * it from a game channel. Clients that are in the game can still send these,
 * and they will be handled here.
 */
static void Sv_ConnectionlessPacket(void) {

	Net_BeginReading(&net_message);
	Net_ReadLong(&net_message); // skip the -1 marker

	const char *s = Net_ReadStringLine(&net_message);

	Cmd_TokenizeString(s);

	const char *c = Cmd_Argv(0);
	const char *a = Net_NetaddrToString(&net_from);

	Com_Debug("Packet from %s: %s\n", a, c);

	if (!g_strcmp0(c, "ping"))
		Sv_Ping_f();
	else if (!g_strcmp0(c, "ack"))
		Sv_Ack_f();
	else if (!g_strcmp0(c, "status"))
		Sv_Status_f();
	else if (!g_strcmp0(c, "info"))
		Sv_Info_f();
	else if (!g_strcmp0(c, "get_challenge"))
		Sv_GetChallenge_f();
	else if (!g_strcmp0(c, "connect"))
		Sv_Connect_f();
	else if (!g_strcmp0(c, "rcon"))
		Sv_Rcon_f();
	else
		Com_Print("Bad connectionless packet from %s:\n%s\n", a, s);
}
开发者ID:chrisnew,项目名称:quetoo,代码行数:36,代码来源:sv_main.c


注:本文中的Cmd_TokenizeString函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。