本文整理汇总了C++中NET_Packet::w方法的典型用法代码示例。如果您正苦于以下问题:C++ NET_Packet::w方法的具体用法?C++ NET_Packet::w怎么用?C++ NET_Packet::w使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NET_Packet
的用法示例。
在下文中一共展示了NET_Packet::w方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void CLevelChanger::feel_touch_new (CObject *tpObject)
{
CActor* l_tpActor = smart_cast<CActor*>(tpObject);
VERIFY (l_tpActor);
if (!l_tpActor->g_Alive())
return;
if (m_bSilentMode) {
NET_Packet p;
p.w_begin (M_CHANGE_LEVEL);
p.w (&m_game_vertex_id,sizeof(m_game_vertex_id));
p.w (&m_level_vertex_id,sizeof(m_level_vertex_id));
p.w_vec3 (m_position);
p.w_vec3 (m_angles);
Level().Send(p,net_flags(TRUE));
return;
}
Fvector p,r;
bool b = get_reject_pos(p,r);
CUIGameSP *pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame());
if (pGameSP)
pGameSP->ChangeLevel (m_game_vertex_id,m_level_vertex_id,m_position,m_angles,p,r,b);
m_entrance_time = Device.fTimeGlobal;
}
示例2: 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 (s_gameid );
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 (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 (&m_tSpawnID, sizeof(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));
}
示例3: OnOk
void CChangeLevelWnd::OnOk()
{
Game().StartStopMenu (this, true);
NET_Packet p;
p.w_begin (M_CHANGE_LEVEL);
p.w (&m_game_vertex_id,sizeof(m_game_vertex_id));
p.w (&m_level_vertex_id,sizeof(m_level_vertex_id));
p.w_vec3 (m_position);
p.w_vec3 (m_angles);
Level().Send (p,net_flags(TRUE));
}
示例4: SendPacket
void BattlEyeServer::SendPacket( int player, void* packet, int len )
{
NET_Packet P;
P.w_begin( M_BATTLEYE );
P.w_u32( len );
P.w( packet, len );
Level().Server->SendTo( (u32)player, P, net_flags() );
}
示例5: Position
void CAI_Stalker::net_Export (NET_Packet& P)
{
R_ASSERT (Local());
// export last known packet
R_ASSERT (!NET.empty());
net_update& N = NET.back();
// P.w_float (inventory().TotalWeight());
// P.w_u32 (m_dwMoney);
P.w_float (GetfHealth());
P.w_u32 (N.dwTimeStamp);
P.w_u8 (0);
P.w_vec3 (N.p_pos);
P.w_float /*w_angle8*/ (N.o_model);
P.w_float /*w_angle8*/ (N.o_torso.yaw);
P.w_float /*w_angle8*/ (N.o_torso.pitch);
P.w_float /*w_angle8*/ (N.o_torso.roll);
P.w_u8 (u8(g_Team()));
P.w_u8 (u8(g_Squad()));
P.w_u8 (u8(g_Group()));
float f1 = 0;
GameGraph::_GRAPH_ID l_game_vertex_id = ai_location().game_vertex_id();
P.w (&l_game_vertex_id, sizeof(l_game_vertex_id));
P.w (&l_game_vertex_id, sizeof(l_game_vertex_id));
// P.w (&f1, sizeof(f1));
// P.w (&f1, sizeof(f1));
if (ai().game_graph().valid_vertex_id(l_game_vertex_id)) {
f1 = Position().distance_to (ai().game_graph().vertex(l_game_vertex_id)->level_point());
P.w (&f1, sizeof(f1));
f1 = Position().distance_to (ai().game_graph().vertex(l_game_vertex_id)->level_point());
P.w (&f1, sizeof(f1));
}
else {
P.w (&f1, sizeof(f1));
P.w (&f1, sizeof(f1));
}
P.w_stringZ (m_sStartDialog);
}
示例6: net_Export
void CAI_Rat::net_Export(NET_Packet& P)
{
R_ASSERT (Local());
// export last known packet
R_ASSERT (!NET.empty());
net_update& N = NET.back();
P.w_float (GetfHealth());
P.w_u32 (N.dwTimeStamp);
P.w_u8 (0);
P.w_vec3 (N.p_pos);
P.w_float (N.o_model);
P.w_float (N.o_torso.yaw);
P.w_float (N.o_torso.pitch);
P.w_float (N.o_torso.roll);
P.w_u8 (u8(g_Team()));
P.w_u8 (u8(g_Squad()));
P.w_u8 (u8(g_Group()));
GameGraph::_GRAPH_ID l_game_vertex_id = ai_location().game_vertex_id();
P.w (&l_game_vertex_id, sizeof(l_game_vertex_id));
P.w (&l_game_vertex_id, sizeof(l_game_vertex_id));
// P.w (&m_fGoingSpeed, sizeof(m_fGoingSpeed));
// P.w (&m_fGoingSpeed, sizeof(m_fGoingSpeed));
float f1 = 0;
if (ai().game_graph().valid_vertex_id(l_game_vertex_id)) {
f1 = Position().distance_to (ai().game_graph().vertex(l_game_vertex_id)->level_point());
P.w (&f1, sizeof(f1));
f1 = Position().distance_to (ai().game_graph().vertex(l_game_vertex_id)->level_point());
P.w (&f1, sizeof(f1));
}
else {
P.w (&f1, sizeof(f1));
P.w (&f1, sizeof(f1));
}
CEatableItem::net_Export(P);
}
示例7:
void CSE_ALifeItemPDA::STATE_Write (NET_Packet &tNetPacket)
{
inherited::STATE_Write (tNetPacket);
tNetPacket.w (&m_original_owner,sizeof(m_original_owner));
#ifdef XRGAME_EXPORTS
tNetPacket.w_stringZ (m_specific_character);
tNetPacket.w_stringZ (m_info_portion);
#else
shared_str tmp_1 = NULL;
shared_str tmp_2 = NULL;
tNetPacket.w_stringZ (tmp_1);
tNetPacket.w_stringZ (tmp_2);
#endif
}
示例8:
void xrServer::Update ()
{
NET_Packet Packet;
u32 position;
csPlayers.Enter ();
VERIFY (verify_entities());
// game update
game->ProcessDelayedEvent();
game->Update ();
// spawn queue
u32 svT = Device.TimerAsync();
while (!(q_respawn.empty() || (svT<q_respawn.begin()->timestamp)))
{
// get
svs_respawn R = *q_respawn.begin();
q_respawn.erase (q_respawn.begin());
//
CSE_Abstract* E = ID_to_entity(R.phantom);
E->Spawn_Write (Packet,FALSE);
u16 ID;
Packet.r_begin (ID); R_ASSERT(M_SPAWN==ID);
ClientID clientID; clientID.set(0xffff);
Process_spawn (Packet,clientID);
}
//
for (u32 client=0; client<net_Players.size(); ++client)
{
// Initialize process and check for available bandwidth
xrClientData* Client = (xrClientData*) net_Players [client];
if (!Client->net_Ready) continue;
if (!HasBandwidth(Client)
#ifdef DEBUG
&& !g_sv_SendUpdate
#endif
) continue;
// Send relevant entities to client
// CSE_Abstract* Base = Client->owner;
u16 PacketType = M_UPDATE;
Packet.w_begin (PacketType);
// GameUpdate
++(Client->game_replicate_id);
u32 g_it = (Client->game_replicate_id % client_Count());
// u32 g_id = net_Players[g_it]->ID;
ClientID g_id = net_Players[g_it]->ID;
game->net_Export_Update (Packet,Client->ID,g_id);
// if (!Client->flags.bLocal)
game->net_Export_GameTime(Packet);
if (!Client->flags.bLocal || client_Count() == 1)
{
#ifdef DEBUG
if (g_Dump_Update_Write) Msg("---- UPDATE_Write to %s --- ", *(Client->Name));
#endif // Entities
NET_Packet tmpPacket;
xrS_entities::iterator I=entities.begin(),E=entities.end();
for (; I!=E; ++I)
{
CSE_Abstract& Test = *(I->second);
if (0==Test.owner) continue; // Phantom(?)
if (!Test.net_Ready) continue;
if (Test.owner == Client && Client->flags.bLocal) continue; // Can't be relevant
if (Test.s_flags.is(M_SPAWN_OBJECT_PHANTOM)) continue; // Surely: phantom
tmpPacket.B.count = 0;
// write specific data
{
tmpPacket.w_u16 (Test.ID );
tmpPacket.w_chunk_open8 (position );
Test.UPDATE_Write (tmpPacket );
#ifdef DEBUG
if (g_Dump_Update_Write) Msg("* %s : %d", Test.name(), u32(tmpPacket.w_tell()-position)-sizeof(u8));
#endif
tmpPacket.w_chunk_close8 (position );
if (Packet.B.count + tmpPacket.B.count < NET_PacketSizeLimit)
{
Packet.w(tmpPacket.B.data, tmpPacket.B.count);
}
else
{
if (Packet.B.count > 2)
{
// if (!Client->flags.bLocal)
// Msg ("- Server Update[%d] to Client : %d", PacketType, Packet.B.count);
SendTo (Client->ID,Packet,net_flags(FALSE,TRUE));
}
PacketType = M_UPDATE_OBJECTS;
Packet.w_begin(PacketType);
}
//.........这里部分代码省略.........