@@ -28,6 +28,64 @@ const int g_netOverlayHeight = 300;
2828const int g_netOverlaySampleSize = 200 ; // milliseconds per sample frame
2929const int g_netOverlaySampleCount = 150 ;
3030
31+ class RageHashList
32+ {
33+ public:
34+ template <int Size >
35+ RageHashList (const char * (&list)[Size ])
36+ {
37+ for (int i = 0 ; i < Size ; i++)
38+ {
39+ m_lookupList.insert ({ HashRageString (list[i]), list[i] });
40+ }
41+ }
42+
43+ inline std::string LookupHash (uint32_t hash)
44+ {
45+ auto it = m_lookupList.find (hash);
46+
47+ if (it != m_lookupList.end ())
48+ {
49+ return std::string (it->second );
50+ }
51+
52+ return fmt::sprintf (" 0x%08x" , hash);
53+ }
54+
55+ private:
56+ std::map<uint32_t , std::string_view> m_lookupList;
57+ };
58+
59+ static const char * g_knownPackets[]
60+ {
61+ " msgConVars" ,
62+ " msgEnd" ,
63+ " msgEntityCreate" ,
64+ " msgNetGameEvent" ,
65+ " msgObjectIds" ,
66+ " msgPackedAcks" ,
67+ " msgPackedClones" ,
68+ " msgPaymentRequest" ,
69+ " msgRequestObjectIds" ,
70+ " msgResStart" ,
71+ " msgResStop" ,
72+ " msgRoute" ,
73+ " msgRpcEntityCreation" ,
74+ " msgRpcNative" ,
75+ " msgServerCommand" ,
76+ " msgServerEvent" ,
77+ " msgTimeSync" ,
78+ " msgTimeSyncReq" ,
79+ " msgWorldGrid" ,
80+ " msgFrame" ,
81+ " msgIHost" ,
82+ " gameStateAck" ,
83+ " msgNetEvent" ,
84+ " msgServerEvent" ,
85+ };
86+
87+ static RageHashList g_hashes{ g_knownPackets };
88+
3189class NetOverlayMetricSink : public INetMetricSink
3290{
3391public:
@@ -45,9 +103,9 @@ class NetOverlayMetricSink : public INetMetricSink
45103
46104 virtual void OnRouteDelayResult (int msec) override ;
47105
48- virtual void OnIncomingCommand (uint32_t type, size_t size) override ;
106+ virtual void OnIncomingCommand (uint32_t type, size_t size, bool reliable ) override ;
49107
50- virtual void OnOutgoingCommand (uint32_t type, size_t size) override ;
108+ virtual void OnOutgoingCommand (uint32_t type, size_t size, bool reliable ) override ;
51109
52110 virtual void OverrideBandwidthStats (uint32_t in, uint32_t out) override ;
53111
@@ -93,6 +151,10 @@ class NetOverlayMetricSink : public INetMetricSink
93151
94152 std::mutex m_metricMutex;
95153
154+ std::map<uint32_t , bool > m_incomingReliable;
155+
156+ std::map<uint32_t , bool > m_outgoingReliable;
157+
96158 std::map<uint32_t , size_t > m_incomingMetrics;
97159
98160 std::map<uint32_t , size_t > m_outgoingMetrics;
@@ -204,13 +266,16 @@ NetOverlayMetricSink::NetOverlayMetricSink()
204266 static bool showIncoming = true ;
205267 static bool showOutgoing = true ;
206268
207- auto showList = [](const decltype (m_lastIncomingMetrics)& list)
269+ auto showList = [](const decltype (m_lastIncomingMetrics)& list, const decltype (m_incomingReliable)& reliable )
208270 {
209- ImGui::Columns (2 );
271+ ImGui::Columns (3 );
210272
211273 for (auto & entry : list)
212274 {
213- ImGui::Text (" 0x%08x" , entry.first );
275+ ImGui::Text (" %s" , (reliable.find (entry.first )->second ? " R" : " U" ));
276+ ImGui::NextColumn ();
277+
278+ ImGui::Text (" %s" , g_hashes.LookupHash (entry.first ));
214279 ImGui::NextColumn ();
215280
216281 ImGui::Text (" %d B" , entry.second );
@@ -222,12 +287,12 @@ NetOverlayMetricSink::NetOverlayMetricSink()
222287
223288 if (ImGui::CollapsingHeader (" Incoming" , &showIncoming))
224289 {
225- showList (m_lastIncomingMetrics);
290+ showList (m_lastIncomingMetrics, m_incomingReliable );
226291 }
227292
228293 if (ImGui::CollapsingHeader (" Outgoing" , &showOutgoing))
229294 {
230- showList (m_lastOutgoingMetrics);
295+ showList (m_lastOutgoingMetrics, m_outgoingReliable );
231296 }
232297 }
233298
@@ -293,16 +358,18 @@ void NetOverlayMetricSink::OnRouteDelayResult(int msec)
293358 m_inRouteDelayMax = *std::max_element (m_inRouteDelaySamplesArchive, m_inRouteDelaySamplesArchive + _countof (m_inRouteDelaySamplesArchive));
294359}
295360
296- void NetOverlayMetricSink::OnIncomingCommand (uint32_t type, size_t size)
361+ void NetOverlayMetricSink::OnIncomingCommand (uint32_t type, size_t size, bool reliable )
297362{
298363 std::unique_lock<std::mutex> lock (m_metricMutex);
299364 m_incomingMetrics[type] += size;
365+ m_incomingReliable[type] = reliable;
300366}
301367
302- void NetOverlayMetricSink::OnOutgoingCommand (uint32_t type, size_t size)
368+ void NetOverlayMetricSink::OnOutgoingCommand (uint32_t type, size_t size, bool reliable )
303369{
304370 std::unique_lock<std::mutex> lock (m_metricMutex);
305371 m_outgoingMetrics[type] += size;
372+ m_outgoingReliable[type] = reliable;
306373}
307374
308375// log data if enabled
@@ -407,14 +474,16 @@ void NetOverlayMetricSink::DrawGraph()
407474 {
408475 " Routed Messages" ,
409476 " Reliables" ,
410- " Misc"
477+ " Misc" ,
478+ " Overhead"
411479 };
412480
413481 static const ImColor colors[NET_PACKET_SUB_MAX] =
414482 {
415483 GetColorIndex (0 ),
416484 GetColorIndex (1 ),
417- GetColorIndex (2 )
485+ GetColorIndex (2 ),
486+ GetColorIndex (3 )
418487 };
419488
420489 struct DataContext
@@ -426,12 +495,14 @@ void NetOverlayMetricSink::DrawGraph()
426495 auto data0 = DataContext{ m_metrics, NET_PACKET_SUB_ROUTED_MESSAGES };
427496 auto data1 = DataContext{ m_metrics, NET_PACKET_SUB_RELIABLES };
428497 auto data2 = DataContext{ m_metrics, NET_PACKET_SUB_MISC };
498+ auto data3 = DataContext{ m_metrics, NET_PACKET_SUB_OVERHEAD };
429499
430500 const void * datas[NET_PACKET_SUB_MAX] =
431501 {
432502 &data0,
433503 &data1,
434- &data2
504+ &data2,
505+ &data3
435506 };
436507
437508 ImGui::PlotMultiLines (" Net Bw" , NET_PACKET_SUB_MAX, names, colors, [](const void * cxt, int idx) -> float
0 commit comments