aboutsummaryrefslogtreecommitdiff
path: root/launcher/minecraft
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/minecraft')
-rw-r--r--launcher/minecraft/AssetsUtils.cpp4
-rw-r--r--launcher/minecraft/MinecraftInstance.cpp14
-rw-r--r--launcher/minecraft/MinecraftInstance.h2
-rw-r--r--launcher/minecraft/OpSys.cpp4
-rw-r--r--launcher/minecraft/OpSys.h13
-rw-r--r--launcher/minecraft/auth/AccountData.cpp4
-rw-r--r--launcher/minecraft/auth/AccountData.h17
-rw-r--r--launcher/minecraft/auth/AccountList.cpp171
-rw-r--r--launcher/minecraft/auth/AccountList.h31
-rw-r--r--launcher/minecraft/auth/AccountTask.cpp75
-rw-r--r--launcher/minecraft/auth/AccountTask.h72
-rw-r--r--launcher/minecraft/auth/AuthRequest.cpp (renamed from launcher/minecraft/auth/flows/AuthRequest.cpp)10
-rw-r--r--launcher/minecraft/auth/AuthRequest.h (renamed from launcher/minecraft/auth/flows/AuthRequest.h)8
-rw-r--r--launcher/minecraft/auth/AuthSession.cpp5
-rw-r--r--launcher/minecraft/auth/AuthSession.h4
-rw-r--r--launcher/minecraft/auth/AuthStep.cpp7
-rw-r--r--launcher/minecraft/auth/AuthStep.h33
-rw-r--r--launcher/minecraft/auth/MinecraftAccount.cpp261
-rw-r--r--launcher/minecraft/auth/MinecraftAccount.h41
-rw-r--r--launcher/minecraft/auth/Parsers.cpp (renamed from launcher/minecraft/auth/flows/Parsers.cpp)6
-rw-r--r--launcher/minecraft/auth/Parsers.h (renamed from launcher/minecraft/auth/flows/Parsers.h)4
-rw-r--r--launcher/minecraft/auth/Yggdrasil.cpp (renamed from launcher/minecraft/auth/flows/Yggdrasil.cpp)34
-rw-r--r--launcher/minecraft/auth/Yggdrasil.h (renamed from launcher/minecraft/auth/flows/Yggdrasil.h)22
-rw-r--r--launcher/minecraft/auth/flows/AuthContext.cpp671
-rw-r--r--launcher/minecraft/auth/flows/AuthContext.h110
-rw-r--r--launcher/minecraft/auth/flows/AuthFlow.cpp71
-rw-r--r--launcher/minecraft/auth/flows/AuthFlow.h45
-rw-r--r--launcher/minecraft/auth/flows/MSA.cpp37
-rw-r--r--launcher/minecraft/auth/flows/MSA.h22
-rw-r--r--launcher/minecraft/auth/flows/MSAInteractive.cpp22
-rw-r--r--launcher/minecraft/auth/flows/MSAInteractive.h13
-rw-r--r--launcher/minecraft/auth/flows/MSASilent.cpp16
-rw-r--r--launcher/minecraft/auth/flows/MSASilent.h13
-rw-r--r--launcher/minecraft/auth/flows/Mojang.cpp27
-rw-r--r--launcher/minecraft/auth/flows/Mojang.h26
-rw-r--r--launcher/minecraft/auth/flows/MojangLogin.cpp18
-rw-r--r--launcher/minecraft/auth/flows/MojangLogin.h17
-rw-r--r--launcher/minecraft/auth/flows/MojangRefresh.cpp17
-rw-r--r--launcher/minecraft/auth/flows/MojangRefresh.h10
-rw-r--r--launcher/minecraft/auth/steps/EntitlementsStep.cpp53
-rw-r--r--launcher/minecraft/auth/steps/EntitlementsStep.h25
-rw-r--r--launcher/minecraft/auth/steps/GetSkinStep.cpp43
-rw-r--r--launcher/minecraft/auth/steps/GetSkinStep.h22
-rw-r--r--launcher/minecraft/auth/steps/LauncherLoginStep.cpp78
-rw-r--r--launcher/minecraft/auth/steps/LauncherLoginStep.h22
-rw-r--r--launcher/minecraft/auth/steps/MSAStep.cpp111
-rw-r--r--launcher/minecraft/auth/steps/MSAStep.h32
-rw-r--r--launcher/minecraft/auth/steps/MigrationEligibilityStep.cpp45
-rw-r--r--launcher/minecraft/auth/steps/MigrationEligibilityStep.h22
-rw-r--r--launcher/minecraft/auth/steps/MinecraftProfileStep.cpp91
-rw-r--r--launcher/minecraft/auth/steps/MinecraftProfileStep.h22
-rw-r--r--launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp158
-rw-r--r--launcher/minecraft/auth/steps/XboxAuthorizationStep.h34
-rw-r--r--launcher/minecraft/auth/steps/XboxProfileStep.cpp73
-rw-r--r--launcher/minecraft/auth/steps/XboxProfileStep.h22
-rw-r--r--launcher/minecraft/auth/steps/XboxUserStep.cpp68
-rw-r--r--launcher/minecraft/auth/steps/XboxUserStep.h22
-rw-r--r--launcher/minecraft/auth/steps/YggdrasilStep.cpp51
-rw-r--r--launcher/minecraft/auth/steps/YggdrasilStep.h28
-rw-r--r--launcher/minecraft/launch/ClaimAccount.cpp2
-rw-r--r--launcher/minecraft/launch/ExtractNatives.cpp7
-rw-r--r--launcher/minecraft/launch/PrintInstanceInfo.cpp45
-rw-r--r--launcher/minecraft/launch/VerifyJavaInstall.cpp7
-rw-r--r--launcher/minecraft/legacy/LegacyInstance.cpp10
-rw-r--r--launcher/minecraft/legacy/LegacyInstance.h6
-rw-r--r--launcher/minecraft/services/CapeChange.cpp8
-rw-r--r--launcher/minecraft/services/CapeChange.h5
-rw-r--r--launcher/minecraft/services/SkinDelete.cpp6
-rw-r--r--launcher/minecraft/services/SkinDelete.h6
-rw-r--r--launcher/minecraft/services/SkinUpload.cpp6
-rw-r--r--launcher/minecraft/services/SkinUpload.h5
-rw-r--r--launcher/minecraft/update/AssetUpdateTask.cpp9
-rw-r--r--launcher/minecraft/update/FMLLibrariesTask.cpp4
-rw-r--r--launcher/minecraft/update/LibrariesTask.cpp4
74 files changed, 1846 insertions, 1283 deletions
diff --git a/launcher/minecraft/AssetsUtils.cpp b/launcher/minecraft/AssetsUtils.cpp
index 1c65a212..7290aeb4 100644
--- a/launcher/minecraft/AssetsUtils.cpp
+++ b/launcher/minecraft/AssetsUtils.cpp
@@ -29,6 +29,8 @@
#include "net/ChecksumValidator.h"
#include "BuildConfig.h"
+#include "Application.h"
+
namespace {
QSet<QString> collectPathsFromDir(QString dirPath)
{
@@ -318,7 +320,7 @@ QString AssetObject::getRelPath()
NetJob::Ptr AssetsIndex::getDownloadJob()
{
- auto job = new NetJob(QObject::tr("Assets for %1").arg(id));
+ auto job = new NetJob(QObject::tr("Assets for %1").arg(id), APPLICATION->network());
for (auto &object : objects.values())
{
auto dl = object.getDownloadAction();
diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp
index 4c16e572..0b3c049b 100644
--- a/launcher/minecraft/MinecraftInstance.cpp
+++ b/launcher/minecraft/MinecraftInstance.cpp
@@ -202,7 +202,7 @@ QString MinecraftInstance::jarModsDir() const
return jarmods_dir.absolutePath();
}
-QString MinecraftInstance::loaderModsDir() const
+QString MinecraftInstance::modsRoot() const
{
return FS::PathCombine(gameRoot(), "mods");
}
@@ -431,8 +431,7 @@ QStringList MinecraftInstance::processMinecraftArgs(
QMap<QString, QString> token_mapping;
// yggdrasil!
- if(session)
- {
+ if(session) {
// token_mapping["auth_username"] = session->username;
token_mapping["auth_session"] = session->session;
token_mapping["auth_access_token"] = session->access_token;
@@ -440,6 +439,9 @@ QStringList MinecraftInstance::processMinecraftArgs(
token_mapping["auth_uuid"] = session->uuid;
token_mapping["user_properties"] = session->serializeUserProperties();
token_mapping["user_type"] = session->user_type;
+ if(session->demo) {
+ args_pattern += " --demo";
+ }
}
// blatant self-promotion.
@@ -872,7 +874,9 @@ shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPt
// if we aren't in offline mode,.
if(session->status != AuthSession::PlayableOffline)
{
- process->appendStep(new ClaimAccount(pptr, session));
+ if(!session->demo) {
+ process->appendStep(new ClaimAccount(pptr, session));
+ }
process->appendStep(new Update(pptr, Net::Mode::Online));
}
else
@@ -961,7 +965,7 @@ std::shared_ptr<ModFolderModel> MinecraftInstance::loaderModList() const
{
if (!m_loader_mod_list)
{
- m_loader_mod_list.reset(new ModFolderModel(loaderModsDir()));
+ m_loader_mod_list.reset(new ModFolderModel(modsRoot()));
m_loader_mod_list->disableInteraction(isRunning());
connect(this, &BaseInstance::runningStatusChanged, m_loader_mod_list.get(), &ModFolderModel::disableInteraction);
}
diff --git a/launcher/minecraft/MinecraftInstance.h b/launcher/minecraft/MinecraftInstance.h
index bb45f37b..fda58aa7 100644
--- a/launcher/minecraft/MinecraftInstance.h
+++ b/launcher/minecraft/MinecraftInstance.h
@@ -40,7 +40,7 @@ public:
QString resourcePacksDir() const;
QString texturePacksDir() const;
QString shaderPacksDir() const;
- QString loaderModsDir() const;
+ QString modsRoot() const override;
QString coreModsDir() const;
QString modsCacheLocation() const;
QString libDir() const;
diff --git a/launcher/minecraft/OpSys.cpp b/launcher/minecraft/OpSys.cpp
index f6a4ed1c..093ec419 100644
--- a/launcher/minecraft/OpSys.cpp
+++ b/launcher/minecraft/OpSys.cpp
@@ -17,6 +17,8 @@
OpSys OpSys_fromString(QString name)
{
+ if (name == "freebsd")
+ return Os_FreeBSD;
if (name == "linux")
return Os_Linux;
if (name == "windows")
@@ -30,6 +32,8 @@ QString OpSys_toString(OpSys name)
{
switch (name)
{
+ case Os_FreeBSD:
+ return "freebsd";
case Os_Linux:
return "linux";
case Os_OSX:
diff --git a/launcher/minecraft/OpSys.h b/launcher/minecraft/OpSys.h
index 63c750b1..0936f817 100644
--- a/launcher/minecraft/OpSys.h
+++ b/launcher/minecraft/OpSys.h
@@ -18,6 +18,7 @@
enum OpSys
{
Os_Windows,
+ Os_FreeBSD,
Os_Linux,
Os_OSX,
Os_Other
@@ -27,11 +28,11 @@ OpSys OpSys_fromString(QString);
QString OpSys_toString(OpSys);
#ifdef Q_OS_WIN32
-#define currentSystem Os_Windows
+ #define currentSystem Os_Windows
+#elif defined Q_OS_MAC
+ #define currentSystem Os_OSX
+#elif defined Q_OS_FREEBSD
+ #define currentSystem Os_FreeBSD
#else
-#ifdef Q_OS_MAC
-#define currentSystem Os_OSX
-#else
-#define currentSystem Os_Linux
+ #define currentSystem Os_Linux
#endif
-#endif \ No newline at end of file
diff --git a/launcher/minecraft/auth/AccountData.cpp b/launcher/minecraft/auth/AccountData.cpp
index 8aa4e37f..7526c951 100644
--- a/launcher/minecraft/auth/AccountData.cpp
+++ b/launcher/minecraft/auth/AccountData.cpp
@@ -438,3 +438,7 @@ QString AccountData::accountDisplayString() const {
}
}
}
+
+QString AccountData::lastError() const {
+ return errorString;
+}
diff --git a/launcher/minecraft/auth/AccountData.h b/launcher/minecraft/auth/AccountData.h
index 09cd2c73..abf84e43 100644
--- a/launcher/minecraft/auth/AccountData.h
+++ b/launcher/minecraft/auth/AccountData.h
@@ -41,6 +41,16 @@ enum class AccountType {
Mojang
};
+enum class AccountState {
+ Unchecked,
+ Offline,
+ Working,
+ Online,
+ Errored,
+ Expired,
+ Gone
+};
+
struct AccountData {
QJsonObject saveState() const;
bool resumeStateFromV2(QJsonObject data);
@@ -64,6 +74,8 @@ struct AccountData {
QString profileId() const;
QString profileName() const;
+ QString lastError() const;
+
AccountType type = AccountType::MSA;
bool legacy = false;
bool canMigrateToMSA = false;
@@ -77,4 +89,9 @@ struct AccountData {
MinecraftProfile minecraftProfile;
MinecraftEntitlement minecraftEntitlement;
Katabasis::Validity validity_ = Katabasis::Validity::None;
+
+ // runtime only information (not saved with the account)
+ QString internalId;
+ QString errorString;
+ AccountState accountState = AccountState::Unchecked;
};
diff --git a/launcher/minecraft/auth/AccountList.cpp b/launcher/minecraft/auth/AccountList.cpp
index d7537345..ef8b435d 100644
--- a/launcher/minecraft/auth/AccountList.cpp
+++ b/launcher/minecraft/auth/AccountList.cpp
@@ -15,6 +15,7 @@
#include "AccountList.h"
#include "AccountData.h"
+#include "AccountTask.h"
#include <QIODevice>
#include <QFile>
@@ -24,18 +25,28 @@
#include <QJsonObject>
#include <QJsonParseError>
#include <QDir>
+#include <QTimer>
#include <QDebug>
#include <FileSystem.h>
#include <QSaveFile>
+#include <chrono>
+
enum AccountListVersion {
MojangOnly = 2,
MojangMSA = 3
};
-AccountList::AccountList(QObject *parent) : QAbstractListModel(parent) { }
+AccountList::AccountList(QObject *parent) : QAbstractListModel(parent) {
+ m_refreshTimer = new QTimer(this);
+ m_refreshTimer->setSingleShot(true);
+ connect(m_refreshTimer, &QTimer::timeout, this, &AccountList::fillQueue);
+ m_nextTimer = new QTimer(this);
+ m_nextTimer->setSingleShot(true);
+ connect(m_nextTimer, &QTimer::timeout, this, &AccountList::tryNext);
+}
AccountList::~AccountList() noexcept {}
@@ -78,9 +89,18 @@ QStringList AccountList::profileNames() const {
void AccountList::addAccount(const MinecraftAccountPtr account)
{
+ // NOTE: Do not allow adding something that's already there
+ if(m_accounts.contains(account)) {
+ return;
+ }
+
+ // hook up notifications for changes in the account
+ connect(account.get(), &MinecraftAccount::changed, this, &AccountList::accountChanged);
+ connect(account.get(), &MinecraftAccount::activityChanged, this, &AccountList::accountActivityChanged);
+
+ // override/replace existing account with the same profileId
auto profileId = account->profileId();
if(profileId.size()) {
- // override/replace existing account with the same profileId
auto existingAccount = findAccountByProfileId(profileId);
if(existingAccount != -1) {
MinecraftAccountPtr existingAccountPtr = m_accounts[existingAccount];
@@ -88,6 +108,8 @@ void AccountList::addAccount(const MinecraftAccountPtr account)
if(m_defaultAccount == existingAccountPtr) {
m_defaultAccount = account;
}
+ // disconnect notifications for changes in the account being replaced
+ existingAccountPtr->disconnect(this);
emit dataChanged(index(existingAccount), index(existingAccount, columnCount(QModelIndex()) - 1));
onListChanged();
return;
@@ -97,8 +119,6 @@ void AccountList::addAccount(const MinecraftAccountPtr account)
// if we don't have this profileId yet, add the account to the end
int row = m_accounts.count();
beginInsertRows(QModelIndex(), row, row);
- connect(account.get(), &MinecraftAccount::changed, this, &AccountList::accountChanged);
- connect(account.get(), &MinecraftAccount::activityChanged, this, &AccountList::accountActivityChanged);
m_accounts.append(account);
endInsertRows();
onListChanged();
@@ -115,6 +135,8 @@ void AccountList::removeAccount(QModelIndex index)
m_defaultAccount = nullptr;
onDefaultAccountChanged();
}
+ account->disconnect(this);
+
beginRemoveRows(QModelIndex(), row, row);
m_accounts.removeAt(index.row());
endRemoveRows();
@@ -193,6 +215,12 @@ void AccountList::accountActivityChanged(bool active)
}
if(found) {
emit listActivityChanged();
+ if(active) {
+ beginActivity();
+ }
+ else {
+ endActivity();
+ }
}
}
@@ -244,13 +272,29 @@ QVariant AccountList::data(const QModelIndex &index, int role) const
}
case StatusColumn: {
- if(account->isActive()) {
- return tr("Working", "Account status");
- }
- if(account->isExpired()) {
- return tr("Expired", "Account status");
+ switch(account->accountState()) {
+ case AccountState::Unchecked: {
+ return tr("Unchecked", "Account status");
+ }
+ case AccountState::Offline: {
+ return tr("Offline", "Account status");
+ }
+ case AccountState::Online: {
+ return tr("Online", "Account status");
+ }
+ case AccountState::Working: {
+ return tr("Working", "Account status");
+ }
+ case AccountState::Errored: {
+ return tr("Errored", "Account status");
+ }
+ case AccountState::Expired: {
+ return tr("Expired", "Account status");
+ }
+ case AccountState::Gone: {
+ return tr("Gone", "Account status");
+ }
}
- return tr("Ready", "Account status");
}
case ProfileNameColumn: {
@@ -583,10 +627,113 @@ void AccountList::setListFilePath(QString path, bool autosave)
bool AccountList::anyAccountIsValid()
{
- for(auto account:m_accounts)
+ for(auto account: m_accounts)
{
- if(account->accountStatus() != NotVerified)
+ if(account->ownsMinecraft()) {
return true;
+ }
}
return false;
}
+
+void AccountList::fillQueue() {
+
+ if(m_defaultAccount && m_defaultAccount->shouldRefresh()) {
+ auto idToRefresh = m_defaultAccount->internalId();
+ m_refreshQueue.push_back(idToRefresh);
+ qDebug() << "AccountList: Queued default account with internal ID " << idToRefresh << " to refresh first";
+ }
+
+ for(int i = 0; i < count(); i++) {
+ auto account = at(i);
+ if(account == m_defaultAccount) {
+ continue;
+ }
+
+ if(account->shouldRefresh()) {