VERY experimental Nintendo Switch 2 emulator
C++
Address a bunch of review comments
fearlessTobifb46c8b4267b
diff --git a/src/common/web_result.h b/src/common/web_result.hindex 13610a7ead..9699266740 100644--- a/src/common/web_result.h+++ b/src/common/web_result.h@@ -21,4 +21,4 @@ struct WebResult {std::string result_string;std::string returned_data;};-} // namespace Commo\ No newline at end of file+} // namespace Commondiff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cppindex 09c85297ad..c02188adcb 100644--- a/src/core/telemetry_session.cpp+++ b/src/core/telemetry_session.cpp@@ -28,11 +28,12 @@ static u64 GenerateTelemetryId() {mbedtls_entropy_context entropy;mbedtls_entropy_init(&entropy);mbedtls_ctr_drbg_context ctr_drbg;- const char* personalization = "yuzu Telemetry ID";+ std::string personalization = "yuzu Telemetry ID";mbedtls_ctr_drbg_init(&ctr_drbg);- mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,- (const unsigned char*)personalization, strlen(personalization));+ ASSERT(mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,+ reinterpret_cast<const unsigned char*>(personalization.c_str()),+ personalization.size()) == 0)ASSERT(mbedtls_ctr_drbg_random(&ctr_drbg, reinterpret_cast<unsigned char*>(&telemetry_id),sizeof(u64)) == 0);@@ -88,7 +89,7 @@ u64 RegenerateTelemetryId() {return new_telemetry_id;}-bool VerifyLogin(std::string username, std::string token) {+bool VerifyLogin(const std::string& username, const std::string& token) {#ifdef ENABLE_WEB_SERVICEreturn WebService::VerifyLogin(Settings::values.web_api_url, username, token);#else@@ -120,7 +121,7 @@ TelemetrySession::TelemetrySession() {u64 program_id{};const Loader::ResultStatus res{System::GetInstance().GetAppLoader().ReadProgramId(program_id)};if (res == Loader::ResultStatus::Success) {- std::string formatted_program_id{fmt::format("{:016X}", program_id)};+ const std::string formatted_program_id{fmt::format("{:016X}", program_id)};AddField(Telemetry::FieldType::Session, "ProgramId", formatted_program_id);std::string name;diff --git a/src/core/telemetry_session.h b/src/core/telemetry_session.hindex e6976ad45b..cec271df05 100644--- a/src/core/telemetry_session.h+++ b/src/core/telemetry_session.h@@ -56,6 +56,6 @@ u64 RegenerateTelemetryId();* @param func A function that gets exectued when the verification is finished* @returns Future with bool indicating whether the verification succeeded*/-bool VerifyLogin(std::string username, std::string token);+bool VerifyLogin(const std::string& username, const std::string& token);} // namespace Corediff --git a/src/web_service/telemetry_json.cpp b/src/web_service/telemetry_json.cppindex a0b7f9c4ea..033ea1ea4f 100644--- a/src/web_service/telemetry_json.cpp+++ b/src/web_service/telemetry_json.cpp@@ -10,6 +10,11 @@namespace WebService {+TelemetryJson::TelemetryJson(const std::string& host, const std::string& username,+ const std::string& token)+ : host(std::move(host)), username(std::move(username)), token(std::move(token)) {}+TelemetryJson::~TelemetryJson() = default;+template <class T>void TelemetryJson::Serialize(Telemetry::FieldType type, const std::string& name, T value) {sections[static_cast<u8>(type)][name] = value;diff --git a/src/web_service/telemetry_json.h b/src/web_service/telemetry_json.hindex 9bc886538b..29d5659649 100644--- a/src/web_service/telemetry_json.h+++ b/src/web_service/telemetry_json.h@@ -18,9 +18,8 @@ namespace WebService {*/class TelemetryJson : public Telemetry::VisitorInterface {public:- TelemetryJson(const std::string& host, const std::string& username, const std::string& token)- : host(host), username(username), token(token) {}- ~TelemetryJson() = default;+ TelemetryJson(const std::string& host, const std::string& username, const std::string& token);+ ~TelemetryJson();void Visit(const Telemetry::Field<bool>& field) override;void Visit(const Telemetry::Field<double>& field) override;diff --git a/src/web_service/web_backend.cpp b/src/web_service/web_backend.cppindex a726fb8eb5..3a3f44dc29 100644--- a/src/web_service/web_backend.cpp+++ b/src/web_service/web_backend.cpp@@ -13,12 +13,12 @@namespace WebService {-static constexpr char API_VERSION[]{"1"};+constexpr char API_VERSION[]{"1"};-constexpr int HTTP_PORT = 80;-constexpr int HTTPS_PORT = 443;+constexpr u32 HTTP_PORT = 80;+constexpr u32 HTTPS_PORT = 443;-constexpr int TIMEOUT_SECONDS = 30;+constexpr u32 TIMEOUT_SECONDS = 30;Client::JWTCache Client::jwt_cache{};diff --git a/src/yuzu/compatdb.cpp b/src/yuzu/compatdb.cppindex 45f8b4461b..91e7542743 100644--- a/src/yuzu/compatdb.cpp+++ b/src/yuzu/compatdb.cpp@@ -27,7 +27,11 @@ CompatDB::CompatDB(QWidget* parent)CompatDB::~CompatDB() = default;-enum class CompatDBPage { Intro = 0, Selection = 1, Final = 2 };+enum class CompatDBPage {+ Intro = 0,+ Selection = 1,+ Final = 2,+};void CompatDB::Submit() {QButtonGroup* compatibility = new QButtonGroup(this);diff --git a/src/yuzu/compatdb.h b/src/yuzu/compatdb.hindex 0a0f27cca5..ca0dd11d61 100644--- a/src/yuzu/compatdb.h+++ b/src/yuzu/compatdb.h@@ -21,7 +21,6 @@ public:private:std::unique_ptr<Ui::CompatDB> ui;-private slots:void Submit();void EnableNext();};diff --git a/src/yuzu/configuration/configure_web.cpp b/src/yuzu/configuration/configure_web.cppindex cfca080147..4b5c39e26a 100644--- a/src/yuzu/configuration/configure_web.cpp+++ b/src/yuzu/configuration/configure_web.cpp@@ -25,7 +25,7 @@ ConfigureWeb::ConfigureWeb(QWidget* parent)this->setConfiguration();}-ConfigureWeb::~ConfigureWeb() {}+ConfigureWeb::~ConfigureWeb() = default;void ConfigureWeb::setConfiguration() {ui->web_credentials_disclaimer->setWordWrap(true);diff --git a/src/yuzu/discord_impl.h b/src/yuzu/discord_impl.hindex d71428c109..4bfda8cdf6 100644--- a/src/yuzu/discord_impl.h+++ b/src/yuzu/discord_impl.h@@ -11,7 +11,7 @@ namespace DiscordRPC {class DiscordImpl : public DiscordInterface {public:DiscordImpl();- ~DiscordImpl();+ ~DiscordImpl() override;void Pause() override;void Update() override;diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cppindex 2d6e0d4fc1..f236c63c5f 100644--- a/src/yuzu/main.cpp+++ b/src/yuzu/main.cpp@@ -115,7 +115,7 @@ void GMainWindow::ShowTelemetryCallout() {}UISettings::values.callout_flags |= static_cast<uint32_t>(CalloutFlag::Telemetry);- static const QString telemetry_message =+ const QString telemetry_message =tr("<a href='https://citra-emu.org/entry/telemetry-and-why-thats-a-good-thing/'>Anonymous ""data is collected</a> to help improve yuzu. ""<br/><br/>Would you like to share your usage data with us?");