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


C++ MSG_WriteLong函数代码示例

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


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

示例1: Netchan_TransmitNextFragment

/*
=================
Netchan_TransmitNextFragment

Send one fragment of the current message
=================
*/
void Netchan_TransmitNextFragment( netchan_t *chan ) {
    msg_t		send;
    byte		send_buf[MAX_PACKETLEN];
    int			fragmentLength;

    // write the packet header
    MSG_InitOOB (&send, send_buf, sizeof(send_buf));				// <-- only do the oob here

    MSG_WriteLong( &send, chan->outgoingSequence | FRAGMENT_BIT );

    // send the qport if we are a client
    if ( chan->sock == NS_CLIENT ) {
        MSG_WriteShort( &send, qport->integer );
    }

    // copy the reliable message to the packet first
    fragmentLength = FRAGMENT_SIZE;
    if ( chan->unsentFragmentStart  + fragmentLength > chan->unsentLength ) {
        fragmentLength = chan->unsentLength - chan->unsentFragmentStart;
    }

    MSG_WriteShort( &send, chan->unsentFragmentStart );
    MSG_WriteShort( &send, fragmentLength );
    MSG_WriteData( &send, chan->unsentBuffer + chan->unsentFragmentStart, fragmentLength );

    // send the datagram
    NET_SendPacket( chan->sock, send.cursize, send.data, chan->remoteAddress );

    if ( showpackets->integer ) {
        Com_Printf ("%s send %4i : s=%i fragment=%i,%i\n"
                    , netsrcString[ chan->sock ]
                    , send.cursize
                    , chan->outgoingSequence
                    , chan->unsentFragmentStart, fragmentLength);
    }

    chan->unsentFragmentStart += fragmentLength;

    // this exit condition is a little tricky, because a packet
    // that is exactly the fragment length still needs to send
    // a second packet of zero length so that the other side
    // can tell there aren't more to follow
    if ( chan->unsentFragmentStart == chan->unsentLength && fragmentLength != FRAGMENT_SIZE ) {
        chan->outgoingSequence++;
        chan->unsentFragments = qfalse;
    }
}
开发者ID:Wbuanguna,项目名称:tremfusion,代码行数:54,代码来源:net_chan.c

示例2: SV_SendClientSnapshot

/*
=======================
SV_SendClientSnapshot

Also called by SV_FinalMessage

=======================
*/
void SV_SendClientSnapshot( client_t* client )
{
	byte        msg_buf[MAX_MSGLEN];
	msg_s       msg;
	
	// build the snapshot
	SV_BuildClientSnapshot( client );
	
	// bots need to have their snapshots build, but
	// the query them directly without needing to be sent
	//if ( client->gentity && client->gentity->r.svFlags & SVF_BOT ) {
	//  return;
	//}
	
	MSG_Init( &msg, msg_buf, sizeof( msg_buf ) );
	msg.allowoverflow = true;
	
	// compression byte is the first byte in all server->client messages
	msg.oob = true;
	MSG_WriteByte( &msg, 0 );
	msg.oob = false;
	
	// NOTE, MRE: all server->client messages now acknowledge
	// let the client know which reliable clientCommands we have received
	MSG_WriteLong( &msg, client->lastClientCommand );
	
	// (re)send any reliable server commands
	SV_UpdateServerCommandsToClient( client, &msg );
	
	// send over all the relevant entityState_s
	// and the playerState_s
	SV_WriteSnapshotToClient( client, &msg );
	
#ifdef USE_VOIP
	SV_WriteVoipToClient( client, &msg );
#endif
	
	// check for overflow
	if ( msg.overflowed )
	{
		Com_Printf( "WARNING: msg overflowed for %s\n", client->name );
		MSG_Clear( &msg );
	}
	
	SV_SendMessageToClient( &msg, client );
}
开发者ID:OnlyTheGhosts,项目名称:OWEngine,代码行数:54,代码来源:sv_snapshot.cpp

示例3: SV_SendServerinfo

