From 62ef7ed711959fc366bd610508573705ae8c98d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Tue, 26 Nov 2024 21:23:43 +0100 Subject: [PATCH] Fix gametime debug graph when dummy is connected Use separate graphs for the main and dummy gametimes to prevent the graph from using an incorrect time scale due to values for both main and dummy connection being added to it. --- src/engine/client/client.cpp | 12 +++++++----- src/engine/client/client.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index d334c0613e4..236331f6d21 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -86,7 +86,7 @@ static const ColorRGBA gs_ClientNetworkErrPrintColor{1.0f, 0.25f, 0.25f, 1.0f}; CClient::CClient() : m_DemoPlayer(&m_SnapshotDelta, true, [&]() { UpdateDemoIntraTimers(); }), m_InputtimeMarginGraph(128), - m_GametimeMarginGraph(128), + m_aGametimeMarginGraphs{128, 128}, m_FpsGraph(4096) { m_StateStartTime = time_get(); @@ -634,7 +634,7 @@ void CClient::Connect(const char *pAddress, const char *pPassword) SetState(IClient::STATE_CONNECTING); m_InputtimeMarginGraph.Init(-150.0f, 150.0f); - m_GametimeMarginGraph.Init(-150.0f, 150.0f); + m_aGametimeMarginGraphs[CONN_MAIN].Init(-150.0f, 150.0f); GenerateTimeoutCodes(aConnectAddrs, NumConnectAddrs); } @@ -753,6 +753,8 @@ void CClient::DummyConnect() m_aNetClient[CONN_DUMMY].Connect7(m_aNetClient[CONN_MAIN].ServerAddress(), 1); else m_aNetClient[CONN_DUMMY].Connect(m_aNetClient[CONN_MAIN].ServerAddress(), 1); + + m_aGametimeMarginGraphs[CONN_DUMMY].Init(-150.0f, 150.0f); } void CClient::DummyDisconnect(const char *pReason) @@ -963,8 +965,8 @@ void CClient::DebugRender() m_FpsGraph.Render(Graphics(), TextRender(), x, sp * 5, w, h, "FPS"); m_InputtimeMarginGraph.Scale(5 * time_freq()); m_InputtimeMarginGraph.Render(Graphics(), TextRender(), x, sp * 6 + h, w, h, "Prediction Margin"); - m_GametimeMarginGraph.Scale(5 * time_freq()); - m_GametimeMarginGraph.Render(Graphics(), TextRender(), x, sp * 7 + h * 2, w, h, "Gametime Margin"); + m_aGametimeMarginGraphs[g_Config.m_ClDummy].Scale(5 * time_freq()); + m_aGametimeMarginGraphs[g_Config.m_ClDummy].Render(Graphics(), TextRender(), x, sp * 7 + h * 2, w, h, "Gametime Margin"); } } @@ -2085,7 +2087,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy) int64_t Now = m_aGameTime[Conn].Get(time_get()); int64_t TickStart = GameTick * time_freq() / GameTickSpeed(); int64_t TimeLeft = (TickStart - Now) * 1000 / time_freq(); - m_aGameTime[Conn].Update(&m_GametimeMarginGraph, (GameTick - 1) * time_freq() / GameTickSpeed(), TimeLeft, CSmoothTime::ADJUSTDIRECTION_DOWN); + m_aGameTime[Conn].Update(&m_aGametimeMarginGraphs[Conn], (GameTick - 1) * time_freq() / GameTickSpeed(), TimeLeft, CSmoothTime::ADJUSTDIRECTION_DOWN); } if(m_aReceivedSnapshots[Conn] > GameTickSpeed() && !m_aCodeRunAfterJoin[Conn]) diff --git a/src/engine/client/client.h b/src/engine/client/client.h index 9ca2699fd76..56e92ac05cf 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -187,7 +187,7 @@ class CClient : public IClient, public CDemoPlayer::IListener // graphs CGraph m_InputtimeMarginGraph; - CGraph m_GametimeMarginGraph; + CGraph m_aGametimeMarginGraphs[NUM_DUMMIES]; CGraph m_FpsGraph; // the game snapshots are modifiable by the game