@@ -296,14 +296,24 @@ void CClient::Rcon(const char *pCmd)
296296
297297float CClient::GotRconCommandsPercentage () const
298298{
299- if (m_ExpectedRconCommands < 1 )
299+ if (m_ExpectedRconCommands <= 0 )
300300 return -1 .0f ;
301301 if (m_GotRconCommands > m_ExpectedRconCommands)
302302 return -1 .0f ;
303303
304304 return (float )m_GotRconCommands / (float )m_ExpectedRconCommands;
305305}
306306
307+ float CClient::GotMaplistPercentage () const
308+ {
309+ if (m_ExpectedMaplistEntries <= 0 )
310+ return -1 .0f ;
311+ if (m_vMaplistEntries.size () > (size_t )m_ExpectedMaplistEntries)
312+ return -1 .0f ;
313+
314+ return (float )m_vMaplistEntries.size () / (float )m_ExpectedMaplistEntries;
315+ }
316+
307317bool CClient::ConnectionProblems () const
308318{
309319 return m_aNetClient[g_Config.m_ClDummy ].GotProblems (MaxLatencyTicks () * time_freq () / GameTickSpeed ()) != 0 ;
@@ -667,6 +677,8 @@ void CClient::DisconnectWithReason(const char *pReason)
667677 m_ExpectedRconCommands = -1 ;
668678 m_GotRconCommands = 0 ;
669679 m_pConsole->DeregisterTempAll ();
680+ m_ExpectedMaplistEntries = -1 ;
681+ m_vMaplistEntries.clear ();
670682 m_aNetClient[CONN_MAIN].Disconnect (pReason);
671683 SetState (IClient::STATE_OFFLINE);
672684 m_pMap->Unload ();
@@ -1846,6 +1858,8 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
18461858 {
18471859 m_pConsole->DeregisterTempAll ();
18481860 m_ExpectedRconCommands = -1 ;
1861+ m_vMaplistEntries.clear ();
1862+ m_ExpectedMaplistEntries = -1 ;
18491863 }
18501864 }
18511865 }
@@ -2214,8 +2228,8 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
22142228 }
22152229 else if (Conn == CONN_MAIN && (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_CMD_GROUP_START)
22162230 {
2217- int ExpectedRconCommands = Unpacker.GetInt ();
2218- if (Unpacker.Error ())
2231+ const int ExpectedRconCommands = Unpacker.GetInt ();
2232+ if (Unpacker.Error () || ExpectedRconCommands < 0 )
22192233 return ;
22202234
22212235 m_ExpectedRconCommands = ExpectedRconCommands;
@@ -2225,6 +2239,34 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
22252239 {
22262240 m_ExpectedRconCommands = -1 ;
22272241 }
2242+ else if (Conn == CONN_MAIN && (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_MAPLIST_ADD)
2243+ {
2244+ while (true )
2245+ {
2246+ const char *pMapName = Unpacker.GetString (CUnpacker::SANITIZE_CC | CUnpacker::SKIP_START_WHITESPACES);
2247+ if (Unpacker.Error ())
2248+ {
2249+ return ;
2250+ }
2251+ if (pMapName[0 ] != ' \0 ' )
2252+ {
2253+ m_vMaplistEntries.emplace_back (pMapName);
2254+ }
2255+ }
2256+ }
2257+ else if (Conn == CONN_MAIN && (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_MAPLIST_GROUP_START)
2258+ {
2259+ const int ExpectedMaplistEntries = Unpacker.GetInt ();
2260+ if (Unpacker.Error () || ExpectedMaplistEntries < 0 )
2261+ return ;
2262+
2263+ m_vMaplistEntries.clear ();
2264+ m_ExpectedMaplistEntries = ExpectedMaplistEntries;
2265+ }
2266+ else if (Conn == CONN_MAIN && (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_MAPLIST_GROUP_END)
2267+ {
2268+ m_ExpectedMaplistEntries = -1 ;
2269+ }
22282270 }
22292271 else if ((pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 )
22302272 {
0 commit comments