From d81fa77d1f0e306a48b91704b33df97fc484e949 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Tue, 17 Feb 2026 10:44:51 +0500 Subject: [PATCH] fix: don't manually format UUIDs Signed-off-by: Octol1ttle --- launcher/LaunchController.cpp | 3 +-- launcher/minecraft/OneSixVersionFormat.cpp | 3 +-- launcher/minecraft/auth/MinecraftAccount.cpp | 12 ++++-------- launcher/minecraft/auth/steps/EntitlementsStep.cpp | 3 +-- .../modplatform/atlauncher/ATLPackInstallTask.cpp | 6 ++---- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/launcher/LaunchController.cpp b/launcher/LaunchController.cpp index d0cd64e51..cddac5f77 100644 --- a/launcher/LaunchController.cpp +++ b/launcher/LaunchController.cpp @@ -289,8 +289,7 @@ void LaunchController::login() auto name = askOfflineName("Player", &ok); if (ok) { m_session = std::make_shared(); - static const QRegularExpression s_removeChars("[{}-]"); - m_session->MakeDemo(name, MinecraftAccount::uuidFromUsername(name).toString().remove(s_removeChars)); + m_session->MakeDemo(name, MinecraftAccount::uuidFromUsername(name).toString(QUuid::Id128)); launchInstance(); return; } diff --git a/launcher/minecraft/OneSixVersionFormat.cpp b/launcher/minecraft/OneSixVersionFormat.cpp index 48ea3b894..34a212f20 100644 --- a/launcher/minecraft/OneSixVersionFormat.cpp +++ b/launcher/minecraft/OneSixVersionFormat.cpp @@ -370,8 +370,7 @@ LibraryPtr OneSixVersionFormat::plusJarModFromJson([[maybe_unused]] ProblemConta } // just make up something unique on the spot for the library name. - auto uuid = QUuid::createUuid(); - QString id = uuid.toString().remove('{').remove('}'); + QString id = QUuid::createUuid().toString(QUuid::WithoutBraces); out->setRawName(GradleSpecifier("org.multimc.jarmods:" + id + ":1")); // filename override is the old name diff --git a/launcher/minecraft/auth/MinecraftAccount.cpp b/launcher/minecraft/auth/MinecraftAccount.cpp index 8799b2c74..1592a22d2 100644 --- a/launcher/minecraft/auth/MinecraftAccount.cpp +++ b/launcher/minecraft/auth/MinecraftAccount.cpp @@ -55,8 +55,7 @@ MinecraftAccount::MinecraftAccount(QObject* parent) : QObject(parent) { - static const QRegularExpression s_removeChars("[{}-]"); - data.internalId = QUuid::createUuid().toString().remove(s_removeChars); + data.internalId = QUuid::createUuid().toString(QUuid::Id128); } MinecraftAccountPtr MinecraftAccount::loadFromJsonV3(const QJsonObject& json) @@ -77,15 +76,14 @@ MinecraftAccountPtr MinecraftAccount::createBlankMSA() MinecraftAccountPtr MinecraftAccount::createOffline(const QString& username) { - static const QRegularExpression s_removeChars("[{}-]"); auto account = makeShared(); account->data.type = AccountType::Offline; account->data.yggdrasilToken.token = "0"; account->data.yggdrasilToken.validity = Validity::Certain; account->data.yggdrasilToken.issueInstant = QDateTime::currentDateTimeUtc(); account->data.yggdrasilToken.extra["userName"] = username; - account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(s_removeChars); - account->data.minecraftProfile.id = uuidFromUsername(username).toString().remove(s_removeChars); + account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString(QUuid::Id128); + account->data.minecraftProfile.id = uuidFromUsername(username).toString(QUuid::Id128); account->data.minecraftProfile.name = username; account->data.minecraftProfile.validity = Validity::Certain; return account; @@ -235,8 +233,6 @@ bool MinecraftAccount::shouldRefresh() const void MinecraftAccount::fillSession(AuthSessionPtr session) { - static const QRegularExpression s_removeChars("[{}-]"); - // volatile auth token session->access_token = data.accessToken(); // profile name @@ -244,7 +240,7 @@ void MinecraftAccount::fillSession(AuthSessionPtr session) // profile ID session->uuid = data.profileId(); if (session->uuid.isEmpty()) - session->uuid = uuidFromUsername(session->player_name).toString().remove(s_removeChars); + session->uuid = uuidFromUsername(session->player_name).toString(QUuid::Id128); // 'legacy' or 'mojang', depending on account type session->user_type = typeString(); if (!session->access_token.isEmpty()) { diff --git a/launcher/minecraft/auth/steps/EntitlementsStep.cpp b/launcher/minecraft/auth/steps/EntitlementsStep.cpp index 35a7de66f..82e9a0bf5 100644 --- a/launcher/minecraft/auth/steps/EntitlementsStep.cpp +++ b/launcher/minecraft/auth/steps/EntitlementsStep.cpp @@ -23,8 +23,7 @@ QString EntitlementsStep::describe() void EntitlementsStep::perform() { - auto uuid = QUuid::createUuid(); - m_entitlements_request_id = uuid.toString().remove('{').remove('}'); + m_entitlements_request_id = QUuid::createUuid().toString(QUuid::WithoutBraces); QUrl url("https://api.minecraftservices.com/entitlements/license?requestId=" + m_entitlements_request_id); auto headers = QList{ { "Content-Type", "application/json" }, diff --git a/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp b/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp index d2742ac5f..871a3a982 100644 --- a/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp +++ b/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp @@ -447,8 +447,7 @@ bool PackInstallTask::createLibrariesComponent(QString instanceRoot, PackProfile } } - auto uuid = QUuid::createUuid(); - auto id = uuid.toString().remove('{').remove('}'); + auto id = QUuid::createUuid().toString(QUuid::WithoutBraces); auto target_id = "org.multimc.atlauncher." + id; auto patchDir = FS::PathCombine(instanceRoot, "patches"); @@ -566,8 +565,7 @@ bool PackInstallTask::createPackComponent(QString instanceRoot, PackProfile* pro return true; } - auto uuid = QUuid::createUuid(); - auto id = uuid.toString().remove('{').remove('}'); + auto id = QUuid::createUuid().toString(QUuid::WithoutBraces); auto target_id = "org.multimc.atlauncher." + id; auto patchDir = FS::PathCombine(instanceRoot, "patches");