本文整理汇总了C++中BF_WriteByte函数的典型用法代码示例。如果您正苦于以下问题:C++ BF_WriteByte函数的具体用法?C++ BF_WriteByte怎么用?C++ BF_WriteByte使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BF_WriteByte函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SV_FinalMessage
/*
==================
SV_FinalMessage
Used by SV_Shutdown to send a final message to all
connected clients before the server goes down. The messages are sent immediately,
not just stuck on the outgoing message list, because the server is going
to totally exit after returning from this function.
==================
*/
void SV_FinalMessage( char *message, qboolean reconnect )
{
sv_client_t *cl;
byte msg_buf[1024];
sizebuf_t msg;
int i;
BF_Init( &msg, "FinalMessage", msg_buf, sizeof( msg_buf ));
BF_WriteByte( &msg, svc_print );
BF_WriteByte( &msg, PRINT_HIGH );
BF_WriteString( &msg, va( "%s\n", message ));
if( reconnect )
{
BF_WriteByte( &msg, svc_changing );
if( sv.loadgame || sv_maxclients->integer > 1 || sv.changelevel )
BF_WriteOneBit( &msg, 1 ); // changelevel
else BF_WriteOneBit( &msg, 0 );
}
else
{
BF_WriteByte( &msg, svc_disconnect );
}
// send it twice
// stagger the packets to crutch operating system limited buffers
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
if( cl->state >= cs_connected && !cl->fakeclient )
Netchan_Transmit( &cl->netchan, BF_GetNumBytesWritten( &msg ), BF_GetData( &msg ));
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
if( cl->state >= cs_connected && !cl->fakeclient )
Netchan_Transmit( &cl->netchan, BF_GetNumBytesWritten( &msg ), BF_GetData( &msg ));
}
示例2: SV_BroadcastPrintf
/*
=================
SV_BroadcastPrintf
Sends text to all active clients
=================
*/
void SV_BroadcastPrintf( int level, char *fmt, ... )
{
char string[MAX_SYSPATH];
va_list argptr;
sv_client_t *cl;
int i;
if( !sv.state ) return;
va_start( argptr, fmt );
Q_vsprintf( string, fmt, argptr );
va_end( argptr );
// echo to console
if( host.type == HOST_DEDICATED ) Msg( "%s", string );
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
{
if( level < cl->messagelevel ) continue;
if( cl->state != cs_spawned ) continue;
if( cl->fakeclient ) continue;
BF_WriteByte( &cl->netchan.message, svc_print );
BF_WriteByte( &cl->netchan.message, level );
BF_WriteString( &cl->netchan.message, string );
}
}
示例3: SV_SendClientDatagram
/*
=======================
SV_SendClientDatagram
=======================
*/
void SV_SendClientDatagram( sv_client_t *cl )
{
byte msg_buf[NET_MAX_PAYLOAD];
sizebuf_t msg;
svs.currentPlayer = cl;
svs.currentPlayerNum = (cl - svs.clients);
BF_Init( &msg, "Datagram", msg_buf, sizeof( msg_buf ));
// always send servertime at new frame
BF_WriteByte( &msg, svc_time );
BF_WriteFloat( &msg, sv.time );
SV_WriteClientdataToMessage( cl, &msg );
SV_WriteEntitiesToClient( cl, &msg );
// copy the accumulated multicast datagram
// for this client out to the message
if( BF_CheckOverflow( &cl->datagram )) MsgDev( D_WARN, "datagram overflowed for %s\n", cl->name );
else BF_WriteBits( &msg, BF_GetData( &cl->datagram ), BF_GetNumBitsWritten( &cl->datagram ));
BF_Clear( &cl->datagram );
if( BF_CheckOverflow( &msg ))
{
// must have room left for the packet header
MsgDev( D_WARN, "msg overflowed for %s\n", cl->name );
BF_Clear( &msg );
}
// send the datagram
Netchan_TransmitBits( &cl->netchan, BF_GetNumBitsWritten( &msg ), BF_GetData( &msg ));
}
示例4: Cmd_ForwardToServer
/*
===================
Cmd_ForwardToServer
adds the current command line as a clc_stringcmd to the client message.
things like godmode, noclip, etc, are commands directed to the server,
so when they are typed in at the console, they will need to be forwarded.
===================
*/
void Cmd_ForwardToServer( void )
{
char str[MAX_CMD_BUFFER];
if( cls.demoplayback )
{
if( !Q_stricmp( Cmd_Argv( 0 ), "pause" ))
cl.refdef.paused ^= 1;
return;
}
if( cls.state != ca_connected && cls.state != ca_active )
{
MsgDev( D_INFO, "Can't \"%s\", not connected\n", Cmd_Argv( 0 ));
return; // not connected
}
BF_WriteByte( &cls.netchan.message, clc_stringcmd );
str[0] = 0;
if( Q_stricmp( Cmd_Argv( 0 ), "cmd" ))
{
Q_strcat( str, Cmd_Argv( 0 ));
Q_strcat( str, " " );
}
if( Cmd_Argc() > 1 )
Q_strcat( str, Cmd_Args( ));
else Q_strcat( str, "\n" );
BF_WriteString( &cls.netchan.message, str );
}
示例5: CL_ParseResourceList
/*
==============
CL_ParseResourceList
==============
*/
void CL_ParseResourceList( sizebuf_t *msg )
{
int i = 0;
Q_memset( &reslist, 0, sizeof( resourcelist_t ));
reslist.rescount = BF_ReadWord( msg ) - 1;
for( i = 0; i < reslist.rescount; i++ )
{
reslist.restype[i] = BF_ReadWord( msg );
Q_strncpy( reslist.resnames[i], BF_ReadString( msg ), CS_SIZE );
}
cls.downloadcount = 0;
for( i = 0; i < reslist.rescount; i++ )
{
if( reslist.restype[i] == t_sound )
CL_CheckingSoundResFile( reslist.resnames[i] );
else CL_CheckingResFile( reslist.resnames[i] );
}
if( !cls.downloadcount )
{
BF_WriteByte( &cls.netchan.message, clc_stringcmd );
BF_WriteString( &cls.netchan.message, "continueloading" );
}
}
示例6: MSG_WriteDeltaMovevars
/*
=============================================================================
movevars_t communication
=============================================================================
*/
qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, movevars_t *from, movevars_t *to )
{
delta_t *pField;
delta_info_t *dt;
int i, startBit;
int numChanges = 0;
dt = Delta_FindStruct( "movevars_t" );
ASSERT( dt && dt->bInitialized );
pField = dt->pFields;
ASSERT( pField );
startBit = msg->iCurBit;
// activate fields and call custom encode func
Delta_CustomEncode( dt, from, to );
BF_WriteByte( msg, svc_deltamovevars );
// process fields
for( i = 0; i < dt->numFields; i++, pField++ )
{
if( Delta_WriteField( msg, pField, from, to, 0.0f ))
numChanges++;
}
// if we have no changes - kill the message
if( !numChanges )
{
BF_SeekToBit( msg, startBit );
return false;
}
return true;
}
示例7: CL_CheckingResFile
/*
==============
CL_CheckingResFile
==============
*/
void CL_CheckingResFile( char *pResFileName )
{
sizebuf_t buf;
byte data[32];
if( FS_FileExists( pResFileName, false ))
return; // already exists
cls.downloadcount++;
if( cl_allow_fragment->integer )
{
Msg( "Starting file download: %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 ));
}
else
HTTP_AddDownload( pResFileName, -1, true );
}
示例8: SV_ClientPrintf
/*
=================
SV_ClientPrintf
Sends text across to be displayed if the level passes
=================
*/
void SV_ClientPrintf( sv_client_t *cl, int level, char *fmt, ... )
{
va_list argptr;
char string[MAX_SYSPATH];
if( level < cl->messagelevel || cl->fakeclient )
return;
va_start( argptr, fmt );
Q_vsprintf( string, fmt, argptr );
va_end( argptr );
BF_WriteByte( &cl->netchan.message, svc_print );
BF_WriteByte( &cl->netchan.message, level );
BF_WriteString( &cl->netchan.message, string );
}
示例9: SV_EmitPings
/*
=============
SV_EmitPings
=============
*/
void SV_EmitPings( sizebuf_t *msg )
{
sv_client_t *cl;
int packet_loss;
int i, ping;
BF_WriteByte( msg, svc_updatepings );
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
{
if( cl->state != cs_spawned )
continue;
SV_GetPlayerStats( cl, &ping, &packet_loss );
// there are 25 bits for each client
BF_WriteOneBit( msg, 1 );
BF_WriteUBitLong( msg, i, MAX_CLIENT_BITS );
BF_WriteUBitLong( msg, ping, 12 );
BF_WriteUBitLong( msg, packet_loss, 7 );
}
// end marker
BF_WriteOneBit( msg, 0 );
}
示例10: CL_ParseCvarValue
/*
==============
CL_ParseCvarValue
Find the client cvar value
and sent it back to the server
==============
*/
void CL_ParseCvarValue( sizebuf_t *msg )
{
const char *cvarName = BF_ReadString( msg );
convar_t *cvar = Cvar_FindVar( cvarName );
// build the answer
BF_WriteByte( &cls.netchan.message, clc_requestcvarvalue );
BF_WriteString( &cls.netchan.message, cvar ? cvar->string : "Not Found" );
}
示例11: pfnParticle
static void pfnParticle( float *origin, int color, float life, int zpos, int zvel )
{
int v;
if( !origin )
{
MsgDev( D_ERROR, "SV_StartParticle: NULL origin. Ignored\n" );
return;
}
BF_WriteByte( &sv.reliable_datagram, svc_particle );
BF_WriteVec3Coord( &sv.reliable_datagram, origin );
BF_WriteChar( &sv.reliable_datagram, 0 ); // no x-vel
BF_WriteChar( &sv.reliable_datagram, 0 ); // no y-vel
v = bound( -128, (zpos * zvel) * 16.0f, 127 );
BF_WriteChar( &sv.reliable_datagram, v ); // write z-vel
BF_WriteByte( &sv.reliable_datagram, 1 );
BF_WriteByte( &sv.reliable_datagram, color );
BF_WriteByte( &sv.reliable_datagram, bound( 0, life * 8, 255 ));
}
示例12: pfnUpdateServerInfo
void pfnUpdateServerInfo( const char *szKey, const char *szValue, const char *unused, void *unused2 )
{
convar_t *cv = Cvar_FindVar( szKey );
if( !cv || !cv->modified ) return; // this cvar not changed
BF_WriteByte( &sv.reliable_datagram, svc_serverinfo );
BF_WriteString( &sv.reliable_datagram, szKey );
BF_WriteString( &sv.reliable_datagram, szValue );
cv->modified = false; // reset state
}
示例13: CL_Precache_f
/*
=================
CL_Precache_f
The server will send this command right
before allowing the client into the server
=================
*/
void CL_Precache_f( void )
{
int spawncount;
spawncount = Q_atoi( Cmd_Argv( 1 ));
CL_PrepSound();
CL_PrepVideo();
BF_WriteByte( &cls.netchan.message, clc_stringcmd );
BF_WriteString( &cls.netchan.message, va( "begin %i\n", spawncount ));
}
示例14: SV_BroadcastCommand
/*
=================
SV_BroadcastCommand
Sends text to all active clients
=================
*/
void SV_BroadcastCommand( char *fmt, ... )
{
va_list argptr;
char string[MAX_SYSPATH];
if( !sv.state ) return;
va_start( argptr, fmt );
Q_vsprintf( string, fmt, argptr );
va_end( argptr );
BF_WriteByte( &sv.reliable_datagram, svc_stufftext );
BF_WriteString( &sv.reliable_datagram, string );
}
示例15: CL_ProcessFile
/*
====================
CL_ProcessFile
A file has been received via the fragmentation/reassembly layer, put it in the right spot and
see if we have finished downloading files.
====================
*/
void CL_ProcessFile( BOOL successfully_received, const char *filename )
{
MsgDev( D_INFO, "Received %s, but file processing is not hooked up!!!\n", filename );
if( cls.downloadfileid == cls.downloadcount - 1 )
{
MsgDev( D_INFO, "All Files downloaded\n" );
BF_WriteByte( &cls.netchan.message, clc_stringcmd );
BF_WriteString( &cls.netchan.message, "continueloading" );
}
cls.downloadfileid++;
}