Skip to content

Commit

Permalink
Fix gametime debug graph when dummy is connected
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Robyt3 committed Nov 26, 2024
1 parent c14874f commit 62ef7ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/engine/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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");
}
}

Expand Down Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion src/engine/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 62ef7ed

Please sign in to comment.