• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ MSG_BeginReading函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: 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;
	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:3ddy,项目名称:Jedi-Outcast,代码行数:39,代码来源:sv_main.cpp


示例3: NQD_ReadPackets

void NQD_ReadPackets (void)
{
	while (CL_GetNQDemoMessage()) {
		MSG_BeginReading ();
		CLNQ_ParseServerMessage();
	}
}
开发者ID:luaman,项目名称:zq,代码行数:7,代码来源:cl_nqdemo.c


示例4: SV_ProcessPacket

/*
* SV_ProcessPacket
*/
static qboolean SV_ProcessPacket( netchan_t *netchan, msg_t *msg )
{
	int zerror;

	if( !Netchan_Process( netchan, msg ) )
		return qfalse; // wasn't accepted for some reason

	// now if compressed, expand it
	MSG_BeginReading( msg );
	MSG_ReadLong( msg ); // sequence
	MSG_ReadLong( msg ); // sequence_ack
	MSG_ReadShort( msg ); // game_port
	if( msg->compressed )
	{
		zerror = Netchan_DecompressMessage( msg );
		if( zerror < 0 )
		{
			// compression error. Drop the packet
			Com_DPrintf( "SV_ProcessPacket: Compression error %i. Dropping packet\n", zerror );
			return qfalse;
		}
	}

	return qtrue;
}
开发者ID:hettoo,项目名称:racesow,代码行数:28,代码来源:sv_main.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(void)
{
    const char * s;
    const char * c;

    MSG_BeginReading(&net_message);
    MSG_ReadLong(&net_message); // skip the -1 marker

    s = MSG_ReadStringLine(&net_message);

    Cmd_TokenizeString(s, false);

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

    if (!strcmp(c, "ping"))
        SVC_Ping();
    else if (!strcmp(c, "ack"))
        SVC_Ack();
    else if (!strcmp(c, "status"))
        SVC_Status();
    else if (!strcmp(c, "info"))
        SVC_Info();
    else if (!strcmp(c, "getchallenge"))
        SVC_GetChallenge();
    else if (!strcmp(c, "connect"))
        SVC_DirectConnect();
    else if (!strcmp(c, "rcon"))
        SVC_RemoteCommand();
    else
        Com_Printf("bad connectionless packet from %s:\n%s\n", NET_AdrToString(net_from), s);
}
开发者ID:libretro,项目名称:quake2-for-ps2,代码行数:42,代码来源:sv_main.c


示例6: 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:codetwister,项目名称:qfusion,代码行数:34,代码来源:sv_oob.c


示例7: TV_Downstream_UpstreamlessPacket

/*
* TV_Downstream_UpstreamlessPacket
*/
void TV_Downstream_UpstreamlessPacket( const socket_t *socket, const netadr_t *address, msg_t *msg )
{
	upstreamless_cmd_t *cmd;
	char *s, *c;

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

	s = MSG_ReadStringLine( msg );

	if( TV_Downstream_SteamServerQuery( s, socket, address, msg ) )
		return;

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

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

	Com_DPrintf( "Bad downstream connectionless packet from %s:\n%s\n", NET_AddressToString( address ), s );
}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:30,代码来源:tv_downstream_oob.c


示例8: SV_PacketEvent

/*
=================
SV_ReadPackets
=================
*/
void SV_PacketEvent( netadr_t from, msg_t *msg ) {
	int			i;
	client_t	*cl;
	int			qport;

	// check for connectionless packet (0xffffffff) first
	if ( msg->cursize >= 4 && *(int *)msg->data == -1) {
		SV_ConnectionlessPacket( from, msg );
		return;
	}

	// read the qport out of the message so we can fix up
	// stupid address translating routers
	MSG_BeginReading( msg );
	MSG_ReadLong( msg );				// sequence number
	MSG_ReadLong( msg );				// sequence number
	qport = MSG_ReadShort( msg ) & 0xffff;

	// find which client the message is from
	for (i=0, cl=svs.clients ; i < 1 ; i++,cl++) {
		if (cl->state == CS_FREE) {
			continue;
		}
		if ( !NET_CompareBaseAdr( from, cl->netchan.remoteAddress ) ) {
			continue;
		}
		// it is possible to have multiple clients from a single IP
		// address, so they are differentiated by the qport variable
		if (cl->netchan.qport != qport) {
			continue;
		}

		// the IP port can't be used to differentiate them, because
		// some address translating routers periodically change UDP
		// port assignments
		if (cl->netchan.remoteAddress.port != from.port) {
			Com_Printf( "SV_ReadPackets: fixing up a translated port\n" );
			cl->netchan.remoteAddress.port = from.port;
		}

		// make sure it is a valid, in sequence packet
		if (Netchan_Process(&cl->netchan, msg)) {
			// zombie clients stil neet to do the Netchan_Process
			// to make sure they don't need to retransmit the final
			// reliable message, but they don't do any other processing
			if (cl->state != CS_ZOMBIE) {
				cl->lastPacketTime = sv.time;	// don't timeout
				cl->frames[ cl->netchan.incomingAcknowledged & PACKET_MASK ]
					.messageAcked = sv.time;
				SV_ExecuteClientMessage( cl, msg );
			}
		}
		return;
	}
	
	// if we received a sequenced packet from an address we don't reckognize,
	// send an out of band disconnect packet to it
	NET_OutOfBandPrint( NS_SERVER, from, "disconnect" );
}
开发者ID:3ddy,项目名称:Jedi-Outcast,代码行数:64,代码来源:sv_main.cpp


