From 4b404191cf054ec3206676f1fccc452bc0a0e223 Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Fri, 15 Jul 2022 21:11:09 +0200 Subject: Address second part of review comments --- src/network/room.cpp | 7 ++++--- src/network/room.h | 32 ++++++-------------------------- src/network/room_member.h | 4 ++++ 3 files changed, 14 insertions(+), 29 deletions(-) (limited to 'src/network') diff --git a/src/network/room.cpp b/src/network/room.cpp index b82a75749..fe55d194c 100644 --- a/src/network/room.cpp +++ b/src/network/room.cpp @@ -1066,8 +1066,8 @@ Room::BanList Room::GetBanList() const { return {room_impl->username_ban_list, room_impl->ip_ban_list}; } -std::vector Room::GetRoomMemberList() const { - std::vector member_list; +std::vector Room::GetRoomMemberList() const { + std::vector member_list; std::lock_guard lock(room_impl->member_mutex); for (const auto& member_impl : room_impl->members) { Member member; @@ -1076,7 +1076,8 @@ std::vector Room::GetRoomMemberList() const { member.display_name = member_impl.user_data.display_name; member.avatar_url = member_impl.user_data.avatar_url; member.mac_address = member_impl.mac_address; - member.game_info = member_impl.game_info; + member.game_name = member_impl.game_info.name; + member.game_id = member_impl.game_info.id; member_list.push_back(member); } return member_list; diff --git a/src/network/room.h b/src/network/room.h index df2253bf8..f282a5ac3 100644 --- a/src/network/room.h +++ b/src/network/room.h @@ -8,11 +8,17 @@ #include #include #include +#include "common/announce_multiplayer_room.h" #include "common/common_types.h" #include "network/verify_user.h" namespace Network { +using AnnounceMultiplayerRoom::GameInfo; +using AnnounceMultiplayerRoom::MacAddress; +using AnnounceMultiplayerRoom::Member; +using AnnounceMultiplayerRoom::RoomInformation; + constexpr u32 network_version = 1; ///< The version of this Room and RoomMember constexpr u16 DefaultRoomPort = 24872; @@ -24,23 +30,6 @@ static constexpr u32 MaxConcurrentConnections = 254; constexpr std::size_t NumChannels = 1; // Number of channels used for the connection -struct RoomInformation { - std::string name; ///< Name of the server - std::string description; ///< Server description - u32 member_slots; ///< Maximum number of members in this room - u16 port; ///< The port of this room - std::string preferred_game; ///< Game to advertise that you want to play - u64 preferred_game_id; ///< Title ID for the advertised game - std::string host_username; ///< Forum username of the host - bool enable_yuzu_mods; ///< Allow yuzu Moderators to moderate on this room -}; - -struct GameInfo { - std::string name{""}; - u64 id{0}; -}; - -using MacAddress = std::array; /// A special MAC address that tells the room we're joining to assign us a MAC address /// automatically. constexpr MacAddress NoPreferredMac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; @@ -95,15 +84,6 @@ public: Closed, ///< The room is not opened and can not accept connections. }; - struct Member { - std::string nickname; ///< The nickname of the member. - std::string username; ///< The web services username of the member. Can be empty. - std::string display_name; ///< The web services display name of the member. Can be empty. - std::string avatar_url; ///< Url to the member's avatar. Can be empty. - GameInfo game_info; ///< The current game of the member - MacAddress mac_address; ///< The assigned mac address of the member. - }; - Room(); ~Room(); diff --git a/src/network/room_member.h b/src/network/room_member.h index ee1c921d4..c835ba863 100644 --- a/src/network/room_member.h +++ b/src/network/room_member.h @@ -9,11 +9,15 @@ #include #include #include +#include "common/announce_multiplayer_room.h" #include "common/common_types.h" #include "network/room.h" namespace Network { +using AnnounceMultiplayerRoom::GameInfo; +using AnnounceMultiplayerRoom::RoomInformation; + /// Information about the received WiFi packets. /// Acts as our own 802.11 header. struct WifiPacket { -- cgit v1.2.3