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


C++ MSG_Init函数代码示例

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


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

示例1: FT_CreateRequest

static ftRequest_t* FT_CreateRequest(const char* address, const char* url)
{
	void* buf;
	
	ftRequest_t* request;
	
	request = Z_Malloc(sizeof(ftRequest_t));
	if(request == NULL)
		return NULL;
	
	Com_Memset(request, 0, sizeof(ftRequest_t));
	request->lock = qtrue;
	request->finallen = -1;
	request->socket = -1;
	request->transfersocket = -1;
	
	if(address != NULL)
	{
		Q_strncpyz(request->address, address, sizeof(request->address));
		/* Open the connection */
		request->socket = NET_TcpClientConnect(request->address);
	
	    if(request->socket < 0)
		{	
			request->socket = -1;
			FT_FreeRequest(request);
			return NULL;
		}
		
	}

	buf = Z_Malloc(INITIAL_BUFFERLEN);
	if( buf == NULL)
	{
		FT_FreeRequest(request);
		return NULL;
	}
	MSG_Init(&request->recvmsg, buf, INITIAL_BUFFERLEN);
	
	buf = Z_Malloc(INITIAL_BUFFERLEN);
	if( buf == NULL)
	{
		FT_FreeRequest(request);
		return NULL;
	}
	MSG_Init(&request->sendmsg, buf, INITIAL_BUFFERLEN);
	
	if(url != NULL)
	{
		Q_strncpyz(request->url, url, sizeof(request->url));
	}
	
	request->startTime = Sys_Milliseconds();
	return request;
	
}
开发者ID:raydvard,项目名称:CoD4X17a_testing,代码行数:56,代码来源:httpftp.c

示例2: SV_WriteDemoMessageForClient

void SV_WriteDemoMessageForClient( byte *data, int dataLen, client_t *client ){

	int len, swlen;
	byte bufData[64];
	msg_t msg;

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

	

	SV_WriteDemoArchive(&msg, client);

	MSG_WriteByte(&msg, 0);

	// write the packet sequence
	len = client->netchan.outgoingSequence;
	swlen = LittleLong( len );
	MSG_WriteLong(&msg, swlen);

	// skip the packet sequencing information
	swlen = LittleLong( dataLen );

	MSG_WriteLong(&msg, swlen);
	FS_DemoWrite( msg.data, msg.cursize, client->demofile );

	FS_DemoWrite( data, dataLen, client->demofile );
//	Com_DPrintf("Writing: %i bytes of demodata\n", dataLen+ msg.cursize);
}
开发者ID:dioda,项目名称:apb,代码行数:28,代码来源:sv_demo.c

示例3: SV_SendClientSnapshot

/*
=======================
SV_SendClientSnapshot
=======================
*/
void SV_SendClientSnapshot( client_t *client ) {
	byte		msg_buf[MAX_MSGLEN];
	msg_t		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->svFlags & SVF_BOT ) {
		return;
	}

	MSG_Init (&msg, msg_buf, sizeof(msg_buf));
	msg.allowoverflow = qtrue;

	// (re)send any reliable server commands
	SV_UpdateServerCommandsToClient( client, &msg );

	// send over all the relevant entityState_t
	// and the playerState_t
	SV_WriteSnapshotToClient( client, &msg );

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

	SV_SendMessageToClient( &msg, client );
}
开发者ID:Hasimir,项目名称:jedi-academy-1,代码行数:36,代码来源:sv_snapshot.cpp

示例4: SV_SendClientEmptyMessage

/*
=======================
SV_SendClientEmptyMessage

This is just an empty message so that we can tell if
the client dropped the gamestate that went out before
=======================
*/
void SV_SendClientEmptyMessage( client_t *client ) {
	msg_t	msg;
	byte	buffer[10];

	MSG_Init( &msg, buffer, sizeof( buffer ) );
	SV_SendMessageToClient( &msg, client );
}
开发者ID:Hasimir,项目名称:jedi-academy-1,代码行数:15,代码来源:sv_snapshot.cpp

