bool CShootingObject::SendHitAllowed (CObject* pUser) { if (Game().IsServerControlHits()) return OnServer(); if (OnServer()) { if (pUser->CLS_ID == CLSID_OBJECT_ACTOR) { if (Level().CurrentControlEntity() != pUser) { return false; } } return true; } else { if (pUser->CLS_ID == CLSID_OBJECT_ACTOR) { if (Level().CurrentControlEntity() == pUser) { return true; } } return false; } };
bool CShootingObject::SendHitAllowed (CObject* pUser) { if (Game().IsServerControlHits()) return OnServer(); if (OnServer()) { if (smart_cast<CActor*>(pUser)) { if (Level().CurrentControlEntity() != pUser) { return false; } } return true; } else { if (smart_cast<CActor*>(pUser)) { if (Level().CurrentControlEntity() == pUser) { return true; } } return false; } };
void CActorCondition::DisableBoostParameters(const SBooster& B) { if(!OnServer()) return; switch(B.m_type) { case eBoostHpRestore: BoostHpRestore(-B.fBoostValue); break; case eBoostPowerRestore: BoostPowerRestore(-B.fBoostValue); break; case eBoostRadiationRestore: BoostRadiationRestore(-B.fBoostValue); break; case eBoostBleedingRestore: BoostBleedingRestore(-B.fBoostValue); break; case eBoostMaxWeight: BoostMaxWeight(-B.fBoostValue); break; case eBoostBurnImmunity: BoostBurnImmunity(-B.fBoostValue); break; case eBoostShockImmunity: BoostShockImmunity(-B.fBoostValue); break; case eBoostRadiationImmunity: BoostRadiationImmunity(-B.fBoostValue); break; case eBoostTelepaticImmunity: BoostTelepaticImmunity(-B.fBoostValue); break; case eBoostChemicalBurnImmunity: BoostChemicalBurnImmunity(-B.fBoostValue); break; case eBoostExplImmunity: BoostExplImmunity(-B.fBoostValue); break; case eBoostStrikeImmunity: BoostStrikeImmunity(-B.fBoostValue); break; case eBoostFireWoundImmunity: BoostFireWoundImmunity(-B.fBoostValue); break; case eBoostWoundImmunity: BoostWoundImmunity(-B.fBoostValue); break; case eBoostRadiationProtection: BoostRadiationProtection(-B.fBoostValue); break; case eBoostTelepaticProtection: BoostTelepaticProtection(-B.fBoostValue); break; case eBoostChemicalBurnProtection: BoostChemicalBurnProtection(-B.fBoostValue); break; default: NODEFAULT; } }
void SArtefactActivation::UpdateActivation() { VERIFY(!ph_world->Processing()); m_cur_state_time += Device.fTimeDelta; if(m_cur_state_time >= m_activation_states[int(m_cur_activation_state)].m_time){ m_cur_activation_state = (EActivationStates)(int)(m_cur_activation_state+1); if(m_cur_activation_state == eMax){ m_cur_activation_state = eNone; m_af->processing_deactivate (); m_af->CPHUpdateObject::Deactivate (); m_af->DestroyObject(); } m_cur_state_time = 0.0f; ChangeEffects (); if(m_cur_activation_state==eSpawnZone && OnServer()) SpawnAnomaly (); } UpdateEffects (); }
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)); } };
void CLevel::Send (NET_Packet& P, u32 dwFlags, u32 dwTimeout) { if (IsDemoPlayStarted() || IsDemoPlayFinished()) return; // optimize the case when server located in our memory if(psNET_direct_connect){ ClientID _clid; _clid.set (1); Server->OnMessage (P, _clid ); }else if (Server && game_configured && OnServer() ) { #ifdef DEBUG VERIFY2(Server->IsPlayersMonitorLockedByMe() == false, "potential deadlock detected"); #endif VERIFY2(csMessagesAndNetQueueDeadLockDetect == false, "deadlock detected!"); Server->OnMessageSync (P,Game().local_svdpnid ); }else IPureClient::Send (P,dwFlags,dwTimeout ); if (g_pGameLevel && Level().game && GameID() != eGameIDSingle && !g_SV_Disable_Auth_Check) { // anti-cheat phTimefactor = 1.f ; psDeviceFlags.set (rsConstantFPS,FALSE) ; } }
void WeaponUsageStatistic::OnExplosionKill(game_PlayerState* ps, const SHit& hit) { if (!CollectData()) return; if (!ps) return; if (!OnServer()) return; CObject* killer = hit.who; if(!killer) return; u16 killer_id = hit.whoID; game_PlayerState* killerPS = Game().GetPlayerByGameID(killer_id); Player_Statistic& PlayerStatKiller = *(FindPlayer(killerPS->getName())); CObject* weapon_object = Level().Objects.net_Find(hit.weaponID); WEAPON_STATS_it WeaponIt = PlayerStatKiller.FindPlayersWeapon(weapon_object->cNameSect().c_str()); WeaponIt->m_dwHitsScored++; WeaponIt->m_dwKillsScored++; HitData NewHit; //--------------------------- NewHit.Completed = true; NewHit.Deadly = true; NewHit.BoneID = hit.boneID; NewHit.TargetID = ps->GameID; NewHit.BulletID = 0; NewHit.Pos0 = killer->Position(); NewHit.Pos1 = weapon_object->Position(); NewHit.TargetName = ps->getName(); NewHit.BoneName = 0; //--------------------------- WeaponIt->m_Hits.push_back(NewHit); }
/////////spawn object representing destroyed item////////////////////////////////////////////////////////////////////////////////// void CPHDestroyable::GenSpawnReplace(u16 ref_id,LPCSTR section,shared_str visual_name) { CSE_Abstract *D = F_entity_Create(section);//*cNameSect() VERIFY (D); CSE_Visual *V =smart_cast<CSE_Visual*>(D); V->set_visual (*visual_name); CSE_PHSkeleton *l_tpPHSkeleton = smart_cast<CSE_PHSkeleton*>(D); VERIFY (l_tpPHSkeleton); l_tpPHSkeleton->source_id = ref_id; //init // Send D->s_name = section;//*cNameSect() D->ID_Parent = u16(-1); InitServerObject (D); if (OnServer()) { NET_Packet P; D->Spawn_Write (P,TRUE); Level().Send (P,net_flags(TRUE)); // Destroy F_entity_Destroy (D); m_depended_objects++; }; };
void CtaArtefactActivation::UpdateActivation() { if (!IsInProgress()) return; VERIFY(!physics_world()->Processing()); m_cur_state_time += Device.fTimeDelta; if(m_cur_state_time >= m_activation_states[int(m_cur_activation_state)].m_time){ m_cur_activation_state = (EActivationStates)(int)(m_cur_activation_state+1); if(m_cur_activation_state == eMax){ m_cur_activation_state = eNone; //m_af->processing_deactivate (); //m_af->DestroyObject(); } m_cur_state_time = 0.0f; ChangeEffects (); if(m_cur_activation_state==eSpawnZone && OnServer()) SpawnAnomaly (); } UpdateEffects (); }
bool CWeaponMagazinedWGrenade::Attach(PIItem pIItem, bool b_send_event) { CGrenadeLauncher* pGrenadeLauncher = smart_cast<CGrenadeLauncher*>(pIItem); if(pGrenadeLauncher && ALife::eAddonAttachable == m_eGrenadeLauncherStatus && 0 == (m_flagsAddOnState&CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher) && !xr_strcmp(*m_sGrenadeLauncherName, pIItem->object().cNameSect())) { m_flagsAddOnState |= CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher; CRocketLauncher::m_fLaunchSpeed = pGrenadeLauncher->GetGrenadeVel(); //уничтожить подствольник из инвентаря if(b_send_event) { if (OnServer()) pIItem->object().DestroyObject (); } InitAddons (); UpdateAddonsVisibility (); if(GetState()==eIdle) PlayAnimIdle (); return true; } else return inherited::Attach(pIItem, b_send_event); }
bool CWeapon::SwitchAmmoType( u32 flags ) { if ( IsPending() || OnClient() ) return false; if ( !(flags & CMD_START) ) return false; u8 l_newType = m_ammoType; bool b1, b2; do { l_newType = u8( (u32(l_newType+1)) % m_ammoTypes.size() ); b1 = (l_newType != m_ammoType); b2 = unlimited_ammo() ? false : ( !m_pInventory->GetAny( m_ammoTypes[l_newType].c_str() ) ); } while( b1 && b2 ); if ( l_newType != m_ammoType ) { m_set_next_ammoType_on_reload = l_newType; if ( OnServer() ) { Reload(); } } return true; }
void CPhysicObject::Interpolate() { net_updatePhData* p = NetSync(); CPHSynchronize* pSyncObj = this->PHGetSyncItem(0); //simple linear interpolation... if (!this->H_Parent() && this->getVisible() && this->m_pPhysicsShell && !OnServer() && p->NET_IItem.size()) { SPHNetState newState = p->NET_IItem.front().State; if (p->NET_IItem.size() >= 2) { float ret_interpolate = interpolate_states(p->NET_IItem.front(), p->NET_IItem.back(), newState); //Msg("Interpolation factor is %0.4f", ret_interpolate); //Msg("Current position is: x = %3.3f, y = %3.3f, z = %3.3f", newState.position.x, newState.position.y, newState.position.z); if (ret_interpolate >= 1.f) { p->NET_IItem.pop_front(); if (m_activated) { Msg("Deactivating object [%d] after interpolation finish", ID()); processing_deactivate(); m_activated = false; } } } pSyncObj->set_State(newState); } }
void CLevel::ClientSend() { if ((GameID() != eGameIDSingle) || OnClient()) // fixed by Shoker { if ( !net_HasBandwidth() ) return; }; NET_Packet P; u32 start = 0; //----------- for E3 ----------------------------- // if () { // if (!(Game().local_player) || Game().local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD)) return; if (CurrentControlEntity()) { CObject* pObj = CurrentControlEntity(); if (!pObj->getDestroy() && pObj->net_Relevant()) { P.w_begin (M_CL_UPDATE); P.w_u16 (u16(pObj->ID()) ); P.w_u32 (0); //reserved place for client's ping pObj->net_Export (P); if (P.B.count>9) { if (!OnServer()) Send (P, net_flags(FALSE)); } } } }; if (m_file_transfer) { m_file_transfer->update_transfer(); m_file_transfer->stop_obsolete_receivers(); } if (OnClient()) { Flush_Send_Buffer(); return; } //------------------------------------------------- while (1) { P.w_begin (M_UPDATE); start = Objects.net_Export (&P, start, max_objects_size); if (P.B.count>2) { Device.Statistic->TEST3.Begin(); Send (P, net_flags(FALSE)); Device.Statistic->TEST3.End(); }else break; } }
void CWeaponRPG7::switch2_Fire() { m_iShotNum = 0; m_bFireSingleShot = true; bWorking = false; if(GetState()==eFire && getRocketCount()) { Fvector p1, d1, p; Fvector p2, d2, d; p1.set (get_LastFP()); d1.set (get_LastFD()); p = p1; d = d1; CEntity* E = smart_cast<CEntity*> (H_Parent()); if(E) { E->g_fireParams (this, p2,d2); p = p2; d = d2; if(IsHudModeNow()) { Fvector p0; float dist = HUD().GetCurrentRayQuery().range; p0.mul (d2,dist); p0.add (p1); p = p1; d.sub (p0,p1); d.normalize_safe(); } } Fmatrix launch_matrix; launch_matrix.identity (); launch_matrix.k.set (d); Fvector::generate_orthonormal_basis(launch_matrix.k, launch_matrix.j, launch_matrix.i); launch_matrix.c.set (p); d.normalize (); d.mul (m_fLaunchSpeed); CRocketLauncher::LaunchRocket (launch_matrix, d, zero_vel); CExplosiveRocket* pGrenade = smart_cast<CExplosiveRocket*>(getCurrentRocket()); VERIFY (pGrenade); pGrenade->SetInitiator (H_Parent()->ID()); if (OnServer()) { NET_Packet P; u_EventGen (P,GE_LAUNCH_ROCKET,ID()); P.w_u16 (u16(getCurrentRocket()->ID())); u_EventSend (P); } } }
void WeaponUsageStatistic::Send_Check_Respond() { if (!OnServer()) return; NET_Packet P; string1024 STrue, SFalse; for (u32 i=0; i<m_Requests.size(); i++) { Bullet_Check_Array& BChA_Request = m_Requests[i]; if (BChA_Request.Requests.empty()) continue; Bullet_Check_Respond_True* pSTrue = (Bullet_Check_Respond_True*) STrue; u32* pSFalse = (u32*) SFalse; //----------------------------------------------------- u32 NumFalse = 0; u32 NumTrue = 0; u32 j=0; while (j<BChA_Request.Requests.size()) { Bullet_Check_Request& curBChR = BChA_Request.Requests[j]; if (!curBChR.Processed) { j++; continue; } else { if (curBChR.Result) { pSTrue->BulletID = curBChR.BulletID; pSTrue->BoneID = curBChR.BoneID; pSTrue++; // HitChecksRespondedTrue++; NumTrue++; } else { *(pSFalse++) = curBChR.BulletID; // HitChecksRespondedFalse++; NumFalse++; }; // HitChecksResponded++; //----------------------------------------------------- *(BChA_Request.Requests.begin()+j) = BChA_Request.Requests.back(); BChA_Request.Requests.pop_back(); } } //----------------------------------------------------- P.w_begin(M_BULLET_CHECK_RESPOND); // Msg("%d-%d || %d-%d", NumFalse, BChA_Request.NumFalse, NumTrue, BChA_Request.NumTrue); P.w_u8(BChA_Request.NumFalse); BChA_Request.NumFalse = 0; P.w_u8(BChA_Request.NumTrue); BChA_Request.NumTrue = 0; if ((char*)pSFalse != (char*)SFalse) P.w(SFalse, u32((char*)pSFalse-(char*)SFalse)); if ((char*)pSTrue != (char*)STrue) P.w(STrue, u32((char*)pSTrue-(char*)STrue)); //----------------------------------------------------- ClientID ClID; ClID.set(BChA_Request.SenderID); if(Level().Server) Level().Server->SendTo(ClID, P); }; }
void CHelicopter::OnShot () { Fvector fire_pos,fire_dir; fire_pos = get_CurrentFirePoint(); fire_dir = m_fire_dir; float fire_trail_speed = 15.0f; clamp (fire_trail_speed,GetCurrVelocity(),300.0f); if(m_enemy.bUseFireTrail){ Fvector enemy_pos = m_enemy.destEnemyPos; float dt = Device.fTimeGlobal - m_enemy.fStartFireTime; VERIFY(dt>=0); float dist = m_enemy.fire_trail_length_curr - dt*fire_trail_speed; if(dist<0) { MGunFireEnd (); return ; } Fvector fp = fire_pos; fp.y = enemy_pos.y; Fvector fd; fd.sub(enemy_pos,fp).normalize_safe(); if(dist > (m_enemy.fire_trail_length_curr/2.0f) ){ fd.mul(-1.0f); dist = dist - (m_enemy.fire_trail_length_curr/2.0f); }else{ dist = (m_enemy.fire_trail_length_curr/2.0f) - dist; } static float fire_trace_width = pSettings->r_float(*cNameSect(),"fire_trace_width"); enemy_pos.mad(fd,dist); Fvector disp_dir; disp_dir.random_point(fire_trace_width); enemy_pos.add(disp_dir); fire_dir.sub(enemy_pos,fire_pos).normalize_safe(); }; FireBullet(fire_pos, fire_dir, fireDispersionBase, m_CurrentAmmo, ID(), ID(), OnServer()); StartShotParticles (); if(m_bLightShotEnabled) Light_Start (); StartFlameParticles (); StartSmokeParticles (fire_pos, zero_vel); OnShellDrop (fire_pos, zero_vel); HUD_SOUND_ITEM::PlaySound (m_sndShot, fire_pos, this, false); }
virtual void Execute(LPCSTR args) { float id1 = 0.0f; sscanf(args ,"%f",&id1); if (id1 < EPS_L) Msg("Invalid time factor! (%.4f)",id1); else { if (!OnServer()) return; Level().Server->game->SetGameTimeFactor(id1); } }
void CTeamBaseZone::feel_touch_delete (CObject *tpObject) { if(OnServer() && tpObject->CLS_ID == CLSID_OBJECT_ACTOR) { NET_Packet P_; u_EventGen (P_,GE_GAME_EVENT,ID() ); P_.w_u16 (GAME_EVENT_PLAYER_LEAVE_TEAM_BASE ); P_.w_u16 ( tpObject->ID() ); P_.w_u8 ( GetZoneTeam() ); u_EventSend (P_,net_flags(TRUE,TRUE)); }; }
void CCustomZone::SwitchZoneState(EZoneState new_state) { if (OnServer()) { // !!! Just single entry for given state !!! NET_Packet P; u_EventGen (P,GE_ZONE_STATE_CHANGE,ID()); P.w_u8 (u8(new_state)); u_EventSend (P); }; m_iPreviousStateTime = m_iStateTime = 0; }
bool CWeaponMagazined::Attach(PIItem pIItem, bool b_send_event) { bool result = false; CScope* pScope = smart_cast<CScope*>(pIItem); CSilencer* pSilencer = smart_cast<CSilencer*>(pIItem); CGrenadeLauncher* pGrenadeLauncher = smart_cast<CGrenadeLauncher*>(pIItem); if (pScope && m_eScopeStatus == CSE_ALifeItemWeapon::eAddonAttachable && (m_flagsAddOnState&CSE_ALifeItemWeapon::eWeaponAddonScope) == 0 && (m_sScopeName == pIItem->object().cNameSect())) { m_flagsAddOnState |= CSE_ALifeItemWeapon::eWeaponAddonScope; result = true; } else if (pSilencer && m_eSilencerStatus == CSE_ALifeItemWeapon::eAddonAttachable && (m_flagsAddOnState&CSE_ALifeItemWeapon::eWeaponAddonSilencer) == 0 && (m_sSilencerName == pIItem->object().cNameSect())) { m_flagsAddOnState |= CSE_ALifeItemWeapon::eWeaponAddonSilencer; result = true; } else if (pGrenadeLauncher && m_eGrenadeLauncherStatus == CSE_ALifeItemWeapon::eAddonAttachable && (m_flagsAddOnState&CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher) == 0 && (m_sGrenadeLauncherName == pIItem->object().cNameSect())) { m_flagsAddOnState |= CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher; result = true; } if (result) { if (b_send_event && OnServer()) { //уничтожить подсоединенную вещь из инвентаря //. pIItem->Drop (); pIItem->object().DestroyObject(); }; UpdateAddonsVisibility(); InitAddons(); return true; } else return inherited::Attach(pIItem, b_send_event); }
void CLevel::net_Update () { if(game_configured){ // If we have enought bandwidth - replicate client data on to server Device.Statistic->netClient2.Begin (); ClientSend (); Device.Statistic->netClient2.End (); } // If server - perform server-update if (Server && OnServer()) { Device.Statistic->netServer.Begin(); Server->Update (); Device.Statistic->netServer.End (); } }
void SArtefactActivation::Start() { VERIFY(!ph_world->Processing()); m_af->StopLights (); m_cur_activation_state = eStarting; m_cur_state_time = 0.0f; m_af->processing_activate(); NET_Packet P; CGameObject::u_EventGen (P,GE_OWNERSHIP_REJECT, m_af->H_Parent()->ID()); P.w_u16 (m_af->ID()); if (OnServer()) CGameObject::u_EventSend (P); m_light->set_active (true); ChangeEffects (); }
void CArtefact::Interpolate() { if (OnServer()) return; net_updateInvData* p = NetSync(); while (p->NET_IItem.size() > 1) //in real no interpolation, just get latest state { p->NET_IItem.pop_front(); } inherited::Interpolate(); if (p->NET_IItem.size()) { p->NET_IItem.clear(); //same as p->NET_IItem.pop_front(); } }
void CPhysicObject::PH_A_CrPr () { if (m_just_after_spawn) { VERIFY(Visual()); IKinematics *K = Visual()->dcast_PKinematics(); VERIFY( K ); if (!PPhysicsShell()) { return; } if(!PPhysicsShell()->isFullActive()) { K->CalculateBones_Invalidate(); K->CalculateBones(TRUE); } PPhysicsShell()->GetGlobalTransformDynamic(&XFORM()); K->CalculateBones_Invalidate(); K->CalculateBones(TRUE); #if 0 Fbox bb= BoundingBox (); DBG_OpenCashedDraw (); Fvector c,r,p; bb.get_CD(c,r ); XFORM().transform_tiny(p,c); DBG_DrawAABB( p, r,D3DCOLOR_XRGB(255, 0, 0)); //PPhysicsShell()->XFORM().transform_tiny(c); Fmatrix mm; PPhysicsShell()->GetGlobalTransformDynamic(&mm); mm.transform_tiny(p,c); DBG_DrawAABB( p, r,D3DCOLOR_XRGB(0, 255, 0)); DBG_ClosedCashedDraw (50000); #endif spatial_move(); m_just_after_spawn = false; VERIFY(!OnServer()); PPhysicsShell()->get_ElementByStoreOrder(0)->Fix(); PPhysicsShell()->SetIgnoreStatic (); //PPhysicsShell()->SetIgnoreDynamic (); //PPhysicsShell()->DisableCollision(); } //CalculateInterpolationParams() };
BOOL CSpectator::net_Spawn ( CSE_Abstract* DC ) { BOOL res = inherited::net_Spawn(DC); if (!res) return FALSE; CSE_Abstract *E = (CSE_Abstract*)(DC); if (!E) return FALSE; cam_active = eacFreeFly; look_idx = 0; cameras[cam_active]->Set (-E->o_Angle.y,-E->o_Angle.x,0); // set's camera orientation cameras[cam_active]->vPosition.set(E->o_Position); if (OnServer()) { E->s_flags.set(M_SPAWN_OBJECT_LOCAL, TRUE); }; return TRUE; };
void CLevel::Send (NET_Packet& P, u32 dwFlags, u32 dwTimeout) { if (IsDemoPlay() && m_bDemoStarted) return; // optimize the case when server located in our memory if(psNET_direct_connect){ ClientID _clid; _clid.set (1); Server->OnMessage (P, _clid ); }else if (Server && game_configured && OnServer() ) { Server->OnMessage (P,Game().local_svdpnid ); }else IPureClient::Send (P,dwFlags,dwTimeout ); if (g_pGameLevel && Level().game && GameID() != GAME_SINGLE && !g_SV_Disable_Auth_Check) { // anti-cheat phTimefactor = 1.f ; psDeviceFlags.set (rsConstantFPS,FALSE) ; } }
void CLevel::cl_Process_Spawn(NET_Packet& P) { // Begin analysis shared_str s_name; P.r_stringZ (s_name); // Create DC (xrSE) CSE_Abstract* E = F_entity_Create (*s_name); R_ASSERT2(E, *s_name); E->Spawn_Read (P); if (E->s_flags.is(M_SPAWN_UPDATE)) E->UPDATE_Read (P); if (!E->match_configuration()) { F_entity_Destroy(E); return; } //------------------------------------------------- //. Msg ("M_SPAWN - %s[%d][%x] - %d %d", *s_name, E->ID, E,E->ID_Parent, Device.dwFrame); //------------------------------------------------- //force object to be local for server client if (OnServer()) { E->s_flags.set(M_SPAWN_OBJECT_LOCAL, TRUE); }; /* game_spawn_queue.push_back(E); if (g_bDebugEvents) ProcessGameSpawns(); /*/ g_sv_Spawn (E); F_entity_Destroy (E); //*/ };
BOOL CSpectator::net_Spawn ( CSE_Abstract* DC ) { BOOL res = inherited::net_Spawn(DC); if (!res) return FALSE; CSE_Abstract *E = (CSE_Abstract*)(DC); if (!E) return FALSE; game_cl_mp* pMPGame = smart_cast<game_cl_mp*> (&Game()); float tmp_roll = 0.f; if (!pMPGame || pMPGame->Is_Spectator_Camera_Allowed(eacFreeFly)) { cam_active = eacFreeFly; } else { game_PlayerState* ps = pMPGame->local_player; s16 tmp_team = ps ? pMPGame->ModifyTeam(ps->team) : -1; if ((tmp_team == -1) || (tmp_team == etSpectatorsTeam)) { cam_active = eacFreeFly; } else { cam_active = eacFixedLookAt; tmp_roll = -E->o_Angle.z; } } look_idx = 0; cameras[cam_active]->Set(-E->o_Angle.y, -E->o_Angle.x, tmp_roll);// set's camera orientation cameras[cam_active]->vPosition.set(E->o_Position); if (OnServer()) { E->s_flags.set(M_SPAWN_OBJECT_LOCAL, TRUE); }; return TRUE; };
void CCustomZone::CreateHit ( u16 id_to, u16 id_from, const Fvector& hit_dir, float hit_power, s16 bone_id, const Fvector& pos_in_bone, float hit_impulse, ALife::EHitType hit_type) { if (OnServer()) { if(m_owner_id != u32(-1) ) id_from = (u16)m_owner_id; NET_Packet l_P; Fvector hdir = hit_dir; SHit Hit = SHit(hit_power, hdir, this, bone_id, pos_in_bone, hit_impulse, hit_type, 0.0f, false); Hit.GenHeader (GE_HIT, id_to); Hit.whoID = id_from; Hit.weaponID = this->ID(); Hit.Write_Packet (l_P); u_EventSend (l_P); }; }
void CWeapon::SwitchState(u32 S) { if (OnClient()) return; #ifndef MASTER_GOLD if ( bDebug ) { Msg("---Server is going to send GE_WPN_STATE_CHANGE to [%d], weapon_section[%s], parent[%s]", S, cNameSect().c_str(), H_Parent() ? H_Parent()->cName().c_str() : "NULL Parent"); } #endif // #ifndef MASTER_GOLD SetNextState ( S ); if (CHudItem::object().Local() && !CHudItem::object().getDestroy() && m_pInventory && OnServer()) { // !!! Just single entry for given state !!! NET_Packet P; CHudItem::object().u_EventGen (P,GE_WPN_STATE_CHANGE,CHudItem::object().ID()); P.w_u8 (u8(S)); P.w_u8 (u8(m_sub_state)); P.w_u8 (m_ammoType); P.w_u8 (u8(iAmmoElapsed & 0xff)); P.w_u8 (m_set_next_ammoType_on_reload); CHudItem::object().u_EventSend (P, net_flags(TRUE, TRUE, FALSE, TRUE)); } }