/*
================
SV_SendServerinfo

Sends the first message from the server to a connected client.
This will be sent on the initial connection and upon each server load.
================
*/
void SV_SendServerinfo (client_t *client)
{
	char			**s;
	char			message[2048];

	MSG_WriteByte (&client->message, svc_print);
	sprintf (message, "%c\nVERSION %4.2f SERVER (%i CRC)", 2, VERSION, pr_crc);
	MSG_WriteString (&client->message,message);

	MSG_WriteByte (&client->message, svc_serverinfo);
	MSG_WriteLong (&client->message, PROTOCOL_VERSION);
	MSG_WriteByte (&client->message, svs.maxclients);

	if (!coop.value && deathmatch.value)
		MSG_WriteByte (&client->message, GAME_DEATHMATCH);
	else
		MSG_WriteByte (&client->message, GAME_COOP);

	sprintf (message, pr_strings+sv.edicts->u.v.message);

	MSG_WriteString (&client->message,message);

	for (s = sv.model_precache+1 ; *s ; s++)
		MSG_WriteString (&client->message, *s);
	MSG_WriteByte (&client->message, 0);

	for (s = sv.sound_precache+1 ; *s ; s++)
		MSG_WriteString (&client->message, *s);
	MSG_WriteByte (&client->message, 0);

// send music
	MSG_WriteByte (&client->message, svc_cdtrack);
	MSG_WriteByte (&client->message, (int) sv.edicts->u.v.sounds);
	MSG_WriteByte (&client->message, (int) sv.edicts->u.v.sounds);

// set view	
	MSG_WriteByte (&client->message, svc_setview);
	MSG_WriteShort (&client->message, NUM_FOR_EDICT(client->edict));

	MSG_WriteByte (&client->message, svc_signonnum);
	MSG_WriteByte (&client->message, 1);

	client->sendsignon = true;
	client->spawned = false;		// need prespawn, spawn, etc
}
开发者ID:Axovera,项目名称:glesquake,代码行数:53,代码来源:sv_main.cpp

示例4: Netchan_Transmit

/*
===============
Netchan_Transmit

Sends a message to a connection, fragmenting if necessary
A 0 length will still generate a packet.
================
*/
void Netchan_Transmit( netchan_t *chan, size_t length, const byte *data ) {
	msg_t		send;
	byte		send_buf[MAX_PACKETLEN];

	if ( length > MAX_MSGLEN ) {
		Com_Error( ERR_DROP, "Netchan_Transmit: length = %i", length );
	}
	chan->unsentFragmentStart = 0;

	// fragment large reliable messages
	if ( length >= FRAGMENT_SIZE ) {
		chan->unsentFragments = qtrue;
		chan->unsentLength = length;
		Com_Memcpy( chan->unsentBuffer, data, length );

		// only send the first fragment now
		Netchan_TransmitNextFragment( chan );

		return;
	}

	// write the packet header
	MSG_InitOOB (&send, send_buf, sizeof(send_buf));

	MSG_WriteLong( &send, chan->outgoingSequence );
	chan->outgoingSequence++;

	// send the qport if we are a client
	if ( chan->sock == NS_CLIENT ) {
		MSG_WriteShort( &send, qport->integer );
	}

	MSG_WriteData( &send, data, length );

	// send the datagram
	NET_SendPacket( chan->sock, send.cursize, send.data, chan->remoteAddress );

	if ( showpackets->integer ) {
		Com_Printf( "%s send %4i : s=%i ack=%i\n"
			, netsrcString[ chan->sock ]
			, send.cursize
			, chan->outgoingSequence - 1
			, chan->incomingSequence );
	}
}
开发者ID:kingtiger01,项目名称:openmohaa-1,代码行数:53,代码来源:net_chan.c

示例5: SV_UpdateServerCommandsToClient

/*
==================
SV_UpdateServerCommandsToClient

(re)send all server commands the client hasn't acknowledged yet
==================
*/
void SV_UpdateServerCommandsToClient( client_t *client, msg_t *msg ) {
	int		i;
	int		reliableAcknowledge;

	if ( client->demo.isBot && client->demo.demorecording ) {
		reliableAcknowledge = client->demo.botReliableAcknowledge;
	} else {
		reliableAcknowledge = client->reliableAcknowledge;
	}

	// write any unacknowledged serverCommands
	for ( i = reliableAcknowledge + 1 ; i <= client->reliableSequence ; i++ ) {
		MSG_WriteByte( msg, svc_serverCommand );
		MSG_WriteLong( msg, i );
		MSG_WriteString( msg, client->reliableCommands[ i & (MAX_RELIABLE_COMMANDS-1) ] );
	}
	client->reliableSent = client->reliableSequence;
}
开发者ID:LeadGuitar,项目名称:OpenJK,代码行数:25,代码来源:sv_snapshot.cpp