示例5: TV_Downstream_ClientResetCommandBuffers

/*
* TV_Downstream_ClientResetCommandBuffers
*/
void TV_Downstream_ClientResetCommandBuffers( client_t *client, qboolean resetReliable )
{
	// clear the sounds datagram
	MSG_Init( &client->soundsmsg, client->soundsmsgData, sizeof( client->soundsmsgData ) );
	MSG_Clear( &client->soundsmsg );

	if( resetReliable )
	{                   // reset the reliable commands buffer
		client->clientCommandExecuted = 0;
		client->reliableAcknowledge = 0;
		client->reliableSequence = 0;
		client->reliableSent = 0;
		memset( client->reliableCommands, 0, sizeof( client->reliableCommands ) );
	}

	// reset frames and game commands
	memset( client->gameCommands, 0, sizeof( client->gameCommands ) );
	client->gameCommandCurrent = 0;
	client->lastframe = -1;
	client->lastSentFrameNum = 0;
	memset( client->snapShots, 0, sizeof( client->snapShots ) );

	// reset the usercommands buffer(clc_move)
	client->UcmdTime = 0;
	client->UcmdExecuted = 0;
	client->UcmdReceived = 0;
	memset( client->ucmds, 0, sizeof( client->ucmds ) );
}
开发者ID:Kaperstone,项目名称:warsow,代码行数:31,代码来源:tv_downstream.c

示例6: PCT_ReconnectCloud

/*************************************************
* Function: PCT_ReconnectCloud
* Description: 
* Author: cxy 
* Returns: 
* Parameter: 
* History:
*************************************************/
void PCT_ReconnectCloud(PTC_ProtocolCon *pstruContoller, u32 u32ReConnectTimer)
{
    u32 u32Index;
    if (PCT_TIMER_INVAILD != pstruContoller->u8ReconnectTimer)
    {
        ZC_Printf("already reconnected \n");
        return;
    }
    

    MSG_Init();
    g_struProtocolController.u8keyRecv = PCT_KEY_UNRECVED;

    for (u32Index = 0; u32Index < ZC_TIMER_MAX_NUM; u32Index++)
    {
        
        if (g_struTimer[u32Index].u8Status == ZC_TIMER_STATUS_USED)
        {
            TIMER_StopTimer((u8)u32Index);
        }
    }
    
    TIMER_Init();
    g_struProtocolController.u8ReconnectTimer = PCT_TIMER_INVAILD;
    g_struProtocolController.u8SendMoudleTimer = PCT_TIMER_INVAILD;
    g_struProtocolController.u8HeartTimer = PCT_TIMER_INVAILD;
    g_struProtocolController.u8MainState = PCT_STATE_INIT;

    pstruContoller->pstruMoudleFun->pfunSetTimer(PCT_TIMER_RECONNECT, 
        u32ReConnectTimer, &pstruContoller->u8ReconnectTimer);
    pstruContoller->struCloudConnection.u32Socket = PCT_INVAILD_SOCKET;
    pstruContoller->u8keyRecv = PCT_KEY_UNRECVED; 
    pstruContoller->u8MainState = PCT_STATE_INIT;
}
开发者ID:greatlevi,项目名称:YD_SHUANGFA,代码行数:42,代码来源:zc_protocol_controller.c

示例7: SV_SendDownloadMessages

int SV_SendDownloadMessages(void)
{
	int i, numDLs = 0;
	client_t *cl;
	msg_t msg;
	byte msgBuffer[MAX_MSGLEN];
	
	for(i=0; i < sv_maxclients->integer; i++)
	{
		cl = &svs.clients[i];
		
		if(cl->state && *cl->downloadName)
		{
			int basesize;

			MSG_Init(&msg, msgBuffer, sizeof(msgBuffer));
			MSG_WriteLong(&msg, cl->lastClientCommand);
			
			basesize = msg.cursize;
			SV_WriteDownloadToClient(cl, &msg);
				
			if (msg.cursize != basesize)
			{
				SV_SendMessageToClient(&msg, cl);
				numDLs++;
			}
		}
	}

	return numDLs;
}
开发者ID:dpadgett,项目名称:OpenJK,代码行数:31,代码来源:sv_client.cpp

