summaryrefslogtreecommitdiff
path: root/src/web_service/announce_room_json.cpp
diff options
context:
space:
mode:
authorGravatar german772022-07-17 22:53:44 -0500
committerGravatar FearlessTobi2022-07-25 21:59:31 +0200
commit899c8bb33094f43fbd8df9afb4ca84718ebac87e (patch)
tree392a54ac863f67b37bdfb006f739e8e840a9ab16 /src/web_service/announce_room_json.cpp
parentAddress second part of review comments (diff)
downloadyuzu-899c8bb33094f43fbd8df9afb4ca84718ebac87e.tar.gz
yuzu-899c8bb33094f43fbd8df9afb4ca84718ebac87e.tar.xz
yuzu-899c8bb33094f43fbd8df9afb4ca84718ebac87e.zip
common: multiplayer: Use GameInfo type
Diffstat (limited to 'src/web_service/announce_room_json.cpp')
-rw-r--r--src/web_service/announce_room_json.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/web_service/announce_room_json.cpp b/src/web_service/announce_room_json.cpp
index 84220b851..082bebaa9 100644
--- a/src/web_service/announce_room_json.cpp
+++ b/src/web_service/announce_room_json.cpp
@@ -19,14 +19,14 @@ static void to_json(nlohmann::json& json, const Member& member) {
19 if (!member.avatar_url.empty()) { 19 if (!member.avatar_url.empty()) {
20 json["avatarUrl"] = member.avatar_url; 20 json["avatarUrl"] = member.avatar_url;
21 } 21 }
22 json["gameName"] = member.game_name; 22 json["gameName"] = member.game.name;
23 json["gameId"] = member.game_id; 23 json["gameId"] = member.game.id;
24} 24}
25 25
26static void from_json(const nlohmann::json& json, Member& member) { 26static void from_json(const nlohmann::json& json, Member& member) {
27 member.nickname = json.at("nickname").get<std::string>(); 27 member.nickname = json.at("nickname").get<std::string>();
28 member.game_name = json.at("gameName").get<std::string>(); 28 member.game.name = json.at("gameName").get<std::string>();
29 member.game_id = json.at("gameId").get<u64>(); 29 member.game.id = json.at("gameId").get<u64>();
30 try { 30 try {
31 member.username = json.at("username").get<std::string>(); 31 member.username = json.at("username").get<std::string>();
32 member.avatar_url = json.at("avatarUrl").get<std::string>(); 32 member.avatar_url = json.at("avatarUrl").get<std::string>();
@@ -42,8 +42,8 @@ static void to_json(nlohmann::json& json, const Room& room) {
42 if (!room.information.description.empty()) { 42 if (!room.information.description.empty()) {
43 json["description"] = room.information.description; 43 json["description"] = room.information.description;
44 } 44 }
45 json["preferredGameName"] = room.information.preferred_game; 45 json["preferredGameName"] = room.information.preferred_game.name;
46 json["preferredGameId"] = room.information.preferred_game_id; 46 json["preferredGameId"] = room.information.preferred_game.id;
47 json["maxPlayers"] = room.information.member_slots; 47 json["maxPlayers"] = room.information.member_slots;
48 json["netVersion"] = room.net_version; 48 json["netVersion"] = room.net_version;
49 json["hasPassword"] = room.has_password; 49 json["hasPassword"] = room.has_password;
@@ -65,8 +65,8 @@ static void from_json(const nlohmann::json& json, Room& room) {
65 } 65 }
66 room.information.host_username = json.at("owner").get<std::string>(); 66 room.information.host_username = json.at("owner").get<std::string>();
67 room.information.port = json.at("port").get<u16>(); 67 room.information.port = json.at("port").get<u16>();
68 room.information.preferred_game = json.at("preferredGameName").get<std::string>(); 68 room.information.preferred_game.name = json.at("preferredGameName").get<std::string>();
69 room.information.preferred_game_id = json.at("preferredGameId").get<u64>(); 69 room.information.preferred_game.id = json.at("preferredGameId").get<u64>();
70 room.information.member_slots = json.at("maxPlayers").get<u32>(); 70 room.information.member_slots = json.at("maxPlayers").get<u32>();
71 room.net_version = json.at("netVersion").get<u32>(); 71 room.net_version = json.at("netVersion").get<u32>();
72 room.has_password = json.at("hasPassword").get<bool>(); 72 room.has_password = json.at("hasPassword").get<bool>();
@@ -83,8 +83,8 @@ namespace WebService {
83 83
84void RoomJson::SetRoomInformation(const std::string& name, const std::string& description, 84void RoomJson::SetRoomInformation(const std::string& name, const std::string& description,
85 const u16 port, const u32 max_player, const u32 net_version, 85 const u16 port, const u32 max_player, const u32 net_version,
86 const bool has_password, const std::string& preferred_game, 86 const bool has_password,
87 const u64 preferred_game_id) { 87 const AnnounceMultiplayerRoom::GameInfo& preferred_game) {
88 room.information.name = name; 88 room.information.name = name;
89 room.information.description = description; 89 room.information.description = description;
90 room.information.port = port; 90 room.information.port = port;
@@ -92,7 +92,6 @@ void RoomJson::SetRoomInformation(const std::string& name, const std::string& de
92 room.net_version = net_version; 92 room.net_version = net_version;
93 room.has_password = has_password; 93 room.has_password = has_password;
94 room.information.preferred_game = preferred_game; 94 room.information.preferred_game = preferred_game;
95 room.information.preferred_game_id = preferred_game_id;
96} 95}
97void RoomJson::AddPlayer(const AnnounceMultiplayerRoom::Member& member) { 96void RoomJson::AddPlayer(const AnnounceMultiplayerRoom::Member& member) {
98 room.members.push_back(member); 97 room.members.push_back(member);