本文整理汇总了C++中NET_Packet::r方法的典型用法代码示例。如果您正苦于以下问题:C++ NET_Packet::r方法的具体用法?C++ NET_Packet::r怎么用?C++ NET_Packet::r使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NET_Packet
的用法示例。
在下文中一共展示了NET_Packet::r方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: net_Import
void CBaseMonster::net_Import(NET_Packet& P)
{
R_ASSERT (Remote());
net_update N;
u8 flags;
float health;
P.r_float (health);
SetfHealth (health);
P.r_u32 (N.dwTimeStamp);
P.r_u8 (flags);
P.r_vec3 (N.p_pos);
P.r_float /*r_angle8*/ (N.o_model);
P.r_float /*r_angle8*/ (N.o_torso.yaw);
P.r_float /*r_angle8*/ (N.o_torso.pitch);
P.r_float /*r_angle8*/ (N.o_torso.roll );
id_Team = P.r_u8();
id_Squad = P.r_u8();
id_Group = P.r_u8();
GameGraph::_GRAPH_ID l_game_vertex_id = ai_location().game_vertex_id();
P.r (&l_game_vertex_id, sizeof(l_game_vertex_id));
P.r (&l_game_vertex_id, sizeof(l_game_vertex_id));
if (NET.empty() || (NET.back().dwTimeStamp<N.dwTimeStamp)) {
NET.push_back (N);
NET_WasInterpolating = TRUE;
}
// P.r (&m_fGoingSpeed, sizeof(m_fGoingSpeed));
// P.r (&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.r (&f1, sizeof(f1));
f1 = Position().distance_to (ai().game_graph().vertex(l_game_vertex_id)->level_point());
P.r (&f1, sizeof(f1));
}
else {
P.r (&f1, sizeof(f1));
P.r (&f1, sizeof(f1));
}
setVisible (TRUE);
setEnabled (TRUE);
}
示例2:
void game_cl_Deathmatch::net_import_state (NET_Packet& P)
{
inherited::net_import_state (P);
m_s32FragLimit = P.r_s32();
m_s32TimeLimit = P.r_s32() * 60000;
m_u32ForceRespawn = P.r_u32() * 1000;
m_cl_dwWarmUp_Time = P.r_u32();
m_bDamageBlockIndicators = !!P.r_u8();
// Teams
u16 t_count;
P.r_u16 (t_count);
teams.clear ();
for (u16 t_it=0; t_it<t_count; ++t_it)
{
game_TeamState ts;
P.r (&ts,sizeof(game_TeamState));
teams.push_back (ts);
};
switch (Phase())
{
case GAME_PHASE_PLAYER_SCORES:
{
P.r_stringZ(WinnerName);
bool NeedSndMessage = (xr_strlen(WinnerName) != 0);
if (NeedSndMessage && local_player && !xr_strcmp(WinnerName, local_player->getName()))
{
PlaySndMessage(ID_YOU_WON);
}
}break;
}
}
示例3: movement
void CAI_Stalker::net_Import (NET_Packet& P)
{
R_ASSERT (Remote());
net_update N;
u8 flags;
P.r_float ();
set_money ( P.r_u32(), false );
float health;
P.r_float (health);
SetfHealth (health);
// fEntityHealth = health;
P.r_u32 (N.dwTimeStamp);
P.r_u8 (flags);
P.r_vec3 (N.p_pos);
P.r_float /*r_angle8*/ (N.o_model);
P.r_float /*r_angle8*/ (N.o_torso.yaw);
P.r_float /*r_angle8*/ (N.o_torso.pitch);
P.r_float /*r_angle8*/ (N.o_torso.roll );
id_Team = P.r_u8();
id_Squad = P.r_u8();
id_Group = P.r_u8();
GameGraph::_GRAPH_ID graph_vertex_id = movement().game_dest_vertex_id();
P.r (&graph_vertex_id, sizeof(GameGraph::_GRAPH_ID));
graph_vertex_id = ai_location().game_vertex_id();
P.r (&graph_vertex_id, sizeof(GameGraph::_GRAPH_ID));
if (NET.empty() || (NET.back().dwTimeStamp<N.dwTimeStamp)) {
NET.push_back (N);
NET_WasInterpolating = TRUE;
}
P.r_float ();
P.r_float ();
P.r_stringZ (m_sStartDialog);
setVisible (TRUE);
setEnabled (TRUE);
}
示例4:
void CSE_ALifeItemPDA::STATE_Read (NET_Packet &tNetPacket, u16 size)
{
inherited::STATE_Read (tNetPacket,size);
if (m_wVersion > 58)
tNetPacket.r (&m_original_owner,sizeof(m_original_owner));
if (m_wVersion > 89)
if ( (m_wVersion > 89)&&(m_wVersion < 98) )
{
int tmp,tmp2;
tNetPacket.r (&tmp, sizeof(int));
tNetPacket.r (&tmp2, sizeof(int));
m_info_portion = NULL;
m_specific_character = NULL;
}else{
tNetPacket.r_stringZ (m_specific_character);
tNetPacket.r_stringZ (m_info_portion);
}
}
示例5:
void CSE_Abstract::load (NET_Packet &tNetPacket)
{
CPureServerObject::load (tNetPacket);
u16 client_data_size = (m_wVersion > 93) ? tNetPacket.r_u16() : tNetPacket.r_u8(); //не может быть больше 256 байт
if (client_data_size > 0) {
#ifdef DEBUG
// Msg ("SERVER:loading:load:%d bytes:%d:%s",client_data_size,ID,s_name_replace ? s_name_replace : "");
#endif // DEBUG
client_data.resize (client_data_size);
tNetPacket.r (&*client_data.begin(),client_data_size);
}
else {
#ifdef DEBUG
if (!client_data.empty())
Msg ("CSE_Abstract::load: client_data is cleared for [%d][%s]",ID,name_replace());
#endif // DEBUG
client_data.clear ();
}
}
示例6:
void message_filter::check_new_data (NET_Packet & packet)
{
u32 tmp_old_pos = packet.r_tell();
msg_type_subtype_t packet_mtype;
packet_mtype.import (packet);
if (packet_mtype.msg_type == M_EVENT_PACK)
{
NET_Packet tmp_packet;
while (!packet.r_eof())
{
tmp_packet.B.count = packet.r_u8();
packet.r (tmp_packet.B.data, tmp_packet.B.count);
packet_mtype.import(tmp_packet);
R_ASSERT2(packet_mtype.msg_type != M_EVENT_PACK, "M_EVENT_PACK in M_EVENT_PACK");
dbg_print_msg (tmp_packet, packet_mtype);
filters_map_t::iterator tmp_iter = m_filters.find(packet_mtype);
if (tmp_iter != m_filters.end())
{
tmp_iter->second(packet_mtype.msg_type,
packet_mtype.msg_subtype,
tmp_packet);
}
}
} else {
dbg_print_msg (packet, packet_mtype);
filters_map_t::iterator tmp_iter = m_filters.find(packet_mtype);
if (tmp_iter != m_filters.end())
{
tmp_iter->second(packet_mtype.msg_type,
packet_mtype.msg_subtype,
packet);
}
}
packet.r_seek (tmp_old_pos);
}
示例7: OnSecureMessage
void xrServer::OnSecureMessage(NET_Packet & P, xrClientData* xrClSender)
{
#ifdef DEBUG
char dbg_tmp_buff[33];
ZeroMemory (dbg_tmp_buff, sizeof(dbg_tmp_buff));
xr_strcpy (dbg_tmp_buff, "xray crypt check");
u32 dbg_encrypt_checksum = secure_messaging::encrypt(dbg_tmp_buff, sizeof(dbg_tmp_buff), xrClSender->m_secret_key);
u32 dbg_decrypt_checksum = secure_messaging::decrypt(dbg_tmp_buff, sizeof(dbg_tmp_buff), xrClSender->m_secret_key);
VERIFY(dbg_encrypt_checksum == dbg_decrypt_checksum);
#endif
NET_Packet dec_packet;
dec_packet.B.count = P.B.count - sizeof(u16) - sizeof(u32); // - r_begin - crypt_check_sum
P.r (dec_packet.B.data, dec_packet.B.count);
u32 checksum = secure_messaging::decrypt(dec_packet.B.data, dec_packet.B.count, xrClSender->m_secret_key);
u32 real_checksum = 0;
P.r_u32 (real_checksum);
VERIFY2 (checksum == real_checksum, "caught cheater");
if (checksum != real_checksum)
return; // WARNING!: do not add any log messages - security treat!
OnMessage (dec_packet, xrClSender->ID);
}
示例8: net_Import
void CAI_Rat::net_Import(NET_Packet& P)
{
R_ASSERT (Remote());
net_update N;
u8 flags;
float health;
P.r_float (health);
SetfHealth (health);
P.r_u32 (N.dwTimeStamp);
P.r_u8 (flags);
P.r_vec3 (N.p_pos);
P.r_angle8 (N.o_model);
P.r_angle8 (N.o_torso.yaw);
P.r_angle8 (N.o_torso.pitch);
P.r_angle8 (N.o_torso.roll );
id_Team = P.r_u8();
id_Squad = P.r_u8();
id_Group = P.r_u8();
GameGraph::_GRAPH_ID t;
P.r (&t, sizeof(t));
P.r (&t, sizeof(t));
ai_location().game_vertex (t);
if (NET.empty() || (NET.back().dwTimeStamp<N.dwTimeStamp)) {
NET.push_back (N);
NET_WasInterpolating = TRUE;
}
setVisible (TRUE);
setEnabled (TRUE);
CEatableItem::net_Import(P);
}
示例9: sizeof
BOOL CSE_Abstract::Spawn_Read (NET_Packet &tNetPacket)
{
u16 dummy16;
// generic
tNetPacket.r_begin (dummy16);
R_ASSERT (M_SPAWN==dummy16);
tNetPacket.r_stringZ (s_name );
string256 temp;
tNetPacket.r_stringZ (temp);
set_name_replace (temp);
tNetPacket.r_u8 (s_gameid );
tNetPacket.r_u8 (s_RP );
tNetPacket.r_vec3 (o_Position );
tNetPacket.r_vec3 (o_Angle );
tNetPacket.r_u16 (RespawnTime );
tNetPacket.r_u16 (ID );
tNetPacket.r_u16 (ID_Parent );
tNetPacket.r_u16 (ID_Phantom );
tNetPacket.r_u16 (s_flags.flags );
// dangerous!!!!!!!!!
if (s_flags.is(M_SPAWN_VERSION))
tNetPacket.r_u16 (m_wVersion);
if (0==m_wVersion) {
tNetPacket.r_pos -= sizeof(u16);
m_wVersion = 0;
return FALSE;
}
if (m_wVersion > 69)
m_script_version = tNetPacket.r_u16();
// read specific data
//client object custom data serialization LOAD
if (m_wVersion > 70) {
u16 client_data_size = (m_wVersion > 93) ? tNetPacket.r_u16() : tNetPacket.r_u8(); //не может быть больше 256 байт
if (client_data_size > 0) {
// Msg ("SERVER:loading:load:%d bytes:%d:%s",client_data_size,ID,s_name_replace ? s_name_replace : "");
client_data.resize (client_data_size);
tNetPacket.r (&*client_data.begin(),client_data_size);
}
else
client_data.clear ();
}
else
client_data.clear ();
if (m_wVersion > 79)
tNetPacket.r (&m_tSpawnID, sizeof(m_tSpawnID));
if (m_wVersion < 112) {
if (m_wVersion > 82)
tNetPacket.r_float ();//m_spawn_probability);
if (m_wVersion > 83) {
tNetPacket.r_u32 ();//m_spawn_flags.assign(tNetPacket.r_u32());
xr_string temp;
tNetPacket.r_stringZ (temp);//tNetPacket.r_stringZ(m_spawn_control);
tNetPacket.r_u32 ();//m_max_spawn_count);
// this stuff we do not need even in case of uncomment
tNetPacket.r_u32 ();//m_spawn_count);
tNetPacket.r_u64 ();//m_last_spawn_time);
}
if (m_wVersion > 84) {
tNetPacket.r_u64 ();//m_min_spawn_interval);
tNetPacket.r_u64 ();//m_max_spawn_interval);
}
}
u16 size;
tNetPacket.r_u16 (size); // size
R_ASSERT3 ((m_tClassID == CLSID_SPECTATOR) || (size > sizeof(size)),"cannot read object, which is not successfully saved :(",name_replace());
STATE_Read (tNetPacket,size);
return TRUE;
}
示例10: ClientReceive
void CLevel::ClientReceive()
{
Demo_StartFrame();
Demo_Update();
m_dwRPC = 0;
m_dwRPS = 0;
for (NET_Packet* P = net_msg_Retreive(); P; P=net_msg_Retreive())
{
//-----------------------------------------------------
m_dwRPC++;
m_dwRPS += P->B.count;
//-----------------------------------------------------
u16 m_type;
u16 ID;
P->r_begin (m_type);
switch (m_type)
{
case M_MAP_SYNC:
{
shared_str map_name;
P->r_stringZ(map_name);
shared_str _name = net_Hosts.size() ? net_Hosts.front().dpSessionName:"";
if(_name.size() && _name!=map_name && OnClient())
{
Msg("!!! map sync failed. current is[%s] server is[%s]",m_name.c_str(), map_name.c_str());
Engine.Event.Defer ("KERNEL:disconnect");
Engine.Event.Defer ("KERNEL:start",m_caServerOptions.size() ? size_t( xr_strdup(*m_caServerOptions)) : 0, m_caClientOptions.size() ? size_t(xr_strdup(*m_caClientOptions)) : 0);
}
}break;
case M_SPAWN:
{
if (!m_bGameConfigStarted || !bReady)
{
Msg ("Unconventional M_SPAWN received : cgf[%s] | bReady[%s]",
(m_bGameConfigStarted) ? "true" : "false",
(bReady) ? "true" : "false");
break;
}
/*/
cl_Process_Spawn(*P);
/*/
game_events->insert (*P);
if (g_bDebugEvents) ProcessGameEvents();
//*/
}
break;
case M_EVENT:
game_events->insert (*P);
if (g_bDebugEvents) ProcessGameEvents();
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);
tmpP.timeReceive = P->timeReceive;
game_events->insert (tmpP);
if (g_bDebugEvents) ProcessGameEvents();
};
break;
case M_UPDATE:
{
game->net_import_update (*P);
//-------------------------------------------
if (OnServer()) break;
//-------------------------------------------
}; // ни в коем случае нельзя здесь ставить break, т.к. в случае если все объекты не влазят в пакет M_UPDATE,
// они досылаются через M_UPDATE_OBJECTS
case M_UPDATE_OBJECTS:
{
Objects.net_Import (P);
if (OnClient()) UpdateDeltaUpd(timeServer());
IClientStatistic pStat = Level().GetStatistic();
u32 dTime = 0;
if ((Level().timeServer() + pStat.getPing()) < P->timeReceive)
{
dTime = pStat.getPing();
}
else
dTime = Level().timeServer() - P->timeReceive + pStat.getPing();
u32 NumSteps = ph_world->CalcNumSteps(dTime);
SetNumCrSteps(NumSteps);
}break;
// case M_UPDATE_OBJECTS:
// {
// Objects.net_Import (P);
// }break;
//----------- for E3 -----------------------------
case M_CL_UPDATE:
//.........这里部分代码省略.........
示例11: Level
bool CALifeUpdateManager::change_level (NET_Packet &net_packet)
{
if (m_changing_level)
return (false);
// prepare_objects_for_save ();
// we couldn't use prepare_objects_for_save since we need
// get updates from client
// then change actor server entity
// then call client net_Save
// then restore actor server entity
Level().ClientSend ();
m_changing_level = true;
GameGraph::_GRAPH_ID safe_graph_vertex_id = graph().actor()->m_tGraphID;
u32 safe_level_vertex_id = graph().actor()->m_tNodeID;
Fvector safe_position = graph().actor()->o_Position;
Fvector safe_angles = graph().actor()->o_Angle;
SRotation safe_torso = graph().actor()->o_torso;
GameGraph::_GRAPH_ID holder_safe_graph_vertex_id = GameGraph::_GRAPH_ID(-1);
u32 holder_safe_level_vertex_id = u32(-1);
Fvector holder_safe_position = Fvector().set(flt_max,flt_max,flt_max);
Fvector holder_safe_angles = Fvector().set(flt_max,flt_max,flt_max);
CSE_ALifeObject *holder = 0;
net_packet.r (&graph().actor()->m_tGraphID,sizeof(graph().actor()->m_tGraphID));
net_packet.r (&graph().actor()->m_tNodeID,sizeof(graph().actor()->m_tNodeID));
net_packet.r_vec3 (graph().actor()->o_Position);
net_packet.r_vec3 (graph().actor()->o_Angle);
Level().ClientSave ();
graph().actor()->o_torso.yaw = graph().actor()->o_Angle.y;
graph().actor()->o_torso.pitch = graph().actor()->o_Angle.x;
graph().actor()->o_torso.roll = 0.f;
if (graph().actor()->m_holderID != 0xffff) {
holder = objects().object(graph().actor()->m_holderID);
holder_safe_graph_vertex_id = holder->m_tGraphID;
holder_safe_level_vertex_id = holder->m_tNodeID;
holder_safe_position = holder->o_Position;
holder_safe_angles = holder->o_Angle;
holder->m_tGraphID = graph().actor()->m_tGraphID;
holder->m_tNodeID = graph().actor()->m_tNodeID;
holder->o_Position = graph().actor()->o_Position;
holder->o_Angle = graph().actor()->o_Angle;
}
string256 autoave_name;
strconcat (sizeof(autoave_name),autoave_name,Core.UserName,"_","autosave");
LPCSTR temp0 = strstr(**m_server_command_line,"/");
VERIFY (temp0);
string256 temp;
*m_server_command_line = strconcat(sizeof(temp),temp,autoave_name,temp0);
save (autoave_name);
graph().actor()->m_tGraphID = safe_graph_vertex_id;
graph().actor()->m_tNodeID = safe_level_vertex_id;
graph().actor()->o_Position = safe_position;
graph().actor()->o_Angle = safe_angles;
graph().actor()->o_torso = safe_torso;
if (graph().actor()->m_holderID != 0xffff) {
VERIFY (holder);
holder->m_tGraphID = holder_safe_graph_vertex_id;
holder->m_tNodeID = holder_safe_level_vertex_id;
holder->o_Position = holder_safe_position;
holder->o_Angle = holder_safe_angles;
}
return (true);
}
示例12:
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);
//.........这里部分代码省略.........