From 8e6c20dc992aefc34e48d8f6d7d0f9ef3e7c0a7a Mon Sep 17 00:00:00 2001 From: 0xf8 <0xf8.dev@proton.me> Date: Tue, 20 Jun 2023 15:08:02 -0400 Subject: [PATCH] Fix the various different bugs i initially created --- launcher/minecraft/MinecraftInstance.cpp | 2 +- launcher/minecraft/auth/AccountData.cpp | 2 +- launcher/minecraft/auth/AccountData.h | 2 +- launcher/minecraft/auth/MinecraftAccount.cpp | 2 +- launcher/minecraft/auth/MinecraftAccount.h | 6 +++--- launcher/minecraft/auth/flows/Custom.cpp | 10 ++++++---- launcher/minecraft/auth/flows/Custom.h | 8 ++++---- launcher/minecraft/auth/steps/CustomProfileStep.cpp | 2 +- launcher/minecraft/auth/steps/CustomStep.cpp | 6 +++++- launcher/minecraft/auth/steps/CustomStep.h | 5 ++++- launcher/minecraft/launch/InjectAuthlib.h | 2 +- 11 files changed, 28 insertions(+), 19 deletions(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index a42189c9..cbd29ab0 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -1035,7 +1035,7 @@ shared_qobject_ptr MinecraftInstance::createLaunchTask(AuthSessionPt } else if (session->user_type == "custom") { - process->appendStep(makeShared(pptr, &m_injector, session.url)); + process->appendStep(makeShared(pptr, &m_injector, session->url)); } process->appendStep(makeShared(pptr, Net::Mode::Online)); diff --git a/launcher/minecraft/auth/AccountData.cpp b/launcher/minecraft/auth/AccountData.cpp index c5aeee63..066118be 100644 --- a/launcher/minecraft/auth/AccountData.cpp +++ b/launcher/minecraft/auth/AccountData.cpp @@ -355,7 +355,7 @@ bool AccountData::resumeStateFromV3(QJsonObject data) { } else if (typeS == "Elyby") { type = AccountType::Elyby; } else if (typeS == "Custom") { - type = AccountType::Custom + type = AccountType::Custom; } else { qWarning() << "Failed to parse account data: type is not recognized."; return false; diff --git a/launcher/minecraft/auth/AccountData.h b/launcher/minecraft/auth/AccountData.h index 895899a0..f571214b 100644 --- a/launcher/minecraft/auth/AccountData.h +++ b/launcher/minecraft/auth/AccountData.h @@ -115,7 +115,7 @@ struct AccountData { QString lastError() const; - QString customUrl const; + QString customUrl; AccountType type = AccountType::MSA; bool legacy = false; diff --git a/launcher/minecraft/auth/MinecraftAccount.cpp b/launcher/minecraft/auth/MinecraftAccount.cpp index 85a387e4..d8b14317 100644 --- a/launcher/minecraft/auth/MinecraftAccount.cpp +++ b/launcher/minecraft/auth/MinecraftAccount.cpp @@ -200,7 +200,7 @@ shared_qobject_ptr MinecraftAccount::loginElyby(QString password) { shared_qobject_ptr MinecraftAccount::loginCustom(QString password, QString url) { Q_ASSERT(m_currentTask.get() == nullptr); - m_currentTask.reset(new customLogin(&data, password, url)); + m_currentTask.reset(new CustomLogin(&data, password, url)); connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded())); connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString))); connect(m_currentTask.get(), &Task::aborted, this, [this]{ authFailed(tr("Aborted")); }); diff --git a/launcher/minecraft/auth/MinecraftAccount.h b/launcher/minecraft/auth/MinecraftAccount.h index 3bb50c5e..eea8f60f 100644 --- a/launcher/minecraft/auth/MinecraftAccount.h +++ b/launcher/minecraft/auth/MinecraftAccount.h @@ -150,8 +150,8 @@ public: /* queries */ return data.profileName(); } - qString customUrl() const { - return data.customUrl(); + QString customUrl() const { + return data.customUrl; } bool isActive() const; @@ -209,7 +209,7 @@ public: /* queries */ return "elyby"; } break; - case AccountType::Custom { + case AccountType::Custom: { return "custom"; } break; diff --git a/launcher/minecraft/auth/flows/Custom.cpp b/launcher/minecraft/auth/flows/Custom.cpp index 2b9b7654..01047fd6 100644 --- a/launcher/minecraft/auth/flows/Custom.cpp +++ b/launcher/minecraft/auth/flows/Custom.cpp @@ -4,7 +4,7 @@ #include "minecraft/auth/steps/CustomProfileStep.h" #include "minecraft/auth/steps/GetSkinStep.h" -customRefresh::customRefresh( +CustomRefresh::CustomRefresh( AccountData *data, QObject *parent ) : AuthFlow(data, parent) { @@ -13,13 +13,15 @@ customRefresh::customRefresh( m_steps.append(makeShared(m_data)); } -customLogin::customLogin( +CustomLogin::CustomLogin( AccountData *data, QString password, QString url, QObject *parent -): AuthFlow(data, parent), m_password(password), m_url(url) { - m_steps.append(makeShared(m_data, m_password, m_url)); +): AuthFlow(data, parent), m_password(password) { + auto step = makeShared(m_data, m_password); + step.get()->setUrl(url); + m_steps.append(step); m_steps.append(makeShared(m_data)); m_steps.append(makeShared(m_data)); } diff --git a/launcher/minecraft/auth/flows/Custom.h b/launcher/minecraft/auth/flows/Custom.h index 01c0f2f5..95d4ac97 100644 --- a/launcher/minecraft/auth/flows/Custom.h +++ b/launcher/minecraft/auth/flows/Custom.h @@ -1,21 +1,21 @@ #pragma once #include "AuthFlow.h" -class customRefresh : public AuthFlow +class CustomRefresh : public AuthFlow { Q_OBJECT public: - explicit customRefresh( + explicit CustomRefresh( AccountData *data, QObject *parent = 0 ); }; -class customLogin : public AuthFlow +class CustomLogin : public AuthFlow { Q_OBJECT public: - explicit customLogin( + explicit CustomLogin( AccountData *data, QString password, QString url, diff --git a/launcher/minecraft/auth/steps/CustomProfileStep.cpp b/launcher/minecraft/auth/steps/CustomProfileStep.cpp index 496a4a7a..d7cd8cbd 100644 --- a/launcher/minecraft/auth/steps/CustomProfileStep.cpp +++ b/launcher/minecraft/auth/steps/CustomProfileStep.cpp @@ -24,7 +24,7 @@ void CustomProfileStep::perform() { // m_data-> - QUrl url = QUrl(m_data.customUrl + "/session/profile/" + m_data->minecraftProfile.id); + QUrl url = QUrl(m_data->customUrl + "/session/profile/" + m_data->minecraftProfile.id); QNetworkRequest req = QNetworkRequest(url); AuthRequest *request = new AuthRequest(this); connect(request, &AuthRequest::finished, this, &CustomProfileStep::onRequestDone); diff --git a/launcher/minecraft/auth/steps/CustomStep.cpp b/launcher/minecraft/auth/steps/CustomStep.cpp index 54298ed9..3592a41e 100644 --- a/launcher/minecraft/auth/steps/CustomStep.cpp +++ b/launcher/minecraft/auth/steps/CustomStep.cpp @@ -4,7 +4,7 @@ #include "minecraft/auth/Parsers.h" #include "minecraft/auth/Yggdrasil.h" -CustomStep::CustomStep(AccountData* data, QString password, QString url) : AuthStep(data), m_password(password), m_url(url) { +CustomStep::CustomStep(AccountData* data, QString password) : AuthStep(data), m_password(password) { m_yggdrasil = new Yggdrasil(m_data, this); connect(m_yggdrasil, &Task::failed, this, &CustomStep::onAuthFailed); @@ -31,6 +31,10 @@ void CustomStep::perform() { } } +void CustomStep::setUrl(QString url) { + this->m_url = url; +} + void CustomStep::onAuthSucceeded() { emit finished(AccountTaskState::STATE_WORKING, tr("Logged in with Custom")); } diff --git a/launcher/minecraft/auth/steps/CustomStep.h b/launcher/minecraft/auth/steps/CustomStep.h index bff05e44..746398bd 100644 --- a/launcher/minecraft/auth/steps/CustomStep.h +++ b/launcher/minecraft/auth/steps/CustomStep.h @@ -10,7 +10,7 @@ class CustomStep : public AuthStep { Q_OBJECT public: - explicit CustomStep(AccountData *data, QString password, QString url); + explicit CustomStep(AccountData *data, QString password); virtual ~CustomStep() noexcept; void perform() override; @@ -18,6 +18,8 @@ public: QString describe() override; + void setUrl(QString url); + private slots: void onAuthSucceeded(); void onAuthFailed(); @@ -25,4 +27,5 @@ private slots: private: Yggdrasil *m_yggdrasil = nullptr; QString m_password; + QString m_url; }; diff --git a/launcher/minecraft/launch/InjectAuthlib.h b/launcher/minecraft/launch/InjectAuthlib.h index 260b00df..9dde82c6 100644 --- a/launcher/minecraft/launch/InjectAuthlib.h +++ b/launcher/minecraft/launch/InjectAuthlib.h @@ -40,7 +40,7 @@ class InjectAuthlib : public LaunchStep { Q_OBJECT public: - InjectAuthlib(LaunchTask *parent, AuthlibInjectorPtr *injector); + InjectAuthlib(LaunchTask *parent, AuthlibInjectorPtr *injector, QString url); virtual ~InjectAuthlib(){}; void executeTask() override;