示例6: Transmite_TerraGCPacket_Remain_Minute_NoticeMessage

void CTerraBillingCtrl_Decoder::
Transmite_TerraGCPacket_Remain_Minute_NoticeMessage(
	playerCharacter_t* pToPlayerRecord,
	const int RemainMinute) const
{
	MSG_BeginWriting(&netMessage);
	
	MSG_Clear(&netMessage);
	{
		MSG_WriteByte(&netMessage, GSC_EXTEND);
		MSG_WriteByte(&netMessage, GSC_EXTEND_TERRA);
		MSG_WriteByte(&netMessage, tagTerraGCPacket::Remain_Minute_NoticeMessage);
		MSG_WriteLong(&netMessage, RemainMinute);		

		NET_SendMessage(&pToPlayerRecord->sock, &netMessage);
	}
	MSG_EndWriting(&netMessage);
}
开发者ID:gthgame,项目名称:gth,代码行数:18,代码来源:CTerraBillingCtrl_Decoder.cpp

示例7: MSG_BeginWriting

void CHelperManager_Encoder::SendMessage_Mypoint_toTaker(
	playerCharacter_t* pPlayer, char* pTakerName,char* pHelperName, int MyPoint)
{
	MSG_BeginWriting(&netMessage);
	MSG_Clear( &netMessage );
	{
		MSG_WriteByte(&netMessage, EXTEND_SECOND);
		MSG_WriteShort( &netMessage, HELPER_SYSTEM );
		MSG_WriteShort(&netMessage, SC_SENDMYPOINT_toAllPlayer);
		MSG_WriteString(&netMessage,pTakerName);
		MSG_WriteString(&netMessage,pHelperName);
		MSG_WriteLong(&netMessage,MyPoint);
		NET_SendMessage(&pPlayer->sock, &netMessage);
	}
	
	MSG_EndWriting(&netMessage);
	
}
开发者ID:gthgame,项目名称:gth,代码行数:18,代码来源:CHelperManager_Encoder.cpp

示例8: strncpy

void CPostFunc::GTH_SendMessage_PostSystem_Send()
{

	
	char    name[NAMESTRING+1];
	char	title[CPostManager::POST_TITLESIZE+1];
	char	message[CPostManager::POST_STRSIZE+1];



	strncpy(name,g_ifMng->m_mailBoxWin->m_name,NAMESTRING);
	name[NAMESTRING]=NULL;
	CTools::Replace_singleQUOTATIONmark_by_doubleQUOTATIONmark(name);


	strncpy(title,g_ifMng->m_mailBoxWin->m_title,CPostManager::POST_TITLESIZE);
	title[CPostManager::POST_TITLESIZE]=NULL;
	CTools::Replace_singleQUOTATIONmark_by_doubleQUOTATIONmark(title);

	strncpy(message,g_ifMng->m_mailBoxWin->m_message,CPostManager::POST_STRSIZE);
	message[CPostManager::POST_STRSIZE]=NULL;
	CTools::Replace_singleQUOTATIONmark_by_doubleQUOTATIONmark(message);







	MSG_BeginWriting(&netMessage);
	MSG_Clear( &netMessage );
	{
		MSG_WriteByte(&netMessage, CC_EXTEND);
		MSG_WriteByte(&netMessage, CC_POSTSYSTEM);
		MSG_WriteByte(&netMessage, POSTSYSTEM_SEND);
		
		MSG_WriteString(&netMessage, name);
		MSG_WriteString(&netMessage, title);
		MSG_WriteString(&netMessage, message);
		MSG_WriteLong(&netMessage, g_ifMng->m_mailBoxWin->m_nak);
		NET_SendMessage(&gsSocket, &netMessage); 
	}
	MSG_EndWriting( &netMessage );	
}
开发者ID:gthgame,项目名称:gth,代码行数:44,代码来源:PostFunc.cpp

