mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-28 22:54:34 +01:00
Fix compilation on linux gcc
This commit is contained in:
parent
ee5cb9c7b9
commit
ec407bd3f1
@ -14,13 +14,13 @@
|
|||||||
namespace Network {
|
namespace Network {
|
||||||
|
|
||||||
#ifndef htonll
|
#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));
|
return ((1 == htonl(1)) ? (x) : ((uint64_t)htonl((x)&0xFFFFFFFF) << 32) | htonl((x) >> 32));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ntohll
|
#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));
|
return ((1 == ntohl(1)) ? (x) : ((uint64_t)ntohl((x)&0xFFFFFFFF) << 32) | ntohl((x) >> 32));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -67,7 +67,7 @@ Packet::operator bool() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Packet& Packet::operator>>(bool& out_data) {
|
Packet& Packet::operator>>(bool& out_data) {
|
||||||
u8 value;
|
u8 value{};
|
||||||
if (*this >> value) {
|
if (*this >> value) {
|
||||||
out_data = (value != 0);
|
out_data = (value != 0);
|
||||||
}
|
}
|
||||||
@ -85,42 +85,42 @@ Packet& Packet::operator>>(u8& out_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Packet& Packet::operator>>(s16& out_data) {
|
Packet& Packet::operator>>(s16& out_data) {
|
||||||
s16 value;
|
s16 value{};
|
||||||
Read(&value, sizeof(value));
|
Read(&value, sizeof(value));
|
||||||
out_data = ntohs(value);
|
out_data = ntohs(value);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Packet& Packet::operator>>(u16& out_data) {
|
Packet& Packet::operator>>(u16& out_data) {
|
||||||
u16 value;
|
u16 value{};
|
||||||
Read(&value, sizeof(value));
|
Read(&value, sizeof(value));
|
||||||
out_data = ntohs(value);
|
out_data = ntohs(value);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Packet& Packet::operator>>(s32& out_data) {
|
Packet& Packet::operator>>(s32& out_data) {
|
||||||
s32 value;
|
s32 value{};
|
||||||
Read(&value, sizeof(value));
|
Read(&value, sizeof(value));
|
||||||
out_data = ntohl(value);
|
out_data = ntohl(value);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Packet& Packet::operator>>(u32& out_data) {
|
Packet& Packet::operator>>(u32& out_data) {
|
||||||
u32 value;
|
u32 value{};
|
||||||
Read(&value, sizeof(value));
|
Read(&value, sizeof(value));
|
||||||
out_data = ntohl(value);
|
out_data = ntohl(value);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Packet& Packet::operator>>(s64& out_data) {
|
Packet& Packet::operator>>(s64& out_data) {
|
||||||
s64 value;
|
s64 value{};
|
||||||
Read(&value, sizeof(value));
|
Read(&value, sizeof(value));
|
||||||
out_data = ntohll(value);
|
out_data = ntohll(value);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Packet& Packet::operator>>(u64& out_data) {
|
Packet& Packet::operator>>(u64& out_data) {
|
||||||
u64 value;
|
u64 value{};
|
||||||
Read(&value, sizeof(value));
|
Read(&value, sizeof(value));
|
||||||
out_data = ntohll(value);
|
out_data = ntohll(value);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -877,8 +877,8 @@ void Room::RoomImpl::HandleWifiPacket(const ENetEvent* event) {
|
|||||||
} else { // Send the data only to the destination client
|
} else { // Send the data only to the destination client
|
||||||
std::lock_guard lock(member_mutex);
|
std::lock_guard lock(member_mutex);
|
||||||
auto member = std::find_if(members.begin(), members.end(),
|
auto member = std::find_if(members.begin(), members.end(),
|
||||||
[destination_address](const Member& member) -> bool {
|
[destination_address](const Member& member_entry) -> bool {
|
||||||
return member.mac_address == destination_address;
|
return member_entry.mac_address == destination_address;
|
||||||
});
|
});
|
||||||
if (member != members.end()) {
|
if (member != members.end()) {
|
||||||
enet_peer_send(member->peer, 0, enet_packet);
|
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);
|
std::lock_guard lock(member_mutex);
|
||||||
auto member =
|
auto member = std::find_if(members.begin(), members.end(),
|
||||||
std::find_if(members.begin(), members.end(), [event](const Member& member) -> bool {
|
[event](const Member& member_entry) -> bool {
|
||||||
return member.peer == event->peer;
|
return member_entry.peer == event->peer;
|
||||||
});
|
});
|
||||||
if (member != members.end()) {
|
if (member != members.end()) {
|
||||||
member->game_info = game_info;
|
member->game_info = game_info;
|
||||||
@ -982,8 +982,9 @@ void Room::RoomImpl::HandleClientDisconnection(ENetPeer* client) {
|
|||||||
std::string nickname, username, ip;
|
std::string nickname, username, ip;
|
||||||
{
|
{
|
||||||
std::lock_guard lock(member_mutex);
|
std::lock_guard lock(member_mutex);
|
||||||
auto member = std::find_if(members.begin(), members.end(), [client](const Member& member) {
|
auto member =
|
||||||
return member.peer == client;
|
std::find_if(members.begin(), members.end(), [client](const Member& member_entry) {
|
||||||
|
return member_entry.peer == client;
|
||||||
});
|
});
|
||||||
if (member != members.end()) {
|
if (member != members.end()) {
|
||||||
nickname = member->nickname;
|
nickname = member->nickname;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace AnnounceMultiplayerRoom {
|
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()) {
|
if (!member.username.empty()) {
|
||||||
json["username"] = member.username;
|
json["username"] = member.username;
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ void to_json(nlohmann::json& json, const Room::Member& member) {
|
|||||||
json["gameId"] = member.game_id;
|
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.nickname = json.at("nickname").get<std::string>();
|
||||||
member.game_name = json.at("gameName").get<std::string>();
|
member.game_name = json.at("gameName").get<std::string>();
|
||||||
member.game_id = json.at("gameId").get<u64>();
|
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["port"] = room.port;
|
||||||
json["name"] = room.name;
|
json["name"] = room.name;
|
||||||
if (!room.description.empty()) {
|
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.verify_UID = json.at("externalGuid").get<std::string>();
|
||||||
room.ip = json.at("address").get<std::string>();
|
room.ip = json.at("address").get<std::string>();
|
||||||
room.name = json.at("name").get<std::string>();
|
room.name = json.at("name").get<std::string>();
|
||||||
|
@ -17,8 +17,8 @@ namespace WebService {
|
|||||||
*/
|
*/
|
||||||
class RoomJson : public AnnounceMultiplayerRoom::Backend {
|
class RoomJson : public AnnounceMultiplayerRoom::Backend {
|
||||||
public:
|
public:
|
||||||
RoomJson(const std::string& host, const std::string& username, const std::string& token)
|
RoomJson(const std::string& host_, const std::string& username_, const std::string& token_)
|
||||||
: client(host, username, token), host(host), username(username), token(token) {}
|
: client(host_, username_, token_), host(host_), username(username_), token(token_) {}
|
||||||
~RoomJson() = default;
|
~RoomJson() = default;
|
||||||
void SetRoomInformation(const std::string& name, const std::string& description, const u16 port,
|
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,
|
const u32 max_player, const u32 net_version, const bool has_password,
|
||||||
|
@ -148,9 +148,9 @@ class LobbyMember {
|
|||||||
public:
|
public:
|
||||||
LobbyMember() = default;
|
LobbyMember() = default;
|
||||||
LobbyMember(const LobbyMember& other) = default;
|
LobbyMember(const LobbyMember& other) = default;
|
||||||
explicit LobbyMember(QString username, QString nickname, u64 title_id, QString 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),
|
: username(std::move(username_)), nickname(std::move(nickname_)), title_id(title_id_),
|
||||||
game_name(std::move(game_name)) {}
|
game_name(std::move(game_name_)) {}
|
||||||
~LobbyMember() = default;
|
~LobbyMember() = default;
|
||||||
|
|
||||||
QString GetName() const {
|
QString GetName() const {
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
#include "yuzu/uisettings.h"
|
#include "yuzu/uisettings.h"
|
||||||
#include "yuzu/util/clickable_label.h"
|
#include "yuzu/util/clickable_label.h"
|
||||||
|
|
||||||
MultiplayerState::MultiplayerState(QWidget* parent, QStandardItemModel* game_list_model,
|
MultiplayerState::MultiplayerState(QWidget* parent, QStandardItemModel* game_list_model_,
|
||||||
QAction* leave_room, QAction* show_room)
|
QAction* leave_room_, QAction* show_room_)
|
||||||
: QWidget(parent), game_list_model(game_list_model), leave_room(leave_room),
|
: QWidget(parent), game_list_model(game_list_model_), leave_room(leave_room_),
|
||||||
show_room(show_room) {
|
show_room(show_room_) {
|
||||||
if (auto member = Network::GetRoomMember().lock()) {
|
if (auto member = Network::GetRoomMember().lock()) {
|
||||||
// register the network structs to use in slots and signals
|
// register the network structs to use in slots and signals
|
||||||
state_callback_handle = member->BindOnStateChanged(
|
state_callback_handle = member->BindOnStateChanged(
|
||||||
|
Loading…
Reference in New Issue
Block a user