Fix compilation on linux gcc

This commit is contained in:
FearlessTobi 2022-07-11 20:40:57 +02:00
parent ee5cb9c7b9
commit ec407bd3f1
6 changed files with 32 additions and 31 deletions

View File

@ -14,13 +14,13 @@
namespace Network {
#ifndef htonll
u64 htonll(u64 x) {
static u64 htonll(u64 x) {
return ((1 == htonl(1)) ? (x) : ((uint64_t)htonl((x)&0xFFFFFFFF) << 32) | htonl((x) >> 32));
}
#endif
#ifndef ntohll
u64 ntohll(u64 x) {
static u64 ntohll(u64 x) {
return ((1 == ntohl(1)) ? (x) : ((uint64_t)ntohl((x)&0xFFFFFFFF) << 32) | ntohl((x) >> 32));
}
#endif
@ -67,7 +67,7 @@ Packet::operator bool() const {
}
Packet& Packet::operator>>(bool& out_data) {
u8 value;
u8 value{};
if (*this >> value) {
out_data = (value != 0);
}
@ -85,42 +85,42 @@ Packet& Packet::operator>>(u8& out_data) {
}
Packet& Packet::operator>>(s16& out_data) {
s16 value;
s16 value{};
Read(&value, sizeof(value));
out_data = ntohs(value);
return *this;
}
Packet& Packet::operator>>(u16& out_data) {
u16 value;
u16 value{};
Read(&value, sizeof(value));
out_data = ntohs(value);
return *this;
}
Packet& Packet::operator>>(s32& out_data) {
s32 value;
s32 value{};
Read(&value, sizeof(value));
out_data = ntohl(value);
return *this;
}
Packet& Packet::operator>>(u32& out_data) {
u32 value;
u32 value{};
Read(&value, sizeof(value));
out_data = ntohl(value);
return *this;
}
Packet& Packet::operator>>(s64& out_data) {
s64 value;
s64 value{};
Read(&value, sizeof(value));
out_data = ntohll(value);
return *this;
}
Packet& Packet::operator>>(u64& out_data) {
u64 value;
u64 value{};
Read(&value, sizeof(value));
out_data = ntohll(value);
return *this;

View File

@ -877,8 +877,8 @@ void Room::RoomImpl::HandleWifiPacket(const ENetEvent* event) {
} else { // Send the data only to the destination client
std::lock_guard lock(member_mutex);
auto member = std::find_if(members.begin(), members.end(),
[destination_address](const Member& member) -> bool {
return member.mac_address == destination_address;
[destination_address](const Member& member_entry) -> bool {
return member_entry.mac_address == destination_address;
});
if (member != members.end()) {
enet_peer_send(member->peer, 0, enet_packet);
@ -955,9 +955,9 @@ void Room::RoomImpl::HandleGameNamePacket(const ENetEvent* event) {
{
std::lock_guard lock(member_mutex);
auto member =
std::find_if(members.begin(), members.end(), [event](const Member& member) -> bool {
return member.peer == event->peer;
auto member = std::find_if(members.begin(), members.end(),
[event](const Member& member_entry) -> bool {
return member_entry.peer == event->peer;
});
if (member != members.end()) {
member->game_info = game_info;
@ -982,8 +982,9 @@ void Room::RoomImpl::HandleClientDisconnection(ENetPeer* client) {
std::string nickname, username, ip;
{
std::lock_guard lock(member_mutex);
auto member = std::find_if(members.begin(), members.end(), [client](const Member& member) {
return member.peer == client;
auto member =
std::find_if(members.begin(), members.end(), [client](const Member& member_entry) {
return member_entry.peer == client;
});
if (member != members.end()) {
nickname = member->nickname;

View File

@ -11,7 +11,7 @@
namespace AnnounceMultiplayerRoom {
void to_json(nlohmann::json& json, const Room::Member& member) {
static void to_json(nlohmann::json& json, const Room::Member& member) {
if (!member.username.empty()) {
json["username"] = member.username;
}
@ -23,7 +23,7 @@ void to_json(nlohmann::json& json, const Room::Member& member) {
json["gameId"] = member.game_id;
}
void from_json(const nlohmann::json& json, Room::Member& member) {
static void from_json(const nlohmann::json& json, Room::Member& member) {
member.nickname = json.at("nickname").get<std::string>();
member.game_name = json.at("gameName").get<std::string>();
member.game_id = json.at("gameId").get<u64>();
@ -36,7 +36,7 @@ void from_json(const nlohmann::json& json, Room::Member& member) {
}
}
void to_json(nlohmann::json& json, const Room& room) {
static void to_json(nlohmann::json& json, const Room& room) {
json["port"] = room.port;
json["name"] = room.name;
if (!room.description.empty()) {
@ -53,7 +53,7 @@ void to_json(nlohmann::json& json, const Room& room) {
}
}
void from_json(const nlohmann::json& json, Room& room) {
static void from_json(const nlohmann::json& json, Room& room) {
room.verify_UID = json.at("externalGuid").get<std::string>();
room.ip = json.at("address").get<std::string>();
room.name = json.at("name").get<std::string>();

View File

@ -17,8 +17,8 @@ namespace WebService {
*/
class RoomJson : public AnnounceMultiplayerRoom::Backend {
public:
RoomJson(const std::string& host, const std::string& username, const std::string& token)
: client(host, username, token), host(host), username(username), token(token) {}
RoomJson(const std::string& host_, const std::string& username_, const std::string& token_)
: client(host_, username_, token_), host(host_), username(username_), token(token_) {}
~RoomJson() = default;
void SetRoomInformation(const std::string& name, const std::string& description, const u16 port,
const u32 max_player, const u32 net_version, const bool has_password,

View File

@ -148,9 +148,9 @@ class LobbyMember {
public:
LobbyMember() = default;
LobbyMember(const LobbyMember& other) = default;
explicit LobbyMember(QString username, QString nickname, u64 title_id, QString game_name)
: username(std::move(username)), nickname(std::move(nickname)), title_id(title_id),
game_name(std::move(game_name)) {}
explicit LobbyMember(QString username_, QString nickname_, u64 title_id_, QString game_name_)
: username(std::move(username_)), nickname(std::move(nickname_)), title_id(title_id_),
game_name(std::move(game_name_)) {}
~LobbyMember() = default;
QString GetName() const {

View File

@ -19,10 +19,10 @@
#include "yuzu/uisettings.h"
#include "yuzu/util/clickable_label.h"
MultiplayerState::MultiplayerState(QWidget* parent, QStandardItemModel* game_list_model,
QAction* leave_room, QAction* show_room)
: QWidget(parent), game_list_model(game_list_model), leave_room(leave_room),
show_room(show_room) {
MultiplayerState::MultiplayerState(QWidget* parent, QStandardItemModel* game_list_model_,
QAction* leave_room_, QAction* show_room_)
: QWidget(parent), game_list_model(game_list_model_), leave_room(leave_room_),
show_room(show_room_) {
if (auto member = Network::GetRoomMember().lock()) {
// register the network structs to use in slots and signals
state_callback_handle = member->BindOnStateChanged(