示例9: Netchan_OutOfBand

/*
	Netchan_OutOfBand

	Sends an out-of-band datagram
*/
void
Netchan_OutOfBand (netadr_t adr, int length, byte * data)
{
	byte        send_buf[MAX_MSGLEN + PACKET_HEADER];
	sizebuf_t   send;

	// write the packet header
	send.data = send_buf;
	send.maxsize = sizeof (send_buf);
	send.cursize = 0;

	MSG_WriteLong (&send, -1);			// -1 sequence means out of band
	SZ_Write (&send, data, length);

	// send the datagram
	// zoid, no input in demo playback mode
	if (!net_blocksend)
		Netchan_SendPacket (send.cursize, send.data, adr);
}
开发者ID:EIREXE,项目名称:Quakeforge-gcw0,代码行数:24,代码来源:net_chan.c

示例10: MSG_BeginWriting

inline void CGMCtrl::TransmitePacket_NProtect_msgs_notify_change(const BOOL in_bEnable) const
{
	MSG_BeginWriting(&netMessage);
	MSG_Clear( &netMessage );
	{
		MSG_WriteByte(&netMessage, EXTEND_SECOND);		
		MSG_WriteShort(&netMessage, GMsystem);
		MSG_WriteShort(&netMessage, tagExtendSecondPacket_GMsystem::GMsystem_NProtect);
		MSG_WriteShort(&netMessage, tagExtendSecondPacket_GMsystem::tagNProtect::msgs_notify_change);
		MSG_WriteLong(&netMessage,in_bEnable);

		for(int i=1; i < MAX_MEMBER_SERVER; i++){ 
			if ( !g_memberServer[i].active )	continue;
			NET_SendUnreliableMessage(&g_memberServer[i].sock, &netMessage);
		}
	}
	MSG_EndWriting(&netMessage);

}
开发者ID:gthgame,项目名称:gth,代码行数:19,代码来源:CGMCtrl.cpp

示例11: MSG_BeginWriting

void CGs_To_Cc::Send(playerCharacter_t* pPlayer,int SystemType,int mainType, int subType,int val, char *TargetPlayerName)
{
	MSG_BeginWriting( &netMessage );
	MSG_Clear( &netMessage );
	{
		MSG_WriteByte(&netMessage, EXTEND_SECOND);
		
		MSG_WriteShort(&netMessage, SystemType);
		MSG_WriteShort(&netMessage, mainType);		
		MSG_WriteShort(&netMessage, subType);	

		MSG_WriteLong(&netMessage, val);	

		MSG_WriteString(&netMessage, TargetPlayerName);	

		NET_SendMessage(&pPlayer->sock, &netMessage);
	}
	MSG_EndWriting(&netMessage);
}
开发者ID:gthgame,项目名称:gth,代码行数:19,代码来源:Gs_To_Cc.cpp

示例12: Netchan_OutOfBand

void Netchan_OutOfBand(netsrc_t sock, netadr_t adr, int length, byte *data)
{
	sizebuf_t send;
	byte send_buf[NET_MAX_PAYLOAD];

	send.buffername = "Netchan_OutOfBand";
	send.data = send_buf;
	send.maxsize = sizeof(send_buf);
	send.cursize = 0;
	send.flags = SIZEBUF_ALLOW_OVERFLOW;

	MSG_WriteLong(&send, -1);
	SZ_Write(&send, data, length);

	if (!g_pcls.demoplayback)
	{
		NET_SendPacket(sock, send.cursize, send.data, adr);
	}
}
开发者ID:Chuvi-w,项目名称:rehlds,代码行数:19,代码来源:net_chan.cpp

示例13: SV_SendClientGameState

