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 (0); 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 (m_gameType.m_GameType.get()); 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_u16 (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)); }
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 }
BOOL CLevel::Connect2Server (LPCSTR options) { NET_Packet P; m_bConnectResultReceived = false ; m_bConnectResult = true ; if (!Connect(options)) return FALSE; //--------------------------------------------------------------------------- if(psNET_direct_connect) m_bConnectResultReceived = true; u32 EndTime = GetTickCount() + ConnectionTimeOut; while (!m_bConnectResultReceived) { ClientReceive (); Sleep (5); if(Server) Server->Update() ; //----------------------------------------- u32 CurTime = GetTickCount(); if (CurTime > EndTime) { NET_Packet P; P.B.count = 0; P.r_pos = 0; P.w_u8(0); P.w_u8(0); P.w_stringZ("Data verification failed. Cheater? [1]"); OnConnectResult(&P); } if (net_isFails_Connect()) { OnConnectRejected (); Disconnect () ; return FALSE; } //----------------------------------------- } Msg ("%c client : connection %s - <%s>", m_bConnectResult ?'*':'!', m_bConnectResult ? "accepted" : "rejected", m_sConnectResult.c_str()); if (!m_bConnectResult) { OnConnectRejected (); Disconnect () ; return FALSE ; }; if(psNET_direct_connect) net_Syncronised = TRUE; else net_Syncronize (); while (!net_IsSyncronised()) { }; //--------------------------------------------------------------------------- P.w_begin (M_CLIENT_REQUEST_CONNECTION_DATA); Send (P, net_flags(TRUE, TRUE, TRUE, TRUE)); //--------------------------------------------------------------------------- return TRUE; };
void xrServer::SendConnectResult(IClient* CL, u8 res, u8 res1, char* ResultStr) { NET_Packet P; P.w_begin (M_CLIENT_CONNECT_RESULT); P.w_u8 (res); P.w_u8 (res1); P.w_stringZ (ResultStr); if (SV_Client && SV_Client == CL) P.w_u8(1); else P.w_u8(0); P.w_stringZ(Level().m_caServerOptions); SendTo (CL->ID, P); };
BOOL CPhantom::net_Spawn(CSE_Abstract* DC) { CSE_ALifeCreaturePhantom* OBJ = smart_cast<CSE_ALifeCreaturePhantom*>(DC); VERIFY(OBJ); // select visual at first LPCSTR vis_name = OBJ->get_visual(); if (!(vis_name&&vis_name[0])){ LPCSTR visuals = pSettings->r_string(cNameSect(),"visuals"); u32 cnt = _GetItemCount(visuals); string256 tmp; OBJ->set_visual (_GetItem(visuals,Random.randI(cnt),tmp)); // inform server NET_Packet P; u_EventGen (P, GE_CHANGE_VISUAL, OBJ->ID); P.w_stringZ (tmp); u_EventSend (P); } SwitchToState (stBirth); // initial state (changed on load method in inherited::) // inherited if (!inherited::net_Spawn(DC)) return FALSE; m_enemy = Level().CurrentEntity(); VERIFY (m_enemy); // default init m_fly_particles = 0; SetfHealth (0.001f); // orientate to enemy XFORM().k.sub (m_enemy->Position(),Position()).normalize(); XFORM().j.set (0,1,0); XFORM().i.crossproduct (XFORM().j,XFORM().k); XFORM().k.getHP (vHP.x,vHP.y); // set animation IKinematicsAnimated *K = smart_cast<IKinematicsAnimated*>(Visual()); m_state_data[stBirth].motion = K->ID_Cycle("birth_0"); m_state_data[stFly].motion = K->ID_Cycle("fly_0"); m_state_data[stContact].motion = K->ID_Cycle("contact_0"); m_state_data[stShoot].motion = K->ID_Cycle("shoot_0"); VERIFY(K->LL_GetMotionDef(m_state_data[stBirth].motion)->flags&esmStopAtEnd); VERIFY(K->LL_GetMotionDef(m_state_data[stContact].motion)->flags&esmStopAtEnd); VERIFY(K->LL_GetMotionDef(m_state_data[stShoot].motion)->flags&esmStopAtEnd); // set state SwitchToState_internal(m_TgtState); setVisible (m_CurState>stIdle?TRUE:FALSE); setEnabled (TRUE); return TRUE; }
void CUICarBodyWnd::InitCarBody(CInventoryOwner* pOur, CInventoryOwner* pOthers) { m_pOurObject = pOur; m_pOthersObject = pOthers; m_pInventoryBox = NULL; u16 our_id = smart_cast<CGameObject*>(m_pOurObject)->ID(); u16 other_id = smart_cast<CGameObject*>(m_pOthersObject)->ID(); m_pUICharacterInfoLeft->InitCharacter (our_id); m_pUIOthersIcon->Show (true); CBaseMonster *monster = NULL; if(m_pOthersObject) { monster = smart_cast<CBaseMonster *>(m_pOthersObject); if (monster || m_pOthersObject->use_simplified_visual() ) { m_pUICharacterInfoRight->ClearInfo (); if(monster) { shared_str monster_tex_name = pSettings->r_string(monster->cNameSect(),"icon"); m_pUICharacterInfoRight->UIIcon().InitTexture(monster_tex_name.c_str()); m_pUICharacterInfoRight->UIIcon().SetStretchTexture(true); } }else { m_pUICharacterInfoRight->InitCharacter (other_id); } } m_pUIPropertiesBox->Hide (); EnableAll (); UpdateLists (); if(!monster){ CInfoPortionWrapper *known_info_registry = xr_new<CInfoPortionWrapper>(); known_info_registry->registry().init (other_id); KNOWN_INFO_VECTOR& known_info = known_info_registry->registry().objects(); KNOWN_INFO_VECTOR_IT it = known_info.begin(); for(int i=0;it!=known_info.end();++it,++i){ (*it).info_id; NET_Packet P; CGameObject::u_EventGen (P,GE_INFO_TRANSFER, our_id); P.w_u16 (0);//not used P.w_stringZ ((*it).info_id); //сообщение P.w_u8 (1); //добавление сообщения CGameObject::u_EventSend (P); } known_info.clear (); xr_delete (known_info_registry); } }
void CSE_SmartCover::STATE_Write(NET_Packet &tNetPacket) { inherited1::STATE_Write (tNetPacket); cform_write (tNetPacket); tNetPacket.w_stringZ (m_description); tNetPacket.w_float (m_hold_position_time); tNetPacket.w_float (m_enter_min_enemy_distance); tNetPacket.w_float (m_exit_min_enemy_distance); tNetPacket.w_u8 ((u8)m_is_combat_cover); tNetPacket.w_u8 ((u8)m_can_fire); }
void WeaponUsageStatistic::OnUpdateRequest(NET_Packet*) { if (aPlayersStatistic.empty()) return; Player_Statistic& PS = aPlayersStatistic.front(); //------------------------------------------------- NET_Packet P; P.w_begin(M_STATISTIC_UPDATE_RESPOND); //------------------------------------------------- P.w_stringZ(PS.PName); PS.net_save(&P); //------------------------------------------------- Level().Send(P); };
void xrGameSpyServer::OnCDKey_ReValidation (int LocalID, int hint, char* challenge) { ClientID ID; ID.set(u32(LocalID)); xrGameSpyClientData* CL = (xrGameSpyClientData*) ID_to_client(ID); if (!CL) return; strcpy_s(CL->m_pChallengeString, challenge); CL->m_iCDKeyReauthHint = hint; //--------- Send Respond --------------------------------------------- NET_Packet P; P.w_begin (M_GAMESPY_CDKEY_VALIDATION_CHALLENGE); P.w_u8(1); P.w_stringZ(CL->m_pChallengeString); SendTo(CL->ID, P); }
void xrGameSpyServer::SendChallengeString_2_Client (IClient* C) { if (!C) return; xrGameSpyClientData* pClient = (xrGameSpyClientData*) C; m_GCDServer.CreateRandomChallenge(pClient->m_pChallengeString, 8); //--------- Send Respond --------------------------------------------- NET_Packet P; P.w_begin (M_GAMESPY_CDKEY_VALIDATION_CHALLENGE); P.w_u8(0); P.w_stringZ(pClient->m_pChallengeString); SendTo(pClient->ID, P); }
void xrServer::OnCL_Disconnected (IClient* CL) { //csPlayers.Enter (); // Game config (all, info includes deleted player now, excludes at the next cl-update) NET_Packet P; P.B.count = 0; P.w_clientID(CL->ID); xrClientData* xrCData = (xrClientData*)(CL); VERIFY(xrCData); if (!xrCData->ps) return; P.w_stringZ(xrCData->ps->getName()); P.w_u16(xrCData->ps->GameID); P.r_pos = 0; ClientID clientID; clientID.set(0); game->AddDelayedEvent(P,GAME_EVENT_PLAYER_DISCONNECTED, 0, clientID); // xrS_entities::iterator I=entities.begin(),E=entities.end(); if (GetClientsCount()>1 && !CL->flags.bLocal) { // Migrate entities for (; I!=E; ++I) { CSE_Abstract* entity = I->second; if (entity->owner == CL) PerformMigration (entity,(xrClientData*)CL,SelectBestClientToMigrateTo(entity,TRUE)); } } else { // Destroy entities while (!entities.empty()) { CSE_Abstract* entity = entities.begin()->second; entity_Destroy (entity); } } //csPlayers.Leave (); Server_Client_Check(CL); }
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); }
void CUIInventoryWnd::DetachAddon(const char* addon_name) { PlaySnd (eInvDetachAddon); if (OnClient()) { NET_Packet P; CurrentIItem()->object().u_EventGen (P, GE_ADDON_DETACH, CurrentIItem()->object().ID()); P.w_stringZ (addon_name); CurrentIItem()->object().u_EventSend (P); }; CurrentIItem()->Detach (addon_name, true); //спр¤тать вещь из активного слота в инвентарь на врем¤ вызова менюшки CActor *pActor = smart_cast<CActor*>(Level().CurrentEntity()); if(pActor && CurrentIItem() == pActor->inventory().ActiveItem()) { m_iCurrentActiveSlot = pActor->inventory().GetActiveSlot(); pActor->inventory().Activate (NO_ACTIVE_SLOT); } }
void CInfoDocument::OnH_A_Chield() { inherited::OnH_A_Chield (); //передать информацию содержащуюся в документе //объекту, который поднял документ CInventoryOwner* pInvOwner = smart_cast<CInventoryOwner*>(H_Parent()); if(!pInvOwner) return; //создать и отправить пакет о получении новой информации if(m_Info.size()) { NET_Packet P; u_EventGen (P,GE_INFO_TRANSFER, H_Parent()->ID()); P.w_u16 (ID()); //отправитель P.w_stringZ (m_Info); //сообщение P.w_u8 (1); //добавление сообщения u_EventSend (P); } }
void CLevel::OnGameSpyChallenge (NET_Packet* P) { Msg("xrGS::CDKey::Level : Responding on Challenge"); u8 Reauth = P->r_u8(); string64 ChallengeStr; P->r_stringZ(ChallengeStr); //-------------------------------------------------------------------- string128 ResponseStr=""; CGameSpy_GCD_Client GCD; GCD.CreateRespond(ResponseStr, ChallengeStr, Reauth); //--------- Send Respond --------------------------------------------- NET_Packet newP; newP.w_begin (M_GAMESPY_CDKEY_VALIDATION_CHALLENGE_RESPOND); newP.w_stringZ(ResponseStr); Send(newP, net_flags(TRUE, TRUE, TRUE, TRUE)); // g_pGamePersistent->LoadTitle("st_validating_cdkey"); };
void CInventoryOwner::TransferInfo(shared_str info_id, bool add_info) const { VERIFY( info_id.size() ); const CObject* pThisObject = smart_cast<const CObject*>(this); VERIFY(pThisObject); //отправляем от нашему PDA пакет информации с номером NET_Packet P; CGameObject::u_EventGen(P, GE_INFO_TRANSFER, pThisObject->ID()); P.w_u16 (pThisObject->ID()); //отправитель P.w_stringZ (info_id); //сообщение P.w_u8 (add_info?1:0); //добавить/удалить информацию CGameObject::u_EventSend(P); CInfoPortion info_portion; info_portion.Load(info_id); { if(add_info) OnReceiveInfo (info_id); else OnDisableInfo (info_id); } }
void game_sv_TeamDeathmatch::OnPlayerConnectFinished (ClientID id_who) { inherited::OnPlayerConnectFinished(id_who); xrClientData* xrCData = m_server->ID_to_client(id_who); // Send Message About Client join Team if (xrCData) { NET_Packet P; // P.w_begin (M_GAMEMESSAGE); GenerateGameMessage (P); P.w_u32 (GAME_EVENT_PLAYER_JOIN_TEAM); P.w_stringZ ( xrCData->name.c_str() ); P.w_u16 (xrCData->ps->team); u_EventSend(P); }; if (xrCData) { if (xrCData->ps) xrCData->ps->m_iTeamKills = 0; } };
void BattlEyeServer::KickPlayer( int player, char* reason ) { xrClientData* tmp_client = static_cast<xrClientData*>( Level().Server->GetClientByID(static_cast<ClientID>(player)) ); if (!tmp_client) { Msg( "! No such player found : %i", player ); return; } LPCSTR reason2; STRCONCAT( reason2, "@", tmp_client->ps->getName(), " ", CStringTable().translate("ui_st_kicked_by_battleye").c_str(), " ", reason ); Msg( reason2 ); if( g_be_message_out )// self { if ( Level().game ) { Level().game->CommonMessageOut( reason2 + 1 ); } } if (Level().Server->GetServerClient() == tmp_client) { // " Disconnecting : %s ! Server's Client kicked by BattlEye Server. Reason: %s", NET_Packet P; P.w_begin ( M_GAMEMESSAGE ); P.w_u32 ( GAME_EVENT_SERVER_DIALOG_MESSAGE ); P.w_stringZ ( reason2 ); Level().Server->SendBroadcast( tmp_client->ID, P ); // to all, except self Level().OnSessionTerminate( reason2 ); //to self Engine.Event.Defer("KERNEL:disconnect"); return; } Level().Server->AddCheater(shared_str(reason2), tmp_client->ID); }
void game_PlayerState::net_Export(NET_Packet& P, BOOL Full) { P.w_u8 (Full ? 1 : 0); if (Full) P.w_stringZ ( name ); P.w_u8 ( team ); P.w_s16 ( m_iRivalKills ); P.w_s16 ( m_iSelfKills ); P.w_s16 ( m_iTeamKills ); P.w_s16 ( m_iDeaths ); P.w_s32 ( money_for_round ); P.w_float_q8 ( experience_D, -1.0f, 2.0f); P.w_u8 ( rank ); P.w_u8 ( af_count ); P.w_u16 ( flags__ ); P.w_u16 ( ping ); P.w_u16 ( GameID ); P.w_s8 ( skin ); P.w_u8 ( m_bCurrentVoteAgreed ); P.w_u32 (Device.dwTimeGlobal - DeathTime); };
void CUIActorMenu::InitDeadBodySearchMode() { m_pDeadBodyBagList->Show (true); m_LeftBackground->Show (true); m_PartnerBottomInfo->Show (true); m_PartnerWeight->Show (true); m_takeall_button->Show (true); if ( m_pPartnerInvOwner ) { m_PartnerCharacterInfo->Show(true); } else { m_PartnerCharacterInfo->Show(false); } InitInventoryContents (m_pInventoryBagList); TIItemContainer items_list; if ( m_pPartnerInvOwner ) { m_pPartnerInvOwner->inventory().AddAvailableItems( items_list, false ); //true UpdatePartnerBag(); } else { VERIFY( m_pInvBox ); m_pInvBox->m_in_use = true; m_pInvBox->AddAvailableItems( items_list ); } std::sort( items_list.begin(), items_list.end(),InventoryUtilities::GreaterRoomInRuck ); TIItemContainer::iterator it = items_list.begin(); TIItemContainer::iterator it_e = items_list.end(); for(; it != it_e; ++it) { CUICellItem* itm = create_cell_item (*it); m_pDeadBodyBagList->SetItem (itm); } CBaseMonster* monster = smart_cast<CBaseMonster*>( m_pPartnerInvOwner ); //only for partner, box = no, monster = no if ( m_pPartnerInvOwner && !monster ) { CInfoPortionWrapper known_info_registry; known_info_registry.registry().init (m_pPartnerInvOwner->object_id()); KNOWN_INFO_VECTOR& known_infos = known_info_registry.registry().objects(); KNOWN_INFO_VECTOR_IT it = known_infos.begin(); for(int i=0;it!=known_infos.end();++it,++i) { NET_Packet P; CGameObject::u_EventGen (P,GE_INFO_TRANSFER, m_pActorInvOwner->object_id()); P.w_u16 (0); P.w_stringZ ((*it).info_id); P.w_u8 (1); CGameObject::u_EventSend (P); } known_infos.clear (); } UpdateDeadBodyBag(); }
void CSE_Visual::visual_write (NET_Packet &tNetPacket) { tNetPacket.w_stringZ (visual_name); tNetPacket.w_u8 (flags.get()); }
void CSE_Motion::motion_write (NET_Packet &tNetPacket) { tNetPacket.w_stringZ (motion_name); }
void CCharacterInfo::save (NET_Packet& stream) { stream.w_stringZ (m_StartDialog); }
void CSE_ALifeItemDocument::STATE_Write (NET_Packet &tNetPacket) { inherited::STATE_Write (tNetPacket); tNetPacket.w_stringZ (m_wDoc); }