示例8: HL2Rcon_SourceRconFlushRedirect

void HL2Rcon_SourceRconFlushRedirect(char* outputbuf, qboolean lastcommand){

	rconUser_t* user;

	if(sourceRcon.redirectUser < 1 || sourceRcon.redirectUser > MAX_RCONUSERS)
		return;

	user = &sourceRcon.activeRconUsers[sourceRcon.redirectUser -1];

	msg_t msg;
	int32_t *updatelen;
	byte sourcemsgbuf[HL2RCON_SOURCEOUTPUTBUF_LENGTH+16];

	MSG_Init(&msg, sourcemsgbuf, sizeof(sourcemsgbuf));
	MSG_WriteLong(&msg, 0); //writing 0 for now
	MSG_WriteLong(&msg, user->lastpacketid);
	MSG_WriteLong(&msg, SERVERDATA_RESPONSE_VALUE);
	MSG_WriteBigString(&msg, outputbuf);

	MSG_WriteByte(&msg, 0);

	//Adjust the length
	updatelen = (int32_t*)msg.data;
	*updatelen = msg.cursize - 4;

	NET_SendData(user->remote.sock, &msg);
}
开发者ID:Call-of-Duty-Scripts,项目名称:CoD4X18-Server,代码行数:27,代码来源:hl2rcon.c

示例9: PCT_Sleep

/*************************************************
* Function: PCT_Sleep
* Description: 
* Author: cxy 
* Returns: 
* Parameter: 
* History:
*************************************************/
void PCT_Sleep()
{
    u32 u32Index;
    MSG_Init();

    g_struProtocolController.u8keyRecv = PCT_KEY_UNRECVED;
    memcpy(g_struProtocolController.u8SessionKey, g_struRegisterInfo.u8PrivateKey, ZC_HS_SESSION_KEY_LEN);
    memcpy(g_struProtocolController.IvSend, g_struRegisterInfo.u8PrivateKey, ZC_HS_SESSION_KEY_LEN);
    memcpy(g_struProtocolController.IvRecv, g_struRegisterInfo.u8PrivateKey, ZC_HS_SESSION_KEY_LEN);
    for (u32Index = 0; u32Index < ZC_TIMER_MAX_NUM; u32Index++)
    {
        if (g_struTimer[u32Index].u8Status == ZC_TIMER_STATUS_USED)
        {
            TIMER_StopTimer((u8)u32Index);
        }
    }

    TIMER_Init();
    g_struProtocolController.u8ReconnectTimer = PCT_TIMER_INVAILD;
    g_struProtocolController.u8SendMoudleTimer = PCT_TIMER_INVAILD;
    g_struProtocolController.u8HeartTimer = PCT_TIMER_INVAILD;
    g_struProtocolController.u8CloudAckTimer = PCT_TIMER_INVAILD;
    g_struProtocolController.u8MainState = PCT_STATE_INIT;
    g_struProtocolController.u8RegisterTimer = PCT_TIMER_INVAILD;
    g_struProtocolController.u32CloudNotAckNum = 0;
    PCT_SendNotifyMsg(ZC_CODE_WIFI_DISCONNECTED);
    ZC_ClientSleep();
}
开发者ID:sdhczw,项目名称:ZC,代码行数:36,代码来源:zc_protocol_controller.c

示例10: MSG_Init

