Skip to content

Commit fa74ece

Browse files
committed
Server list now shows host region, expected latency.
1 parent bae4229 commit fa74ece

4 files changed

Lines changed: 40 additions & 11 deletions

File tree

GeneralsMD/Code/GameEngine/Include/GameNetwork/GeneralsOnline/OnlineServices_LobbyInterface.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ struct LobbyEntry
7171
std::string password;
7272

7373
std::vector<LobbyMemberEntry> members;
74+
75+
std::string region;
76+
77+
int latency;
7478
};
7579

7680
enum class EJoinLobbyResult

GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ enum {
7676
COLUMN_LADDER,
7777
COLUMN_NUMPLAYERS,
7878
COLUMN_PASSWORD,
79-
COLUMN_PING,
79+
COLUMN_OBSERVER,
8080
COLUMN_USE_STATS,
81-
COLUMN_OBSERVER,
81+
COLUMN_PING
8282
};
8383
#else
8484
enum {
@@ -336,6 +336,14 @@ static void gameTooltip(GameWindow* window,
336336
UnicodeString gameName;
337337
gameName.format(L"%s", from_utf8(lobbyEntry.name).c_str());
338338
tooltip.format(TheGameText->fetch("TOOLTIP:GameInfoGameName"), gameName.str());
339+
340+
UnicodeString region;
341+
region.format(L"\n\nRegion: %s", from_utf8(lobbyEntry.region).c_str());
342+
tooltip.concat(region);
343+
344+
UnicodeString latency;
345+
latency.format(L"\nLatency: %d (%d frames)\n", lobbyEntry.latency, ConvertMSLatencyToGenToolFrames(lobbyEntry.latency));
346+
tooltip.concat(latency);
339347
#else
340348
tooltip.format(TheGameText->fetch("TOOLTIP:GameInfoGameName"), room->getGameName().str());
341349
#endif
@@ -663,8 +671,7 @@ static Int insertGame(GameWindow* win, LobbyEntry& lobbyInfo, Bool showMap)
663671
bool bAllowSpectators = lobbyInfo.allow_observers;
664672
bool bTrackStats = lobbyInfo.track_stats;
665673

666-
// TODO_NGMP
667-
int latency = 5;
674+
int latency = lobbyInfo.latency;
668675

669676
// TODO_NGMP: Asian text
670677
/*
@@ -799,11 +806,11 @@ static Int insertGame(GameWindow* win, LobbyEntry& lobbyInfo, Bool showMap)
799806
}
800807
// CLH picking an arbitrary number for our ping display
801808
// TODO_NGMP: Better values for this
802-
if (ping < 30)
809+
if (ping < 250)
803810
{
804811
GadgetListBoxAddEntryImage(win, pingImages[0], index, COLUMN_PING, width, height);
805812
}
806-
else if (ping < 70)
813+
else if (ping < 500)
807814
{
808815
GadgetListBoxAddEntryImage(win, pingImages[1], index, COLUMN_PING, width, height);
809816
}

GeneralsMD/Code/GameEngine/Source/GameNetwork/GeneralsOnline/OnlineServices_Init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ void NGMP_OnlineServicesManager::InitSentry()
881881

882882
sentry_options_set_dsn(options, "https://61750bebd112d279bcc286d617819269@o4509316925554688.ingest.us.sentry.io/4509316927586304");
883883
sentry_options_set_database_path(options, strDumpPath.c_str());
884-
sentry_options_set_release(options, "generalsonline-client@101525_QFE9");
884+
sentry_options_set_release(options, "generalsonline-client@110725");
885885

886886

887887
#if _DEBUG

GeneralsMD/Code/GameEngine/Source/GameNetwork/GeneralsOnline/OnlineServices_LobbyInterface.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,16 @@ void NGMP_OnlineServices_LobbyInterface::SearchForLobbies(std::function<void()>
462462
std::map<std::string, std::string> mapHeaders;
463463

464464
NGMP_OnlineServicesManager::GetInstance()->GetHTTPManager()->SendGETRequest(strURI.c_str(), EIPProtocolVersion::DONT_CARE, mapHeaders, [=](bool bSuccess, int statusCode, std::string strBody, HTTPRequest* pReq)
465-
{
466-
// TODO_NGMP: Error handling
467-
try
468465
{
469-
nlohmann::json jsonObject = nlohmann::json::parse(strBody);
466+
try
467+
{
468+
nlohmann::json jsonObject = nlohmann::json::parse(strBody);
469+
470+
std::vector<int> vecLatencies;
470471

472+
jsonObject["latencies"].get_to(vecLatencies);
473+
474+
int latencyIndex = 0;
471475
for (const auto& lobbyEntryIter : jsonObject["lobbies"])
472476
{
473477
LobbyEntry lobbyEntry;
@@ -490,6 +494,19 @@ void NGMP_OnlineServices_LobbyInterface::SearchForLobbies(std::function<void()>
490494
lobbyEntryIter["IniCRC"].get_to(lobbyEntry.ini_crc);
491495
lobbyEntryIter["MatchID"].get_to(lobbyEntry.match_id);
492496
lobbyEntryIter["LobbyType"].get_to(lobbyEntry.lobby_type);
497+
lobbyEntryIter["Region"].get_to(lobbyEntry.region);
498+
499+
// attach latency
500+
if (latencyIndex < vecLatencies.size())
501+
{
502+
lobbyEntry.latency = vecLatencies[latencyIndex];
503+
}
504+
else
505+
{
506+
// dummy value
507+
lobbyEntry.latency = 9001;
508+
}
509+
++latencyIndex;
493510

494511
// correct map path
495512
if (lobbyEntry.map_official)
@@ -722,6 +739,7 @@ void NGMP_OnlineServices_LobbyInterface::UpdateRoomDataCache(std::function<void(
722739
lobbyEntryIter["IniCRC"].get_to(lobbyEntry.ini_crc);
723740
lobbyEntryIter["MatchID"].get_to(lobbyEntry.match_id);
724741
lobbyEntryIter["LobbyType"].get_to(lobbyEntry.lobby_type);
742+
lobbyEntryIter["Region"].get_to(lobbyEntry.region);
725743

726744
// store, we'll need it later and lobby obj gets destroyed on leave
727745
m_CurrentMatchID = lobbyEntry.match_id;

0 commit comments

Comments
 (0)