void CActor::AddGameTask (const CInfoPortion* info_portion) const { VERIFY(info_portion); if(info_portion->GameTasks().empty()) return; for(TASK_ID_VECTOR::const_iterator it = info_portion->GameTasks().begin(); it != info_portion->GameTasks().end(); it++) { GameTaskManager().GiveGameTaskToActor(*it, 0); } }
void CLevel::OnFrame () { #ifdef DEBUG_MEMORY_MANAGER debug_memory_guard __guard__; #endif // DEBUG_MEMORY_MANAGER #ifdef DEBUG DBG_RenderUpdate( ); #endif // #ifdef DEBUG Fvector temp_vector; m_feel_deny.feel_touch_update (temp_vector, 0.f); if (GameID()!=eGameIDSingle) psDeviceFlags.set(rsDisableObjectsAsCrows,true); else psDeviceFlags.set(rsDisableObjectsAsCrows,false); // commit events from bullet manager from prev-frame Device.Statistic->TEST0.Begin (); BulletManager().CommitEvents (); Device.Statistic->TEST0.End (); // Client receive if (net_isDisconnected()) { if (OnClient() && GameID() != eGameIDSingle) { #ifdef DEBUG Msg("* I'm disconnected, so clear all objects..."); #endif // #ifdef DEBUG ClearAllObjects(); } Engine.Event.Defer ("kernel:disconnect"); return; } else { Device.Statistic->netClient1.Begin(); ClientReceive (); Device.Statistic->netClient1.End (); } ProcessGameEvents (); if (m_bNeed_CrPr) make_NetCorrectionPrediction(); if(!g_dedicated_server ) { if (g_mt_config.test(mtMap)) Device.seqParallel.push_back (fastdelegate::FastDelegate0<>(m_map_manager,&CMapManager::Update)); else MapManager().Update (); if( IsGameTypeSingle() && Device.dwPrecacheFrame==0 ) { if (g_mt_config.test(mtMap)) Device.seqParallel.push_back (fastdelegate::FastDelegate0<>(m_game_task_manager,&CGameTaskManager::UpdateTasks)); else GameTaskManager().UpdateTasks(); } } // Inherited update inherited::OnFrame (); // Draw client/server stats if ( !g_dedicated_server && psDeviceFlags.test(rsStatistic)) { CGameFont* F = HUD().Font().pFontDI; if (!psNET_direct_connect) { if ( IsServer() ) { const IServerStatistic* S = Server->GetStatistic(); F->SetHeightI (0.015f); F->OutSetI (0.0f,0.5f); F->SetColor (D3DCOLOR_XRGB(0,255,0)); F->OutNext ("IN: %4d/%4d (%2.1f%%)", S->bytes_in_real, S->bytes_in, 100.f*float(S->bytes_in_real)/float(S->bytes_in)); F->OutNext ("OUT: %4d/%4d (%2.1f%%)", S->bytes_out_real, S->bytes_out, 100.f*float(S->bytes_out_real)/float(S->bytes_out)); F->OutNext ("client_2_sever ping: %d", net_Statistic.getPing()); F->OutNext ("SPS/Sended : %4d/%4d", S->dwBytesPerSec, S->dwBytesSended); F->OutNext ("sv_urate/cl_urate : %4d/%4d", psNET_ServerUpdate, psNET_ClientUpdate); F->SetColor (D3DCOLOR_XRGB(255,255,255)); struct net_stats_functor { xrServer* m_server; CGameFont* F; void operator()(IClient* C) { m_server->UpdateClientStatistic(C); F->OutNext("%10s: P(%d), BPS(%2.1fK), MRR(%2d), MSR(%2d), Retried(%2d), Blocked(%2d)", //Server->game->get_option_s(*C->Name,"name",*C->Name), C->name.c_str(), C->stats.getPing(), float(C->stats.getBPS()),// /1024, C->stats.getMPS_Receive (), C->stats.getMPS_Send (), C->stats.getRetriedCount(), C->stats.dwTimesBlocked ); } }; net_stats_functor tmp_functor; tmp_functor.m_server = Server; tmp_functor.F = F; Server->ForEachClientDo(tmp_functor); } if (IsClient()) { IPureClient::UpdateStatistic(); F->SetHeightI(0.015f); F->OutSetI (0.0f,0.5f); F->SetColor (D3DCOLOR_XRGB(0,255,0)); F->OutNext ("client_2_sever ping: %d", net_Statistic.getPing()); F->OutNext ("sv_urate/cl_urate : %4d/%4d", psNET_ServerUpdate, psNET_ClientUpdate); F->SetColor (D3DCOLOR_XRGB(255,255,255)); F->OutNext("P(%d), BPS(%2.1fK), MRR(%2d), MSR(%2d), Retried(%2d), Blocked(%2d), Sended(%2d), SPS(%2d)", //Server->game->get_option_s(C->Name,"name",C->Name), // C->Name, net_Statistic.getPing(), float(net_Statistic.getBPS()),// /1024, net_Statistic.getMPS_Receive (), net_Statistic.getMPS_Send (), net_Statistic.getRetriedCount(), net_Statistic.dwTimesBlocked, net_Statistic.dwBytesSended, net_Statistic.dwBytesPerSec ); #ifdef DEBUG if (!pStatGraphR) { pStatGraphR = new CStatGraph(); pStatGraphR->SetRect(50, 700, 300, 68, 0xff000000, 0xff000000); //m_stat_graph->SetGrid(0, 0.0f, 10, 1.0f, 0xff808080, 0xffffffff); pStatGraphR->SetMinMax(0.0f, 65536.0f, 1000); pStatGraphR->SetStyle(CStatGraph::stBarLine); pStatGraphR->AppendSubGraph(CStatGraph::stBarLine); } pStatGraphR->AppendItem(float(net_Statistic.getBPS()), 0xff00ff00, 0); F->OutSet(20.f, 700.f); F->OutNext("64 KBS"); #endif } } } else { #ifdef DEBUG if (pStatGraphR) xr_delete(pStatGraphR); #endif } // g_pGamePersistent->Environment().SetGameTime (GetGameDayTimeSec(),GetGameTimeFactor()); g_pGamePersistent->Environment().SetGameTime (GetEnvironmentGameDayTimeSec(),game->GetEnvironmentGameTimeFactor()); //Device.Statistic->cripting.Begin (); if (!g_dedicated_server) ai().script_engine().script_process (ScriptEngine::eScriptProcessorLevel)->update(); //Device.Statistic->Scripting.End (); m_ph_commander->update (); m_ph_commander_scripts->update (); // autosave_manager().update (); //просчитать полет пуль Device.Statistic->TEST0.Begin (); BulletManager().CommitRenderSet (); Device.Statistic->TEST0.End (); // update static sounds if(!g_dedicated_server) { if (g_mt_config.test(mtLevelSounds)) Device.seqParallel.push_back (fastdelegate::FastDelegate0<>(m_level_sound_manager,&CLevelSoundManager::Update)); else m_level_sound_manager->Update (); } // deffer LUA-GC-STEP if (!g_dedicated_server) { if (g_mt_config.test(mtLUA_GC)) Device.seqParallel.push_back (fastdelegate::FastDelegate0<>(this,&CLevel::script_gc)); else script_gc () ; } //----------------------------------------------------- if (pStatGraphR) { static float fRPC_Mult = 10.0f; static float fRPS_Mult = 1.0f; pStatGraphR->AppendItem(float(m_dwRPC)*fRPC_Mult, 0xffff0000, 1); pStatGraphR->AppendItem(float(m_dwRPS)*fRPS_Mult, 0xff00ff00, 0); }; }
void CLevel::OnAlifeSimulatorLoaded() { MapManager().ResetStorage(); GameTaskManager().ResetStorage(); }
void CActor::shedule_Update (u32 DT) { setSVU(OnServer()); //установить режим показа HUD для текущего активного слота CHudItem* pHudItem = smart_cast<CHudItem*>(inventory().ActiveItem()); if(pHudItem && !pHudItem->object().getDestroy()) pHudItem->SetHUDmode(HUDview()); //обновление инвентаря UpdateInventoryOwner (DT); if (GameID() == GAME_SINGLE) GameTaskManager().UpdateTasks (); if(m_holder || !getEnabled() || !Ready()) { m_sDefaultObjAction = NULL; inherited::shedule_Update (DT); /* if (OnServer()) { Check_Weapon_ShowHideState(); }; */ return; } // clamp (DT,0u,100u); float dt = float(DT)/1000.f; // Check controls, create accel, prelimitary setup "mstate_real" //----------- for E3 ----------------------------- // if (Local() && (OnClient() || Level().CurrentEntity()==this)) if (Level().CurrentControlEntity() == this && (!Level().IsDemoPlay() || Level().IsServerDemo())) //------------------------------------------------ { g_cl_CheckControls (mstate_wishful,NET_SavedAccel,NET_Jump,dt); { /* if (mstate_real & mcJump) { NET_Packet P; u_EventGen(P, GE_ACTOR_JUMPING, ID()); P.w_sdir(NET_SavedAccel); P.w_float(NET_Jump); u_EventSend(P); } */ } g_cl_Orientate (mstate_real,dt); g_Orientate (mstate_real,dt); g_Physics (NET_SavedAccel,NET_Jump,dt); g_cl_ValidateMState (dt,mstate_wishful); g_SetAnimation (mstate_real); // Check for game-contacts Fvector C; float R; //m_PhysicMovementControl->GetBoundingSphere (C,R); Center(C); R=Radius(); feel_touch_update (C,R); // Dropping if (b_DropActivated) { f_DropPower += dt*0.1f; clamp (f_DropPower,0.f,1.f); } else { f_DropPower = 0.f; } if (!Level().IsDemoPlay()) { //----------------------------------------------------- mstate_wishful &=~mcAccel; mstate_wishful &=~mcLStrafe; mstate_wishful &=~mcRStrafe; mstate_wishful &=~mcLLookout; mstate_wishful &=~mcRLookout; mstate_wishful &=~mcFwd; mstate_wishful &=~mcBack; extern bool g_bAutoClearCrouch; if (g_bAutoClearCrouch) mstate_wishful &=~mcCrouch; //----------------------------------------------------- } } else { make_Interpolation(); if (NET.size()) { // NET_SavedAccel = NET_Last.p_accel; // mstate_real = mstate_wishful = NET_Last.mstate; g_sv_Orientate (mstate_real,dt ); g_Orientate (mstate_real,dt ); g_Physics (NET_SavedAccel,NET_Jump,dt ); if (!m_bInInterpolation) g_cl_ValidateMState (dt,mstate_wishful); g_SetAnimation (mstate_real); if (NET_Last.mstate & mcCrouch) { if (isActorAccelerated(mstate_real, IsZoomAimingMode())) character_physics_support()->movement()->ActivateBox(1, true); else character_physics_support()->movement()->ActivateBox(2, true); } else character_physics_support()->movement()->ActivateBox(0, true); } mstate_old = mstate_real; } if (this == Level().CurrentViewEntity()) { UpdateMotionIcon (mstate_real); }; NET_Jump = 0; inherited::shedule_Update (DT); //эффектор включаемый при ходьбе if (!pCamBobbing) { pCamBobbing = xr_new<CEffectorBobbing> (); Cameras().AddCamEffector (pCamBobbing); } pCamBobbing->SetState (mstate_real, conditions().IsLimping(), IsZoomAimingMode()); //звук тяжелого дыхания при уталости и хромании if(this==Level().CurrentControlEntity() && !g_pGamePersistent->bDedicatedServer ) { if(conditions().IsLimping() && g_Alive()){ if(!m_HeavyBreathSnd._feedback()){ m_HeavyBreathSnd.play_at_pos(this, Fvector().set(0,ACTOR_HEIGHT,0), sm_Looped | sm_2D); }else{ m_HeavyBreathSnd.set_position(Fvector().set(0,ACTOR_HEIGHT,0)); } }else if(m_HeavyBreathSnd._feedback()){ m_HeavyBreathSnd.stop (); } float bs = conditions().BleedingSpeed(); if(bs>0.6f) { Fvector snd_pos; snd_pos.set(0,ACTOR_HEIGHT,0); if(!m_BloodSnd._feedback()) m_BloodSnd.play_at_pos(this, snd_pos, sm_Looped | sm_2D); else m_BloodSnd.set_position(snd_pos); float v = bs+0.25f; m_BloodSnd.set_volume (v); }else{ if(m_BloodSnd._feedback()) m_BloodSnd.stop(); } } //если в режиме HUD, то сама модель актера не рисуется if(!character_physics_support()->IsRemoved()) setVisible (!HUDview ()); //что актер видит перед собой collide::rq_result& RQ = HUD().GetCurrentRayQuery(); if(!input_external_handler_installed() && RQ.O && RQ.range<inventory().GetTakeDist()) { m_pObjectWeLookingAt = smart_cast<CGameObject*>(RQ.O); CGameObject *game_object = smart_cast<CGameObject*>(RQ.O); m_pUsableObject = smart_cast<CUsableScriptObject*>(game_object); m_pInvBoxWeLookingAt = smart_cast<CInventoryBox*>(game_object); inventory().m_pTarget = smart_cast<PIItem>(game_object); m_pPersonWeLookingAt = smart_cast<CInventoryOwner*>(game_object); m_pVehicleWeLookingAt = smart_cast<CHolderCustom*>(game_object); CEntityAlive* pEntityAlive = smart_cast<CEntityAlive*>(game_object); if (GameID() == GAME_SINGLE ) { if (m_pUsableObject && m_pUsableObject->tip_text()) { m_sDefaultObjAction = CStringTable().translate( m_pUsableObject->tip_text() ); } else { if (m_pPersonWeLookingAt && pEntityAlive->g_Alive()) m_sDefaultObjAction = m_sCharacterUseAction; else if (pEntityAlive && !pEntityAlive->g_Alive()) { bool b_allow_drag = !!pSettings->line_exist("ph_capture_visuals",pEntityAlive->cNameVisual()); if(b_allow_drag) m_sDefaultObjAction = m_sDeadCharacterUseOrDragAction; else m_sDefaultObjAction = m_sDeadCharacterUseAction; }else if (m_pVehicleWeLookingAt) m_sDefaultObjAction = m_sCarCharacterUseAction; else if (inventory().m_pTarget && inventory().m_pTarget->CanTake() ) m_sDefaultObjAction = m_sInventoryItemUseAction; //. else if (m_pInvBoxWeLookingAt) //. m_sDefaultObjAction = m_sInventoryBoxUseAction; else m_sDefaultObjAction = NULL; } } } else { inventory().m_pTarget = NULL; m_pPersonWeLookingAt = NULL; m_sDefaultObjAction = NULL; m_pUsableObject = NULL; m_pObjectWeLookingAt = NULL; m_pVehicleWeLookingAt = NULL; m_pInvBoxWeLookingAt = NULL; } // UpdateSleep (); //для свойст артефактов, находящихся на поясе UpdateArtefactsOnBelt (); m_pPhysics_support->in_shedule_Update (DT); Check_for_AutoPickUp (); };