summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/common/announce_multiplayer_room.h1
-rw-r--r--src/core/core.cpp9
-rw-r--r--src/network/room.cpp12
-rw-r--r--src/network/room_member.cpp4
-rw-r--r--src/network/room_member.h2
-rw-r--r--src/yuzu/multiplayer/chat_room.cpp21
6 files changed, 38 insertions, 11 deletions
diff --git a/src/common/announce_multiplayer_room.h b/src/common/announce_multiplayer_room.h
index cb004e0eb..4a3100fa4 100644
--- a/src/common/announce_multiplayer_room.h
+++ b/src/common/announce_multiplayer_room.h
@@ -16,6 +16,7 @@ namespace AnnounceMultiplayerRoom {
struct GameInfo {
std::string name{""};
u64 id{0};
+ std::string version{""};
};
struct Member {
diff --git a/src/core/core.cpp b/src/core/core.cpp
index ea32a4a8d..e651ce100 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -319,10 +319,19 @@ struct System::Impl {
if (app_loader->ReadTitle(name) != Loader::ResultStatus::Success) {
LOG_ERROR(Core, "Failed to read title for ROM (Error {})", load_result);
}
+
+ std::string title_version;
+ const FileSys::PatchManager pm(program_id, system.GetFileSystemController(),
+ system.GetContentProvider());
+ const auto metadata = pm.GetControlMetadata();
+ if (metadata.first != nullptr) {
+ title_version = metadata.first->GetVersionString();
+ }
if (auto room_member = room_network.GetRoomMember().lock()) {
Network::GameInfo game_info;
game_info.name = name;
game_info.id = program_id;
+ game_info.version = title_version;
room_member->SendGameInfo(game_info);
}
diff --git a/src/network/room.cpp b/src/network/room.cpp
index 34298f010..8c63b255b 100644
--- a/src/network/room.cpp
+++ b/src/network/room.cpp
@@ -221,7 +221,7 @@ public:
* Extracts the game name from a received ENet packet and broadcasts it.
* @param event The ENet event that was received.
*/
- void HandleGameNamePacket(const ENetEvent* event);
+ void HandleGameInfoPacket(const ENetEvent* event);
/**
* Removes the client from the members list if it was in it and announces the change
@@ -242,7 +242,7 @@ void Room::RoomImpl::ServerLoop() {
HandleJoinRequest(&event);
break;
case IdSetGameInfo:
- HandleGameNamePacket(&event);
+ HandleGameInfoPacket(&event);
break;
case IdProxyPacket:
HandleProxyPacket(&event);
@@ -778,6 +778,7 @@ void Room::RoomImpl::BroadcastRoomInformation() {
packet.Write(member.fake_ip);
packet.Write(member.game_info.name);
packet.Write(member.game_info.id);
+ packet.Write(member.game_info.version);
packet.Write(member.user_data.username);
packet.Write(member.user_data.display_name);
packet.Write(member.user_data.avatar_url);
@@ -817,6 +818,7 @@ void Room::RoomImpl::HandleProxyPacket(const ENetEvent* event) {
in_packet.IgnoreBytes(sizeof(u16)); // Port
in_packet.IgnoreBytes(sizeof(u8)); // Protocol
+
bool broadcast;
in_packet.Read(broadcast); // Broadcast
@@ -909,7 +911,7 @@ void Room::RoomImpl::HandleChatPacket(const ENetEvent* event) {
}
}
-void Room::RoomImpl::HandleGameNamePacket(const ENetEvent* event) {
+void Room::RoomImpl::HandleGameInfoPacket(const ENetEvent* event) {
Packet in_packet;
in_packet.Append(event->packet->data, event->packet->dataLength);
@@ -917,6 +919,7 @@ void Room::RoomImpl::HandleGameNamePacket(const ENetEvent* event) {
GameInfo game_info;
in_packet.Read(game_info.name);
in_packet.Read(game_info.id);
+ in_packet.Read(game_info.version);
{
std::lock_guard lock(member_mutex);
@@ -935,7 +938,8 @@ void Room::RoomImpl::HandleGameNamePacket(const ENetEvent* event) {
if (game_info.name.empty()) {
LOG_INFO(Network, "{} is not playing", display_name);
} else {
- LOG_INFO(Network, "{} is playing {}", display_name, game_info.name);
+ LOG_INFO(Network, "{} is playing {} ({})", display_name, game_info.name,
+ game_info.version);
}
}
}
diff --git a/src/network/room_member.cpp b/src/network/room_member.cpp
index 367bf377f..06818af78 100644
--- a/src/network/room_member.cpp
+++ b/src/network/room_member.cpp
@@ -103,7 +103,7 @@ public:
/**
* Extracts a ProxyPacket from a received ENet packet.
- * @param event The ENet event that was received.
+ * @param event The ENet event that was received.
*/
void HandleProxyPackets(const ENetEvent* event);
@@ -315,6 +315,7 @@ void RoomMember::RoomMemberImpl::HandleRoomInformationPacket(const ENetEvent* ev
packet.Read(member.fake_ip);
packet.Read(member.game_info.name);
packet.Read(member.game_info.id);
+ packet.Read(member.game_info.version);
packet.Read(member.username);
packet.Read(member.display_name);
packet.Read(member.avatar_url);
@@ -622,6 +623,7 @@ void RoomMember::SendGameInfo(const GameInfo& game_info) {
packet.Write(static_cast<u8>(IdSetGameInfo));
packet.Write(game_info.name);
packet.Write(game_info.id);
+ packet.Write(game_info.version);
room_member_impl->Send(std::move(packet));
}
diff --git a/src/network/room_member.h b/src/network/room_member.h
index 4252b7146..f578f7f6a 100644
--- a/src/network/room_member.h
+++ b/src/network/room_member.h
@@ -146,7 +146,7 @@ public:
const std::string& password = "", const std::string& token = "");
/**
- * Sends a WiFi packet to the room.
+ * Sends a Proxy packet to the room.
* @param packet The WiFi packet to send.
*/
void SendProxyPacket(const ProxyPacket& packet);
diff --git a/src/yuzu/multiplayer/chat_room.cpp b/src/yuzu/multiplayer/chat_room.cpp
index 51ece1f21..21582b3d6 100644
--- a/src/yuzu/multiplayer/chat_room.cpp
+++ b/src/yuzu/multiplayer/chat_room.cpp
@@ -122,19 +122,22 @@ public:
static const int UsernameRole = Qt::UserRole + 2;
static const int AvatarUrlRole = Qt::UserRole + 3;
static const int GameNameRole = Qt::UserRole + 4;
+ static const int GameVersionRole = Qt::UserRole + 5;
PlayerListItem() = default;
explicit PlayerListItem(const std::string& nickname, const std::string& username,
- const std::string& avatar_url, const std::string& game_name) {
+ const std::string& avatar_url,
+ const AnnounceMultiplayerRoom::GameInfo& game_info) {
setEditable(false);
setData(QString::fromStdString(nickname), NicknameRole);
setData(QString::fromStdString(username), UsernameRole);
setData(QString::fromStdString(avatar_url), AvatarUrlRole);
- if (game_name.empty()) {
+ if (game_info.name.empty()) {
setData(QObject::tr("Not playing a game"), GameNameRole);
} else {
- setData(QString::fromStdString(game_name), GameNameRole);
+ setData(QString::fromStdString(game_info.name), GameNameRole);
}
+ setData(QString::fromStdString(game_info.version), GameVersionRole);
}
QVariant data(int role) const override {
@@ -149,7 +152,15 @@ public:
} else {
name = QStringLiteral("%1 (%2)").arg(nickname, username);
}
- return QStringLiteral("%1\n %2").arg(name, data(GameNameRole).toString());
+ const QString version = data(GameVersionRole).toString();
+ QString version_string;
+ if (version.isEmpty()) {
+ version_string = QString{};
+ } else {
+ version_string = QStringLiteral("(%1)").arg(version);
+ }
+ return QStringLiteral("%1\n %2 %3")
+ .arg(name, data(GameNameRole).toString(), version_string);
}
};
@@ -366,7 +377,7 @@ void ChatRoom::SetPlayerList(const Network::RoomMember::MemberList& member_list)
if (member.nickname.empty())
continue;
QStandardItem* name_item = new PlayerListItem(member.nickname, member.username,
- member.avatar_url, member.game_info.name);
+ member.avatar_url, member.game_info);
#ifdef ENABLE_WEB_SERVICE
if (!icon_cache.count(member.avatar_url) && !member.avatar_url.empty()) {