Browse Source

Add latency data to ZT public game descriptions

pull/8278/head
staphen 4 months ago committed by Anders Jenbo
parent
commit
3247b00a64
  1. 5
      Source/DiabloUI/multi/selgame.cpp
  2. 6
      Source/dvlnet/base_protocol.h
  3. 2
      Source/multi.h

5
Source/DiabloUI/multi/selgame.cpp

@ -288,6 +288,11 @@ void selgame_GameSelection_Focus(size_t value)
infoString.append(playerName); infoString.append(playerName);
infoString += ' '; infoString += ' ';
} }
infoString += '\n';
if (gameInfo.peerIsRelayed.value_or(false))
infoString.append(fmt::format(fmt::runtime(_("Latency: {:d} ms (RELAYED)")), gameInfo.latency.value_or(0)));
else
infoString.append(fmt::format(fmt::runtime(_("Latency: {:d} ms")), gameInfo.latency.value_or(0)));
} else { } else {
infoString.append(GetErrorMessageIncompatibility(gameInfo.gameData)); infoString.append(GetErrorMessageIncompatibility(gameInfo.gameData));
} }

6
Source/dvlnet/base_protocol.h

@ -551,8 +551,10 @@ std::vector<GameInfo> base_protocol<P>::get_gamelist()
std::vector<GameInfo> ret; std::vector<GameInfo> ret;
ret.reserve(game_list.size()); ret.reserve(game_list.size());
for (const auto &[name, gameInfo] : game_list) { for (const auto &[name, gameInfo] : game_list) {
const auto &[gameData, players, _] = gameInfo; const auto &[gameData, players, endpoint] = gameInfo;
ret.push_back(GameInfo { name, gameData, players }); std::optional<int> latency = proto.get_latency_to(endpoint);
std::optional<bool> isRelayed = proto.is_peer_relayed(endpoint);
ret.push_back(GameInfo { name, gameData, players, latency, isRelayed });
} }
c_sort(ret, [](const GameInfo &a, const GameInfo &b) { return a.name < b.name; }); c_sort(ret, [](const GameInfo &a, const GameInfo &b) { return a.name < b.name; });
return ret; return ret;

2
Source/multi.h

@ -45,6 +45,8 @@ struct GameInfo {
std::string name; std::string name;
GameData gameData; GameData gameData;
std::vector<std::string> players; std::vector<std::string> players;
std::optional<int> latency;
std::optional<bool> peerIsRelayed;
}; };
extern bool gbSomebodyWonGameKludge; extern bool gbSomebodyWonGameKludge;

Loading…
Cancel
Save