本文整理汇总了C++中MSG_BeginReading函数的典型用法代码示例。如果您正苦于以下问题:C++ MSG_BeginReading函数的具体用法?C++ MSG_BeginReading怎么用?C++ MSG_BeginReading使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MSG_BeginReading函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) );
}
}
}
}
示例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);
}
}
示例3: NQD_ReadPackets
void NQD_ReadPackets (void)
{
while (CL_GetNQDemoMessage()) {
MSG_BeginReading ();
CLNQ_ParseServerMessage();
}
}
示例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;
}
示例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);
}
示例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 );
}
示例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 );
}
示例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" );
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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 );
}