From 65718e2876374aecf2ac29856387dab4394ca47f Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Sun, 28 Aug 2022 19:31:16 +0200 Subject: Address review comments --- src/core/hle/service/ldn/ldn_types.h | 19 ++++++------------- src/dedicated_room/yuzu_room.cpp | 7 +------ src/yuzu/multiplayer/chat_room.cpp | 4 +--- src/yuzu/multiplayer/direct_connect.cpp | 1 + src/yuzu/multiplayer/direct_connect.h | 5 ++++- src/yuzu/multiplayer/host_room.cpp | 1 + src/yuzu/multiplayer/host_room.h | 4 ++-- src/yuzu/multiplayer/lobby.cpp | 1 + src/yuzu/multiplayer/lobby.h | 5 ++++- src/yuzu/multiplayer/state.cpp | 1 + src/yuzu/multiplayer/state.h | 5 ++++- 11 files changed, 26 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/core/hle/service/ldn/ldn_types.h b/src/core/hle/service/ldn/ldn_types.h index 0af653164..6231e936d 100644 --- a/src/core/hle/service/ldn/ldn_types.h +++ b/src/core/hle/service/ldn/ldn_types.h @@ -145,26 +145,19 @@ struct NetworkId { static_assert(sizeof(NetworkId) == 0x20, "NetworkId is an invalid size"); struct Ssid { - u8 length; - std::array raw; + u8 length{}; + std::array raw{}; - Ssid() { - length = 0; - std::memset(raw.data(), 0, raw.size()); - } + Ssid() = default; - Ssid(std::string data) { + explicit Ssid(std::string_view data) { length = static_cast(std::min(data.size(), SsidLengthMax)); - std::memcpy(raw.data(), data.data(), length); + data.copy(raw.data(), length); raw[length] = 0; } std::string GetStringValue() const { - return std::string(raw.data(), length); - } - - bool operator==(const Ssid& b) const { - return (length == b.length) && (std::memcmp(raw.data(), b.raw.data(), length) == 0); + return std::string(raw.data()); } }; static_assert(sizeof(Ssid) == 0x22, "Ssid is an invalid size"); diff --git a/src/dedicated_room/yuzu_room.cpp b/src/dedicated_room/yuzu_room.cpp index 173a53317..7b6deba41 100644 --- a/src/dedicated_room/yuzu_room.cpp +++ b/src/dedicated_room/yuzu_room.cpp @@ -76,12 +76,7 @@ static constexpr char BanListMagic[] = "YuzuRoom-BanList-1"; static constexpr char token_delimiter{':'}; static void PadToken(std::string& token) { - const auto remainder = token.size() % 3; - if (remainder == 0) { - return; - } - - for (size_t i = 0; i < (3 - remainder); i++) { + while (token.size() % 4 != 0) { token.push_back('='); } } diff --git a/src/yuzu/multiplayer/chat_room.cpp b/src/yuzu/multiplayer/chat_room.cpp index bddceb795..9e672f82e 100644 --- a/src/yuzu/multiplayer/chat_room.cpp +++ b/src/yuzu/multiplayer/chat_room.cpp @@ -154,9 +154,7 @@ public: } const QString version = data(GameVersionRole).toString(); QString version_string; - if (version.isEmpty()) { - version_string = QString{}; - } else { + if (!version.isEmpty()) { version_string = QStringLiteral("(%1)").arg(version); } return QStringLiteral("%1\n %2 %3") diff --git a/src/yuzu/multiplayer/direct_connect.cpp b/src/yuzu/multiplayer/direct_connect.cpp index 65b5f0b9d..017063074 100644 --- a/src/yuzu/multiplayer/direct_connect.cpp +++ b/src/yuzu/multiplayer/direct_connect.cpp @@ -8,6 +8,7 @@ #include #include #include "common/settings.h" +#include "core/core.h" #include "core/internal_network/network_interface.h" #include "network/network.h" #include "ui_direct_connect.h" diff --git a/src/yuzu/multiplayer/direct_connect.h b/src/yuzu/multiplayer/direct_connect.h index defa4f4ec..e39dd1e0d 100644 --- a/src/yuzu/multiplayer/direct_connect.h +++ b/src/yuzu/multiplayer/direct_connect.h @@ -6,13 +6,16 @@ #include #include #include -#include "core/core.h" #include "yuzu/multiplayer/validation.h" namespace Ui { class DirectConnect; } +namespace Core { +class System; +} + class DirectConnectWindow : public QDialog { Q_OBJECT diff --git a/src/yuzu/multiplayer/host_room.cpp b/src/yuzu/multiplayer/host_room.cpp index ad7dcc36d..0c6adfd04 100644 --- a/src/yuzu/multiplayer/host_room.cpp +++ b/src/yuzu/multiplayer/host_room.cpp @@ -12,6 +12,7 @@ #include #include "common/logging/log.h" #include "common/settings.h" +#include "core/core.h" #include "core/internal_network/network_interface.h" #include "network/announce_multiplayer_session.h" #include "ui_host_room.h" diff --git a/src/yuzu/multiplayer/host_room.h b/src/yuzu/multiplayer/host_room.h index 63c0d2333..034cb2eef 100644 --- a/src/yuzu/multiplayer/host_room.h +++ b/src/yuzu/multiplayer/host_room.h @@ -8,7 +8,6 @@ #include #include #include -#include "core/core.h" #include "network/network.h" #include "yuzu/multiplayer/chat_room.h" #include "yuzu/multiplayer/validation.h" @@ -18,8 +17,9 @@ class HostRoom; } namespace Core { +class System; class AnnounceMultiplayerSession; -} +} // namespace Core class ConnectionError; class ComboBoxProxyModel; diff --git a/src/yuzu/multiplayer/lobby.cpp b/src/yuzu/multiplayer/lobby.cpp index c5fb846c7..107d40547 100644 --- a/src/yuzu/multiplayer/lobby.cpp +++ b/src/yuzu/multiplayer/lobby.cpp @@ -6,6 +6,7 @@ #include #include "common/logging/log.h" #include "common/settings.h" +#include "core/core.h" #include "core/internal_network/network_interface.h" #include "network/network.h" #include "ui_lobby.h" diff --git a/src/yuzu/multiplayer/lobby.h b/src/yuzu/multiplayer/lobby.h index 49fd4c473..2696aec21 100644 --- a/src/yuzu/multiplayer/lobby.h +++ b/src/yuzu/multiplayer/lobby.h @@ -9,7 +9,6 @@ #include #include #include "common/announce_multiplayer_room.h" -#include "core/core.h" #include "network/announce_multiplayer_session.h" #include "network/network.h" #include "yuzu/multiplayer/validation.h" @@ -21,6 +20,10 @@ class Lobby; class LobbyModel; class LobbyFilterProxyModel; +namespace Core { +class System; +} + /** * Listing of all public games pulled from services. The lobby should be simple enough for users to * find the game they want to play, and join it. diff --git a/src/yuzu/multiplayer/state.cpp b/src/yuzu/multiplayer/state.cpp index d1a68b182..66e098296 100644 --- a/src/yuzu/multiplayer/state.cpp +++ b/src/yuzu/multiplayer/state.cpp @@ -8,6 +8,7 @@ #include #include "common/announce_multiplayer_room.h" #include "common/logging/log.h" +#include "core/core.h" #include "yuzu/game_list.h" #include "yuzu/multiplayer/client_room.h" #include "yuzu/multiplayer/direct_connect.h" diff --git a/src/yuzu/multiplayer/state.h b/src/yuzu/multiplayer/state.h index 3921f2fc3..c92496413 100644 --- a/src/yuzu/multiplayer/state.h +++ b/src/yuzu/multiplayer/state.h @@ -4,7 +4,6 @@ #pragma once #include -#include "core/core.h" #include "network/announce_multiplayer_session.h" #include "network/network.h" @@ -15,6 +14,10 @@ class ClientRoomWindow; class DirectConnectWindow; class ClickableLabel; +namespace Core { +class System; +} + class MultiplayerState : public QWidget { Q_OBJECT; -- cgit v1.2.3