Skip to content

Commit 52d4f0c

Browse files
committed
Add support for unverified player count
Your server implementation must encode the ping status as [0x728D, player count as uint16_t, 0xFFFF]
1 parent 4e18928 commit 52d4f0c

File tree

8 files changed

+20
-6
lines changed

8 files changed

+20
-6
lines changed

Client/core/CQueryReceiver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ SQueryInfo CQueryReceiver::GetServerResponse()
183183

184184
// Recover server ping status if present
185185
const SString strPingStatus = strBuildNumber.Right(strBuildNumber.length() - strlen(strBuildNumber) - 1);
186-
CCore::GetSingleton().GetNetwork()->UpdatePingStatus(*strPingStatus, info.players);
186+
CCore::GetSingleton().GetNetwork()->UpdatePingStatus(*strPingStatus, info.players, info.isStatusVerified);
187187

188188
// Recover server http port if present
189189
const SString strNetRoute = strPingStatus.Right(strPingStatus.length() - strlen(strPingStatus) - 1);

Client/core/CQueryReceiver.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct SQueryInfo
1616
{
1717
containingInfo = false;
1818
port = 0;
19+
isStatusVerified = true;
1920
isPassworded = false;
2021
serials = false;
2122
players = 0;
@@ -33,6 +34,7 @@ struct SQueryInfo
3334
SString gameType;
3435
SString mapName;
3536
SString versionText;
37+
bool isStatusVerified;
3638
bool isPassworded;
3739
bool serials;
3840
ushort players;

Client/core/ServerBrowser/CServerBrowser.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,8 @@ void CServerBrowser::AddServerToList(CServerListItem* pServer, const ServerBrows
10811081
const SString strVersion = !bIncludeOtherVersions ? "" : pServer->strVersion;
10821082
const SString strVersionSortKey = pServer->strVersionSortKey + pServer->strTieBreakSortKey;
10831083

1084-
const SString strPlayers = pServer->nMaxPlayers == 0 ? "" : SString("%d / %d", pServer->nPlayers, pServer->nMaxPlayers);
1084+
const SString strVerified = pServer->isStatusVerified ? "" : "*";
1085+
const SString strPlayers = pServer->nMaxPlayers == 0 ? "" : SString("%d / %d %s", pServer->nPlayers, pServer->nMaxPlayers, *strVerified);
10851086
const SString strPlayersSortKey = SString("%04d-", pServer->nMaxPlayers ? pServer->nPlayers + 1 : 0) + pServer->strTieBreakSortKey;
10861087

10871088
const SString strPing = pServer->nPing == 9999 ? "" : SString("%d", pServer->nPing);
@@ -1125,6 +1126,12 @@ void CServerBrowser::AddServerToList(CServerListItem* pServer, const ServerBrows
11251126
m_pServerList[Type]->SetItemColor(iIndex, m_hPing[Type], color.R, color.G, color.B, color.A);
11261127
m_pServerList[Type]->SetItemColor(iIndex, m_hGame[Type], color.R, color.G, color.B, color.A);
11271128

1129+
if (!pServer->isStatusVerified)
1130+
{
1131+
SColor orange = SColorRGBA(230, 200, 180, color.A);
1132+
m_pServerList[Type]->SetItemColor(iIndex, m_hPlayers[Type], orange.R, orange.G, orange.B, orange.A);
1133+
}
1134+
11281135
// If the index was modified from the original, then update all indexes because it means there was some sort
11291136
if (pServer->iRowIndex != iIndex)
11301137
UpdateRowIndexMembers(Type);

Client/core/ServerBrowser/CServerInfo.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,13 +469,15 @@ void CServerInfo::Connect()
469469

470470
void CServerInfo::ResetServerGUI(CServerListItem* pServer)
471471
{
472+
const SString strVerified = pServer->isStatusVerified ? "" : "*";
473+
472474
// Set our GUI elements to display the server information
473475
m_pServerNameLabel->SetText(pServer->strName.c_str());
474476
m_pServerAddressLabel->SetText(pServer->strEndpoint.c_str());
475477
m_pGamemodeLabel->SetText(pServer->strGameMode.c_str());
476478
m_pMapLabel->SetText(pServer->strMap.c_str());
477-
m_pPlayersLabel->SetText(SString("%i/%i", pServer->nPlayers, pServer->nMaxPlayers).c_str());
478-
479+
m_pPlayersLabel->SetText(SString("%d / %d %s", pServer->nPlayers, pServer->nMaxPlayers, *strVerified).c_str());
480+
479481
m_pPasswordedLabel->SetText(pServer->bPassworded ? _("Yes") : _("No"));
480482
m_pLatencyLabel->SetText(SString("%i", pServer->nPing));
481483

Client/core/ServerBrowser/CServerList.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ bool CServerListItem::ParseQuery()
514514
if ((uiMasterServerSaysRestrictions & RESTRICTION_PLAYER_LIST) == false)
515515
vecPlayers = info.playersPool;
516516

517+
isStatusVerified = info.isStatusVerified;
517518
bScanned = true;
518519

519520
PostChange();

Client/core/ServerBrowser/CServerList.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class CServerListItem
139139
bScanned = false;
140140
bSkipped = false;
141141
bSerials = false;
142+
isStatusVerified = true;
142143
bPassworded = false;
143144
bKeepFlag = false;
144145
iRowIndex = -1;
@@ -182,6 +183,7 @@ class CServerListItem
182183
unsigned short nPlayers; // Current players
183184
unsigned short nMaxPlayers; // Maximum players
184185
unsigned short nPing; // Ping time
186+
bool isStatusVerified; // Ping status verified
185187
bool bPassworded; // Password protected
186188
bool bSerials; // Serial verification on
187189
bool bScanned;

Client/sdk/net/CNet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class CNet
115115

116116
virtual const char* GetNextBuffer() = 0;
117117
virtual const char* GetDiagnosticStatus() = 0;
118-
virtual void UpdatePingStatus(const char* szStatus, ushort& usDataRef) = 0;
118+
virtual void UpdatePingStatus(const char* szStatus, ushort& usDataRef, bool& isVerified) = 0;
119119

120120
virtual bool VerifySignature(const char* pData, unsigned long ulSize) = 0;
121121

Shared/sdk/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108

109109
#define _ASE_VERSION QUOTE_DEFINE(MTASA_VERSION_MAJOR) "." QUOTE_DEFINE(MTASA_VERSION_MINOR)
110110
#define _NETCODE_VERSION_BRANCH_ID 0x4 // Use 0x1 - 0xF to indicate an incompatible branch is being used (0x0 is reserved, 0x4 is trunk)
111-
#define _CLIENT_NET_MODULE_VERSION 0x0AE // (0x000 - 0xfff) Lvl9 wizards only
111+
#define _CLIENT_NET_MODULE_VERSION 0x0AF // (0x000 - 0xfff) Lvl9 wizards only
112112
#define _SERVER_NET_MODULE_VERSION 0x0AB // (0x000 - 0xfff) Lvl9 wizards only
113113
#define _NETCODE_VERSION 0x1DA // (0x000 - 0xfff) Increment when net messages change (pre-release)
114114

0 commit comments

Comments
 (0)