示例9: Test_Poll

static void Test_Poll(void)
{
    struct qsockaddr clientaddr;
    int		control;
    int		len;
    char	name[32];
    char	address[64];
    int		colors;
    int		frags;
    int		connectTime;
    byte	playerNumber;

    net_landriverlevel = testDriver;

    while (1) {
        len = dfunc.Read(testSocket, net_message.data, net_message.maxsize, &clientaddr);
        if (len < sizeof(int)) {
            break;
        }

        net_message.cursize = len;

        MSG_BeginReading();
        control = BigLong(*((int *)net_message.data));
        MSG_ReadLong();
        if (control == -1) {
            break;
        }
        if ((control & (~NETFLAG_LENGTH_MASK)) !=  NETFLAG_CTL) {
            break;
        }
        if ((control & NETFLAG_LENGTH_MASK) != len) {
            break;
        }

        if (MSG_ReadByte() != CCREP_PLAYER_INFO) {
            Sys_Error("Unexpected repsonse to Player Info request\n");
        }

        playerNumber = MSG_ReadByte();
        Q_strcpy(name, MSG_ReadString());
        colors = MSG_ReadLong();
        frags = MSG_ReadLong();
        connectTime = MSG_ReadLong();
        Q_strcpy(address, MSG_ReadString());

        Con_Printf("%s\n  frags:%3i  colors:%u %u  time:%u\n  %s\n", name, frags, colors >> 4, colors & 0x0f, connectTime / 60, address);
    }

    testPollCount--;
    if (testPollCount) {
        SchedulePollProcedure(&testPollProcedure, 0.1);
    } else {
        dfunc.CloseSocket(testSocket);
        testInProgress = false;
    }
}
开发者ID:carriercomm,项目名称:flQuake,代码行数:57,代码来源:net_dgrm.c


示例10: Test2_Poll

