1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 11:47:46 +00:00

Move most of the custom server settings to be per-account

This makes it way easier to switch between retail and alternative (other
than Sapphire) servers.
This commit is contained in:
Joshua Goins 2025-03-17 19:14:20 -04:00
parent 7104de9ce9
commit 2466bc5448
7 changed files with 146 additions and 146 deletions

View file

@ -39,8 +39,6 @@ SPDX-License-Identifier: CC0-1.0
<entry key="IsSapphire" type="bool">
<default>false</default>
</entry>
<entry key="LobbyUrl" type="string">
</entry>
<entry key="RememberPassword" type="bool">
<default>false</default>
</entry>
@ -63,5 +61,26 @@ SPDX-License-Identifier: CC0-1.0
</entry>
<entry key="IsFreeTrial" type="bool">
</entry>
<entry name="PreferredProtocol" type="String">
<default>https</default>
</entry>
<entry name="GMServerHost" type="String">
<default></default>
</entry>
<entry name="LobbyHost" type="String">
<default></default>
</entry>
<entry name="LobbyHostPort" type="int">
<default>7000</default>
</entry>
<entry name="SquareEnixServer" type="String">
<default>ffxiv.com</default>
</entry>
<entry name="SquareEnixLoginServer" type="String">
<default>square-enix.com</default>
</entry>
<entry name="MainServer" type="String">
<default>finalfantasyxiv.com</default>
</entry>
</group>
</kcfg>

View file

@ -36,15 +36,6 @@ SPDX-License-Identifier: CC0-1.0
<entry name="DalamudDistribServer" type="String">
<default>kamori.goats.dev</default>
</entry>
<entry name="SquareEnixServer" type="String">
<default>ffxiv.com</default>
</entry>
<entry name="SquareEnixLoginServer" type="String">
<default>square-enix.com</default>
</entry>
<entry name="MainServer" type="String">
<default>finalfantasyxiv.com</default>
</entry>
<entry name="PreferredProtocol" type="String">
<default>https</default>
</entry>
@ -54,11 +45,5 @@ SPDX-License-Identifier: CC0-1.0
<entry key="EnableRenderDocCapture" type="bool">
<default>false</default>
</entry>
<entry name="CustomGameServer" type="String">
<default></default>
</entry>
<entry name="CustomGameServerPort" type="int">
<default>7000</default>
</entry>
</group>
</kcfg>

View file

