本文整理汇总了C++中NET_Packet::w_seek方法的典型用法代码示例。如果您正苦于以下问题:C++ NET_Packet::w_seek方法的具体用法?C++ NET_Packet::w_seek怎么用?C++ NET_Packet::w_seek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NET_Packet
的用法示例。
在下文中一共展示了NET_Packet::w_seek方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
void CSE_Abstract::Spawn_Write (NET_Packet &tNetPacket, BOOL bLocal)
{
// generic
tNetPacket.w_begin (M_SPAWN);
tNetPacket.w_stringZ (s_name );
tNetPacket.w_stringZ (s_name_replace ? s_name_replace : "");
tNetPacket.w_u8 (0);
tNetPacket.w_u8 (s_RP );
tNetPacket.w_vec3 (o_Position );
tNetPacket.w_vec3 (o_Angle );
tNetPacket.w_u16 (RespawnTime );
tNetPacket.w_u16 (ID );
tNetPacket.w_u16 (ID_Parent );
tNetPacket.w_u16 (ID_Phantom );
s_flags.set (M_SPAWN_VERSION,TRUE);
if (bLocal)
tNetPacket.w_u16 (u16(s_flags.flags|M_SPAWN_OBJECT_LOCAL) );
else
tNetPacket.w_u16 (u16(s_flags.flags&~(M_SPAWN_OBJECT_LOCAL|M_SPAWN_OBJECT_ASPLAYER)));
tNetPacket.w_u16 (SPAWN_VERSION);
tNetPacket.w_u16 (m_gameType.m_GameType.get());
tNetPacket.w_u16 (script_server_object_version());
//client object custom data serialization SAVE
u16 client_data_size = (u16)client_data.size(); //не может быть больше 256 байт
tNetPacket.w_u16 (client_data_size);
// Msg ("SERVER:saving:save:%d bytes:%d:%s",client_data_size,ID,s_name_replace ? s_name_replace : "");
if (client_data_size > 0) {
tNetPacket.w (&*client_data.begin(),client_data_size);
}
tNetPacket.w_u16 (m_tSpawnID);
// tNetPacket.w_float (m_spawn_probability);
// tNetPacket.w_u32 (m_spawn_flags.get());
// tNetPacket.w_stringZ (m_spawn_control);
// tNetPacket.w_u32 (m_max_spawn_count);
// tNetPacket.w_u64 (m_min_spawn_interval);
// tNetPacket.w_u64 (m_max_spawn_interval);
#ifdef XRSE_FACTORY_EXPORTS
CScriptValueContainer::assign();
#endif
// write specific data
u32 position = tNetPacket.w_tell();
tNetPacket.w_u16 (0);
STATE_Write (tNetPacket);
u16 size = u16(tNetPacket.w_tell() - position);
//#ifdef XRSE_FACTORY_EXPORTS
R_ASSERT3 ((m_tClassID == CLSID_SPECTATOR) || (size > sizeof(size)),
"object isn't successfully saved, get your backup :(",name_replace());
//#endif
tNetPacket.w_seek (position,&size,sizeof(u16));
}
示例2:
u32 xrServer::OnMessage (NET_Packet& P, ClientID sender) // Non-Zero means broadcasting with "flags" as returned
{
if (g_pGameLevel && Level().IsDemoSave()) Level().Demo_StoreServerData(P.B.data, P.B.count);
u16 type;
P.r_begin (type);
csPlayers.Enter ();
VERIFY (verify_entities());
xrClientData* CL = ID_to_client(sender);
switch (type)
{
case M_UPDATE:
{
Process_update (P,sender); // No broadcast
VERIFY (verify_entities());
}break;
case M_SPAWN:
{
// R_ASSERT(CL->flags.bLocal);
if (CL->flags.bLocal)
Process_spawn (P,sender);
VERIFY (verify_entities());
}break;
case M_EVENT:
{
Process_event (P,sender);
VERIFY (verify_entities());
}break;
case M_EVENT_PACK:
{
NET_Packet tmpP;
while (!P.r_eof())
{
tmpP.B.count = P.r_u8();
P.r (&tmpP.B.data, tmpP.B.count);
OnMessage (tmpP, sender);
};
}break;
case M_CL_UPDATE:
{
xrClientData* CL = ID_to_client (sender);
if (!CL) break;
CL->net_Ready = TRUE;
if (!CL->net_PassUpdates)
break;
//-------------------------------------------------------------------
u32 ClientPing = CL->stats.getPing();
P.w_seek(P.r_tell()+2, &ClientPing, 4);
//-------------------------------------------------------------------
if (SV_Client)
SendTo (SV_Client->ID, P, net_flags(TRUE, TRUE));
VERIFY (verify_entities());
}break;
case M_MOVE_PLAYERS_RESPOND:
{
xrClientData* CL = ID_to_client (sender);
if (!CL) break;
CL->net_Ready = TRUE;
CL->net_PassUpdates = TRUE;
}break;
//-------------------------------------------------------------------
case M_CL_PING_CHALLENGE:
{
P.r_u32();
u32 id = sender.value();
P.w_seek( P.r_tell(), &(id), 4);
if (SV_Client) SendTo (SV_Client->ID, P, net_flags(FALSE));
}break;
case M_CL_PING_CHALLENGE_RESPOND:
{
P.r_u32();
u32 id = P.r_u32();
ClientID clientID; clientID.set(id);
u32 clLastPing = P.r_u32();
xrClientData* pCL = ID_to_client(clientID);
pCL->ps->Rping = u16(clLastPing);
SendTo (clientID, P, net_flags(FALSE));
}break;
//-------------------------------------------------------------------
case M_CL_INPUT:
{
xrClientData* CL = ID_to_client (sender);
if (CL) CL->net_Ready = TRUE;
if (SV_Client) SendTo (SV_Client->ID, P, net_flags(TRUE, TRUE));
VERIFY (verify_entities());
}break;
case M_GAMEMESSAGE:
{
ClientID clientID;clientID.setBroadcast();
SendBroadcast (clientID,P,net_flags(TRUE,TRUE));
VERIFY (verify_entities());
}break;
case M_CLIENTREADY:
{
xrClientData* CL = ID_to_client(sender);
//.........这里部分代码省略.........