summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorGravatar FearlessTobi2021-12-25 20:27:52 +0100
committerGravatar FearlessTobi2022-07-25 21:59:28 +0200
commit705f7db84dd85555a6aef1e136cf251725cef293 (patch)
treee110c6482a11d711d18515afce4fc50adcee76e7 /src/network
parentnetwork: Add initial files and enet dependency (diff)
downloadyuzu-705f7db84dd85555a6aef1e136cf251725cef293.tar.gz
yuzu-705f7db84dd85555a6aef1e136cf251725cef293.tar.xz
yuzu-705f7db84dd85555a6aef1e136cf251725cef293.zip
yuzu: Add ui files for multiplayer rooms
Diffstat (limited to 'src/network')
-rw-r--r--src/network/room.cpp8
-rw-r--r--src/network/room.h4
-rw-r--r--src/network/room_member.cpp25
-rw-r--r--src/network/verify_user.h2
4 files changed, 20 insertions, 19 deletions
diff --git a/src/network/room.cpp b/src/network/room.cpp
index cd0c0ebc4..528867146 100644
--- a/src/network/room.cpp
+++ b/src/network/room.cpp
@@ -251,7 +251,7 @@ public:
251void Room::RoomImpl::ServerLoop() { 251void Room::RoomImpl::ServerLoop() {
252 while (state != State::Closed) { 252 while (state != State::Closed) {
253 ENetEvent event; 253 ENetEvent event;
254 if (enet_host_service(server, &event, 50) > 0) { 254 if (enet_host_service(server, &event, 16) > 0) {
255 switch (event.type) { 255 switch (event.type) {
256 case ENET_EVENT_TYPE_RECEIVE: 256 case ENET_EVENT_TYPE_RECEIVE:
257 switch (event.packet->data[0]) { 257 switch (event.packet->data[0]) {
@@ -599,7 +599,7 @@ bool Room::RoomImpl::HasModPermission(const ENetPeer* client) const {
599 if (sending_member == members.end()) { 599 if (sending_member == members.end()) {
600 return false; 600 return false;
601 } 601 }
602 if (room_information.enable_citra_mods && 602 if (room_information.enable_yuzu_mods &&
603 sending_member->user_data.moderator) { // Community moderator 603 sending_member->user_data.moderator) { // Community moderator
604 604
605 return true; 605 return true;
@@ -1014,7 +1014,7 @@ bool Room::Create(const std::string& name, const std::string& description,
1014 const u32 max_connections, const std::string& host_username, 1014 const u32 max_connections, const std::string& host_username,
1015 const std::string& preferred_game, u64 preferred_game_id, 1015 const std::string& preferred_game, u64 preferred_game_id,
1016 std::unique_ptr<VerifyUser::Backend> verify_backend, 1016 std::unique_ptr<VerifyUser::Backend> verify_backend,
1017 const Room::BanList& ban_list, bool enable_citra_mods) { 1017 const Room::BanList& ban_list, bool enable_yuzu_mods) {
1018 ENetAddress address; 1018 ENetAddress address;
1019 address.host = ENET_HOST_ANY; 1019 address.host = ENET_HOST_ANY;
1020 if (!server_address.empty()) { 1020 if (!server_address.empty()) {
@@ -1037,7 +1037,7 @@ bool Room::Create(const std::string& name, const std::string& description,
1037 room_impl->room_information.preferred_game = preferred_game; 1037 room_impl->room_information.preferred_game = preferred_game;
1038 room_impl->room_information.preferred_game_id = preferred_game_id; 1038 room_impl->room_information.preferred_game_id = preferred_game_id;
1039 room_impl->room_information.host_username = host_username; 1039 room_impl->room_information.host_username = host_username;
1040 room_impl->room_information.enable_citra_mods = enable_citra_mods; 1040 room_impl->room_information.enable_yuzu_mods = enable_yuzu_mods;
1041 room_impl->password = password; 1041 room_impl->password = password;
1042 room_impl->verify_backend = std::move(verify_backend); 1042 room_impl->verify_backend = std::move(verify_backend);
1043 room_impl->username_ban_list = ban_list.first; 1043 room_impl->username_ban_list = ban_list.first;
diff --git a/src/network/room.h b/src/network/room.h
index a67984837..5d4371c16 100644
--- a/src/network/room.h
+++ b/src/network/room.h
@@ -32,7 +32,7 @@ struct RoomInformation {
32 std::string preferred_game; ///< Game to advertise that you want to play 32 std::string preferred_game; ///< Game to advertise that you want to play
33 u64 preferred_game_id; ///< Title ID for the advertised game 33 u64 preferred_game_id; ///< Title ID for the advertised game
34 std::string host_username; ///< Forum username of the host 34 std::string host_username; ///< Forum username of the host
35 bool enable_citra_mods; ///< Allow Citra Moderators to moderate on this room 35 bool enable_yuzu_mods; ///< Allow yuzu Moderators to moderate on this room
36}; 36};
37 37
38struct GameInfo { 38struct GameInfo {
@@ -148,7 +148,7 @@ public:
148 const std::string& host_username = "", const std::string& preferred_game = "", 148 const std::string& host_username = "", const std::string& preferred_game = "",
149 u64 preferred_game_id = 0, 149 u64 preferred_game_id = 0,
150 std::unique_ptr<VerifyUser::Backend> verify_backend = nullptr, 150 std::unique_ptr<VerifyUser::Backend> verify_backend = nullptr,
151 const BanList& ban_list = {}, bool enable_citra_mods = false); 151 const BanList& ban_list = {}, bool enable_yuzu_mods = false);
152 152
153 /** 153 /**
154 * Sets the verification GUID of the room. 154 * Sets the verification GUID of the room.
diff --git a/src/network/room_member.cpp b/src/network/room_member.cpp
index e43004027..d6ace9b39 100644
--- a/src/network/room_member.cpp
+++ b/src/network/room_member.cpp
@@ -86,7 +86,7 @@ public:
86 * @params password The password for the room 86 * @params password The password for the room
87 * the server to assign one for us. 87 * the server to assign one for us.
88 */ 88 */
89 void SendJoinRequest(const std::string& nickname, const std::string& console_id_hash, 89 void SendJoinRequest(const std::string& nickname_, const std::string& console_id_hash,
90 const MacAddress& preferred_mac = NoPreferredMac, 90 const MacAddress& preferred_mac = NoPreferredMac,
91 const std::string& password = "", const std::string& token = ""); 91 const std::string& password = "", const std::string& token = "");
92 92
@@ -159,7 +159,7 @@ void RoomMember::RoomMemberImpl::MemberLoop() {
159 while (IsConnected()) { 159 while (IsConnected()) {
160 std::lock_guard lock(network_mutex); 160 std::lock_guard lock(network_mutex);
161 ENetEvent event; 161 ENetEvent event;
162 if (enet_host_service(client, &event, 100) > 0) { 162 if (enet_host_service(client, &event, 16) > 0) {
163 switch (event.type) { 163 switch (event.type) {
164 case ENET_EVENT_TYPE_RECEIVE: 164 case ENET_EVENT_TYPE_RECEIVE:
165 switch (event.packet->data[0]) { 165 switch (event.packet->data[0]) {
@@ -251,16 +251,17 @@ void RoomMember::RoomMemberImpl::MemberLoop() {
251 break; 251 break;
252 } 252 }
253 } 253 }
254 std::list<Packet> packets;
254 { 255 {
255 std::lock_guard lock(send_list_mutex); 256 std::lock_guard send_lock(send_list_mutex);
256 for (const auto& packet : send_list) { 257 packets.swap(send_list);
257 ENetPacket* enetPacket = enet_packet_create(packet.GetData(), packet.GetDataSize(), 258 }
258 ENET_PACKET_FLAG_RELIABLE); 259 for (const auto& packet : packets) {
259 enet_peer_send(server, 0, enetPacket); 260 ENetPacket* enetPacket = enet_packet_create(packet.GetData(), packet.GetDataSize(),
260 } 261 ENET_PACKET_FLAG_RELIABLE);
261 enet_host_flush(client); 262 enet_peer_send(server, 0, enetPacket);
262 send_list.clear();
263 } 263 }
264 enet_host_flush(client);
264 } 265 }
265 Disconnect(); 266 Disconnect();
266}; 267};
@@ -274,14 +275,14 @@ void RoomMember::RoomMemberImpl::Send(Packet&& packet) {
274 send_list.push_back(std::move(packet)); 275 send_list.push_back(std::move(packet));
275} 276}
276 277
277void RoomMember::RoomMemberImpl::SendJoinRequest(const std::string& nickname, 278void RoomMember::RoomMemberImpl::SendJoinRequest(const std::string& nickname_,
278 const std::string& console_id_hash, 279 const std::string& console_id_hash,
279 const MacAddress& preferred_mac, 280 const MacAddress& preferred_mac,
280 const std::string& password, 281 const std::string& password,
281 const std::string& token) { 282 const std::string& token) {
282 Packet packet; 283 Packet packet;
283 packet << static_cast<u8>(IdJoinRequest); 284 packet << static_cast<u8>(IdJoinRequest);
284 packet << nickname; 285 packet << nickname_;
285 packet << console_id_hash; 286 packet << console_id_hash;
286 packet << preferred_mac; 287 packet << preferred_mac;
287 packet << network_version; 288 packet << network_version;
diff --git a/src/network/verify_user.h b/src/network/verify_user.h
index 01b9877c8..5c3852d4a 100644
--- a/src/network/verify_user.h
+++ b/src/network/verify_user.h
@@ -13,7 +13,7 @@ struct UserData {
13 std::string username; 13 std::string username;
14 std::string display_name; 14 std::string display_name;
15 std::string avatar_url; 15 std::string avatar_url;
16 bool moderator = false; ///< Whether the user is a Citra Moderator. 16 bool moderator = false; ///< Whether the user is a yuzu Moderator.
17}; 17};
18 18
19/** 19/**