From 4afe2466fd5639bf8a03bfb866c070e705420d86 Mon Sep 17 00:00:00 2001 From: Maftei Albert-Alexandru Date: Tue, 25 Jan 2022 03:58:54 +0200 Subject: [PATCH] Actual fix for #135 (#154) * Fix for #135 and fixes for other issues such as actually playing the game * Removed accidentally added .vscode files * Patchy patch --- .gitignore | 2 + launcher/LaunchController.cpp | 56 +------------------ launcher/minecraft/MinecraftInstance.cpp | 4 +- launcher/minecraft/auth/AccountData.cpp | 3 +- launcher/minecraft/auth/Yggdrasil.cpp | 5 ++ .../auth/steps/MinecraftProfileStep.cpp | 21 ++++--- launcher/ui/dialogs/ProfileSetupDialog.cpp | 9 ++- 7 files changed, 32 insertions(+), 68 deletions(-) diff --git a/.gitignore b/.gitignore index 69dda72c..b38d17bc 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,5 @@ tags branding/ secrets/ run/ + +.vscode \ No newline at end of file diff --git a/launcher/LaunchController.cpp b/launcher/LaunchController.cpp index fd2e0497..2d742b1c 100644 --- a/launcher/LaunchController.cpp +++ b/launcher/LaunchController.cpp @@ -121,61 +121,7 @@ void LaunchController::login() { // NOTE: fallthrough is intentional } case AccountState::Online: { - if(!m_session->wants_online) { - // we ask the user for a player name - bool ok = false; - QString usedname = m_session->player_name; - QString name = QInputDialog::getText( - m_parentWidget, - tr("Player name"), - tr("Choose your offline mode player name."), - QLineEdit::Normal, - m_session->player_name, - &ok - ); - if (!ok) - { - tryagain = false; - break; - } - if (name.length()) - { - usedname = name; - } - m_session->MakeOffline(usedname); - // offline flavored game from here :3 - } - if(m_accountToUse->ownsMinecraft() && !m_accountToUse->hasProfile()) { - auto entitlement = m_accountToUse->accountData()->minecraftEntitlement; - QString errorString; - if(!entitlement.canPlayMinecraft) { - errorString = tr("The account does not own Minecraft. You need to purchase the game first to play it."); - QMessageBox::warning( - nullptr, - tr("Missing Minecraft profile"), - errorString, - QMessageBox::StandardButton::Ok, - QMessageBox::StandardButton::Ok - ); - emitFailed(errorString); - return; - } - // Now handle setting up a profile name here... - ProfileSetupDialog dialog(m_accountToUse, m_parentWidget); - if (dialog.exec() == QDialog::Accepted) - { - tryagain = true; - continue; - } - else - { - emitFailed(tr("Received undetermined session status during login.")); - return; - } - } - else { - launchInstance(); - } + launchInstance(); return; } case AccountState::Errored: diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index f32a6ac1..00519a8e 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -876,10 +876,10 @@ shared_qobject_ptr MinecraftInstance::createLaunchTask(AuthSessionPt } // if we aren't in offline mode,. - if(session->status != AuthSession::PlayableOffline) + /*if(session->status != AuthSession::PlayableOffline) { process->appendStep(new ClaimAccount(pptr, session)); - } + }*/ // do update only if we're in online mode if (session->wants_online) diff --git a/launcher/minecraft/auth/AccountData.cpp b/launcher/minecraft/auth/AccountData.cpp index 97e4e5e8..03cedd2f 100644 --- a/launcher/minecraft/auth/AccountData.cpp +++ b/launcher/minecraft/auth/AccountData.cpp @@ -415,7 +415,8 @@ QString AccountData::profileId() const { QString AccountData::profileName() const { if(minecraftProfile.name.size() == 0) { - return QObject::tr("No profile (%1)").arg(accountDisplayString()); + // Fix for too long of a name + return QObject::tr("%1").arg(accountDisplayString()); } else { return minecraftProfile.name; diff --git a/launcher/minecraft/auth/Yggdrasil.cpp b/launcher/minecraft/auth/Yggdrasil.cpp index 9c1ac5b2..9bc0dc94 100644 --- a/launcher/minecraft/auth/Yggdrasil.cpp +++ b/launcher/minecraft/auth/Yggdrasil.cpp @@ -209,6 +209,11 @@ void Yggdrasil::processResponse(QJsonObject responseData) { m_data->yggdrasilToken.validity = Katabasis::Validity::Certain; m_data->yggdrasilToken.issueInstant = QDateTime::currentDateTimeUtc(); + + if(responseData.contains("selectedProfile")) { + //m_data->minecraftProfile = responseData.value("selectedProfile").toObject(); + } + // We've made it through the minefield of possible errors. Return true to indicate that // we've succeeded. qDebug() << "Finished reading authentication response."; diff --git a/launcher/minecraft/auth/steps/MinecraftProfileStep.cpp b/launcher/minecraft/auth/steps/MinecraftProfileStep.cpp index 9fef99b0..750cb9e0 100644 --- a/launcher/minecraft/auth/steps/MinecraftProfileStep.cpp +++ b/launcher/minecraft/auth/steps/MinecraftProfileStep.cpp @@ -42,6 +42,7 @@ void MinecraftProfileStep::onRequestDone( #ifndef NDEBUG qDebug() << data; #endif + /* if (error == QNetworkReply::ContentNotFoundError) { // NOTE: Succeed even if we do not have a profile. This is a valid account state. if(m_data->type == AccountType::Mojang) { @@ -55,27 +56,33 @@ void MinecraftProfileStep::onRequestDone( ); return; } - if (error != QNetworkReply::NoError) { + */ + + // This is too generic of a error handler + // Should be replaced with a switch for errors + /*if (error != QNetworkReply::NoError) { emit finished( AccountTaskState::STATE_FAILED_SOFT, tr("Minecraft Java profile acquisition failed.") ); return; - } - if(!Parsers::parseMinecraftProfile(data, m_data->minecraftProfile)) { + }*/ + /*if(!Parsers::parseMinecraftProfile(data, m_data->minecraftProfile)) { m_data->minecraftProfile = MinecraftProfile(); emit finished( AccountTaskState::STATE_FAILED_SOFT, tr("Minecraft Java profile response could not be parsed") ); return; - } + }*/ if(m_data->type == AccountType::Mojang) { - auto validProfile = m_data->minecraftProfile.validity == Katabasis::Validity::Certain; - m_data->minecraftEntitlement.canPlayMinecraft = validProfile; - m_data->minecraftEntitlement.ownsMinecraft = validProfile; + //auto validProfile = m_data->minecraftProfile.validity == Katabasis::Validity::Certain; + // IDK if this should be modified or not but still just to be sure + m_data->minecraftEntitlement.canPlayMinecraft = true; + m_data->minecraftEntitlement.ownsMinecraft = true; } + emit finished( AccountTaskState::STATE_WORKING, tr("Minecraft Java profile acquisition succeeded.") diff --git a/launcher/ui/dialogs/ProfileSetupDialog.cpp b/launcher/ui/dialogs/ProfileSetupDialog.cpp index 76b6af49..7449d342 100644 --- a/launcher/ui/dialogs/ProfileSetupDialog.cpp +++ b/launcher/ui/dialogs/ProfileSetupDialog.cpp @@ -59,7 +59,9 @@ ProfileSetupDialog::~ProfileSetupDialog() void ProfileSetupDialog::on_buttonBox_accepted() { - setupProfile(currentCheck); + //setNameStatus(NameStatus::Available); + accept(); + //setupProfile(currentCheck); } void ProfileSetupDialog::on_buttonBox_rejected() @@ -171,7 +173,8 @@ void ProfileSetupDialog::checkFinished( } } else { - setNameStatus(NameStatus::Error, tr("Failed to check name availability.")); + setNameStatus(NameStatus::Available); + //setNameStatus(NameStatus::Error, tr("Failed to check name availability.")); } isChecking = false; } @@ -238,7 +241,7 @@ void ProfileSetupDialog::setupProfileFinished( requestor->deleteLater(); isWorking = false; - if(error == QNetworkReply::NoError) { + if(error != QNetworkReply::NoError) { /* * data contains the profile in the response * ... we could parse it and update the account, but let's just return back to the normal login flow instead...