static void Test2_Poll(void)
{
	struct qsockaddr clientaddr;
	int		control;
	int		len;
	char	name[256];
	char	value[256];

	net_landriverlevel = test2Driver;
	name[0] = 0;

	len = dfunc.Read (test2Socket, net_message.data, net_message.maxsize, &clientaddr);
	if (len < sizeof(int))
		goto Reschedule;

	net_message.cursize = len;

	MSG_BeginReading ();
	control = BigLong(*((int *)net_message.data));
	MSG_ReadLong();
	if (control == -1)
		goto Error;
	if ((control & (~NETFLAG_LENGTH_MASK)) !=  NETFLAG_CTL)
		goto Error;
	if ((control & NETFLAG_LENGTH_MASK) != len)
		goto Error;

	if (MSG_ReadByte() != CCREP_RULE_INFO)
		goto Error;

	Q_strcpy(name, MSG_ReadString());
	if (name[0] == 0)
		goto Done;
	Q_strcpy(value, MSG_ReadString());

	Con_Printf("%-16.16s  %-16.16s\n", name, value);

	SZ_Clear(&net_message);
	// save space for the header, filled in later
	MSG_WriteLong(&net_message, 0);
	MSG_WriteByte(&net_message, CCREQ_RULE_INFO);
	MSG_WriteString(&net_message, name);
	*((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
	dfunc.Write (test2Socket, net_message.data, net_message.cursize, &clientaddr);
	SZ_Clear(&net_message);

Reschedule:
	SchedulePollProcedure(&test2PollProcedure, 0.05);
	return;

Error:
	Con_Printf("Unexpected repsonse to Rule Info request\n");
Done:
	dfunc.CloseSocket(test2Socket);
	test2InProgress = false;
	return;
}
开发者ID:Izhido,项目名称:qrevpak,代码行数:57,代码来源:net_dgrm.c


示例11: MSG_BeginReading

unsigned char *W_ConvertWAD3TextureBGRA(sizebuf_t *sb)
{
	unsigned char *in, *data, *out, *pal;
	int d, p;
	unsigned char name[16];
	unsigned int mipoffset[4];

	MSG_BeginReading(sb);
	MSG_ReadBytes(sb, 16, name);
	image_width = MSG_ReadLittleLong(sb);
	image_height = MSG_ReadLittleLong(sb);
	mipoffset[0] = MSG_ReadLittleLong(sb);
	mipoffset[1] = MSG_ReadLittleLong(sb); // should be mipoffset[0] + image_width*image_height
	mipoffset[2] = MSG_ReadLittleLong(sb); // should be mipoffset[1] + image_width*image_height/4
	mipoffset[3] = MSG_ReadLittleLong(sb); // should be mipoffset[2] + image_width*image_height/16
	pal = sb->data + mipoffset[3] + (image_width / 8 * image_height / 8) + 2;

	// bail if any data looks wrong
	if (image_width < 0
	 || image_width > 4096
	 || image_height < 0
	 || image_height > 4096
	 || mipoffset[0] != 40
	 || mipoffset[1] != mipoffset[0] + image_width * image_height
	 || mipoffset[2] != mipoffset[1] + image_width / 2 * image_height / 2
	 || mipoffset[3] != mipoffset[2] + image_width / 4 * image_height / 4
	 || (unsigned int)sb->cursize < (mipoffset[3] + image_width / 8 * image_height / 8 + 2 + 768))
		return NULL;

	in = (unsigned char *)sb->data + mipoffset[0];
	data = out = (unsigned char *)Mem_Alloc(tempmempool, image_width * image_height * 4);
	if (!data)
		return NULL;
	for (d = 0;d < image_width * image_height;d++)
	{
		p = *in++;
		if (name[0] == '{' && p == 255)
			out[0] = out[1] = out[2] = out[3] = 0;
		else
		{
			p *= 3;
			out[2] = pal[p];
			out[1] = pal[p+1];
			out[0] = pal[p+2];
			out[3] = 255;
		}
		out += 4;
	}
	return data;
}
开发者ID:divVerent,项目名称:darkplaces-travis,代码行数:50,代码来源:wad.c


示例12: 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 (void)
{
	const char	*s;
	const char	*c;

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

	s = MSG_ReadStringLine ();

	Cmd_TokenizeString (s);

	c = Cmd_Argv(0);

	if (!strcmp(c, "ping") || ( c[0] == A2A_PING && (c[1] == 0 || c[1] == '\n')) )
	{
		SVC_Ping ();
		return;
	}
	if (c[0] == A2A_ACK && (c[1] == 0 || c[1] == '\n') )
	{
		Con_Printf ("A2A_ACK from %s\n", NET_AdrToString (net_from));
		return;
	}
	else if (c[0] == A2S_ECHO)
	{
		NET_SendPacket (net_message.cursize, net_message.data, net_from);
		return;
	}
	else if (!strcmp(c,"status"))
	{
		SVC_Status ();
		return;
	}
	else if (!strcmp(c,"log"))
	{
		SVC_Log ();
		return;
	}
	else if (!strcmp(c,"connect"))
	{
		SVC_DirectConnect ();
		return;
	}
	else if (!strcmp(c, "rcon"))
		SVC_RemoteCommand ();
	else
		Con_Printf ("bad connectionless packet from %s:\n%s\n", NET_AdrToString (net_from), s);
}
开发者ID:crutchwalkfactory,项目名称:motocakerteam,代码行数:59,代码来源:sv_main.c


示例13: Netchan_CopyNormalFragments

/* <66786> ../engine/net_chan.c:1723 */
qboolean Netchan_CopyNormalFragments(netchan_t *chan)
{
	fragbuf_t *p, *n;

	if (!chan->incomingready[FRAG_NORMAL_STREAM])
		return FALSE;

	if (!chan->incomingbufs[FRAG_NORMAL_STREAM])
	{
		Con_Printf("Netchan_CopyNormalFragments:  Called with no fragments readied\n");
		chan->incomingready[FRAG_NORMAL_STREAM] = FALSE;
		return FALSE;
	}

	p = chan->incomingbufs[FRAG_NORMAL_STREAM];

	SZ_Clear(&net_message);
	MSG_BeginReading();

	while (p)
	{
		n = p->next;

		SZ_Write(&net_message, p->frag_message.data, p->frag_message.cursize);

		Mem_Free(p);
		p = n;
	}

	if (*(uint32 *)net_message.data == MAKEID('B', 'Z', '2', '\0'))
	{
		char uncompressed[65536];
		unsigned int uncompressedSize = 65536;
		BZ2_bzBuffToBuffDecompress(uncompressed, &uncompressedSize, (char*)net_message.data + 4, net_message.cursize - 4, 1, 0);
		Q_memcpy(net_message.data, uncompressed, uncompressedSize);
		net_message.cursize = uncompressedSize;
	}

	chan->incomingbufs[FRAG_NORMAL_STREAM] = NULL;
	chan->incomingready[FRAG_NORMAL_STREAM] = false;

	return TRUE;
}
开发者ID:omertelli,项目名称:rehlds,代码行数:44,代码来源:net_chan.cpp


示例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.
=================
*/
void SV_ConnectionlessPacket (void)
{
    char	*s;
    char	*c;
    int s_token = 0;
    // r1ch fix: make sure we never talk to ourselves
//	if (NET_IsLocalAddress (net_from.ip[0] == 127) && !NET_IsLocalHost(net_from) && ShortSwap(net_from.port) == server_port)
    /*	if ( (net_from.ip[0] == 127) && (net_from.type != NA_LOOPBACK) && (ShortSwap(net_from.port) == server_port) )
    	{
    		Com_DPrintf ("dropped %d byte connectionless packet from self! (spoofing attack?)\n", net_message.cursize);
    		return;
    	}*/

    MSG_BeginReading (&net_message);
    MSG_ReadLong (&net_message);		// skip the -1 marker

    s = MSG_ReadStringLine (&net_message);

    Cmd_TokenizeString (s, false);

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

    if ((s_token = Q_STLookup(&packet_stable, c)) != -1) {
        if (s_token == s_ping)
            SVC_Ping ();
        else if (s_token == s_ack)
            SVC_Ack ();
        else if (s_token == s_status)
            SVC_Status ();
        else if (s_token == s_info)
            SVC_Info ();
        else if (s_token == s_getchallenge)
            SVC_GetChallenge ();
        else if (s_token == s_connect)
            SVC_DirectConnect ();
        else if (s_token == s_rcon)
            SVC_RemoteCommand ();
    } else
        Com_Printf ("bad connectionless packet from %s:\n%s\n"
                    , NET_AdrToString (net_from), s);
}
开发者ID:postfix,项目名称:quake2vr,代码行数:52,代码来源:sv_main.c


示例15: TV_Upstream_ConnectionlessPacket

/*
* TV_Upstream_ConnectionlessPacket
*/
void TV_Upstream_ConnectionlessPacket( upstream_t *upstream, msg_t *msg ) {
	upstreamless_cmd_t *cmd;
	char *s, *c;

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

	s = MSG_ReadStringLine( msg );
	Cmd_TokenizeString( s );
	c = Cmd_Argv( 0 );

	for( cmd = upstream_upstreamless_cmds; cmd->name; cmd++ ) {
		if( !strcmp( c, cmd->name ) ) {
			cmd->func( upstream, msg );
			return;
		}
	}

	Com_DPrintf( "%s" S_COLOR_WHITE ": Bad upstream connectionless packet: %s\n", upstream->name, c );
}
开发者ID:Picmip,项目名称:qfusion,代码行数:23,代码来源:tv_upstream_oob.c


示例16: HTTPServer_AuthEvent

/* Detecting the clientside protocol and process the 1st chunk of data if it is a http client */
tcpclientstate_t HTTPServer_AuthEvent(netadr_t* from, msg_t* msg, int *connectionId)
{
	
	ftRequest_t* request;
	*connectionId = 0;
	
	char protocol[MAX_STRING_CHARS];
	char* line;
	
	MSG_BeginReading(msg);
	
	line = MSG_ReadStringLine(msg, protocol, sizeof(protocol));
	if (line != NULL) {
		if ( Q_strncmp(line, "GET", 3) && Q_strncmp(line, "POST", 4) && Q_strncmp(line, "HEAD", 4) ) {
			return TCP_AUTHNOTME;
		}
		if( strstr(line, "HTTP/1.0") == NULL && strstr(line, "HTTP/1.1") == NULL )
		{
			/* Is not a HTTP client */
			return TCP_AUTHNOTME;
		}
	}
	
	request = FT_CreateRequest(NULL, NULL);
	
	if(request == NULL)
		return TCP_AUTHBAD;
	
	*connectionId = (int)request;

	
	if (HTTPServer_Event(from, msg, *connectionId) == qtrue)
	{
		return TCP_AUTHBAD;
	}	

	return TCP_AUTHSUCCESSFULL;
}
开发者ID:raydvard,项目名称:CoD4X17a_testing,代码行数:39,代码来源:httpftp.c


示例17: demoPlayForwardFrame

static void demoPlayForwardFrame( demoPlay_t *play ) {
	int			blockSize;
	msg_t		msg;
	demoFrame_t *copyFrame;

	if (play->filePos + 4 > play->fileSize) {
		play->lastFrame = qtrue;
		return;
	}
	play->lastFrame = qfalse;
	play->filePos += 4;
	FS_Read( &blockSize, 4, play->fileHandle );
	blockSize = LittleLong( blockSize );
	FS_Read( demoBuffer, blockSize, play->fileHandle );
	play->filePos += blockSize;
	MSG_Init( &msg, demoBuffer, sizeof(demoBuffer) );
	MSG_BeginReading( &msg );
	msg.cursize = blockSize;
	copyFrame = play->frame;
	play->frame = play->nextFrame;
	play->nextFrame = copyFrame;
	demoFrameUnpack( &msg, play->frame, play->nextFrame );
	play->frameNumber++;
}
开发者ID:mightycow,项目名称:q3mme,代码行数:24,代码来源:cl_demos.c


示例18: qtv_connectionless_packet

static void
qtv_connectionless_packet (void)
{
	const char *cmd, *str;

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

	str = MSG_ReadString (net_message);
	COM_TokenizeString (str, qtv_args);
	cmd_args = qtv_args;

	cmd = qtv_args->argv[0]->str;
	if (!strcmp (cmd, "ping")) {
		qtv_ping ();
	} else if (!strcmp (cmd, "status")) {
		qtv_status ();
	} else if (!strcmp (cmd, "getchallenge")) {
		Client_NewConnection ();
	} else if (cmd[0]) {
		switch (cmd[0]) {
			default:
				goto bad_packet;
			case A2C_PRINT:
				Sys_Printf ("%s", str + 1);
				break;
			case A2A_PING:
				qtv_ping ();
				break;
		}
	} else {
bad_packet:
		Sys_Printf ("bad connectionless packet from %s:\n%s\n",
					NET_AdrToString (net_from), str);
	}
}
开发者ID:EIREXE,项目名称:Quakeforge-gcw0,代码行数:36,代码来源:qtv.c


示例19: Netchan_Process

/*
* Netchan_Process
* 
* Returns false if the message should not be processed due to being
* out of order or a fragment.
* 
* Msg must be large enough to hold MAX_MSGLEN, because if this is the
* final fragment of a multi-part message, the entire thing will be
* copied out.
*/
bool Netchan_Process( netchan_t *chan, msg_t *msg )
{
	int sequence, sequence_ack;
	int game_port = -1;
	int fragmentStart, fragmentLength;
	bool fragmented = false;
	int headerlength;
	bool compressed = false;
	bool lastfragment = false;

	// get sequence numbers
	MSG_BeginReading( msg );
	sequence = MSG_ReadLong( msg );
	sequence_ack = MSG_ReadLong( msg ); // wsw : jal : by now our header sends incoming ack too (q3 doesn't)

	// check for fragment information
	if( sequence & FRAGMENT_BIT )
	{
		sequence &= ~FRAGMENT_BIT;
		fragmented = true;

		if( net_showfragments->integer )
			Com_Printf( "Process fragmented packet (%s) (id:%i)\n", NET_SocketToString( chan->socket ), sequence );
	}
	else
	{
		fragmented = false;
	}

	// wsw : jal : check for compressed information
	if( sequence_ack & FRAGMENT_BIT )
	{
		sequence_ack &= ~FRAGMENT_BIT;
		compressed = true;
		if( !fragmented )
			msg->compressed = true;
	}

	// read the game port if we are a server
	if( chan->socket->server )
		game_port = MSG_ReadShort( msg );

	// read the fragment information
	if( fragmented )
	{
		fragmentStart = MSG_ReadShort( msg );
		fragmentLength = MSG_ReadShort( msg );
		if( fragmentLength & FRAGMENT_LAST )
		{
			lastfragment = true;
			fragmentLength &= ~FRAGMENT_LAST;
		}
	}
	else
	{
		fragmentStart = 0; // stop warning message
		fragmentLength = 0;
	}

	if( showpackets->integer )
	{
		if( fragmented )
		{
			Com_Printf( "%s recv %4i : s=%i fragment=%i,%i\n", NET_SocketToString( chan->socket ), msg->cursize,
				sequence, fragmentStart, fragmentLength );
		}
		else
		{
			Com_Printf( "%s recv %4i : s=%i\n", NET_SocketToString( chan->socket ), msg->cursize, sequence );
		}
	}

	//
	// discard out of order or duplicated packets
	//
	if( sequence <= chan->incomingSequence )
	{
		if( showdrop->integer || showpackets->integer )
		{
			Com_Printf( "%s:Out of order packet %i at %i\n", NET_AddressToString( &chan->remoteAddress ), sequence,
				chan->incomingSequence );
		}
		return false;
	}

	//
	// dropped packets don't keep the message from being used
	//
	chan->dropped = sequence - ( chan->incomingSequence+1 );
	if( chan->dropped > 0 )
//.........这里部分代码省略.........
开发者ID:tenght,项目名称:qfusion,代码行数:101,代码来源:net_chan.c


示例20: 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 (void)
{
	char	*s;
	char	*c;

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

	s = MSG_ReadStringLine ();
	s[1023] = 0;

	Cmd_TokenizeString (s);

	c = Cmd_Argv(0);

	if (!strcmp(c, "ping") || ( c[0] == A2A_PING && (c[1] == 0 || c[1] == '\n')) )
	{
		SVC_Ping ();
		return;
	}
	if (c[0] == A2A_ACK && (c[1] == 0 || c[1] == '\n') )
	{
		Com_Printf ("A2A_ACK from %s\n", NET_AdrToString (net_from));
		return;
	}
	else if (!strcmp(c,"status"))
	{
		SVC_Status ();
		return;
	}
	else if (!strcmp(c,"log"))
	{
		SVC_Log ();
		return;
	}
	else if (!strcmp(c,"connect"))
	{
		SVC_DirectConnect ();
		return;
	}
#ifdef MAUTH
	else if (c[0] == M2S_AUTH_TOK && (c[1] == 0 || c[1] == '\n') )
	{
        Com_Printf("MAUTH: Adding token from %s to auth queue\n", NET_AdrToString(net_from));
        // Provisionally add auth record...
        if (SV_AuthListAdd(&authtokq))
        {
            //SV_AuthListPrint(&authtokq);
            //SV_AuthListPrint(&authclientq);
            // Send S2M_AUTH_TOK_CHK as a spoofing check...
            Master_AuthTokChk(authtokq.start->name, authtokq.start->hash);
        }
        else
        {
            Com_Printf("MAUTH: Failure to add token from %s -- already added?\n", NET_AdrToString(net_from));
            // FIXME Send S2M_AUTH_TOK_NACK
        }
		return;
	}
	else if (c[0] == M2S_AUTH_TOK_ACK && (c[1] == 0 || c[1] == '\n') )
	{
        // The master is sending us the correct name and hash;
        // check that what we've got agrees with this.

        // FIXME do we trust this packet?
       
        char tok_ack = S2C_AUTH_TOK_ACK;
        authclient_t *newclient = NULL;
        qbool result;
        result = SV_AuthListValidate(&authtokq, &newclient);
        //SV_AuthListPrint(&authtokq);
        //SV_AuthListPrint(&authclientq);

        // Check the client is valid...
        if( !result )
        {
            Com_Printf("MAUTH: Client is not valid!\n");
            return;
        }
        
        // Tell client they can connect...
        Com_Printf("MAUTH: Telling client %s on %s to connect...\n", newclient->name, NET_AdrToString(newclient->client_addr));
		NET_SendPacket (NS_SERVER, 1, &tok_ack, newclient->client_addr);
		return;
	}
	/*else if (c[0] == M2S_AUTH_TOK_NACK && (c[1] == 0 || c[1] == '\n') )
    {
        // Master said this token not valid -- FIXME how can we trust this?
        // FIXME remove player details from auth queue.
        Com_Printf("MAUTH: Player invalid!\n");
//.........这里部分代码省略.........
开发者ID:matatk,项目名称:agrip,代码行数:101,代码来源:sv_main.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MSG_BeginWriting函数代码示例发布时间:2022-05-30
下一篇:
C++ MSGPACK_UNUSED函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap