本文整理汇总了C++中MSG_Init函数的典型用法代码示例。如果您正苦于以下问题:C++ MSG_Init函数的具体用法?C++ MSG_Init怎么用?C++ MSG_Init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MSG_Init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: 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 ) {
msg_t msg;
byte msgBuffer[MAX_MSGLEN];
MSG_Init( &msg, msgBuffer, sizeof( msgBuffer ) );
// MW - my attempt to fix illegible server message errors caused by
// packet fragmentation of initial snapshot.
while(client->state&&client->netchan.unsentFragments)
{
// send additional message fragments if the last message
// was too large to send at once
Com_Printf ("[ISM]SV_SendClientGameState() [2] for %s, writing out old fragments\n", client->name);
SV_Netchan_TransmitNextFragment(&client->netchan);
}
Com_DPrintf ("SV_SendClientGameState() for %s\n", client->name);
Com_DPrintf( "Going from CS_CONNECTED to CS_PRIMED for %s\n", client->name );
if ( client->state == CS_CONNECTED )
client->state = CS_PRIMED;
client->pureAuthentic = 0;
client->gotCP = qfalse;
// 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;
SV_CreateClientGameStateMessage( client, &msg );
// deliver this to the client
SV_SendMessageToClient( &msg, client );
}
开发者ID:Avygeil,项目名称:NewJK,代码行数:45,代码来源:sv_client.cpp
示例17: MSG_ReadString
/*
================
rvDebuggerServer::HandleInspectVariable
Respondes to a request from the debugger client to inspect the value of a given variable
================
*/
void rvDebuggerServer::HandleInspectVariable ( msg_t* in_msg )
{
char varname[256];
int scopeDepth;
if ( !mBreak )
{
return;
}
scopeDepth = (short)MSG_ReadShort ( in_msg );
MSG_ReadString ( in_msg, varname, 256 );
idStr varvalue;
msg_t msg;
byte buffer[MAX_MSGLEN];
// Initialize the message
MSG_Init( &msg, buffer, sizeof( buffer ) );
MSG_WriteShort ( &msg, (int)DBMSG_INSPECTVARIABLE );
if ( !mBreakInterpreter->GetRegisterValue ( varname, varvalue, scopeDepth ) )
{
varvalue = "???";
}
MSG_WriteShort ( &msg, (short)scopeDepth );
MSG_WriteString ( &msg, varname );
MSG_WriteString ( &msg, varvalue );
SendPacket ( msg.data, msg.cursize );
}
开发者ID:0culus,项目名称:Doom3-for-MacOSX-,代码行数:40,代码来源:DebuggerServer.cpp
示例18: Netchan_Transmit
/*
* Netchan_Transmit
*
* Sends a message to a connection, fragmenting if necessary
* A 0 length will still generate a packet.
*/
bool Netchan_Transmit( netchan_t *chan, msg_t *msg )
{
msg_t send;
uint8_t send_buf[MAX_PACKETLEN];
assert( msg );
if( msg->cursize > MAX_MSGLEN )
{
Com_Error( ERR_DROP, "Netchan_Transmit: Excessive length = %i", msg->cursize );
return false;
}
chan->unsentFragmentStart = 0;
chan->unsentIsCompressed = false;
// fragment large reliable messages
if( msg->cursize >= FRAGMENT_SIZE )
{
chan->unsentFragments = true;
chan->unsentLength = msg->cursize;
chan->unsentIsCompressed = msg->compressed;
memcpy( chan->unsentBuffer, msg->data, msg->cursize );
// only send the first fragment now
return Netchan_TransmitNextFragment( chan );
}
// write the packet header
MSG_Init( &send, send_buf, sizeof( send_buf ) );
MSG_Clear( &send );
MSG_WriteLong( &send, chan->outgoingSequence );
// wsw : jal : by now our header sends incoming ack too (q3 doesn't)
// wsw : jal : also add compressed information if it's compressed
if( msg->compressed )
MSG_WriteLong( &send, chan->incomingSequence | FRAGMENT_BIT );
else
MSG_WriteLong( &send, chan->incomingSequence );
chan->outgoingSequence++;
// send the game port if we are a client
if( !chan->socket->server )
MSG_WriteShort( &send, game_port );
MSG_CopyData( &send, msg->data, msg->cursize );
// send the datagram
if( !NET_SendPacket( chan->socket, send.data, send.cursize, &chan->remoteAddress ) )
return false;
if( showpackets->integer )
{
Com_Printf( "%s send %4i : s=%i ack=%i\n", NET_SocketToString( chan->socket ), send.cursize,
chan->outgoingSequence - 1, chan->incomingSequence );
}
return true;
}
开发者ID:tenght,项目名称:qfusion,代码行数:65,代码来源:net_chan.c
示例19: 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;
entityState_t *base, nullstate;
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] );
}
}
// write the baselines
memset( &nullstate, 0, sizeof( nullstate ) );
for ( start = 0 ; start < MAX_GENTITIES; start++ ) {
base = &sv.svEntities[start].baseline;
if ( !base->number ) {
continue;
}
MSG_WriteByte( &msg, svc_baseline );
MSG_WriteDeltaEntity( &msg, &nullstate, base, qtrue );
}
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:CairnTrenor,项目名称:OpenJK,代码行数:65,代码来源:sv_client.cpp
示例20: SV_RecordDemo
void SV_RecordDemo( client_t *cl, char *demoName ) {
char name[MAX_OSPATH];
byte bufData[MAX_MSGLEN];
msg_t msg;
int len;
if ( cl->demo.demorecording ) {
Com_Printf( "Already recording.\n" );
return;
}
if ( cl->state != CS_ACTIVE ) {
Com_Printf( "Client is not active.\n" );
return;
}
// open the demo file
Q_strncpyz( cl->demo.demoName, demoName, sizeof( cl->demo.demoName ) );
Com_sprintf( name, sizeof( name ), "demos/%s.dm_%d", cl->demo.demoName, PROTOCOL_VERSION );
Com_Printf( "recording to %s.\n", name );
cl->demo.demofile = FS_FOpenFileWrite( name );
if ( !cl->demo.demofile ) {
Com_Printf ("ERROR: couldn't open.\n");
return;
}
cl->demo.demorecording = qtrue;
// don't start saving messages until a non-delta compressed message is received
cl->demo.demowaiting = qtrue;
cl->demo.isBot = ( cl->netchan.remoteAddress.type == NA_BOT ) ? qtrue : qfalse;
cl->demo.botReliableAcknowledge = cl->reliableSent;
// write out the gamestate message
MSG_Init( &msg, bufData, sizeof( bufData ) );
// NOTE, MRE: all server->client messages now acknowledge
int tmp = cl->reliableSent;
SV_CreateClientGameStateMessage( cl, &msg );
cl->reliableSent = tmp;
// finished writing the client packet
MSG_WriteByte( &msg, svc_EOF );
// write it to the demo file
len = LittleLong( cl->netchan.outgoingSequence - 1 );
FS_Write( &len, 4, cl->demo.demofile );
len = LittleLong( msg.cursize );
FS_Write( &len, 4, cl->demo.demofile );
FS_Write( msg.data, msg.cursize, cl->demo.demofile );
// the rest of the demo file will be copied from net messages
}
开发者ID:adnanfzafar,项目名称:OpenJK,代码行数:54,代码来源:sv_ccmds.cpp
注:本文中的MSG_Init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论