@ -73,7 +73,7 @@ Account *AccountManager::createSapphireAccount(const QString &lobbyUrl, const QS
const auto account = new Account(QUuid::createUuid().toString(), this);
account->config()->setIsSapphire(true);
account->config()->setName(username);
account->config()->setLobbyUrl(lobbyUrl);
account->config()->setLobbyHost(lobbyUrl);
insertAccount(account);

View file

@ -186,8 +186,8 @@ void LauncherCore::fetchAvatar(Account *account)
qDebug(ASTRA_LOG) << "Did not find lodestone character " << account->config()->lodestoneId() << " in cache, fetching from Lodestone.";
QUrl url;
url.setScheme(config()->preferredProtocol());
url.setHost(QStringLiteral("na.%1").arg(config()->mainServer())); // TODO: NA isnt the only thing in the world...
url.setScheme(account->config()->preferredProtocol());
url.setHost(QStringLiteral("na.%1").arg(account->config()->mainServer())); // TODO: NA isnt the only thing in the world...
url.setPath(QStringLiteral("/lodestone/character/%1").arg(account->config()->lodestoneId()));
const QNetworkRequest request(url);
@ -367,7 +367,7 @@ void LauncherCore::setupIgnoreSSL(QNetworkReply *reply)
{
Q_ASSERT(reply != nullptr);
if (config()->preferredProtocol() == QStringLiteral("http")) {
if (reply->request().url().scheme() == QStringLiteral("http")) {
connect(reply, &QNetworkReply::sslErrors, this, [reply](const QList<QSslError> &errors) {
reply->ignoreSslErrors(errors);
});
@ -471,7 +471,7 @@ QCoro::Task<> LauncherCore::beginLogin(LoginInformation &info)
std::optional<LoginAuth> auth;
if (!info.profile->config()->isBenchmark()) {
if (info.profile->account()->config()->isSapphire()) {
auth = co_await m_sapphireLogin->login(info.profile->account()->config()->lobbyUrl(), info);
auth = co_await m_sapphireLogin->login(info.profile->account()->config()->lobbyHost(), info);
} else {
auth = co_await m_squareEnixLogin->login(&info);
}
@ -505,8 +505,8 @@ QCoro::Task<> LauncherCore::fetchNews()
query.addQueryItem(QStringLiteral("media"), QStringLiteral("pcapp"));
QUrl headlineUrl;
headlineUrl.setScheme(config()->preferredProtocol());
headlineUrl.setHost(QStringLiteral("frontier.%1").arg(config()->squareEnixServer()));
headlineUrl.setScheme(currentProfile()->account()->config()->preferredProtocol());
headlineUrl.setHost(QStringLiteral("frontier.%1").arg(currentProfile()->account()->config()->squareEnixServer()));
headlineUrl.setPath(QStringLiteral("/news/headline.json"));
headlineUrl.setQuery(query);
@ -524,8 +524,8 @@ QCoro::Task<> LauncherCore::fetchNews()
co_await headlineReply;
QUrl bannerUrl;
bannerUrl.setScheme(config()->preferredProtocol());
bannerUrl.setHost(QStringLiteral("frontier.%1").arg(config()->squareEnixServer()));
bannerUrl.setScheme(currentProfile()->account()->config()->preferredProtocol());
bannerUrl.setHost(QStringLiteral("frontier.%1").arg(currentProfile()->account()->config()->squareEnixServer()));
bannerUrl.setPath(QStringLiteral("/v2/topics/%1/banner.json").arg(QStringLiteral("en-us")));
bannerUrl.setQuery(query);

View file

@ -74,10 +74,10 @@ QCoro::Task<std::optional<LoginAuth>> SquareEnixLogin::login(LoginInformation *i
}
// Inject custom game server if set
if (!m_launcher.config()->customGameServer().isEmpty()) {
m_auth.frontierHost = m_launcher.config()->customGameServer();
m_auth.lobbyHost = m_launcher.config()->customGameServer();
m_auth.lobbyHostPort = m_launcher.config()->customGameServerPort();
if (!info->profile->account()->config()->lobbyHost().isEmpty()) {
m_auth.frontierHost = info->profile->account()->config()->gMServerHost();
m_auth.lobbyHost = info->profile->account()->config()->lobbyHost();
m_auth.lobbyHostPort = info->profile->account()->config()->lobbyHostPort();
}
co_return m_auth;
@ -89,8 +89,8 @@ QCoro::Task<bool> SquareEnixLogin::checkGateStatus() const
qInfo(ASTRA_LOG) << "Checking if the gate is open...";
QUrl url;
url.setScheme(m_launcher.config()->preferredProtocol());
url.setHost(QStringLiteral("frontier.%1").arg(m_launcher.config()->squareEnixServer()));
url.setScheme(m_info->profile->account()->config()->preferredProtocol());
url.setHost(QStringLiteral("frontier.%1").arg(m_info->profile->account()->config()->squareEnixServer()));
url.setPath(QStringLiteral("/worldStatus/gate_status.json"));
url.setQuery(QString::number(QDateTime::currentMSecsSinceEpoch()));
@ -130,8 +130,8 @@ QCoro::Task<bool> SquareEnixLogin::checkLoginStatus() const
qInfo(ASTRA_LOG) << "Checking if login is open...";
QUrl url;
url.setScheme(m_launcher.config()->preferredProtocol());
url.setHost(QStringLiteral("frontier.%1").arg(m_launcher.config()->squareEnixServer()));
url.setScheme(m_info->profile->account()->config()->preferredProtocol());
url.setHost(QStringLiteral("frontier.%1").arg(m_info->profile->account()->config()->squareEnixServer()));
url.setPath(QStringLiteral("/worldStatus/login_status.json"));
url.setQuery(QString::number(QDateTime::currentMSecsSinceEpoch()));
@ -153,7 +153,7 @@ QCoro::Task<bool> SquareEnixLogin::checkLoginStatus() const
qInfo(ASTRA_LOG) << "Login is open!";
co_return true;
} else {
qInfo(ASTRA_LOG) << "Lgoin is closed!";
qInfo(ASTRA_LOG) << "Login is closed!";
Q_EMIT m_launcher.loginError(i18n("The login gate is closed, the game may be under maintenance.\n\n%1", reply->errorString()));
co_return false;
}
@ -173,7 +173,7 @@ QCoro::Task<bool> SquareEnixLogin::checkBootUpdates()
QUrl url;
url.setScheme(QStringLiteral("http"));
url.setHost(QStringLiteral("patch-bootver.%1").arg(m_launcher.config()->squareEnixServer()));
url.setHost(QStringLiteral("patch-bootver.%1").arg(m_info->profile->account()->config()->squareEnixServer()));
url.setPath(QStringLiteral("/http/%1/%2/%3/").arg(platform, bootUpdateChannel, m_info->profile->bootVersion()));
url.setQuery(query);
@ -184,7 +184,7 @@ QCoro::Task<bool> SquareEnixLogin::checkBootUpdates()
request.setHeader(QNetworkRequest::KnownHeaders::UserAgentHeader, patchUserAgent);
}
request.setRawHeader(QByteArrayLiteral("Host"), QStringLiteral("patch-bootver.%1").arg(m_launcher.config()->squareEnixServer()).toUtf8());
request.setRawHeader(QByteArrayLiteral("Host"), QStringLiteral("patch-bootver.%1").arg(m_info->profile->account()->config()->squareEnixServer()).toUtf8());
Utility::printRequest(QStringLiteral("GET"), request);
const auto reply = m_launcher.mgr()->get(request);
@ -241,8 +241,8 @@ QCoro::Task<std::optional<SquareEnixLogin::StoredInfo>> SquareEnixLogin::getStor
}
QUrl url;
url.setScheme(m_launcher.config()->preferredProtocol());
url.setHost(QStringLiteral("ffxiv-login.%1").arg(m_launcher.config()->squareEnixLoginServer()));
url.setScheme(m_info->profile->account()->config()->preferredProtocol());
url.setHost(QStringLiteral("ffxiv-login.%1").arg(m_info->profile->account()->config()->squareEnixLoginServer()));
url.setPath(QStringLiteral("/oauth/ffxivarr/login/top"));
url.setQuery(query);
@ -299,8 +299,8 @@ QCoro::Task<bool> SquareEnixLogin::loginOAuth()
postData.addQueryItem(QStringLiteral("otppw"), m_info->oneTimePassword);
QUrl url;
url.setScheme(m_launcher.config()->preferredProtocol());
url.setHost(QStringLiteral("ffxiv-login.%1").arg(m_launcher.config()->squareEnixLoginServer()));
url.setScheme(m_info->profile->account()->config()->preferredProtocol());
url.setHost(QStringLiteral("ffxiv-login.%1").arg(m_info->profile->account()->config()->squareEnixLoginServer()));
url.setPath(QStringLiteral("/oauth/ffxivarr/login/login.send"));
QNetworkRequest request(url);
@ -360,8 +360,8 @@ QCoro::Task<bool> SquareEnixLogin::registerSession()
qInfo(ASTRA_LOG) << "Registering the session...";
QUrl url;
url.setScheme(m_launcher.config()->preferredProtocol());
url.setHost(QStringLiteral("patch-gamever.%1").arg(m_launcher.config()->squareEnixServer()));
url.setScheme(m_info->profile->account()->config()->preferredProtocol());
url.setHost(QStringLiteral("patch-gamever.%1").arg(m_info->profile->account()->config()->squareEnixServer()));
url.setPath(QStringLiteral("/http/%1/%2/%3/%4").arg(platform, gameUpdateChannel, m_info->profile->baseGameVersion(), m_SID));
auto request = QNetworkRequest(url);

View file

@ -51,6 +51,10 @@ FormCard.FormCardPage {
Kirigami.Action {
id: loginAction
text: i18n("Login")
},
Kirigami.Action {
id: developerAction
text: i18n("Developer")
}
]
@ -255,6 +259,101 @@ FormCard.FormCardPage {
}
}
FormCard.FormCard {
visible: developerAction.checked
Layout.fillWidth: true
Layout.topMargin: Kirigami.Units.largeSpacing * 4
FormCard.FormTextFieldDelegate {
id: preferredProtocolDelegate
label: i18n("Preferred Protocol")
text: page.account.config.preferredProtocol
onTextChanged: page.account.config.preferredProtocol = text
}
FormCard.FormDelegateSeparator {
above: preferredProtocolDelegate
below: squareMainServerDelegate
}
FormCard.FormTextFieldDelegate {
id: squareMainServerDelegate
label: i18n("SE Main Server (ffxiv.com)")
text: page.account.config.squareEnixServer
onTextChanged: page.account.config.squareEnixServer = text
}
FormCard.FormDelegateSeparator {
above: squareMainServerDelegate
below: loginServerDelegate
}
FormCard.FormTextFieldDelegate {
id: loginServerDelegate
label: i18n("SE Login Server (square-enix.com)")
text: page.account.config.squareEnixLoginServer
onTextChanged: page.account.config.squareEnixLoginServer = text
}
FormCard.FormDelegateSeparator {
above: loginServerDelegate
below: mainServerDelegate
}
FormCard.FormTextFieldDelegate {
id: mainServerDelegate
label: i18n("Main Server (finalfantasyxiv.com)")
text: page.account.config.mainServer
onTextChanged: page.account.config.mainServer = text
}
FormCard.FormDelegateSeparator {
above: mainServerDelegate
below: gmServerDelegate
}
FormCard.FormTextFieldDelegate {
id: gmServerDelegate
label: i18n("GM Server (leave blank for default)")
text: page.account.config.gMServerHost
onTextChanged: page.account.config.gMServerHost = text
}
FormCard.FormDelegateSeparator {
above: gmServerDelegate
below: gameServerDelegate
}
FormCard.FormTextFieldDelegate {
id: gameServerDelegate
label: i18n("Lobby Server (leave blank for default)")
text: page.account.config.lobbyHost
onTextChanged: page.account.config.lobbyHost = text
}
FormCard.FormDelegateSeparator {
above: gameServerDelegate
below: gameServerPortDelegate
}
FormCard.FormSpinBoxDelegate {
id: gameServerPortDelegate
label: i18n("Lobby Server Port")
value: page.account.config.lobbyHostPort
onValueChanged: page.account.config.lobbyHostPort = value
from: 1
to: 999999
}
}
Kirigami.PromptDialog {
id: deletePrompt

View file

@ -85,42 +85,6 @@ FormCard.FormCardPage {
FormCard.FormCard {
Layout.fillWidth: true
FormCard.FormButtonDelegate {
id: resetToDefaultsDelegate
text: i18n("Reset to Defaults")
onClicked: {
preferredProtocolDelegate.text = LauncherCore.config.defaultPreferredProtocol();
dalamudServerDelegate.text = LauncherCore.config.defaultDalamudDistribServer();
squareMainServerDelegate.text = LauncherCore.config.defaultSquareEnixServer();
loginServerDelegate.text = LauncherCore.config.defaultSquareEnixLoginServer();
mainServerDelegate.text = LauncherCore.config.defaultMainServer();
}
}
FormCard.FormDelegateSeparator {
above: resetToDefaultsDelegate
below: localServerDelegate
}
FormCard.FormButtonDelegate {
id: localServerDelegate
text: i18n("Set to localhost")
onClicked: {
preferredProtocolDelegate.text = "http";
squareMainServerDelegate.text = "ffxiv.localhost";
loginServerDelegate.text = "square.localhost";
}
}
FormCard.FormDelegateSeparator {
above: localServerDelegate
below: preferredProtocolDelegate
}
FormCard.FormTextFieldDelegate {
id: preferredProtocolDelegate
@ -141,72 +105,5 @@ FormCard.FormCardPage {
text: LauncherCore.config.dalamudDistribServer
onTextChanged: LauncherCore.config.dalamudDistribServer = text
}
FormCard.FormDelegateSeparator {
above: dalamudServerDelegate
below: squareMainServerDelegate
}
FormCard.FormTextFieldDelegate {
id: squareMainServerDelegate
label: i18n("SE Main Server (ffxiv.com)")
text: LauncherCore.config.squareEnixServer
onTextChanged: LauncherCore.config.squareEnixServer = text
}
FormCard.FormDelegateSeparator {
above: squareMainServerDelegate
below: loginServerDelegate
}
FormCard.FormTextFieldDelegate {
id: loginServerDelegate
label: i18n("SE Login Server (square-enix.com)")
text: LauncherCore.config.squareEnixLoginServer
onTextChanged: LauncherCore.config.squareEnixLoginServer = text
}
FormCard.FormDelegateSeparator {
above: loginServerDelegate
below: mainServerDelegate
}
FormCard.FormTextFieldDelegate {
id: mainServerDelegate
label: i18n("Main Server (finalfantasyxiv.com)")
text: LauncherCore.config.mainServer
onTextChanged: LauncherCore.config.mainServer = text
}
FormCard.FormDelegateSeparator {
above: mainServerDelegate
below: gameServerDelegate
}
FormCard.FormTextFieldDelegate {
id: gameServerDelegate
label: i18n("Game Server (leave blank for default)")
text: LauncherCore.config.customGameServer
onTextChanged: LauncherCore.config.customGameServer = text
}
FormCard.FormDelegateSeparator {
above: gameServerDelegate
below: gameServerPortDelegate
}
FormCard.FormSpinBoxDelegate {
id: gameServerPortDelegate
label: i18n("Game Server Port")
value: LauncherCore.config.customGameServerPort
onValueChanged: LauncherCore.config.customGameServerPort = value
from: 1
to: 999999
}
}
}