本文整理汇总了C++中NET_Packet类的典型用法代码示例。如果您正苦于以下问题:C++ NET_Packet类的具体用法?C++ NET_Packet怎么用?C++ NET_Packet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NET_Packet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void CArtefact::OnAnimationEnd(u32 state)
{
switch (state)
{
case eHiding:
{
SwitchState(eHidden);
}break;
case eShowing:
{
SwitchState(eIdle);
}break;
case eActivating:
{
if(Local())
{
SwitchState (eHiding);
NET_Packet P;
u_EventGen (P, GEG_PLAYER_ACTIVATEARTEFACT, H_Parent()->ID());
P.w_u16 (ID());
u_EventSend (P);
}
}break;
};
}
示例2:
void CUIInventoryWnd::SendEvent_Item_Eat (PIItem pItem)
{
NET_Packet P;
pItem->object().u_EventGen (P, GEG_PLAYER_ITEM_EAT, pItem->object().H_Parent()->ID());
P.w_u16 (pItem->object().ID());
pItem->object().u_EventSend (P);
};
示例3: Level
void CEntity::KillEntity(u16 whoID)
{
if (whoID != ID()) {
#ifdef DEBUG
if (m_killer_id != ALife::_OBJECT_ID(-1)) {
Msg ("! Entity [%s][%s] already has killer with id %d, but new killer id arrived - %d",*cNameSect(),*cName(),m_killer_id,whoID);
CObject *old_killer = Level().Objects.net_Find(m_killer_id);
Msg ("! Old killer is %s",old_killer ? *old_killer->cName() : "unknown");
CObject *new_killer = Level().Objects.net_Find(whoID);
Msg ("! New killer is %s",new_killer ? *new_killer->cName() : "unknown");
VERIFY (m_killer_id == ALife::_OBJECT_ID(-1));
}
#endif
}
else {
if (m_killer_id != ALife::_OBJECT_ID(-1))
return;
}
m_killer_id = whoID;
set_death_time ();
if (!getDestroy()){
NET_Packet P;
u_EventGen (P,GE_DIE,ID());
P.w_u16 (u16(whoID));
P.w_u32 (0);
if (OnServer())
u_EventSend (P, net_flags(TRUE, TRUE, FALSE, TRUE));
}
};
示例4: SaveNetState
void CCar::SaveNetState(NET_Packet& P)
{
CPHSkeleton::SaveNetState (P);
P.w_vec3(Position());
Fvector Angle;
XFORM().getXYZ(Angle);
P.w_vec3(Angle);
{
xr_map<u16,SDoor>::iterator i,e;
i=m_doors.begin();
e=m_doors.end();
P.w_u16(u16(m_doors.size()));
for(;i!=e;++i)
i->second.SaveNetState(P);
}
{
xr_map<u16,SWheel>::iterator i,e;
i=m_wheels_map.begin();
e=m_wheels_map.end();
P.w_u16(u16(m_wheels_map.size()));
for(;i!=e;++i)
i->second.SaveNetState(P);
}
P.w_float(GetfHealth());
}
示例5: ai
//передаче вещи из своего инвентаря в инвентарь партнера
void CScriptGameObject::TransferItem(CScriptGameObject* pItem, CScriptGameObject* pForWho)
{
if (!pItem || !pForWho) {
ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"cannot transfer NULL item");
return;
}
CInventoryItem* pIItem = smart_cast<CInventoryItem*>(&pItem->object());
if (!pIItem) {
ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"Cannot transfer not CInventoryItem item");
return ;
}
// выбросить у себя
NET_Packet P;
CGameObject::u_EventGen (P,GE_TRADE_SELL, object().ID());
P.w_u16 (pIItem->object().ID());
CGameObject::u_EventSend (P);
// отдать партнеру
CGameObject::u_EventGen (P,GE_TRADE_BUY, pForWho->object().ID());
P.w_u16 (pIItem->object().ID());
CGameObject::u_EventSend (P);
}
示例6: 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;
}
}
示例7: R_ASSERT
bool CInventory::Eat(PIItem pIItem)
{
R_ASSERT(pIItem->m_pCurrentInventory==this);
//устанаовить съедобна ли вещь
CEatableItem* pItemToEat = smart_cast<CEatableItem*>(pIItem);
R_ASSERT (pItemToEat);
CEntityAlive *entity_alive = smart_cast<CEntityAlive*>(m_pOwner);
R_ASSERT (entity_alive);
pItemToEat->UseBy (entity_alive);
if(IsGameTypeSingle() && Actor()->m_inventory == this)
Actor()->callback(GameObject::eUseObject)((smart_cast<CGameObject*>(pIItem))->lua_game_object());
if(pItemToEat->Empty() && entity_alive->Local())
{
NET_Packet P;
CGameObject::u_EventGen (P,GE_OWNERSHIP_REJECT,entity_alive->ID());
P.w_u16 (pIItem->object().ID());
CGameObject::u_EventSend (P);
CGameObject::u_EventGen (P,GE_DESTROY,pIItem->object().ID());
CGameObject::u_EventSend (P);
return false;
}
return true;
}
示例8:
void game_cl_TeamDeathmatch::net_import_state (NET_Packet& P)
{
bool teamsEqual = (!teams.empty())?(teams[0].score == teams[1].score) : false;
inherited::net_import_state (P);
m_bFriendlyIndicators = !!P.r_u8();
m_bFriendlyNames = !!P.r_u8();
if (!teams.empty())
{
if (teamsEqual)
{
if (teams[0].score != teams[1].score)
{
if (Level().CurrentViewEntity())
{
if (teams[0].score > teams[1].score)
PlaySndMessage(ID_TEAM1_LEAD);
else
PlaySndMessage(ID_TEAM2_LEAD);
}
}
}
else
{
if (teams[0].score == teams[1].score)
if (Level().CurrentViewEntity())
PlaySndMessage(ID_TEAMS_EQUAL);
}
};
}
示例9: object
void CInventoryItem::net_Export (NET_Packet& P)
{
P.w_float (m_fCondition);
P.w_u32 (Level().timeServer());
///////////////////////////////////////
CPHSynchronize* pSyncObj = NULL;
SPHNetState State;
pSyncObj = object().PHGetSyncItem (0);
if (pSyncObj && !object().H_Parent())
pSyncObj->get_State(State);
else
State.position.set(object().Position());
///////////////////////////////////////
u16 NumItems = object().PHGetSyncItemsNumber();
if (object().H_Parent())
NumItems = CSE_ALifeInventoryItem::FLAG_NO_POSITION;
else
if (IsGameTypeSingle())
NumItems = 0;
P.w_u16 ( NumItems );
if (NumItems != CSE_ALifeInventoryItem::FLAG_NO_POSITION)
P.w_vec3 ( State.position);
if (!NumItems || (NumItems == CSE_ALifeInventoryItem::FLAG_NO_POSITION))
return;
position_Export(P,State);
};
示例10: PickupModeUpdate
void CActor::PickupModeUpdate()
{
if(!m_bPickupMode) return;
if (GameID() != GAME_SINGLE) return;
//подбирание объекта
if(inventory().m_pTarget && inventory().m_pTarget->Useful() &&
m_pUsableObject && m_pUsableObject->nonscript_usable() &&
!Level().m_feel_deny.is_object_denied(smart_cast<CGameObject*>(inventory().m_pTarget)) )
{
NET_Packet P;
u_EventGen(P, GE_OWNERSHIP_TAKE, ID());
P.w_u16(inventory().m_pTarget->object().ID());
u_EventSend(P);
}
//. ????? GetNearest ?????
feel_touch_update (Position(), /*inventory().GetTakeDist()*/m_fPickupInfoRadius);
CFrustum frustum;
frustum.CreateFromMatrix(Device.mFullTransform,FRUSTUM_P_LRTB|FRUSTUM_P_FAR);
//. slow (ray-query test)
for(xr_vector<CObject*>::iterator it = feel_touch.begin(); it != feel_touch.end(); it++)
if (CanPickItem(frustum,Device.vCameraPosition,*it)) PickupInfoDraw(*it);
}
示例11: CLevel__cl_Process_CustomEventServer
void CLevel__cl_Process_CustomEventServer(NET_Packet& pack)
{
if (HookHandle->IsServer()) {
unsigned char type = 0;
pack.r_u8(type);
if (type == e_so_engine_packet) {
unsigned char e;
pack.r_u8(e);
switch (e) {
case e_add_money: {
LogHandle->Write("CLevel__cl_Process_CustomEventServer add money event");
ClientID cl_id;
pack.r_clientID(cl_id);
HookHandle->Add_money_mp(cl_id);
}break;
default:
LogHandle->Write("CLevel__cl_Process_CustomEventServer unknown event %d",e);
break;
}
} else if (type == e_so_script_packet) {
char data[2048];
pack.r_stringZ(data);
LogHandle->Write("Recieved data at server side '%s'",data);
HookHandle->messanges_sv.push_back(data);
} else {
LogHandle->Write("ERROR: CLevel__cl_Process_CustomEventServer unknown type");
}
}
}
示例12: 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;
};
}
示例13:
void CGameObject::net_Save (NET_Packet &net_packet)
{
u32 position;
net_packet.w_chunk_open16 (position);
save (net_packet);
// Script Binder Save ---------------------------------------
#ifdef DEBUG
if (psAI_Flags.test(aiSerialize)) {
Msg(">> **** Save script object [%s] *****", *cName());
Msg(">> Before save :: packet position = [%u]", net_packet.w_tell());
}
#endif
CScriptBinder::save (net_packet);
#ifdef DEBUG
if (psAI_Flags.test(aiSerialize)) {
Msg(">> After save :: packet position = [%u]", net_packet.w_tell());
}
#endif
// ----------------------------------------------------------
net_packet.w_chunk_close16 (position);
}
示例14: SendPickUpEvent
void game_cl_Deathmatch::SendPickUpEvent(u16 ID_who, u16 ID_what)
{
NET_Packet P;
u_EventGen (P, GE_OWNERSHIP_TAKE_MP_FORCED, ID_who);
P.w_u16 (ID_what);
u_EventSend (P);
};
示例15: Level
void game_cl_Deathmatch::OnSkinMenu_Ok ()
{
CObject *l_pObj = Level().CurrentEntity();
CGameObject *l_pPlayer = smart_cast<CGameObject*>(l_pObj);
if(!l_pPlayer) return;
NET_Packet P;
l_pPlayer->u_EventGen (P, GE_GAME_EVENT, l_pPlayer->ID() );
P.w_u16(GAME_EVENT_PLAYER_GAME_MENU);
P.w_u8(PLAYER_CHANGE_SKIN);
P.w_s8 ((u8)pCurSkinMenu->GetActiveIndex());
l_pPlayer->u_EventSend (P);
//-----------------------------------------------------------------
m_bSkinSelected = TRUE;
// second stub here
if (pCurBuyMenu)
{
if (-1 == pCurSkinMenu->GetActiveIndex())
pCurBuyMenu->SetSkin(0);
else
pCurBuyMenu->SetSkin((u8)pCurSkinMenu->GetActiveIndex());
}
};