/*
================
SV_SendClientGameState

Sends the first message from the server to a connected client.
This will be sent on the initial connection and upon each new map load.

It will be resent if the client acknowledges a later message but has
the wrong gamestate.
================
*/
void SV_SendClientGameState( client_t *client ) {
	int			start;
	msg_t		msg;
	byte		msgBuffer[MAX_MSGLEN];

	Com_DPrintf ("SV_SendGameState() for %s\n", client->name);
	client->state = CS_PRIMED;

	// when we receive the first packet from the client, we will
	// notice that it is from a different serverid and that the
	// gamestate message was not just sent, forcing a retransmit
	client->gamestateMessageNum = client->netchan.outgoingSequence;

	// clear the reliable message list for this client
	client->reliableSequence = 0;
	client->reliableAcknowledge = 0;

	MSG_Init( &msg, msgBuffer, sizeof( msgBuffer ) );

	// send the gamestate
	MSG_WriteByte( &msg, svc_gamestate );
	MSG_WriteLong( &msg, client->reliableSequence );

	// write the configstrings
	for ( start = 0 ; start < MAX_CONFIGSTRINGS ; start++ ) {
		if (sv.configstrings[start][0]) {
			MSG_WriteByte( &msg, svc_configstring );
			MSG_WriteShort( &msg, start );
			MSG_WriteString( &msg, sv.configstrings[start] );
		}
	}

	MSG_WriteByte( &msg, 0 );

	// check for overflow
	if ( msg.overflowed ) {
		Com_Printf ("WARNING: GameState overflowed for %s\n", client->name);
	}

	// deliver this to the client
	SV_SendMessageToClient( &msg, client );
}
开发者ID:AlexCSilva,项目名称:jediacademy,代码行数:53,代码来源:sv_client.cpp

示例14: TV_Downstream_AddReliableCommandsToMessage

/*
* TV_Downstream_AddReliableCommandsToMessage
* 
* (re)send all server commands the client hasn't acknowledged yet
*/
void TV_Downstream_AddReliableCommandsToMessage( client_t *client, msg_t *msg )
{
	unsigned int i;

	// write any unacknowledged serverCommands
	for( i = client->reliableAcknowledge + 1; i <= client->reliableSequence; i++ )
	{
		if( !strlen( client->reliableCommands[i & ( MAX_RELIABLE_COMMANDS-1 )] ) )
			continue;

		MSG_WriteByte( msg, svc_servercmd );
		if( !client->reliable )
			MSG_WriteLong( msg, i );
		MSG_WriteString( msg, client->reliableCommands[i & ( MAX_RELIABLE_COMMANDS-1 )] );
	}

	client->reliableSent = client->reliableSequence;
	if( client->reliable )
		client->reliableAcknowledge = client->reliableSent;
}
开发者ID:Kaperstone,项目名称:warsow,代码行数:25,代码来源:tv_downstream.c

示例15: SV_Customization

// Sends resource to all other players, optionally skipping originating player.
void SV_Customization(client_t *pPlayer, resource_t *pResource, qboolean bSkipPlayer)
{
	int i;
	int nPlayerNumber;
	client_t *pHost;

	// Get originating player id
	for (i = 0, pHost = g_psvs.clients; i < g_psvs.maxclients; i++, pHost++)
	{
		if (pHost == pPlayer)
			break;
	}
	if (i == g_psvs.maxclients)
	{
		Sys_Error("Couldn't find player index for customization.");
	}

	nPlayerNumber = i;

	// Send resource to all other active players
	for (i = 0, pHost = g_psvs.clients; i < g_psvs.maxclients; i++, pHost++)
	{
		if (!pHost->active && !pHost->spawned || pHost->fakeclient)
			continue;

		if (pHost == pPlayer && bSkipPlayer)
			continue;

		MSG_WriteByte(&pHost->netchan.message, svc_customization);
		MSG_WriteByte(&pHost->netchan.message, nPlayerNumber);
		MSG_WriteByte(&pHost->netchan.message, pResource->type);
		MSG_WriteString(&pHost->netchan.message, pResource->szFileName);
		MSG_WriteShort(&pHost->netchan.message, pResource->nIndex);
		MSG_WriteLong(&pHost->netchan.message, pResource->nDownloadSize);
		MSG_WriteByte(&pHost->netchan.message, pResource->ucFlags);
		if (pResource->ucFlags & RES_CUSTOM)
		{
			SZ_Write(&pHost->netchan.message, pResource->rgucMD5_hash, 16);
		}
	}
}
开发者ID:Adidasman1,项目名称:rehlds,代码行数:42,代码来源:sv_upld.cpp


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