Address review comments

This commit is contained in:
FearlessTobi 2022-08-28 19:31:16 +02:00
parent 6791301d9a
commit 65718e2876
11 changed files with 26 additions and 27 deletions

View File

@ -145,26 +145,19 @@ struct NetworkId {
static_assert(sizeof(NetworkId) == 0x20, "NetworkId is an invalid size"); static_assert(sizeof(NetworkId) == 0x20, "NetworkId is an invalid size");
struct Ssid { struct Ssid {
u8 length; u8 length{};
std::array<char, SsidLengthMax + 1> raw; std::array<char, SsidLengthMax + 1> raw{};
Ssid() { Ssid() = default;
length = 0;
std::memset(raw.data(), 0, raw.size());
}
Ssid(std::string data) { explicit Ssid(std::string_view data) {
length = static_cast<u8>(std::min(data.size(), SsidLengthMax)); length = static_cast<u8>(std::min(data.size(), SsidLengthMax));
std::memcpy(raw.data(), data.data(), length); data.copy(raw.data(), length);
raw[length] = 0; raw[length] = 0;
} }
std::string GetStringValue() const { std::string GetStringValue() const {
return std::string(raw.data(), length); return std::string(raw.data());
}
bool operator==(const Ssid& b) const {
return (length == b.length) && (std::memcmp(raw.data(), b.raw.data(), length) == 0);
} }
}; };
static_assert(sizeof(Ssid) == 0x22, "Ssid is an invalid size"); static_assert(sizeof(Ssid) == 0x22, "Ssid is an invalid size");

View File

@ -76,12 +76,7 @@ static constexpr char BanListMagic[] = "YuzuRoom-BanList-1";
static constexpr char token_delimiter{':'}; static constexpr char token_delimiter{':'};
static void PadToken(std::string& token) { static void PadToken(std::string& token) {
const auto remainder = token.size() % 3; while (token.size() % 4 != 0) {
if (remainder == 0) {
return;
}
for (size_t i = 0; i < (3 - remainder); i++) {
token.push_back('='); token.push_back('=');
} }
} }

View File

@ -154,9 +154,7 @@ public:
} }
const QString version = data(GameVersionRole).toString(); const QString version = data(GameVersionRole).toString();
QString version_string; QString version_string;
if (version.isEmpty()) { if (!version.isEmpty()) {
version_string = QString{};
} else {
version_string = QStringLiteral("(%1)").arg(version); version_string = QStringLiteral("(%1)").arg(version);
} }
return QStringLiteral("%1\n %2 %3") return QStringLiteral("%1\n %2 %3")

View File

@ -8,6 +8,7 @@
#include <QString> #include <QString>
#include <QtConcurrent/QtConcurrentRun> #include <QtConcurrent/QtConcurrentRun>
#include "common/settings.h" #include "common/settings.h"
#include "core/core.h"
#include "core/internal_network/network_interface.h" #include "core/internal_network/network_interface.h"
#include "network/network.h" #include "network/network.h"
#include "ui_direct_connect.h" #include "ui_direct_connect.h"

View File

@ -6,13 +6,16 @@
#include <memory> #include <memory>
#include <QDialog> #include <QDialog>
#include <QFutureWatcher> #include <QFutureWatcher>
#include "core/core.h"
#include "yuzu/multiplayer/validation.h" #include "yuzu/multiplayer/validation.h"
namespace Ui { namespace Ui {
class DirectConnect; class DirectConnect;
} }
namespace Core {
class System;
}
class DirectConnectWindow : public QDialog { class DirectConnectWindow : public QDialog {
Q_OBJECT Q_OBJECT

View File

@ -12,6 +12,7 @@
#include <QtConcurrent/QtConcurrentRun> #include <QtConcurrent/QtConcurrentRun>
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/settings.h" #include "common/settings.h"
#include "core/core.h"
#include "core/internal_network/network_interface.h" #include "core/internal_network/network_interface.h"
#include "network/announce_multiplayer_session.h" #include "network/announce_multiplayer_session.h"
#include "ui_host_room.h" #include "ui_host_room.h"

View File

@ -8,7 +8,6 @@
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QVariant> #include <QVariant>
#include "core/core.h"
#include "network/network.h" #include "network/network.h"
#include "yuzu/multiplayer/chat_room.h" #include "yuzu/multiplayer/chat_room.h"
#include "yuzu/multiplayer/validation.h" #include "yuzu/multiplayer/validation.h"
@ -18,8 +17,9 @@ class HostRoom;
} }
namespace Core { namespace Core {
class System;
class AnnounceMultiplayerSession; class AnnounceMultiplayerSession;
} } // namespace Core
class ConnectionError; class ConnectionError;
class ComboBoxProxyModel; class ComboBoxProxyModel;

View File

@ -6,6 +6,7 @@
#include <QtConcurrent/QtConcurrentRun> #include <QtConcurrent/QtConcurrentRun>
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/settings.h" #include "common/settings.h"
#include "core/core.h"
#include "core/internal_network/network_interface.h" #include "core/internal_network/network_interface.h"
#include "network/network.h" #include "network/network.h"
#include "ui_lobby.h" #include "ui_lobby.h"

View File

@ -9,7 +9,6 @@
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QStandardItemModel> #include <QStandardItemModel>
#include "common/announce_multiplayer_room.h" #include "common/announce_multiplayer_room.h"
#include "core/core.h"
#include "network/announce_multiplayer_session.h" #include "network/announce_multiplayer_session.h"
#include "network/network.h" #include "network/network.h"
#include "yuzu/multiplayer/validation.h" #include "yuzu/multiplayer/validation.h"
@ -21,6 +20,10 @@ class Lobby;
class LobbyModel; class LobbyModel;
class LobbyFilterProxyModel; class LobbyFilterProxyModel;
namespace Core {
class System;
}
/** /**
* Listing of all public games pulled from services. The lobby should be simple enough for users to * 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. * find the game they want to play, and join it.

View File

@ -8,6 +8,7 @@
#include <QStandardItemModel> #include <QStandardItemModel>
#include "common/announce_multiplayer_room.h" #include "common/announce_multiplayer_room.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/core.h"
#include "yuzu/game_list.h" #include "yuzu/game_list.h"
#include "yuzu/multiplayer/client_room.h" #include "yuzu/multiplayer/client_room.h"
#include "yuzu/multiplayer/direct_connect.h" #include "yuzu/multiplayer/direct_connect.h"

View File

@ -4,7 +4,6 @@
#pragma once #pragma once
#include <QWidget> #include <QWidget>
#include "core/core.h"
#include "network/announce_multiplayer_session.h" #include "network/announce_multiplayer_session.h"
#include "network/network.h" #include "network/network.h"
@ -15,6 +14,10 @@ class ClientRoomWindow;
class DirectConnectWindow; class DirectConnectWindow;
class ClickableLabel; class ClickableLabel;
namespace Core {
class System;
}
class MultiplayerState : public QWidget { class MultiplayerState : public QWidget {
Q_OBJECT; Q_OBJECT;