summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorFearlessTobi <thm.frey@gmail.com>2021-12-25 20:27:52 +0100
committerFearlessTobi <thm.frey@gmail.com>2022-07-25 21:59:28 +0200
commit705f7db84dd85555a6aef1e136cf251725cef293 (patch)
treee110c6482a11d711d18515afce4fc50adcee76e7 /src/network
parentnetwork: Add initial files and enet dependency (diff)
downloadyuzu-705f7db84dd85555a6aef1e136cf251725cef293.tar
yuzu-705f7db84dd85555a6aef1e136cf251725cef293.tar.gz
yuzu-705f7db84dd85555a6aef1e136cf251725cef293.tar.bz2
yuzu-705f7db84dd85555a6aef1e136cf251725cef293.tar.lz
yuzu-705f7db84dd85555a6aef1e136cf251725cef293.tar.xz
yuzu-705f7db84dd85555a6aef1e136cf251725cef293.tar.zst
yuzu-705f7db84dd85555a6aef1e136cf251725cef293.zip
Diffstat (limited to '')
-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:
void Room::RoomImpl::ServerLoop() {
while (state != State::Closed) {
ENetEvent event;
- if (enet_host_service(server, &event, 50) > 0) {
+ if (enet_host_service(server, &event, 16) > 0) {
switch (event.type) {
case ENET_EVENT_TYPE_RECEIVE:
switch (event.packet->data[0]) {
@@ -599,7 +599,7 @@ bool Room::RoomImpl::HasModPermission(const ENetPeer* client) const {
if (sending_member == members.end()) {
return false;
}
- if (room_information.enable_citra_mods &&
+ if (room_information.enable_yuzu_mods &&
sending_member->user_data.moderator) { // Community moderator
return true;
@@ -1014,7 +1014,7 @@ bool Room::Create(const std::string& name, const std::string& description,
const u32 max_connections, const std::string& host_username,
const std::string& preferred_game, u64 preferred_game_id,
std::unique_ptr<VerifyUser::Backend> verify_backend,
- const Room::BanList& ban_list, bool enable_citra_mods) {
+ const Room::BanList& ban_list, bool enable_yuzu_mods) {
ENetAddress address;
address.host = ENET_HOST_ANY;
if (!server_address.empty()) {
@@ -1037,7 +1037,7 @@ bool Room::Create(const std::string& name, const std::string& description,
room_impl->room_information.preferred_game = preferred_game;
room_impl->room_information.preferred_game_id = preferred_game_id;
room_impl->room_information.host_username = host_username;
- room_impl->room_information.enable_citra_mods = enable_citra_mods;
+ room_impl->room_information.enable_yuzu_mods = enable_yuzu_mods;
room_impl->password = password;
room_impl->verify_backend = std::move(verify_backend);
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 {
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_citra_mods; ///< Allow Citra Moderators to moderate on this room
+ bool enable_yuzu_mods; ///< Allow yuzu Moderators to moderate on this room
};
struct GameInfo {
@@ -148,7 +148,7 @@ public:
const std::string& host_username = "", const std::string& preferred_game = "",
u64 preferred_game_id = 0,
std::unique_ptr<VerifyUser::Backend> verify_backend = nullptr,
- const BanList& ban_list = {}, bool enable_citra_mods = false);
+ const BanList& ban_list = {}, bool enable_yuzu_mods = false);
/**
* 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:
* @params password The password for the room
* the server to assign one for us.
*/
- void SendJoinRequest(const std::string& nickname, const std::string& console_id_hash,
+ void SendJoinRequest(const std::string& nickname_, const std::string& console_id_hash,
const MacAddress& preferred_mac = NoPreferredMac,
const std::string& password = "", const std::string& token = "");
@@ -159,7 +159,7 @@ void RoomMember::RoomMemberImpl::MemberLoop() {
while (IsConnected()) {
std::lock_guard lock(network_mutex);
ENetEvent event;
- if (enet_host_service(client, &event, 100) > 0) {
+ if (enet_host_service(client, &event, 16) > 0) {
switch (event.type) {
case ENET_EVENT_TYPE_RECEIVE:
switch (event.packet->data[0]) {
@@ -251,16 +251,17 @@ void RoomMember::RoomMemberImpl::MemberLoop() {
break;
}
}
+ std::list<Packet> packets;
{
- std::lock_guard lock(send_list_mutex);
- for (const auto& packet : send_list) {
- ENetPacket* enetPacket = enet_packet_create(packet.GetData(), packet.GetDataSize(),
- ENET_PACKET_FLAG_RELIABLE);
- enet_peer_send(server, 0, enetPacket);
- }
- enet_host_flush(client);
- send_list.clear();
+ std::lock_guard send_lock(send_list_mutex);
+ packets.swap(send_list);
+ }
+ for (const auto& packet : packets) {
+ ENetPacket* enetPacket = enet_packet_create(packet.GetData(), packet.GetDataSize(),
+ ENET_PACKET_FLAG_RELIABLE);
+ enet_peer_send(server, 0, enetPacket);
}
+ enet_host_flush(client);
}
Disconnect();
};
@@ -274,14 +275,14 @@ void RoomMember::RoomMemberImpl::Send(Packet&& packet) {
send_list.push_back(std::move(packet));
}
-void RoomMember::RoomMemberImpl::SendJoinRequest(const std::string& nickname,
+void RoomMember::RoomMemberImpl::SendJoinRequest(const std::string& nickname_,
const std::string& console_id_hash,
const MacAddress& preferred_mac,
const std::string& password,
const std::string& token) {
Packet packet;
packet << static_cast<u8>(IdJoinRequest);
- packet << nickname;
+ packet << nickname_;
packet << console_id_hash;
packet << preferred_mac;
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 {
std::string username;
std::string display_name;
std::string avatar_url;
- bool moderator = false; ///< Whether the user is a Citra Moderator.
+ bool moderator = false; ///< Whether the user is a yuzu Moderator.
};
/**