summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/common/announce_multiplayer_room.h35
-rw-r--r--src/core/announce_multiplayer_session.cpp8
-rw-r--r--src/network/room.cpp8
-rw-r--r--src/network/room.h3
-rw-r--r--src/network/room_member.cpp2
-rw-r--r--src/web_service/announce_room_json.cpp21
-rw-r--r--src/web_service/announce_room_json.h3
-rw-r--r--src/web_service/verify_user_jwt.h2
-rw-r--r--src/yuzu/multiplayer/host_room.cpp21
-rw-r--r--src/yuzu/multiplayer/lobby.cpp11
-rw-r--r--src/yuzu/uisettings.h8
11 files changed, 60 insertions, 62 deletions
diff --git a/src/common/announce_multiplayer_room.h b/src/common/announce_multiplayer_room.h
index 2ff38b6cf..a9e2f89b7 100644
--- a/src/common/announce_multiplayer_room.h
+++ b/src/common/announce_multiplayer_room.h
@@ -15,30 +15,28 @@ namespace AnnounceMultiplayerRoom {
using MacAddress = std::array<u8, 6>;
+struct GameInfo {
+ std::string name{""};
+ u64 id{0};
+};
+
struct Member {
std::string username;
std::string nickname;
std::string display_name;
std::string avatar_url;
MacAddress mac_address;
- std::string game_name;
- u64 game_id;
+ GameInfo game;
};
struct RoomInformation {
- std::string name; ///< Name of the server
- std::string description; ///< Server description
- u32 member_slots; ///< Maximum number of members in this room
- u16 port; ///< The port of this room
- 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_yuzu_mods; ///< Allow yuzu Moderators to moderate on this room
-};
-
-struct GameInfo {
- std::string name{""};
- u64 id{0};
+ std::string name; ///< Name of the server
+ std::string description; ///< Server description
+ u32 member_slots; ///< Maximum number of members in this room
+ u16 port; ///< The port of this room
+ GameInfo preferred_game; ///< Game to advertise that you want to play
+ std::string host_username; ///< Forum username of the host
+ bool enable_yuzu_mods; ///< Allow yuzu Moderators to moderate on this room
};
struct Room {
@@ -75,8 +73,7 @@ public:
*/
virtual 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 std::string& preferred_game,
- const u64 preferred_game_id) = 0;
+ const bool has_password, const GameInfo& preferred_game) = 0;
/**
* Adds a player information to the data that gets announced
* @param nickname The nickname of the player
@@ -125,8 +122,8 @@ public:
~NullBackend() = 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*/, const std::string& /*preferred_game*/,
- const u64 /*preferred_game_id*/) override {}
+ const bool /*has_password*/,
+ const GameInfo& /*preferred_game*/) override {}
void AddPlayer(const Member& /*member*/) override {}
WebService::WebResult Update() override {
return WebService::WebResult{WebService::WebResult::Code::NoWebservice,
diff --git a/src/core/announce_multiplayer_session.cpp b/src/core/announce_multiplayer_session.cpp
index f8aa9bb0b..db9eaeac8 100644
--- a/src/core/announce_multiplayer_session.cpp
+++ b/src/core/announce_multiplayer_session.cpp
@@ -89,10 +89,10 @@ AnnounceMultiplayerSession::~AnnounceMultiplayerSession() {
void AnnounceMultiplayerSession::UpdateBackendData(std::shared_ptr<Network::Room> room) {
Network::RoomInformation room_information = room->GetRoomInformation();
std::vector<AnnounceMultiplayerRoom::Member> memberlist = room->GetRoomMemberList();
- backend->SetRoomInformation(
- room_information.name, room_information.description, room_information.port,
- room_information.member_slots, Network::network_version, room->HasPassword(),
- room_information.preferred_game, room_information.preferred_game_id);
+ backend->SetRoomInformation(room_information.name, room_information.description,
+ room_information.port, room_information.member_slots,
+ Network::network_version, room->HasPassword(),
+ room_information.preferred_game);
backend->ClearPlayers();
for (const auto& member : memberlist) {
backend->AddPlayer(member);
diff --git a/src/network/room.cpp b/src/network/room.cpp
index fe55d194c..22491b299 100644
--- a/src/network/room.cpp
+++ b/src/network/room.cpp
@@ -811,7 +811,7 @@ void Room::RoomImpl::BroadcastRoomInformation() {
packet << room_information.description;
packet << room_information.member_slots;
packet << room_information.port;
- packet << room_information.preferred_game;
+ packet << room_information.preferred_game.name;
packet << room_information.host_username;
packet << static_cast<u32>(members.size());
@@ -1013,7 +1013,7 @@ Room::~Room() = default;
bool Room::Create(const std::string& name, const std::string& description,
const std::string& server_address, u16 server_port, const std::string& password,
const u32 max_connections, const std::string& host_username,
- const std::string& preferred_game, u64 preferred_game_id,
+ const GameInfo preferred_game,
std::unique_ptr<VerifyUser::Backend> verify_backend,
const Room::BanList& ban_list, bool enable_yuzu_mods) {
ENetAddress address;
@@ -1036,7 +1036,6 @@ bool Room::Create(const std::string& name, const std::string& description,
room_impl->room_information.member_slots = max_connections;
room_impl->room_information.port = server_port;
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_yuzu_mods = enable_yuzu_mods;
room_impl->password = password;
@@ -1076,8 +1075,7 @@ std::vector<Member> Room::GetRoomMemberList() const {
member.display_name = member_impl.user_data.display_name;
member.avatar_url = member_impl.user_data.avatar_url;
member.mac_address = member_impl.mac_address;
- member.game_name = member_impl.game_info.name;
- member.game_id = member_impl.game_info.id;
+ member.game = member_impl.game_info;
member_list.push_back(member);
}
return member_list;
diff --git a/src/network/room.h b/src/network/room.h
index f282a5ac3..90a82563f 100644
--- a/src/network/room.h
+++ b/src/network/room.h
@@ -125,8 +125,7 @@ public:
const std::string& server = "", u16 server_port = DefaultRoomPort,
const std::string& password = "",
const u32 max_connections = MaxConcurrentConnections,
- const std::string& host_username = "", const std::string& preferred_game = "",
- u64 preferred_game_id = 0,
+ const std::string& host_username = "", const GameInfo = {},
std::unique_ptr<VerifyUser::Backend> verify_backend = nullptr,
const BanList& ban_list = {}, bool enable_yuzu_mods = false);
diff --git a/src/network/room_member.cpp b/src/network/room_member.cpp
index d6ace9b39..11a2e276e 100644
--- a/src/network/room_member.cpp
+++ b/src/network/room_member.cpp
@@ -303,7 +303,7 @@ void RoomMember::RoomMemberImpl::HandleRoomInformationPacket(const ENetEvent* ev
packet >> info.description;
packet >> info.member_slots;
packet >> info.port;
- packet >> info.preferred_game;
+ packet >> info.preferred_game.name;
packet >> info.host_username;
room_information.name = info.name;
room_information.description = info.description;
diff --git a/src/web_service/announce_room_json.cpp b/src/web_service/announce_room_json.cpp
index 84220b851..082bebaa9 100644
--- a/src/web_service/announce_room_json.cpp
+++ b/src/web_service/announce_room_json.cpp
@@ -19,14 +19,14 @@ static void to_json(nlohmann::json& json, const Member& member) {
if (!member.avatar_url.empty()) {
json["avatarUrl"] = member.avatar_url;
}
- json["gameName"] = member.game_name;
- json["gameId"] = member.game_id;
+ json["gameName"] = member.game.name;
+ json["gameId"] = member.game.id;
}
static void from_json(const nlohmann::json& json, 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>();
+ member.game.name = json.at("gameName").get<std::string>();
+ member.game.id = json.at("gameId").get<u64>();
try {
member.username = json.at("username").get<std::string>();
member.avatar_url = json.at("avatarUrl").get<std::string>();
@@ -42,8 +42,8 @@ static void to_json(nlohmann::json& json, const Room& room) {
if (!room.information.description.empty()) {
json["description"] = room.information.description;
}
- json["preferredGameName"] = room.information.preferred_game;
- json["preferredGameId"] = room.information.preferred_game_id;
+ json["preferredGameName"] = room.information.preferred_game.name;
+ json["preferredGameId"] = room.information.preferred_game.id;
json["maxPlayers"] = room.information.member_slots;
json["netVersion"] = room.net_version;
json["hasPassword"] = room.has_password;
@@ -65,8 +65,8 @@ static void from_json(const nlohmann::json& json, Room& room) {
}
room.information.host_username = json.at("owner").get<std::string>();
room.information.port = json.at("port").get<u16>();
- room.information.preferred_game = json.at("preferredGameName").get<std::string>();
- room.information.preferred_game_id = json.at("preferredGameId").get<u64>();
+ room.information.preferred_game.name = json.at("preferredGameName").get<std::string>();
+ room.information.preferred_game.id = json.at("preferredGameId").get<u64>();
room.information.member_slots = json.at("maxPlayers").get<u32>();
room.net_version = json.at("netVersion").get<u32>();
room.has_password = json.at("hasPassword").get<bool>();
@@ -83,8 +83,8 @@ namespace WebService {
void RoomJson::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 std::string& preferred_game,
- const u64 preferred_game_id) {
+ const bool has_password,
+ const AnnounceMultiplayerRoom::GameInfo& preferred_game) {
room.information.name = name;
room.information.description = description;
room.information.port = port;
@@ -92,7 +92,6 @@ void RoomJson::SetRoomInformation(const std::string& name, const std::string& de
room.net_version = net_version;
room.has_password = has_password;
room.information.preferred_game = preferred_game;
- room.information.preferred_game_id = preferred_game_id;
}
void RoomJson::AddPlayer(const AnnounceMultiplayerRoom::Member& member) {
room.members.push_back(member);
diff --git a/src/web_service/announce_room_json.h b/src/web_service/announce_room_json.h
index 811c76fbd..24ec29c65 100644
--- a/src/web_service/announce_room_json.h
+++ b/src/web_service/announce_room_json.h
@@ -22,8 +22,7 @@ public:
~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,
- const std::string& preferred_game,
- const u64 preferred_game_id) override;
+ const AnnounceMultiplayerRoom::GameInfo& preferred_game) override;
void AddPlayer(const AnnounceMultiplayerRoom::Member& member) override;
WebResult Update() override;
WebResult Register() override;
diff --git a/src/web_service/verify_user_jwt.h b/src/web_service/verify_user_jwt.h
index 826e01eed..6db74c208 100644
--- a/src/web_service/verify_user_jwt.h
+++ b/src/web_service/verify_user_jwt.h
@@ -10,6 +10,8 @@
namespace WebService {
+std::string GetPublicKey(const std::string& host);
+
class VerifyUserJWT final : public Network::VerifyUser::Backend {
public:
VerifyUserJWT(const std::string& host);
diff --git a/src/yuzu/multiplayer/host_room.cpp b/src/yuzu/multiplayer/host_room.cpp
index 5470b8b86..053e22fe4 100644
--- a/src/yuzu/multiplayer/host_room.cpp
+++ b/src/yuzu/multiplayer/host_room.cpp
@@ -132,21 +132,24 @@ void HostRoomWindow::Host() {
}
ui->host->setDisabled(true);
- auto game_name = ui->game_list->currentData(Qt::DisplayRole).toString();
- auto game_id = ui->game_list->currentData(GameListItemPath::ProgramIdRole).toLongLong();
- auto port = ui->port->isModified() ? ui->port->text().toInt() : Network::DefaultRoomPort;
- auto password = ui->password->text().toStdString();
+ const AnnounceMultiplayerRoom::GameInfo game{
+ .name = ui->game_list->currentData(Qt::DisplayRole).toString().toStdString(),
+ .id = ui->game_list->currentData(GameListItemPath::ProgramIdRole).toULongLong(),
+ };
+ const auto port =
+ ui->port->isModified() ? ui->port->text().toInt() : Network::DefaultRoomPort;
+ const auto password = ui->password->text().toStdString();
const bool is_public = ui->host_type->currentIndex() == 0;
Network::Room::BanList ban_list{};
if (ui->load_ban_list->isChecked()) {
ban_list = UISettings::values.multiplayer_ban_list;
}
if (auto room = Network::GetRoom().lock()) {
- bool created = room->Create(
- ui->room_name->text().toStdString(),
- ui->room_description->toPlainText().toStdString(), "", port, password,
- ui->max_player->value(), Settings::values.yuzu_username.GetValue(),
- game_name.toStdString(), game_id, CreateVerifyBackend(is_public), ban_list);
+ const bool created =
+ room->Create(ui->room_name->text().toStdString(),
+ ui->room_description->toPlainText().toStdString(), "", port, password,
+ ui->max_player->value(), Settings::values.yuzu_username.GetValue(),
+ game, CreateVerifyBackend(is_public), ban_list);
if (!created) {
NetworkMessage::ErrorManager::ShowError(
NetworkMessage::ErrorManager::COULD_NOT_CREATE_ROOM);
diff --git a/src/yuzu/multiplayer/lobby.cpp b/src/yuzu/multiplayer/lobby.cpp
index 6cc5f8f7e..1b6b782d9 100644
--- a/src/yuzu/multiplayer/lobby.cpp
+++ b/src/yuzu/multiplayer/lobby.cpp
@@ -214,7 +214,7 @@ void Lobby::OnRefreshLobby() {
for (int r = 0; r < game_list->rowCount(); ++r) {
auto index = game_list->index(r, 0);
auto game_id = game_list->data(index, GameListItemPath::ProgramIdRole).toULongLong();
- if (game_id != 0 && room.information.preferred_game_id == game_id) {
+ if (game_id != 0 && room.information.preferred_game.id == game_id) {
smdh_icon = game_list->data(index, Qt::DecorationRole).value<QPixmap>();
}
}
@@ -223,8 +223,8 @@ void Lobby::OnRefreshLobby() {
for (auto member : room.members) {
QVariant var;
var.setValue(LobbyMember{QString::fromStdString(member.username),
- QString::fromStdString(member.nickname), member.game_id,
- QString::fromStdString(member.game_name)});
+ QString::fromStdString(member.nickname), member.game.id,
+ QString::fromStdString(member.game.name)});
members.append(var);
}
@@ -232,8 +232,9 @@ void Lobby::OnRefreshLobby() {
auto row = QList<QStandardItem*>({
first_item,
new LobbyItemName(room.has_password, QString::fromStdString(room.information.name)),
- new LobbyItemGame(room.information.preferred_game_id,
- QString::fromStdString(room.information.preferred_game), smdh_icon),
+ new LobbyItemGame(room.information.preferred_game.id,
+ QString::fromStdString(room.information.preferred_game.name),
+ smdh_icon),
new LobbyItemHost(QString::fromStdString(room.information.host_username),
QString::fromStdString(room.ip), room.information.port,
QString::fromStdString(room.verify_UID)),
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h
index 83a6cffa3..6cd4d6cb2 100644
--- a/src/yuzu/uisettings.h
+++ b/src/yuzu/uisettings.h
@@ -105,12 +105,12 @@ struct Values {
// multiplayer settings
Settings::Setting<QString> multiplayer_nickname{QStringLiteral("yuzu"), "nickname"};
Settings::Setting<QString> multiplayer_ip{{}, "ip"};
- Settings::SwitchableSetting<uint> multiplayer_port{24872, 0, 65535, "port"};
+ Settings::SwitchableSetting<uint, true> multiplayer_port{24872, 0, 65535, "port"};
Settings::Setting<QString> multiplayer_room_nickname{{}, "room_nickname"};
Settings::Setting<QString> multiplayer_room_name{{}, "room_name"};
- Settings::SwitchableSetting<uint> multiplayer_max_player{8, 0, 8, "max_player"};
- Settings::SwitchableSetting<uint> multiplayer_room_port{24872, 0, 65535, "room_port"};
- Settings::SwitchableSetting<uint> multiplayer_host_type{0, 0, 1, "host_type"};
+ Settings::SwitchableSetting<uint, true> multiplayer_max_player{8, 0, 8, "max_player"};
+ Settings::SwitchableSetting<uint, true> multiplayer_room_port{24872, 0, 65535, "room_port"};
+ Settings::SwitchableSetting<uint, true> multiplayer_host_type{0, 0, 1, "host_type"};
Settings::Setting<qulonglong> multiplayer_game_id{{}, "game_id"};
Settings::Setting<QString> multiplayer_room_description{{}, "room_description"};
std::pair<std::vector<std::string>, std::vector<std::string>> multiplayer_ban_list;