本文整理汇总了C++中NET_Packet::r_u16方法的典型用法代码示例。如果您正苦于以下问题:C++ NET_Packet::r_u16方法的具体用法?C++ NET_Packet::r_u16怎么用?C++ NET_Packet::r_u16使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NET_Packet
的用法示例。
在下文中一共展示了NET_Packet::r_u16方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Process_save
void xrServer::Process_save(NET_Packet& P, ClientID sender)
{
xrClientData* CL = ID_to_client(sender);
if (CL) CL->net_Ready = TRUE;
R_ASSERT(CL->flags.bLocal);
// while has information
while (!P.r_eof())
{
// find entity
u16 ID;
u16 size;
P.r_u16 (ID);
P.r_u16 (size);
s32 _pos_start = P.r_tell ();
CSE_Abstract *E = ID_to_entity(ID);
if (E) {
E->net_Ready = TRUE;
E->load (P);
}
else
P.r_advance (size);
s32 _pos_end = P.r_tell ();
s32 _size = size;
if (_size != (_pos_end-_pos_start)) {
Msg ("! load/save mismatch, object: '%s'",E?E->name_replace():"unknown");
s32 _rollback = _pos_start+_size;
P.r_seek (_rollback);
}
}
}
示例2: OnEvent
void CWeaponMagazinedWGrenade::OnEvent(NET_Packet& P, u16 type)
{
inherited::OnEvent(P,type);
u16 id;
switch (type)
{
case GE_OWNERSHIP_TAKE:
{
P.r_u16(id);
CRocketLauncher::AttachRocket(id, this);
}
break;
case GE_OWNERSHIP_REJECT :
case GE_LAUNCH_ROCKET :
{
bool bLaunch = (type==GE_LAUNCH_ROCKET);
P.r_u16 (id);
CRocketLauncher::DetachRocket(id, bLaunch);
if(bLaunch)
{
PlayAnimShoot ();
PlaySound ("sndShotG", get_LastFP2());
AddShotEffector ();
StartFlameParticles2();
}
break;
}
}
}
示例3: Level
void CAI_Trader::OnEvent (NET_Packet& P, u16 type)
{
inherited::OnEvent (P,type);
CInventoryOwner::OnEvent (P,type);
u16 id;
CObject* Obj;
switch (type) {
case GE_TRADE_BUY:
case GE_OWNERSHIP_TAKE:
P.r_u16 (id);
Obj = Level().Objects.net_Find (id);
if(inventory().CanTakeItem(smart_cast<CInventoryItem*>(Obj))){
Obj->H_SetParent(this);
inventory().Take(smart_cast<CGameObject*>(Obj), false, false);
}else
{
NET_Packet P;
u_EventGen (P,GE_OWNERSHIP_REJECT,ID());
P.w_u16 (u16(Obj->ID()));
u_EventSend (P);
}
break;
case GE_TRADE_SELL:
case GE_OWNERSHIP_REJECT:
P.r_u16 (id);
Obj = Level().Objects.net_Find (id);
if(inventory().Drop(smart_cast<CGameObject*>(Obj)))
Obj->H_SetParent(0,!P.r_eof() && P.r_u8());
break;
case GE_TRANSFER_AMMO:
break;
}
}
示例4:
void game_PlayerState::net_Import(NET_Packet& P)
{
BOOL bFullUpdate = !!P.r_u8();
if (bFullUpdate)
P.r_stringZ (name);
P.r_u8 ( team );
P.r_s16 ( m_iRivalKills );
P.r_s16 ( m_iSelfKills );
P.r_s16 ( m_iTeamKills );
P.r_s16 ( m_iDeaths );
P.r_s32 ( money_for_round );
P.r_float_q8 ( experience_D, -1.0f, 2.0f);
P.r_u8 ( rank );
P.r_u8 ( af_count );
P.r_u16 ( flags__ );
P.r_u16 ( ping );
P.r_u16 ( GameID );
P.r_s8 ( skin );
P.r_u8 ( m_bCurrentVoteAgreed );
DeathTime = P.r_u32();
};
示例5: OnEvent
void CInventoryBox::OnEvent(NET_Packet& P, u16 type)
{
inherited::OnEvent (P, type);
switch (type)
{
case GE_OWNERSHIP_TAKE:
{
u16 id;
P.r_u16(id);
CObject* itm = Level().Objects.net_Find(id); VERIFY(itm);
m_items.push_back (id);
itm->H_SetParent (this);
itm->setVisible (FALSE);
itm->setEnabled (FALSE);
}break;
case GE_OWNERSHIP_REJECT:
{
u16 id;
P.r_u16(id);
CObject* itm = Level().Objects.net_Find(id); VERIFY(itm);
xr_vector<u16>::iterator it;
it = std::find(m_items.begin(),m_items.end(),id); VERIFY(it!=m_items.end());
m_items.erase (it);
itm->H_SetParent (NULL,!P.r_eof() && P.r_u8());
if( m_in_use )
{
CGameObject* GO = smart_cast<CGameObject*>(itm);
Actor()->callback(GameObject::eInvBoxItemTake)( this->lua_game_object(), GO->lua_game_object() );
}
}break;
};
}
示例6:
void SHit::Read_Packet (NET_Packet Packet)
{
u16 type_dummy;
Packet.r_begin (type_dummy);
Packet.r_u32 (Time);
Packet.r_u16 (PACKET_TYPE);
Packet.r_u16 (DestID);
Read_Packet_Cont (Packet);
};
示例7: GetPlayerByGameID
void game_cl_TeamDeathmatch::TranslateGameMessage (u32 msg, NET_Packet& P)
{
CStringTable st;
string512 Text;
// LPSTR Color_Teams[3] = {"%c[255,255,255,255]", "%c[255,64,255,64]", "%c[255,64,64,255]"};
char Color_Main[] = "%c[255,192,192,192]";
// LPSTR TeamsNames[3] = {"Zero Team", "Team Green", "Team Blue"};
switch(msg) {
case GAME_EVENT_PLAYER_JOIN_TEAM: //tdm
{
string64 PlayerName;
P.r_stringZ (PlayerName);
u16 Team;
P.r_u16 (Team);
sprintf_s(Text, "%s%s %s%s %s%s",
"",//no color
PlayerName,
Color_Main,
*st.translate("mp_joined"),
CTeamInfo::GetTeam_color_tag(int(Team)),
CTeamInfo::GetTeam_name(int(Team)));
CommonMessageOut(Text);
//---------------------------------------
Msg("%s %s %s", PlayerName, *st.translate("mp_joined"),
CTeamInfo::GetTeam_name(int(Team)));
}break;
case PLAYER_CHANGE_TEAM://tdm
{
u16 PlayerID, OldTeam, NewTeam;
P.r_u16 (PlayerID);
P.r_u16 (OldTeam);
P.r_u16 (NewTeam);
game_PlayerState* pPlayer = GetPlayerByGameID(PlayerID);
if (!pPlayer) break;
sprintf_s(Text, "%s%s %s%s %s%s",
CTeamInfo::GetTeam_color_tag(int(OldTeam)),
pPlayer->name,
Color_Main,
*st.translate("mp_switched_to"),
CTeamInfo::GetTeam_color_tag(int(NewTeam)),
CTeamInfo::GetTeam_name(int(NewTeam)));
CommonMessageOut(Text);
//---------------------------------------
Msg("%s *s %s", pPlayer->name, *st.translate("mp_switched_to"), CTeamInfo::GetTeam_name(int(NewTeam)));
}break;
default:
inherited::TranslateGameMessage(msg,P);
};
}
示例8: OnEvent
void CHelicopter::OnEvent( NET_Packet& P, u16 type)
{
inherited::OnEvent(P,type);
CExplosive::OnEvent(P,type);
u16 id;
switch (type) {
case GE_OWNERSHIP_TAKE : {
P.r_u16(id);
CRocketLauncher::AttachRocket(id, this);
} break;
case GE_OWNERSHIP_REJECT : {
P.r_u16(id);
CRocketLauncher::DetachRocket(id);
} break;
}
}
示例9: NetSync
void CInventoryItem::net_Import (NET_Packet& P)
{
P.r_float (m_fCondition) ;
net_update_IItem N ;
N.dwTimeStamp=P.r_u32 ( );
u16 NumItems = 0;
NumItems=P.r_u16 ( );
if (CSE_ALifeInventoryItem::FLAG_NO_POSITION != NumItems)
N.State.position=P.r_vec3 ();
if (!NumItems || (CSE_ALifeInventoryItem::FLAG_NO_POSITION == NumItems)) return;
position_Import (P,N) ;
net_updateData *p = NetSync() ;
if ( !p->NET_IItem.empty() &&
(p->NET_IItem.back().dwTimeStamp>=N.dwTimeStamp))
return;
if (!p->NET_IItem.empty()){
m_flags.set (FInInterpolate, TRUE);
// m_bInterpolate = true;
}
Level().AddObject_To_Objects4CrPr (m_object);
object().CrPr_SetActivated (false);
object().CrPr_SetActivationStep (0);
p->NET_IItem.push_back (N);
while (p->NET_IItem.size() > 2)
{
p->NET_IItem.pop_front ();
};
};
示例10: OnEvent
void CInventoryItem::OnEvent (NET_Packet& P, u16 type)
{
switch (type)
{
case GE_ADDON_ATTACH:
{
u16 ItemID;
P.r_u16 (ItemID);
CInventoryItem* ItemToAttach = smart_cast<CInventoryItem*>(Level().Objects.net_Find(ItemID));
if (!ItemToAttach) break;
Attach(ItemToAttach,true);
}break;
case GE_ADDON_DETACH:
{
string64 i_name;
P.r_stringZ (i_name);
Detach(i_name, true);
}break;
case GE_CHANGE_POS:
{
Fvector p;
P.r_vec3(p);
CPHSynchronize* pSyncObj = NULL;
pSyncObj = object().PHGetSyncItem(0);
if (!pSyncObj) return;
SPHNetState state;
pSyncObj->get_State(state);
state.position = p;
state.previous_position = p;
pSyncObj->set_State(state);
}break;
}
}
示例11:
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;
}
}
示例12: OnEvent
void CCar::OnEvent(NET_Packet& P, u16 type)
{
inherited::OnEvent (P,type);
CExplosive::OnEvent (P,type);
//обработка сообщений, нужных для работы с багажником машины
u16 id;
switch (type)
{
case GE_OWNERSHIP_TAKE:
{
P.r_u16 (id);
CObject* O = Level().Objects.net_Find (id);
if( GetInventory()->CanTakeItem(smart_cast<CInventoryItem*>(O)) )
{
O->H_SetParent(this);
GetInventory()->Take(smart_cast<CGameObject*>(O), false, false);
}
else
{
if (!O || !O->H_Parent() || (this != O->H_Parent())) return;
NET_Packet P;
u_EventGen(P,GE_OWNERSHIP_REJECT,ID());
P.w_u16(u16(O->ID()));
u_EventSend(P);
}
}break;
case GE_OWNERSHIP_REJECT:
{
P.r_u16 (id);
CObject* O = Level().Objects.net_Find (id);
bool just_before_destroy = !P.r_eof() && P.r_u8();
O->SetTmpPreDestroy (just_before_destroy);
GetInventory()->DropItem(smart_cast<CGameObject*>(O), just_before_destroy, just_before_destroy);
//if(GetInventory()->DropItem(smart_cast<CGameObject*>(O), just_before_destroy))
//{
// O->H_SetParent(0, just_before_destroy);
//}
//moved to DropItem
}break;
}
}
示例13: LoadNetState
void CPHSkeleton::LoadNetState(NET_Packet& P)
{
CPhysicsShellHolder* obj=PPhysicsShellHolder();
IKinematics* K=smart_cast<IKinematics*>(obj->Visual());
P.r_u8 (m_flags.flags);
if(K)
{
K->LL_SetBonesVisible(P.r_u64());
K->LL_SetBoneRoot(P.r_u16());
}
u16 bones_number=P.r_u16();
for(u16 i=0;i<bones_number;i++)
{
SPHNetState state;
state.net_Load(P);
obj->PHGetSyncItem(i)->set_State(state);
}
}
示例14:
void CSE_ALifeItem::STATE_Read (NET_Packet &tNetPacket, u16 size)
{
inherited1::STATE_Read (tNetPacket, size);
if ((m_tClassID == CLSID_OBJECT_W_BINOCULAR) && (m_wVersion < 37)) {
tNetPacket.r_u16 ();
tNetPacket.r_u16 ();
tNetPacket.r_u8 ();
}
inherited2::STATE_Read (tNetPacket, size);
}
示例15: Level
void game_cl_ArtefactHunt::net_import_state (NET_Packet& P)
{
inherited::net_import_state (P);
P.r_u8 (artefactsNum);
P.r_u16 (artefactBearerID);
P.r_u8 (teamInPossession);
P.r_u16 (artefactID);
bBearerCantSprint = !!P.r_u8();
iReinforcementTime = P.r_s32();
if (iReinforcementTime > 0)
{
P.r_s32 (dReinforcementTime);
dReinforcementTime += Level().timeServer();
}
else
dReinforcementTime = 0;
}