summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar FearlessTobi2022-07-11 20:40:57 +0200
committerGravatar FearlessTobi2022-07-25 21:59:30 +0200
commitec407bd3f1988c6f5d147307c662703c7bc94751 (patch)
tree8792652886c6b9250bea7e609b9828d9a94d3e31 /src
parentweb_service: Fix -Wmissing-field-initializers (diff)
downloadyuzu-ec407bd3f1988c6f5d147307c662703c7bc94751.tar.gz
yuzu-ec407bd3f1988c6f5d147307c662703c7bc94751.tar.xz
yuzu-ec407bd3f1988c6f5d147307c662703c7bc94751.zip
Fix compilation on linux gcc
Diffstat (limited to 'src')
-rw-r--r--src/network/packet.cpp18
-rw-r--r--src/network/room.cpp19
-rw-r--r--src/web_service/announce_room_json.cpp8
-rw-r--r--src/web_service/announce_room_json.h4
-rw-r--r--src/yuzu/multiplayer/lobby_p.h6
-rw-r--r--src/yuzu/multiplayer/state.cpp8
6 files changed, 32 insertions, 31 deletions
diff --git a/src/network/packet.cpp b/src/network/packet.cpp
index 8fc5feabd..a3c1e1644 100644
--- a/src/network/packet.cpp
+++ b/src/network/packet.cpp
@@ -14,13 +14,13 @@
14namespace Network { 14namespace Network {
15 15
16#ifndef htonll 16#ifndef htonll
17u64 htonll(u64 x) { 17static u64 htonll(u64 x) {
18 return ((1 == htonl(1)) ? (x) : ((uint64_t)htonl((x)&0xFFFFFFFF) << 32) | htonl((x) >> 32)); 18 return ((1 == htonl(1)) ? (x) : ((uint64_t)htonl((x)&0xFFFFFFFF) << 32) | htonl((x) >> 32));
19} 19}
20#endif 20#endif
21 21
22#ifndef ntohll 22#ifndef ntohll
23u64 ntohll(u64 x) { 23static u64 ntohll(u64 x) {
24 return ((1 == ntohl(1)) ? (x) : ((uint64_t)ntohl((x)&0xFFFFFFFF) << 32) | ntohl((x) >> 32)); 24 return ((1 == ntohl(1)) ? (x) : ((uint64_t)ntohl((x)&0xFFFFFFFF) << 32) | ntohl((x) >> 32));
25} 25}
26#endif 26#endif
@@ -67,7 +67,7 @@ Packet::operator bool() const {
67} 67}
68 68
69Packet& Packet::operator>>(bool& out_data) { 69Packet& Packet::operator>>(bool& out_data) {
70 u8 value; 70 u8 value{};
71 if (*this >> value) { 71 if (*this >> value) {
72 out_data = (value != 0); 72 out_data = (value != 0);
73 } 73 }
@@ -85,42 +85,42 @@ Packet& Packet::operator>>(u8& out_data) {
85} 85}
86 86
87Packet& Packet::operator>>(s16& out_data) { 87Packet& Packet::operator>>(s16& out_data) {
88 s16 value; 88 s16 value{};
89 Read(&value, sizeof(value)); 89 Read(&value, sizeof(value));
90 out_data = ntohs(value); 90 out_data = ntohs(value);
91 return *this; 91 return *this;
92} 92}
93 93
94Packet& Packet::operator>>(u16& out_data) { 94Packet& Packet::operator>>(u16& out_data) {
95 u16 value; 95 u16 value{};
96 Read(&value, sizeof(value)); 96 Read(&value, sizeof(value));
97 out_data = ntohs(value); 97 out_data = ntohs(value);
98 return *this; 98 return *this;
99} 99}
100 100
101Packet& Packet::operator>>(s32& out_data) { 101Packet& Packet::operator>>(s32& out_data) {
102 s32 value; 102 s32 value{};
103 Read(&value, sizeof(value)); 103 Read(&value, sizeof(value));
104 out_data = ntohl(value); 104 out_data = ntohl(value);
105 return *this; 105 return *this;
106} 106}
107 107
108Packet& Packet::operator>>(u32& out_data) { 108Packet& Packet::operator>>(u32& out_data) {
109 u32 value; 109 u32 value{};
110 Read(&value, sizeof(value)); 110 Read(&value, sizeof(value));
111 out_data = ntohl(value); 111 out_data = ntohl(value);
112 return *this; 112 return *this;
113} 113}
114 114
115Packet& Packet::operator>>(s64& out_data) { 115Packet& Packet::operator>>(s64& out_data) {
116 s64 value; 116 s64 value{};
117 Read(&value, sizeof(value)); 117 Read(&value, sizeof(value));
118 out_data = ntohll(value); 118 out_data = ntohll(value);
119 return *this; 119 return *this;
120} 120}
121 121
122Packet& Packet::operator>>(u64& out_data) { 122Packet& Packet::operator>>(u64& out_data) {
123 u64 value; 123 u64 value{};
124 Read(&value, sizeof(value)); 124 Read(&value, sizeof(value));
125 out_data = ntohll(value); 125 out_data = ntohll(value);
126 return *this; 126 return *this;
diff --git a/src/network/room.cpp b/src/network/room.cpp
index 528867146..b82a75749 100644
--- a/src/network/room.cpp
+++ b/src/network/room.cpp
@@ -877,8 +877,8 @@ void Room::RoomImpl::HandleWifiPacket(const ENetEvent* event) {
877 } else { // Send the data only to the destination client 877 } else { // Send the data only to the destination client
878 std::lock_guard lock(member_mutex); 878 std::lock_guard lock(member_mutex);
879 auto member = std::find_if(members.begin(), members.end(), 879 auto member = std::find_if(members.begin(), members.end(),
880 [destination_address](const Member& member) -> bool { 880 [destination_address](const Member& member_entry) -> bool {
881 return member.mac_address == destination_address; 881 return member_entry.mac_address == destination_address;
882 }); 882 });
883 if (member != members.end()) { 883 if (member != members.end()) {
884 enet_peer_send(member->peer, 0, enet_packet); 884 enet_peer_send(member->peer, 0, enet_packet);
@@ -955,10 +955,10 @@ void Room::RoomImpl::HandleGameNamePacket(const ENetEvent* event) {
955 955
956 { 956 {
957 std::lock_guard lock(member_mutex); 957 std::lock_guard lock(member_mutex);
958 auto member = 958 auto member = std::find_if(members.begin(), members.end(),
959 std::find_if(members.begin(), members.end(), [event](const Member& member) -> bool { 959 [event](const Member& member_entry) -> bool {
960 return member.peer == event->peer; 960 return member_entry.peer == event->peer;
961 }); 961 });
962 if (member != members.end()) { 962 if (member != members.end()) {
963 member->game_info = game_info; 963 member->game_info = game_info;
964 964
@@ -982,9 +982,10 @@ void Room::RoomImpl::HandleClientDisconnection(ENetPeer* client) {
982 std::string nickname, username, ip; 982 std::string nickname, username, ip;
983 { 983 {
984 std::lock_guard lock(member_mutex); 984 std::lock_guard lock(member_mutex);
985 auto member = std::find_if(members.begin(), members.end(), [client](const Member& member) { 985 auto member =
986 return member.peer == client; 986 std::find_if(members.begin(), members.end(), [client](const Member& member_entry) {
987 }); 987 return member_entry.peer == client;
988 });
988 if (member != members.end()) { 989 if (member != members.end()) {
989 nickname = member->nickname; 990 nickname = member->nickname;
990 username = member->user_data.username; 991 username = member->user_data.username;
diff --git a/src/web_service/announce_room_json.cpp b/src/web_service/announce_room_json.cpp
index 32249f28e..984a59f77 100644
--- a/src/web_service/announce_room_json.cpp
+++ b/src/web_service/announce_room_json.cpp
@@ -11,7 +11,7 @@
11 11
12namespace AnnounceMultiplayerRoom { 12namespace AnnounceMultiplayerRoom {
13 13
14void to_json(nlohmann::json& json, const Room::Member& member) { 14static void to_json(nlohmann::json& json, const Room::Member& member) {
15 if (!member.username.empty()) { 15 if (!member.username.empty()) {
16 json["username"] = member.username; 16 json["username"] = member.username;
17 } 17 }
@@ -23,7 +23,7 @@ void to_json(nlohmann::json& json, const Room::Member& member) {
23 json["gameId"] = member.game_id; 23 json["gameId"] = member.game_id;
24} 24}
25 25
26void from_json(const nlohmann::json& json, Room::Member& member) { 26static void from_json(const nlohmann::json& json, Room::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>();
@@ -36,7 +36,7 @@ void from_json(const nlohmann::json& json, Room::Member& member) {
36 } 36 }
37} 37}
38 38
39void to_json(nlohmann::json& json, const Room& room) { 39static void to_json(nlohmann::json& json, const Room& room) {
40 json["port"] = room.port; 40 json["port"] = room.port;
41 json["name"] = room.name; 41 json["name"] = room.name;
42 if (!room.description.empty()) { 42 if (!room.description.empty()) {
@@ -53,7 +53,7 @@ void to_json(nlohmann::json& json, const Room& room) {
53 } 53 }
54} 54}
55 55
56void from_json(const nlohmann::json& json, Room& room) { 56static void from_json(const nlohmann::json& json, Room& room) {
57 room.verify_UID = json.at("externalGuid").get<std::string>(); 57 room.verify_UID = json.at("externalGuid").get<std::string>();
58 room.ip = json.at("address").get<std::string>(); 58 room.ip = json.at("address").get<std::string>();
59 room.name = json.at("name").get<std::string>(); 59 room.name = json.at("name").get<std::string>();
diff --git a/src/web_service/announce_room_json.h b/src/web_service/announce_room_json.h
index ac02af5b1..f65c93214 100644
--- a/src/web_service/announce_room_json.h
+++ b/src/web_service/announce_room_json.h
@@ -17,8 +17,8 @@ namespace WebService {
17 */ 17 */
18class RoomJson : public AnnounceMultiplayerRoom::Backend { 18class RoomJson : public AnnounceMultiplayerRoom::Backend {
19public: 19public:
20 RoomJson(const std::string& host, const std::string& username, const std::string& token) 20 RoomJson(const std::string& host_, const std::string& username_, const std::string& token_)
21 : client(host, username, token), host(host), username(username), token(token) {} 21 : client(host_, username_, token_), host(host_), username(username_), token(token_) {}
22 ~RoomJson() = default; 22 ~RoomJson() = default;
23 void SetRoomInformation(const std::string& name, const std::string& description, const u16 port, 23 void SetRoomInformation(const std::string& name, const std::string& description, const u16 port,
24 const u32 max_player, const u32 net_version, const bool has_password, 24 const u32 max_player, const u32 net_version, const bool has_password,
diff --git a/src/yuzu/multiplayer/lobby_p.h b/src/yuzu/multiplayer/lobby_p.h
index 749ca627f..afb8b99dc 100644
--- a/src/yuzu/multiplayer/lobby_p.h
+++ b/src/yuzu/multiplayer/lobby_p.h
@@ -148,9 +148,9 @@ class LobbyMember {
148public: 148public:
149 LobbyMember() = default; 149 LobbyMember() = default;
150 LobbyMember(const LobbyMember& other) = default; 150 LobbyMember(const LobbyMember& other) = default;
151 explicit LobbyMember(QString username, QString nickname, u64 title_id, QString game_name) 151 explicit LobbyMember(QString username_, QString nickname_, u64 title_id_, QString game_name_)
152 : username(std::move(username)), nickname(std::move(nickname)), title_id(title_id), 152 : username(std::move(username_)), nickname(std::move(nickname_)), title_id(title_id_),
153 game_name(std::move(game_name)) {} 153 game_name(std::move(game_name_)) {}
154 ~LobbyMember() = default; 154 ~LobbyMember() = default;
155 155
156 QString GetName() const { 156 QString GetName() const {
diff --git a/src/yuzu/multiplayer/state.cpp b/src/yuzu/multiplayer/state.cpp
index b2aaed982..e96b03e5d 100644
--- a/src/yuzu/multiplayer/state.cpp
+++ b/src/yuzu/multiplayer/state.cpp
@@ -19,10 +19,10 @@
19#include "yuzu/uisettings.h" 19#include "yuzu/uisettings.h"
20#include "yuzu/util/clickable_label.h" 20#include "yuzu/util/clickable_label.h"
21 21
22MultiplayerState::MultiplayerState(QWidget* parent, QStandardItemModel* game_list_model, 22MultiplayerState::MultiplayerState(QWidget* parent, QStandardItemModel* game_list_model_,
23 QAction* leave_room, QAction* show_room) 23 QAction* leave_room_, QAction* show_room_)
24 : QWidget(parent), game_list_model(game_list_model), leave_room(leave_room), 24 : QWidget(parent), game_list_model(game_list_model_), leave_room(leave_room_),
25 show_room(show_room) { 25 show_room(show_room_) {
26 if (auto member = Network::GetRoomMember().lock()) { 26 if (auto member = Network::GetRoomMember().lock()) {
27 // register the network structs to use in slots and signals 27 // register the network structs to use in slots and signals
28 state_callback_handle = member->BindOnStateChanged( 28 state_callback_handle = member->BindOnStateChanged(