mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 13:17:41 +02:00
chore: make all the regexes static const
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
@ -38,7 +38,6 @@
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QRegularExpression>
|
||||
#include <QUuid>
|
||||
|
||||
namespace {
|
||||
|
@ -55,7 +55,8 @@
|
||||
|
||||
MinecraftAccount::MinecraftAccount(QObject* parent) : QObject(parent)
|
||||
{
|
||||
data.internalId = QUuid::createUuid().toString().remove(QRegularExpression("[{}-]"));
|
||||
static const QRegularExpression s_removeChars("[{}-]");
|
||||
data.internalId = QUuid::createUuid().toString().remove(s_removeChars);
|
||||
}
|
||||
|
||||
MinecraftAccountPtr MinecraftAccount::loadFromJsonV3(const QJsonObject& json)
|
||||
@ -76,14 +77,15 @@ MinecraftAccountPtr MinecraftAccount::createBlankMSA()
|
||||
|
||||
MinecraftAccountPtr MinecraftAccount::createOffline(const QString& username)
|
||||
{
|
||||
static const QRegularExpression s_removeChars("[{}-]");
|
||||
auto account = makeShared<MinecraftAccount>();
|
||||
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(QRegularExpression("[{}-]"));
|
||||
account->data.minecraftProfile.id = uuidFromUsername(username).toString().remove(QRegularExpression("[{}-]"));
|
||||
account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(s_removeChars);
|
||||
account->data.minecraftProfile.id = uuidFromUsername(username).toString().remove(s_removeChars);
|
||||
account->data.minecraftProfile.name = username;
|
||||
account->data.minecraftProfile.validity = Validity::Certain;
|
||||
return account;
|
||||
@ -231,6 +233,7 @@ bool MinecraftAccount::shouldRefresh() const
|
||||
|
||||
void MinecraftAccount::fillSession(AuthSessionPtr session)
|
||||
{
|
||||
static const QRegularExpression s_removeChars("[{}-]");
|
||||
if (ownsMinecraft() && !hasProfile()) {
|
||||
session->status = AuthSession::RequiresProfileSetup;
|
||||
} else {
|
||||
@ -248,7 +251,7 @@ void MinecraftAccount::fillSession(AuthSessionPtr session)
|
||||
// profile ID
|
||||
session->uuid = data.profileId();
|
||||
if (session->uuid.isEmpty())
|
||||
session->uuid = uuidFromUsername(session->player_name).toString().remove(QRegularExpression("[{}-]"));
|
||||
session->uuid = uuidFromUsername(session->player_name).toString().remove(s_removeChars);
|
||||
// 'legacy' or 'mojang', depending on account type
|
||||
session->user_type = typeString();
|
||||
if (!session->access_token.isEmpty()) {
|
||||
|
Reference in New Issue
Block a user