summaryrefslogtreecommitdiffstats
path: root/logic/OneSixInstance.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-01-27 03:00:49 +0100
committerPetr Mrázek <peterix@gmail.com>2014-01-27 03:00:49 +0100
commitffbc5bb62c0cd771b26cb1d9b5afdccef77075b4 (patch)
tree78b10cee3dc25acba02954aaf4f0e44ee4c295de /logic/OneSixInstance.cpp
parentd7113de3bd3cb43b1bc68792cd27a716b012f2b5 (diff)
downloadMultiMC-ffbc5bb62c0cd771b26cb1d9b5afdccef77075b4.tar
MultiMC-ffbc5bb62c0cd771b26cb1d9b5afdccef77075b4.tar.gz
MultiMC-ffbc5bb62c0cd771b26cb1d9b5afdccef77075b4.tar.lz
MultiMC-ffbc5bb62c0cd771b26cb1d9b5afdccef77075b4.tar.xz
MultiMC-ffbc5bb62c0cd771b26cb1d9b5afdccef77075b4.zip
Offline mode can be used even when online.
Allow the user to pick a player name for offline mode. Big auth refactor. Now using session objects instead of the accounts themselves. Sessions only last for one instance start and hold all the auth and player data.
Diffstat (limited to 'logic/OneSixInstance.cpp')
-rw-r--r--logic/OneSixInstance.cpp39
1 files changed, 12 insertions, 27 deletions
diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp
index ab87a1db..67649f77 100644
--- a/logic/OneSixInstance.cpp
+++ b/logic/OneSixInstance.cpp
@@ -41,9 +41,9 @@ OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *setting_o
reloadFullVersion();
}
-std::shared_ptr<Task> OneSixInstance::doUpdate(bool only_prepare)
+std::shared_ptr<Task> OneSixInstance::doUpdate()
{
- return std::shared_ptr<Task>(new OneSixUpdate(this, only_prepare));
+ return std::shared_ptr<Task>(new OneSixUpdate(this));
}
QString replaceTokensIn(QString text, QMap<QString, QString> with)
@@ -130,7 +130,7 @@ QDir OneSixInstance::reconstructAssets(std::shared_ptr<OneSixVersion> version)
return virtualRoot;
}
-QStringList OneSixInstance::processMinecraftArgs(MojangAccountPtr account)
+QStringList OneSixInstance::processMinecraftArgs(AuthSessionPtr session)
{
I_D(OneSixInstance);
auto version = d->version;
@@ -138,17 +138,11 @@ QStringList OneSixInstance::processMinecraftArgs(MojangAccountPtr account)
QMap<QString, QString> token_mapping;
// yggdrasil!
- token_mapping["auth_username"] = account->username();
- token_mapping["auth_session"] = account->sessionId();
- token_mapping["auth_access_token"] = account->accessToken();
- token_mapping["auth_player_name"] = account->currentProfile()->name;
- token_mapping["auth_uuid"] = account->currentProfile()->id;
-
- // this is for offline?:
- /*
- map["auth_player_name"] = "Player";
- map["auth_player_name"] = "00000000-0000-0000-0000-000000000000";
- */
+ token_mapping["auth_username"] = session->username;
+ token_mapping["auth_session"] = session->session;
+ token_mapping["auth_access_token"] = session->access_token;
+ token_mapping["auth_player_name"] = session->player_name;
+ token_mapping["auth_uuid"] = session->uuid;
// these do nothing and are stupid.
token_mapping["profile_name"] = name();
@@ -159,17 +153,8 @@ QStringList OneSixInstance::processMinecraftArgs(MojangAccountPtr account)
QString absAssetsDir = QDir("assets/").absolutePath();
token_mapping["game_assets"] = reconstructAssets(d->version).absolutePath();
- auto user = account->user();
- QJsonObject userAttrs;
- for (auto key : user.properties.keys())
- {
- auto array = QJsonArray::fromStringList(user.properties.values(key));
- userAttrs.insert(key, array);
- }
- QJsonDocument value(userAttrs);
-
- token_mapping["user_properties"] = value.toJson(QJsonDocument::Compact);
- token_mapping["user_type"] = account->currentProfile()->legacy ? "legacy" : "mojang";
+ token_mapping["user_properties"] = session->serializeUserProperties();
+ token_mapping["user_type"] = session->user_type;
// 1.7.3+ assets tokens
token_mapping["assets_root"] = absAssetsDir;
token_mapping["assets_index_name"] = version->assets;
@@ -182,7 +167,7 @@ QStringList OneSixInstance::processMinecraftArgs(MojangAccountPtr account)
return parts;
}
-MinecraftProcess *OneSixInstance::prepareForLaunch(MojangAccountPtr account)
+MinecraftProcess *OneSixInstance::prepareForLaunch(AuthSessionPtr session)
{
I_D(OneSixInstance);
@@ -207,7 +192,7 @@ MinecraftProcess *OneSixInstance::prepareForLaunch(MojangAccountPtr account)
}
launchScript += "mainClass " + version->mainClass + "\n";
- for (auto param : processMinecraftArgs(account))
+ for (auto param : processMinecraftArgs(session))
{
launchScript += "param " + param + "\n";
}