/*
================
rvDebuggerServer::HandleInspectCallstack

Handle an incoming inspect callstack message by sending a message
back to the client with the callstack data.
================
*/
void rvDebuggerServer::HandleInspectCallstack ( msg_t* in_msg )
{
	msg_t		 msg;
	byte		 buffer[MAX_MSGLEN];
	int			 i;
	prstack_t	 temp;

	MSG_Init( &msg, buffer, sizeof( buffer ) );
	MSG_WriteShort ( &msg, (int)DBMSG_INSPECTCALLSTACK );	

	MSG_WriteShort ( &msg, (int)mBreakInterpreter->GetCallstackDepth ( ) );

	// write out the current function
	temp.f = mBreakInterpreter->GetCurrentFunction ( );
	temp.s = 0;
	temp.stackbase = 0;
	MSG_WriteCallstackFunc ( &msg, &temp );	

	// Run through all of the callstack and write each to the msg		
	for ( i = mBreakInterpreter->GetCallstackDepth ( ) - 1; i > 0; i -- )
	{
		MSG_WriteCallstackFunc ( &msg, mBreakInterpreter->GetCallstack ( ) + i );	
	}
		
	SendPacket ( msg.data, msg.cursize );
}
开发者ID:0culus,项目名称:Doom3-for-MacOSX-,代码行数:34,代码来源:DebuggerServer.cpp

示例11: PCT_Init

/*************************************************
* Function: PCT_Init
* Description: 
* Author: cxy 
* Returns: 
* Parameter: 
* History:
*************************************************/
void PCT_Init(PTC_ModuleAdapter *pstruAdapter)
{
    g_struProtocolController.pstruMoudleFun = pstruAdapter;

    g_struProtocolController.struCloudConnection.u32Socket = PCT_INVAILD_SOCKET;

    /*config connection type*/
    g_struProtocolController.struCloudConnection.u16Port = ZC_CLOUD_PORT;
    g_struProtocolController.struCloudConnection.u8IpType = ZC_IPTYPE_IPV4;
    g_struProtocolController.struCloudConnection.u8ConnectionType = ZC_CONNECT_TYPE_TCP;

    g_struProtocolController.struClientConnection.u32Socket = PCT_INVAILD_SOCKET;

    /*config connection type*/
    g_struProtocolController.struClientConnection.u16Port = ZC_SERVER_PORT;
    g_struProtocolController.struClientConnection.u8IpType = ZC_IPTYPE_IPV4;
    g_struProtocolController.struClientConnection.u8ConnectionType = ZC_CONNECT_TYPE_TCP;

    ZC_ConfigInitPara();

    MSG_Init();
    TIMER_Init();
    
    g_struProtocolController.u8keyRecv = PCT_KEY_UNRECVED;
    g_struProtocolController.u8ReconnectTimer = PCT_TIMER_INVAILD;
    g_struProtocolController.u8SendMoudleTimer = PCT_TIMER_INVAILD;
    g_struProtocolController.u8HeartTimer = PCT_TIMER_INVAILD;
    g_struProtocolController.u8RegisterTimer = PCT_TIMER_INVAILD;

    g_struProtocolController.u8MainState = PCT_STATE_INIT;

    //ZC_ClientInit();
}
开发者ID:greatlevi,项目名称:YD_SHUANGFA,代码行数:41,代码来源:zc_protocol_controller.c

示例12: Sys_GetEvent

/*
================
Sys_GetEvent

================
*/
sysEvent_t Sys_GetEvent( void ) {
	sysEvent_t	ev;
	char		*s;
	msg_t		netmsg;
	netadr_t	adr;

	// return if we have data
	if ( eventHead > eventTail ) {
		eventTail++;
		return eventQue[ ( eventTail - 1 ) & MASK_QUED_EVENTS ];
	}

	// pump the message loop
	// in vga this calls KBD_Update, under X, it calls GetEvent
	Sys_SendKeyEvents ();

	// check for console commands
	s = Sys_ConsoleInput();
	if ( s ) {
		char	*b;
		int		len;

		len = strlen( s ) + 1;
		b = (char *)malloc( len );
		strcpy( b, s );
		Sys_QueEvent( 0, SE_CONSOLE, 0, 0, len, b );
	}

	// check for other input devices
	IN_Frame();

	// check for network packets
	MSG_Init( &netmsg, sys_packetReceived, sizeof( sys_packetReceived ) );
#if 0
	if ( Sys_GetPacket ( &adr, &netmsg ) ) {
		netadr_t		*buf;
		int				len;

		// copy out to a seperate buffer for qeueing
		len = sizeof( netadr_t ) + netmsg.cursize;
		buf = malloc( len );
		*buf = adr;
		memcpy( buf+1, netmsg.data, netmsg.cursize );
		Sys_QueEvent( 0, SE_PACKET, 0, 0, len, buf );
	}
#endif

	// return if we have data
	if ( eventHead > eventTail ) {
		eventTail++;
		return eventQue[ ( eventTail - 1 ) & MASK_QUED_EVENTS ];
	}

	// create an empty event to return

	memset( &ev, 0, sizeof( ev ) );
	ev.evTime = Sys_Milliseconds();

	return ev;
}
开发者ID:Hasimir,项目名称:jedi-academy-1,代码行数:66,代码来源:unix_main.cpp

