本文整理汇总了C++中Netchan_Transmit函数的典型用法代码示例。如果您正苦于以下问题:C++ Netchan_Transmit函数的具体用法?C++ Netchan_Transmit怎么用?C++ Netchan_Transmit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Netchan_Transmit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: SV_Restart_f
static void
SV_Restart_f (void)
{
client_t *client;
int j;
SZ_Clear (net_message->message);
MSG_WriteByte (net_message->message, svc_print);
MSG_WriteByte (net_message->message, PRINT_HIGH);
MSG_WriteString (net_message->message,
"\x9d\x9e\x9e\x9e\x9e\x9e\x9e\x9e"
"\x9e\x9e\x9e\x9e\x9e\x9e\x9e\x9e"
"\x9e\x9e\x9e\x9e\x9e\x9e\x9e\x9e"
"\x9e\x9e\x9f\n"
" Server \xf2\xe5\xf3\xf4\xe1\xf2\xf4 engaged\xae\xae\xae\n"
"\x9d\x9e\x9e\x9e\x9e\x9e\x9e\x9e"
"\x9e\x9e\x9e\x9e\x9e\x9e\x9e\x9e"
"\x9e\x9e\x9e\x9e\x9e\x9e\x9e\x9e"
"\x9e\x9e\x9f\n\n");
MSG_WriteByte (net_message->message, svc_stufftext);
MSG_WriteString (net_message->message, RESTART_CLSTUFF);
MSG_WriteByte (net_message->message, svc_disconnect);
for (j = 0, client = svs.clients; j < MAX_CLIENTS; j++, client++) {
if (client->state >= cs_spawned)
Netchan_Transmit (&client->netchan, net_message->message->cursize,
net_message->message->data);
}
Sys_Printf ("Shutting down: server restart, shell must relaunch server\n");
SV_Shutdown ();
// Error code 2 on exit, indication shell must restart the server
exit (2);
}
开发者ID:luaman,项目名称:qforge-1,代码行数:34,代码来源:sv_ccmds.c
示例2: SV_SendClientMessages
/*
=======================
SV_SendClientMessages
=======================
*/
void SV_SendClientMessages( void )
{
sv_client_t *cl;
int i;
if( sv.state == ss_dead )
return;
// send a message to each connected client
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
{
if( !cl->state ) continue;
if( !cl->edict || (cl->edict->v.flags & (FL_FAKECLIENT|FL_SPECTATOR)))
continue;
// update any userinfo packets that have changed
if( cl->sendinfo )
{
cl->sendinfo = false;
SV_FullClientUpdate( cl, &sv.multicast );
}
if( cl->sendmovevars )
{
cl->sendmovevars = false;
SV_UpdatePhysinfo( cl, &sv.multicast );
}
// if the reliable message overflowed, drop the client
if( cl->netchan.message.overflowed )
{
MSG_Clear( &cl->netchan.message );
MSG_Clear( &cl->reliable );
MSG_Clear( &cl->datagram );
SV_BroadcastPrintf( PRINT_HIGH, "%s overflowed\n", cl->name );
SV_DropClient( cl );
cl->send_message = true;
}
// only send messages if the client has sent one
if( !cl->send_message ) continue;
if( cl->state == cs_spawned )
{
// don't overrun bandwidth
if( SV_RateDrop( cl )) continue;
SV_SendClientDatagram( cl );
}
else
{
// just update reliable
if( cl->netchan.message.cursize || svs.realtime - cl->netchan.last_sent > 1000 )
Netchan_Transmit( &cl->netchan, 0, NULL );
}
// yes, message really sended
cl->send_message = false;
}
}
开发者ID:a1batross,项目名称:Xash3D_ancient,代码行数:65,代码来源:sv_frame.c
示例3: CL_Netchan_Transmit
/*
===============
CL_Netchan_Transmit
================
*/
void CL_Netchan_Transmit(netchan_t * chan, msg_t * msg)
{
MSG_WriteByte(msg, clc_EOF);
CL_Netchan_Encode(msg);
Netchan_Transmit(chan, msg->cursize, msg->data);
}
开发者ID:otty,项目名称:cake3,代码行数:12,代码来源:cl_net_chan.c
示例4: Sv_DropClient
/*
* @brief Called when the player is totally leaving the server, either willingly
* or unwillingly. This is NOT called if the entire server is quitting
* or crashing.
*/
void Sv_DropClient(sv_client_t *cl) {
g_entity_t *ent;
Mem_ClearBuffer(&cl->net_chan.message);
Mem_ClearBuffer(&cl->datagram.buffer);
if (cl->datagram.messages) {
g_list_free_full(cl->datagram.messages, Mem_Free);
}
if (cl->state > SV_CLIENT_FREE) { // send the disconnect
if (cl->state == SV_CLIENT_ACTIVE) { // after informing the game module
svs.game->ClientDisconnect(cl->entity);
}
Net_WriteByte(&cl->net_chan.message, SV_CMD_DISCONNECT);
Netchan_Transmit(&cl->net_chan, cl->net_chan.message.data, cl->net_chan.message.size);
}
if (cl->download.buffer) {
Fs_Free(cl->download.buffer);
}
ent = cl->entity;
memset(cl, 0, sizeof(*cl));
cl->entity = ent;
cl->last_frame = -1;
}
开发者ID:chrisnew,项目名称:quetoo,代码行数:36,代码来源:sv_main.c
示例5: SV_Netchan_TransmitNextFragment
/*
=================
SV_Netchan_TransmitNextFragment
=================
*/
void SV_Netchan_TransmitNextFragment(client_t *client)
{
Netchan_TransmitNextFragment(&client->netchan);
while (!client->netchan.unsentFragments && client->netchan_start_queue)
{
// make sure the netchan queue has been properly initialized (you never know)
//if (!client->netchan_end_queue) {
// Com_Error(ERR_DROP, "netchan queue is not properly initialized in SV_Netchan_TransmitNextFragment");
//}
// the last fragment was transmitted, check wether we have queued messages
netchan_buffer_t *netbuf = client->netchan_start_queue;
// pop from queue
client->netchan_start_queue = netbuf->next;
if (!client->netchan_start_queue)
{
client->netchan_end_queue = NULL;
}
SV_Netchan_Encode(client, &netbuf->msg, netbuf->lastClientCommandString);
Netchan_Transmit(&client->netchan, netbuf->msg.cursize, netbuf->msg.data);
Z_Free(netbuf);
}
}
开发者ID:scenna,项目名称:etlegacy,代码行数:31,代码来源:sv_net_chan.c
示例6: SV_Netchan_TransmitNextFragment
/*
=================
SV_Netchan_TransmitNextFragment
=================
*/
void SV_Netchan_TransmitNextFragment(client_t *client) {
Netchan_TransmitNextFragment(&client->netchan);
if (!client->netchan.unsentFragments)
{
// make sure the netchan queue has been properly initialized (you never know)
if ((!client->netchan_end_queue) && (client->state >= CS_CONNECTED)) {
Com_Error(ERR_DROP, "netchan queue is not properly initialized in SV_Netchan_TransmitNextFragment\n");
}
// the last fragment was transmitted, check wether we have queued messages
if (client->netchan_start_queue) {
netchan_buffer_t *netbuf;
Com_DPrintf("#462 Netchan_TransmitNextFragment: popping a queued message for transmit\n");
netbuf = client->netchan_start_queue;
SV_Netchan_Encode(client, &netbuf->msg);
Netchan_Transmit(&client->netchan, netbuf->msg.cursize, netbuf->msg.data);
// pop from queue
client->netchan_start_queue = netbuf->next;
if (!client->netchan_start_queue) {
Com_DPrintf("#462 Netchan_TransmitNextFragment: emptied queue\n");
client->netchan_end_queue = &client->netchan_start_queue;
}
else
Com_DPrintf("#462 Netchan_TransmitNextFragment: remaining queued message\n");
Z_Free(netbuf);
}
}
}
开发者ID:alexanderkress,项目名称:ioq3-for-UrbanTerror-4.2,代码行数:32,代码来源:sv_net_chan.c
示例7: SV_Netchan_TransmitNextInQueue
void SV_Netchan_TransmitNextInQueue(client_t *client) {
netchan_buffer_t *netbuf;
Com_DPrintf("#462 Netchan_TransmitNextFragment: popping a queued message for transmit\n");
netbuf = client->netchan_start_queue;
#ifdef LEGACY_PROTOCOL
if(client->compat)
SV_Netchan_Encode(client, &netbuf->msg, netbuf->clientCommandString);
#endif
Netchan_Transmit(&client->netchan, netbuf->msg.cursize, netbuf->msg.data);
// pop from queue
client->netchan_start_queue = netbuf->next;
if(!client->netchan_start_queue)
{
Com_DPrintf("#462 Netchan_TransmitNextFragment: emptied queue\n");
client->netchan_end_queue = &client->netchan_start_queue;
}
else
Com_DPrintf("#462 Netchan_TransmitNextFragment: remaining queued message\n");
Z_Free(netbuf);
}
开发者ID:Razish,项目名称:QtZ,代码行数:25,代码来源:sv_net_chan.c
示例8: CL_CheckingResFile
/*
==============
CL_CheckingResFile
==============
*/
void CL_CheckingResFile( char *pResFileName )
{
sizebuf_t buf;
byte data[32];
if( FS_FileExists( pResFileName, false ))
return; // already existing
cls.downloadcount++;
Msg( "Starting downloads file: %s\n", pResFileName );
if( cls.state == ca_disconnected ) return;
BF_Init( &buf, "ClientPacket", data, sizeof( data ));
BF_WriteByte( &buf, clc_resourcelist );
BF_WriteString( &buf, pResFileName );
if( !cls.netchan.remote_address.type ) // download in singleplayer ???
cls.netchan.remote_address.type = NA_LOOPBACK;
// make sure message will be delivered
Netchan_Transmit( &cls.netchan, BF_GetNumBytesWritten( &buf ), BF_GetData( &buf ));
}
开发者ID:adamixik,项目名称:xash3d,代码行数:31,代码来源:cl_parse.c
示例9: fragments
/*
=======================================================================================================================================
SV_Netchan_Transmit
https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=462
If there are some unsent fragments (which may happen if the snapshots and the gamestate are fragmenting, and collide on send for
instance) then buffer them and make sure they get sent in correct order.
=======================================================================================================================================
*/
void SV_Netchan_Transmit(client_t *client, msg_t *msg) {
MSG_WriteByte(msg, svc_EOF);
if (client->netchan.unsentFragments || client->netchan_start_queue) {
netchan_buffer_t *netbuf;
Com_DPrintf("#462 SV_Netchan_Transmit: unsent fragments, stacked\n");
netbuf = (netchan_buffer_t *)Z_Malloc(sizeof(netchan_buffer_t));
// store the msg, we can't store it encoded, as the encoding depends on stuff we still have to finish sending
MSG_Copy(&netbuf->msg, netbuf->msgBuffer, sizeof(netbuf->msgBuffer), msg);
#ifdef LEGACY_PROTOCOL
if (client->compat) {
Q_strncpyz(netbuf->clientCommandString, client->lastClientCommandString, sizeof(netbuf->clientCommandString));
}
#endif
netbuf->next = NULL;
// insert it in the queue, the message will be encoded and sent later
*client->netchan_end_queue = netbuf;
client->netchan_end_queue = &(*client->netchan_end_queue)->next;
} else {
#ifdef LEGACY_PROTOCOL
if (client->compat) {
SV_Netchan_Encode(client, msg, client->lastClientCommandString);
}
#endif
Netchan_Transmit(&client->netchan, msg->cursize, msg->data);
}
}
开发者ID:ioid3-games,项目名称:ioid3-q3,代码行数:39,代码来源:sv_net_chan.c
示例10: Sv_DropClient
/*
* Sv_DropClient
*
* Called when the player is totally leaving the server, either willingly
* or unwillingly. This is NOT called if the entire server is quitting
* or crashing.
*/
void Sv_DropClient(sv_client_t *cl) {
g_edict_t *ent;
if (cl->state > SV_CLIENT_FREE) { // send the disconnect
if (cl->state == SV_CLIENT_ACTIVE) { // after informing the game module
svs.game->ClientDisconnect(cl->edict);
}
Msg_WriteByte(&cl->netchan.message, SV_CMD_DISCONNECT);
Netchan_Transmit(&cl->netchan, cl->netchan.message.size,
cl->netchan.message.data);
}
if (cl->download) {
Fs_FreeFile(cl->download);
cl->download = NULL;
}
ent = cl->edict;
memset(cl, 0, sizeof(*cl));
cl->edict = ent;
cl->last_frame = -1;
}
开发者ID:darkshade9,项目名称:aq2w,代码行数:33,代码来源:sv_main.c
示例11: CL_Netchan_Transmit
/*
=======================================================================================================================================
CL_Netchan_Transmit
=======================================================================================================================================
*/
void CL_Netchan_Transmit(netchan_t *chan, msg_t *msg) {
MSG_WriteByte(msg, clc_EOF);
Netchan_Transmit(chan, msg->cursize, msg->data);
// transmit all fragments without delay
while (CL_Netchan_TransmitNextFragment(chan)) {
Com_DPrintf("WARNING: #462 unsent fragments (not supposed to happen!)\n");
}
}
开发者ID:KuehnhammerTobias,项目名称:ioqw,代码行数:14,代码来源:cl_net_chan.c
示例12: CL_Netchan_Transmit
/*
================
CL_Netchan_Transmit
================
*/
void CL_Netchan_Transmit( netchan_t *chan, msg_t* msg ) {
MSG_WriteByte( msg, clc_EOF );
CL_WriteBinaryMessage( msg );
if ( !SV_GameIsSinglePlayer() ) {
CL_Netchan_Encode( msg );
}
Netchan_Transmit( chan, msg->cursize, msg->data );
}
开发者ID:AdrienJaguenet,项目名称:Enemy-Territory,代码行数:14,代码来源:cl_net_chan.c
示例13: CL_SendDisconnectMessage
/*
=====================
CL_SendDisconnectMessage
Sends a disconnect message to the server
=====================
*/
void CL_SendDisconnectMessage( void )
{
sizebuf_t buf;
byte data[32];
if( cls.state == ca_disconnected ) return;
BF_Init( &buf, "LastMessage", data, sizeof( data ));
BF_WriteByte( &buf, clc_stringcmd );
BF_WriteString( &buf, "disconnect" );
if( !cls.netchan.remote_address.type )
cls.netchan.remote_address.type = NA_LOOPBACK;
// make sure message will be delivered
Netchan_Transmit( &cls.netchan, BF_GetNumBytesWritten( &buf ), BF_GetData( &buf ));
Netchan_Transmit( &cls.netchan, BF_GetNumBytesWritten( &buf ), BF_GetData( &buf ));
Netchan_Transmit( &cls.netchan, BF_GetNumBytesWritten( &buf ), BF_GetData( &buf ));
}
开发者ID:Reedych,项目名称:xash3d,代码行数:26,代码来源:cl_main.c
示例14: SV_Netchan_Transmit
//extern byte chksum[65536];
void SV_Netchan_Transmit( client_t *client, msg_t *msg) { //int length, const byte *data ) {
// int i;
MSG_WriteByte( msg, svc_EOF );
// for(i=SV_ENCODE_START;i<msg->cursize;i++) {
// chksum[i-SV_ENCODE_START] = msg->data[i];
// }
// Huff_Compress( msg, SV_ENCODE_START );
SV_Netchan_Encode( client, msg );
Netchan_Transmit( &client->netchan, msg->cursize, msg->data );
}
开发者ID:ataceyhun,项目名称:jk2mv,代码行数:11,代码来源:sv_net_chan.cpp
示例15: Cl_SendCommands
/**
* @brief Pumps the command cycle, sending the most recently gathered movement to the server.
* @details Commands must meet a certain duration, in milliseconds, in order to be sent. This
* prevents saturating the network channel with very small movement commands, which are also
* problematic for the physics and prediction code.
*/
void Cl_SendCommands(void) {
const uint32_t delta = quetoo.ticks - cls.net_chan.last_sent;
if (delta < 8 && !r_swap_interval->value) {
return;
}
switch (cls.state) {
case CL_CONNECTED:
case CL_LOADING:
if (cls.net_chan.message.size || delta > 1000) {
Netchan_Transmit(&cls.net_chan, NULL, 0);
cl.packet_counter++;
}
break;
case CL_ACTIVE:
Cl_WriteUserInfoCommand();
Cl_FinalizeMovementCommand();
mem_buf_t buf;
byte data[sizeof(cl_cmd_t) * 3];
Mem_InitBuffer(&buf, data, sizeof(data));
Cl_WriteMovementCommand(&buf);
Netchan_Transmit(&cls.net_chan, buf.data, buf.size);
cl.packet_counter++;
Cl_InitMovementCommand();
break;
default:
break;
}
}
开发者ID:jdolan,项目名称:quetoo,代码行数:49,代码来源:cl_cmd.c
示例16: CL_Netchan_Transmit
/*
===============
CL_Netchan_Transmit
================
*/
void CL_Netchan_Transmit( netchan_t *chan, msg_t* msg ) {
// int i;
MSG_WriteByte( msg, clc_EOF );
// for(i=CL_ENCODE_START;i<msg->cursize;i++) {
// chksum[i-CL_ENCODE_START] = msg->data[i];
// }
// Huff_Compress( msg, CL_ENCODE_START );
CL_Netchan_Encode( msg );
Netchan_Transmit( chan, msg->cursize, msg->data );
}
开发者ID:AlexXT,项目名称:OpenJK,代码行数:16,代码来源:cl_net_chan.cpp
示例17: SV_SendClientDatagram
/*
=======================
SV_SendClientDatagram
=======================
*/
bool SV_SendClientDatagram( sv_client_t *cl )
{
byte msg_buf[MAX_MSGLEN];
sizebuf_t msg;
SV_BuildClientFrame( cl );
MSG_Init( &msg, msg_buf, sizeof( msg_buf ));
// send over all the relevant entity_state_t
// and the player state
SV_WriteFrameToClient( cl, &msg );
// copy the accumulated reliable datagram
// for this client out to the message
// it is necessary for this to be after the WriteEntities
// so that entity references will be current
if( cl->reliable.overflowed ) MsgDev( D_ERROR, "reliable datagram overflowed for %s\n", cl->name );
else MSG_WriteData( &msg, cl->reliable.data, cl->reliable.cursize );
MSG_Clear( &cl->reliable );
if( msg.overflowed )
{
// must have room left for the packet header
MsgDev( D_WARN, "msg overflowed for %s\n", cl->name );
MSG_Clear( &msg );
}
// copy the accumulated multicast datagram
// for this client out to the message
// it is necessary for this to be after the WriteEntities
// so that entity references will be current
if( cl->datagram.overflowed ) MsgDev( D_WARN, "datagram overflowed for %s\n", cl->name );
else MSG_WriteData( &msg, cl->datagram.data, cl->datagram.cursize );
MSG_Clear( &cl->datagram );
if( msg.overflowed )
{
// must have room left for the packet header
MsgDev( D_WARN, "msg overflowed for %s\n", cl->name );
MSG_Clear( &msg );
}
// send the datagram
Netchan_Transmit( &cl->netchan, msg.cursize, msg.data );
// record the size for rate estimation
cl->message_size[sv.framenum % RATE_MESSAGES] = msg.cursize;
return true;
}
开发者ID:a1batross,项目名称:Xash3D_ancient,代码行数:56,代码来源:sv_frame.c
示例18: CL_Netchan_Transmit
/*
=======================================================================================================================================
CL_Netchan_Transmit
=======================================================================================================================================
*/
void CL_Netchan_Transmit(netchan_t *chan, msg_t *msg) {
MSG_WriteByte(msg, clc_EOF);
#ifdef LEGACY_PROTOCOL
if (chan->compat) {
CL_Netchan_Encode(msg);
}
#endif
Netchan_Transmit(chan, msg->cursize, msg->data);
// transmit all fragments without delay
while (CL_Netchan_TransmitNextFragment(chan)) {
Com_DPrintf("WARNING: #462 unsent fragments (not supposed to happen!)\n");
}
}
开发者ID:ioid3-games,项目名称:ioid3-q3,代码行数:19,代码来源:cl_net_chan.c
示例19: CL_Netchan_Transmit
/*
===============
CL_Netchan_Transmit
================
*/
void CL_Netchan_Transmit( netchan_t *chan, msg_t* msg )
{
MSG_WriteByte( msg, clc_EOF );
CL_Netchan_Encode( msg );
if( !Netchan_Transmit( chan, msg->cursize, msg->data ) )
{
// Don't call Com_Error if we're already disconnecting!
if( com_errorEntered )
return;
// Quickly detect dead connections: (may want to put in some relaxation here?)
Com_Error( ERR_DROP, "@MENUS_LOST_CONNECTION" );
}
}
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:20,代码来源:cl_net_chan.cpp
示例20: fragments
/*
===============
SV_Netchan_Transmit
TTimo
show_bug.cgi?id=462
if there are some unsent fragments (which may happen if the snapshots
and the gamestate are fragmenting, and collide on send for instance)
then buffer them and make sure they get sent in correct order
================
*/
void SV_Netchan_Transmit( client_t *client, msg_t *msg )
{
//int length, const byte *data ) {
MSG_WriteByte( msg, svc_EOF );
SV_WriteBinaryMessage( msg, client );
if ( client->netchan.unsentFragments )
{
netchan_buffer_t *netbuf;
//Com_DPrintf("SV_Netchan_Transmit: there are unsent fragments remaining\n");
netbuf = ( netchan_buffer_t * ) Z_Malloc( sizeof( netchan_buffer_t ) );
// store the msg, we can't store it encoded, as the encoding depends on stuff we still have to finish sending
MSG_Copy( &netbuf->msg, netbuf->msgBuffer, sizeof( netbuf->msgBuffer ), msg );
// copy the command, since the command number used for encryption is
// already compressed in the buffer, and receiving a new command would
// otherwise lose the proper encryption key
strcpy( netbuf->lastClientCommandString, client->lastClientCommandString );
// insert it in the queue, the message will be encoded and sent later
//% *client->netchan_end_queue = netbuf;
//% client->netchan_end_queue = &(*client->netchan_end_queue)->next;
netbuf->next = NULL;
if ( !client->netchan_start_queue )
{
client->netchan_start_queue = netbuf;
}
else
{
client->netchan_end_queue->next = netbuf;
}
client->netchan_end_queue = netbuf;
// emit the next fragment of the current message for now
Netchan_TransmitNextFragment( &client->netchan );
}
else
{
SV_Netchan_Encode( client, msg, client->lastClientCommandString );
Netchan_Transmit( &client->netchan, msg->cursize, msg->data );
}
}
开发者ID:Wattos,项目名称:Unvanquished,代码行数:57,代码来源:sv_net_chan.c
注:本文中的Netchan_Transmit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论