void CCustomMonster::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(); if (NET.empty() || (NET.back().dwTimeStamp<N.dwTimeStamp)) { NET.push_back (N); NET_WasInterpolating = TRUE; } setVisible (TRUE); setEnabled (TRUE); }
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(); };
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"); } } }
void CPhantom::net_Import (NET_Packet& P) { // import R_ASSERT (Remote()); u8 flags; float health; P.r_float (health); SetfHealth (health); float fDummy; u32 dwDummy; P.r_float (fDummy); P.r_u32 (dwDummy); P.r_u32 (dwDummy); P.r_u32 (dwDummy); P.r_u8 (flags); float yaw, pitch, bank = 0, roll = 0; P.r_float /*r_angle8*/ (yaw); P.r_float /*r_angle8*/ (yaw); P.r_float /*r_angle8*/ (pitch); P.r_float /*r_angle8*/ (roll); id_Team = P.r_u8(); id_Squad = P.r_u8(); id_Group = P.r_u8(); XFORM().setHPB (yaw,pitch,bank); }
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); } }; }
void CPhysicObject::net_Import (NET_Packet& P) { u8 NumItems = 0; NumItems = P.r_u8(); if (!NumItems) return; CSE_ALifeObjectPhysic::mask_num_items num_items; num_items.common = NumItems; NumItems = num_items.num_items; /*if (num_items.mask & CSE_ALifeObjectPhysic::animated) { net_Import_Anim_Params(P); }*/ net_update_PItem N; N.dwTimeStamp = Device.dwTimeGlobal; net_Import_PH_Params(P,N,num_items); //////////////////////////////////////////// P.r_u8(); // freezed or not.. if (this->cast_game_object()->Local()) { return; } net_updatePhData *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); Level().AddObject_To_Objects4CrPr (this); //this->CrPr_SetActivated (false); //this->CrPr_SetActivationStep (0); p->NET_IItem.push_back (N); while (p->NET_IItem.size() > 2) { p->NET_IItem.pop_front (); } if (!m_activated) { #ifdef DEBUG Msg("Activating object [%d] before interpolation starts", ID()); #endif // #ifdef DEBUG processing_activate(); m_activated = true; } };
void CSE_ALifeItemWeaponShotGun::UPDATE_Read (NET_Packet& P) { inherited::UPDATE_Read(P); m_AmmoIDs.clear(); u8 AmmoCount = P.r_u8(); for (u8 i=0; i<AmmoCount; i++) { m_AmmoIDs.push_back(P.r_u8()); } }
void CWeapon::net_Import(NET_Packet& P) { inherited::net_Import (P); float _cond; P.r_float_q8 (_cond,0.0f,1.0f); SetCondition (_cond); u8 flags = 0; P.r_u8 (flags); u16 ammo_elapsed = 0; P.r_u16 (ammo_elapsed); u8 NewAddonState; P.r_u8 (NewAddonState); m_flagsAddOnState = NewAddonState; UpdateAddonsVisibility (); u8 ammoType, wstate; P.r_u8 (ammoType); P.r_u8 (wstate); u8 Zoom; P.r_u8 ((u8)Zoom); if (H_Parent() && H_Parent()->Remote()) { if (Zoom) OnZoomIn(); else OnZoomOut(); }; switch (wstate) { case eFire: case eFire2: case eSwitch: case eReload: { }break; default: { if (ammoType >= m_ammoTypes.size()) Msg("!! Weapon [%d], State - [%d]", ID(), wstate); else { m_ammoType = ammoType; SetAmmoElapsed((ammo_elapsed)); } }break; } VERIFY((u32)iAmmoElapsed == m_magazine.size()); }
void CSE_ALifeItemWeapon::UPDATE_Read(NET_Packet &tNetPacket) { inherited::UPDATE_Read (tNetPacket); tNetPacket.r_float_q8 (m_fCondition,0.0f,1.0f); tNetPacket.r_u8 (wpn_flags); tNetPacket.r_u16 (a_elapsed); tNetPacket.r_u8 (m_addon_flags.flags); tNetPacket.r_u8 (ammo_type); tNetPacket.r_u8 (wpn_state); tNetPacket.r_u8 (m_bZoom); }
void CSE_ALifeItemWeapon::STATE_Read(NET_Packet &tNetPacket, u16 size) { inherited::STATE_Read (tNetPacket, size); tNetPacket.r_u16 (a_current); tNetPacket.r_u16 (a_elapsed); tNetPacket.r_u8 (wpn_state); if (m_wVersion > 40) tNetPacket.r_u8 (m_addon_flags.flags); if (m_wVersion > 46) tNetPacket.r_u8 (ammo_type); }
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); }
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; }; }
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; } }
void CSE_ALifeItemWeapon::OnEvent (NET_Packet &tNetPacket, u16 type, u32 time, ClientID sender ) { inherited::OnEvent (tNetPacket,type,time,sender); switch (type) { case GE_WPN_STATE_CHANGE: { tNetPacket.r_u8 (wpn_state); // u8 sub_state = tNetPacket.r_u8(); // u8 NewAmmoType = tNetPacket.r_u8(); // u8 AmmoElapsed = tNetPacket.r_u8(); }break; } }
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; } }
void CSE_SmartCover::STATE_Read (NET_Packet &tNetPacket, u16 size) { inherited1::STATE_Read (tNetPacket, size); cform_read (tNetPacket); tNetPacket.r_stringZ (m_description); m_hold_position_time = tNetPacket.r_float(); if (m_wVersion >= 120) { m_enter_min_enemy_distance = tNetPacket.r_float(); m_exit_min_enemy_distance = tNetPacket.r_float(); } if (m_wVersion >= 122) m_is_combat_cover = tNetPacket.r_u8(); if (m_wVersion >= 128) m_can_fire = tNetPacket.r_u8(); }
void CSE_ALifeItemWeaponMagazinedWGL::UPDATE_Read (NET_Packet& P) { u8 _data = P.r_u8(); m_bGrenadeMode = !!(_data & 0x1); ammo_type2 = _data>>6; a_current2 = _data>>1 & 0x1F; inherited::UPDATE_Read(P); }
void CALifeStorageManager::save (NET_Packet &net_packet) { prepare_objects_for_save (); shared_str game_name; net_packet.r_stringZ (game_name); save (*game_name,!!net_packet.r_u8()); }
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); }
void CWeaponMagazinedWGrenade::net_Import (NET_Packet& P) { bool NewMode = FALSE; NewMode = !!P.r_u8(); if (NewMode != m_bGrenadeMode) SwitchMode (); inherited::net_Import (P); }
void CSE_ALifeItemTorch::UPDATE_Read (NET_Packet &tNetPacket) { inherited::UPDATE_Read (tNetPacket); BYTE F = tNetPacket.r_u8(); m_active = !!(F & eTorchActive); m_nightvision_active = !!(F & eNightVisionActive); m_attached = !!(F & eAttached); }
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; }
void CWeaponMagazined::net_Import(NET_Packet& P) { // if (Level().IsDemoPlay()) // Msg("CWeapon::net_Import [%d]", ID()); inherited::net_Import(P); m_iCurFireMode = P.r_u8(); SetQueueSize(GetCurrentFireMode()); }
void CWeaponStatMgun::net_Import(NET_Packet& P) // import from server { inheritedPH::net_Import (P); u8 state = P.r_u8(); load_data (m_destEnemyDir, P); if(TRUE==IsWorking()&&!state) FireEnd (); if(FALSE==IsWorking()&&state) FireStart (); }
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); }
void CWeapon::OnEvent(NET_Packet& P, u16 type) { switch (type) { case GE_ADDON_CHANGE: { P.r_u8 (m_flagsAddOnState); InitAddons(); UpdateAddonsVisibility(); }break; case GE_WPN_STATE_CHANGE: { u8 state; P.r_u8 (state); P.r_u8 (m_sub_state); // u8 NewAmmoType = P.r_u8(); u8 AmmoElapsed = P.r_u8(); u8 NextAmmo = P.r_u8(); if (NextAmmo == undefined_ammo_type) m_set_next_ammoType_on_reload = undefined_ammo_type; else m_set_next_ammoType_on_reload = NextAmmo; if (OnClient()) SetAmmoElapsed(int(AmmoElapsed)); OnStateSwitch (u32(state)); } break; default: { inherited::OnEvent(P,type); }break; } };
void game_sv_CaptureTheArtefact::OnEvent(NET_Packet & tNetPacket, u16 type, u32 time, ClientID sender ) { switch (type) { case GAME_EVENT_PLAYER_KILL: { u16 ID = tNetPacket.r_u16(); xrClientData* l_pC = (xrClientData*)get_client(ID); if (!l_pC) break; KillPlayer (l_pC->ID, l_pC->ps->GameID); }break; case GAME_EVENT_PLAYER_BUY_FINISHED: { xrClientData* l_pC = m_server->ID_to_client(sender); OnPlayerBuyFinished(l_pC->ID, tNetPacket); }break; case GAME_EVENT_PLAYER_ENTER_TEAM_BASE: { u16 pl_id = tNetPacket.r_u16(); //warning, in editor green team zone has 1 id, blue team zone has id 2 u8 z_t_id = tNetPacket.r_u8(); z_t_id--; // :( !!! OnObjectEnterTeamBase(pl_id, z_t_id); }break; case GAME_EVENT_PLAYER_LEAVE_TEAM_BASE: { u16 pl_id = tNetPacket.r_u16(); u8 z_t_id = tNetPacket.r_u8(); z_t_id--; // :( !!! OnObjectLeaveTeamBase(pl_id, z_t_id); }break; default: inherited::OnEvent(tNetPacket, type, time, sender); };//switch }
void CCustomZone::OnEvent (NET_Packet& P, u16 type) { switch (type) { case GE_ZONE_STATE_CHANGE: { u8 S; P.r_u8 (S); OnStateSwitch (EZoneState(S)); break; } } inherited::OnEvent(P, type); };
void CLevel__cl_Process_CustomEvent(NET_Packet& pack) { if (!HookHandle->IsServer() || (HookHandle->IsServer() && !HookHandle->IsDedicated())) { unsigned char type = 0; pack.r_u8(type); if (type == e_so_engine_packet) { unsigned char e; pack.r_u8(e); switch (e) { default: LogHandle->Write("CLevel__cl_Process_CustomEvent unknown event %d",e); break; } } else if (type == e_so_script_packet) { char data[2048]; pack.r_stringZ(data); LogHandle->Write("Recieved data at client side '%s'",data); HookHandle->messanges_cl.push_back(data); } else { LogHandle->Write("ERROR: CLevel__cl_Process_CustomEvent unknown type"); } } }
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); }