示例13: PCT_DisConnectCloud

/*************************************************
* Function: PCT_DisConnectCloud
* Description: 
* Author: cxy 
* Returns: 
* Parameter: 
* History:
*************************************************/
void PCT_DisConnectCloud(PTC_ProtocolCon *pstruContoller)
{
    pstruContoller->u8MainState = PCT_STATE_DISCONNECT_CLOUD;
    pstruContoller->u8keyRecv = PCT_KEY_UNRECVED;
    MSG_Init();
    PCT_SendNotifyMsg(ZC_CODE_CLOUD_DISCONNECTED);
}
开发者ID:greatlevi,项目名称:YD_SHUANGFA,代码行数:15,代码来源:zc_protocol_controller.c

示例14: SV_Demo_WriteSnap

/*
* SV_Demo_WriteSnap
*/
void SV_Demo_WriteSnap( void )
{
	int i;
	msg_t msg;
	uint8_t msg_buffer[MAX_MSGLEN];

	if( !svs.demo.file )
		return;

	for( i = 0; i < sv_maxclients->integer; i++ )
	{
		if( svs.clients[i].state >= CS_SPAWNED && svs.clients[i].edict &&
			!( svs.clients[i].edict->r.svflags & SVF_NOCLIENT ) )
			break;
	}
	if( i == sv_maxclients->integer )
	{                               // FIXME
		Com_Printf( "No players left, stopping server side demo recording\n" );
		SV_Demo_Stop_f();
		return;
	}

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

	SV_BuildClientFrameSnap( &svs.demo.client );

	SV_WriteFrameSnapToClient( &svs.demo.client, &msg );

	SV_AddReliableCommandsToMessage( &svs.demo.client, &msg );

	SV_Demo_WriteMessage( &msg );

	svs.demo.duration = svs.gametime - svs.demo.basetime;
	svs.demo.client.lastframe = sv.framenum; // FIXME: is this needed?
}
开发者ID:cfr,项目名称:qfusion,代码行数:38,代码来源:sv_demos.c

示例15: SV_WriteDemoArchive

void SV_WriteDemoArchive(client_t *client){

	byte bufData[72];
	msg_t msg;

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

	int archiveIndex;
	playerState_t *ps = SV_GameClientNum(client - svs.clients);
	vec3_t nullvec = {0, 0, 0};

	MSG_WriteByte(&msg, 1);

	archiveIndex = client->demoArchiveIndex % 256;
	MSG_WriteLong(&msg, archiveIndex);
	MSG_WriteVector(&msg, ps->origin);

	MSG_WriteVector(&msg, nullvec);
	MSG_WriteLong(&msg, 0); //Velocity

	MSG_WriteLong(&msg, 0);
	MSG_WriteLong(&msg, ps->commandTime);
	MSG_WriteVector(&msg, ps->viewangles);
	client->demoArchiveIndex++;

	FS_DemoWrite( msg.data, msg.cursize, &client->demofile );
}
开发者ID:BraXi,项目名称:CoD4X18-Server,代码行数:27,代码来源:sv_demo.c


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