summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorFearlessTobi <thm.frey@gmail.com>2022-07-25 17:08:20 +0200
committerFearlessTobi <thm.frey@gmail.com>2022-07-25 21:59:31 +0200
commit6a2dcc8b3d4ed0940e33d60fee701bcdb063eb6b (patch)
treeb70962e3698930c5b06d777bd912caa89a912391 /src/network
parentyuzu_cmd: Fix compilation (diff)
downloadyuzu-6a2dcc8b3d4ed0940e33d60fee701bcdb063eb6b.tar
yuzu-6a2dcc8b3d4ed0940e33d60fee701bcdb063eb6b.tar.gz
yuzu-6a2dcc8b3d4ed0940e33d60fee701bcdb063eb6b.tar.bz2
yuzu-6a2dcc8b3d4ed0940e33d60fee701bcdb063eb6b.tar.lz
yuzu-6a2dcc8b3d4ed0940e33d60fee701bcdb063eb6b.tar.xz
yuzu-6a2dcc8b3d4ed0940e33d60fee701bcdb063eb6b.tar.zst
yuzu-6a2dcc8b3d4ed0940e33d60fee701bcdb063eb6b.zip
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network.cpp28
-rw-r--r--src/network/network.h4
-rw-r--r--src/network/room.cpp16
-rw-r--r--src/network/room_member.cpp6
-rw-r--r--src/network/verify_user.cpp2
-rw-r--r--src/network/verify_user.h6
6 files changed, 32 insertions, 30 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp
index e1401a403..36b70c36f 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -10,8 +10,8 @@
namespace Network {
RoomNetwork::RoomNetwork() {
- g_room = std::make_shared<Room>();
- g_room_member = std::make_shared<RoomMember>();
+ m_room = std::make_shared<Room>();
+ m_room_member = std::make_shared<RoomMember>();
}
bool RoomNetwork::Init() {
@@ -19,30 +19,30 @@ bool RoomNetwork::Init() {
LOG_ERROR(Network, "Error initalizing ENet");
return false;
}
- g_room = std::make_shared<Room>();
- g_room_member = std::make_shared<RoomMember>();
+ m_room = std::make_shared<Room>();
+ m_room_member = std::make_shared<RoomMember>();
LOG_DEBUG(Network, "initialized OK");
return true;
}
std::weak_ptr<Room> RoomNetwork::GetRoom() {
- return g_room;
+ return m_room;
}
std::weak_ptr<RoomMember> RoomNetwork::GetRoomMember() {
- return g_room_member;
+ return m_room_member;
}
void RoomNetwork::Shutdown() {
- if (g_room_member) {
- if (g_room_member->IsConnected())
- g_room_member->Leave();
- g_room_member.reset();
+ if (m_room_member) {
+ if (m_room_member->IsConnected())
+ m_room_member->Leave();
+ m_room_member.reset();
}
- if (g_room) {
- if (g_room->GetState() == Room::State::Open)
- g_room->Destroy();
- g_room.reset();
+ if (m_room) {
+ if (m_room->GetState() == Room::State::Open)
+ m_room->Destroy();
+ m_room.reset();
}
enet_deinitialize();
LOG_DEBUG(Network, "shutdown OK");
diff --git a/src/network/network.h b/src/network/network.h
index 74eb42bf5..a38f04029 100644
--- a/src/network/network.h
+++ b/src/network/network.h
@@ -27,8 +27,8 @@ public:
void Shutdown();
private:
- std::shared_ptr<RoomMember> g_room_member; ///< RoomMember (Client) for network games
- std::shared_ptr<Room> g_room; ///< Room (Server) for network games
+ std::shared_ptr<RoomMember> m_room_member; ///< RoomMember (Client) for network games
+ std::shared_ptr<Room> m_room; ///< Room (Server) for network games
};
} // namespace Network
diff --git a/src/network/room.cpp b/src/network/room.cpp
index 22491b299..b22c5fb89 100644
--- a/src/network/room.cpp
+++ b/src/network/room.cpp
@@ -29,8 +29,8 @@ public:
std::atomic<State> state{State::Closed}; ///< Current state of the room.
RoomInformation room_information; ///< Information about this room.
- std::string verify_UID; ///< A GUID which may be used for verfication.
- mutable std::mutex verify_UID_mutex; ///< Mutex for verify_UID
+ std::string verify_uid; ///< A GUID which may be used for verfication.
+ mutable std::mutex verify_uid_mutex; ///< Mutex for verify_uid
std::string password; ///< The password required to connect to this room.
@@ -369,8 +369,8 @@ void Room::RoomImpl::HandleJoinRequest(const ENetEvent* event) {
std::string uid;
{
- std::lock_guard lock(verify_UID_mutex);
- uid = verify_UID;
+ std::lock_guard lock(verify_uid_mutex);
+ uid = verify_uid;
}
member.user_data = verify_backend->LoadUserData(uid, token);
@@ -1056,8 +1056,8 @@ const RoomInformation& Room::GetRoomInformation() const {
}
std::string Room::GetVerifyUID() const {
- std::lock_guard lock(room_impl->verify_UID_mutex);
- return room_impl->verify_UID;
+ std::lock_guard lock(room_impl->verify_uid_mutex);
+ return room_impl->verify_uid;
}
Room::BanList Room::GetBanList() const {
@@ -1086,8 +1086,8 @@ bool Room::HasPassword() const {
}
void Room::SetVerifyUID(const std::string& uid) {
- std::lock_guard lock(room_impl->verify_UID_mutex);
- room_impl->verify_UID = uid;
+ std::lock_guard lock(room_impl->verify_uid_mutex);
+ room_impl->verify_uid = uid;
}
void Room::Destroy() {
diff --git a/src/network/room_member.cpp b/src/network/room_member.cpp
index 11a2e276e..d8cb32721 100644
--- a/src/network/room_member.cpp
+++ b/src/network/room_member.cpp
@@ -416,8 +416,9 @@ void RoomMember::RoomMemberImpl::Disconnect() {
room_information.member_slots = 0;
room_information.name.clear();
- if (!server)
+ if (!server) {
return;
+ }
enet_peer_disconnect(server, 0);
ENetEvent event;
@@ -483,8 +484,9 @@ template <typename T>
void RoomMember::RoomMemberImpl::Invoke(const T& data) {
std::lock_guard lock(callback_mutex);
CallbackSet<T> callback_set = callbacks.Get<T>();
- for (auto const& callback : callback_set)
+ for (auto const& callback : callback_set) {
(*callback)(data);
+ }
}
template <typename T>
diff --git a/src/network/verify_user.cpp b/src/network/verify_user.cpp
index d9d98e495..51094e9bc 100644
--- a/src/network/verify_user.cpp
+++ b/src/network/verify_user.cpp
@@ -10,7 +10,7 @@ Backend::~Backend() = default;
NullBackend::~NullBackend() = default;
-UserData NullBackend::LoadUserData([[maybe_unused]] const std::string& verify_UID,
+UserData NullBackend::LoadUserData([[maybe_unused]] const std::string& verify_uid,
[[maybe_unused]] const std::string& token) {
return {};
}
diff --git a/src/network/verify_user.h b/src/network/verify_user.h
index 5c3852d4a..ddae67e99 100644
--- a/src/network/verify_user.h
+++ b/src/network/verify_user.h
@@ -25,11 +25,11 @@ public:
/**
* Verifies the given token and loads the information into a UserData struct.
- * @param verify_UID A GUID that may be used for verification.
+ * @param verify_uid A GUID that may be used for verification.
* @param token A token that contains user data and verification data. The format and content is
* decided by backends.
*/
- virtual UserData LoadUserData(const std::string& verify_UID, const std::string& token) = 0;
+ virtual UserData LoadUserData(const std::string& verify_uid, const std::string& token) = 0;
};
/**
@@ -40,7 +40,7 @@ class NullBackend final : public Backend {
public:
~NullBackend();
- UserData LoadUserData(const std::string& verify_UID, const std::string& token) override;
+ UserData LoadUserData(const std::string& verify_uid, const std::string& token) override;
};
} // namespace Network::VerifyUser