MCPcopy Create free account
hub / github.com/ddnet/ddnet / Update

Method Update

src/engine/client/client.cpp:2699–3001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2697}
2698
2699void CClient::Update()
2700{
2701 PumpNetwork();
2702
2703 if(State() == IClient::STATE_DEMOPLAYBACK)
2704 {
2705 if(m_DemoPlayer.IsPlaying())
2706 {
2707#if defined(CONF_VIDEORECORDER)
2708 if(IVideo::Current())
2709 {
2710 IVideo::Current()->NextVideoFrame();
2711 IVideo::Current()->NextAudioFrameTimeline([this](short *pFinalOut, unsigned Frames) {
2712 Sound()->Mix(pFinalOut, Frames);
2713 });
2714 }
2715#endif
2716
2717 m_DemoPlayer.Update();
2718
2719 // update timers
2720 const CDemoPlayer::CPlaybackInfo *pInfo = m_DemoPlayer.Info();
2721 m_aCurGameTick[0] = pInfo->m_Info.m_CurrentTick;
2722 m_aPrevGameTick[0] = pInfo->m_PreviousTick;
2723 m_aGameIntraTick[0] = pInfo->m_IntraTick;
2724 m_aGameTickTime[0] = pInfo->m_TickTime;
2725 }
2726 else
2727 {
2728 // Disconnect when demo playback stopped, either due to playback error
2729 // or because the end of the demo was reached when rendering it.
2730 DisconnectWithReason(m_DemoPlayer.ErrorMessage());
2731 if(m_DemoPlayer.ErrorMessage()[0] != '\0')
2732 {
2733 SWarning Warning(Localize("Error playing demo"), m_DemoPlayer.ErrorMessage());
2734 Warning.m_AutoHide = false;
2735 AddWarning(Warning);
2736 }
2737 }
2738 }
2739 else if(State() == IClient::STATE_ONLINE)
2740 {
2741 if(m_LastDummy != (bool)g_Config.m_ClDummy)
2742 {
2743 // Invalidate references to !m_ClDummy snapshots
2744 GameClient()->InvalidateSnapshot();
2745 GameClient()->OnDummySwap();
2746 }
2747
2748 if(m_aapSnapshots[!g_Config.m_ClDummy][SNAP_CURRENT])
2749 {
2750 // switch dummy snapshot
2751 int64_t Now = m_aGameTime[!g_Config.m_ClDummy].Get(time_get());
2752 while(true)
2753 {
2754 if(!m_aapSnapshots[!g_Config.m_ClDummy][SNAP_CURRENT]->m_pNext)
2755 break;
2756 int64_t TickStart = m_aapSnapshots[!g_Config.m_ClDummy][SNAP_CURRENT]->m_Tick * time_freq() / GameTickSpeed();

Callers 4

ProcessServerPacketMethod · 0.45
PumpNetworkMethod · 0.45
RunMethod · 0.45
UpdateAndSwapMethod · 0.45

Calls 15

LocalizeFunction · 0.85
time_getFunction · 0.85
time_freqFunction · 0.85
absoluteFunction · 0.85
str_formatFunction · 0.85
RandomUuidFunction · 0.85
dbg_msgFunction · 0.85
NextVideoFrameMethod · 0.80
MixMethod · 0.80
InfoMethod · 0.80
InvalidateSnapshotMethod · 0.80

Tested by

no test coverage detected