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

Add support for specifying a custom lobby/GM server

This commit is contained in:
Joshua Goins 2025-03-08 13:51:26 -05:00
parent 69051696e1
commit 4214b769df
8 changed files with 89 additions and 8 deletions

View file

@ -54,5 +54,11 @@ 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

@ -49,7 +49,8 @@ struct LoginAuth {
int maxExpansion = 1;
// if empty, don't set on the client
QString lobbyhost, frontierHost;
QString lobbyHost, frontierHost;
int lobbyHostPort;
};
class LauncherCore : public QObject

View file

@ -26,6 +26,8 @@ class LauncherSettings : public QObject
Q_PROPERTY(bool argumentsEncrypted READ argumentsEncrypted WRITE setArgumentsEncrypted NOTIFY encryptedArgumentsChanged)
Q_PROPERTY(bool enableRenderDocCapture READ enableRenderDocCapture WRITE setEnableRenderDocCapture NOTIFY enableRenderDocCaptureChanged)
Q_PROPERTY(bool enableSync READ enableSync WRITE setEnableSync NOTIFY enableSyncChanged)
Q_PROPERTY(QString customGameServer READ customGameServer WRITE setCustomGameServer NOTIFY customGameServerChanged)
Q_PROPERTY(int customGameServerPort READ customGameServerPort WRITE setCustomGameServerPort NOTIFY customGameServerPortChanged)
public:
explicit LauncherSettings(QObject *parent = nullptr);
@ -74,6 +76,12 @@ public:
[[nodiscard]] bool enableSync() const;
void setEnableSync(bool enabled);
[[nodiscard]] QString customGameServer() const;
void setCustomGameServer(const QString &value);
[[nodiscard]] int customGameServerPort() const;
void setCustomGameServerPort(int port);
Config *config();
Q_SIGNALS:
@ -89,6 +97,8 @@ Q_SIGNALS:
void encryptedArgumentsChanged();
void enableRenderDocCaptureChanged();
void enableSyncChanged();
void customGameServerChanged();
void customGameServerPortChanged();
private:
Config *m_config = nullptr;

View file

@ -228,11 +228,11 @@ QString GameRunner::getGameArgs(const Profile &profile, const std::optional<Logi
Utility::createPathIfNeeded(profile.winePrefixPath());
if (auth) {
if (!auth->lobbyhost.isEmpty()) {
if (!auth->lobbyHost.isEmpty()) {
gameArgs.push_back({QStringLiteral("DEV.GMServerHost"), auth->frontierHost});
for (int i = 1; i < 9; i++) {
gameArgs.push_back({QStringLiteral("DEV.LobbyHost0%1").arg(QString::number(i)), auth->lobbyhost});
gameArgs.push_back({QStringLiteral("DEV.LobbyPort0%1").arg(QString::number(i)), QString::number(54994)});
gameArgs.push_back({QStringLiteral("DEV.LobbyHost0%1").arg(QString::number(i)), auth->lobbyHost});
gameArgs.push_back({QStringLiteral("DEV.LobbyPort0%1").arg(QString::number(i)), QString::number(auth->lobbyHostPort)});
}
}

View file

@ -214,6 +214,34 @@ void LauncherSettings::setEnableSync(const bool enabled)
}
}
QString LauncherSettings::customGameServer() const
{
return m_config->customGameServer();
}
void LauncherSettings::setCustomGameServer(const QString &value)
{
if (m_config->customGameServer() != value) {
m_config->setCustomGameServer(value);
m_config->save();
Q_EMIT customGameServerChanged();
}
}
int LauncherSettings::customGameServerPort() const
{
return m_config->customGameServerPort();
}
void LauncherSettings::setCustomGameServerPort(const int port)
{
if (m_config->customGameServerPort() != port) {
m_config->setCustomGameServerPort(port);
m_config->save();
Q_EMIT customGameServerPortChanged();
}
}
Config *LauncherSettings::config()
{
return m_config;

View file

@ -40,8 +40,9 @@ QCoro::Task<std::optional<LoginAuth>> SapphireLogin::login(const QString &lobbyU
if (!document.isEmpty()) {
LoginAuth auth;
auth.SID = document["sId"_L1].toString();
auth.lobbyhost = document["lobbyHost"_L1].toString();
auth.lobbyHost = document["lobbyHost"_L1].toString();
auth.frontierHost = document["frontierHost"_L1].toString();
auth.lobbyHostPort = 54994; // TODO: where did this come from?
auth.region = 3;
co_return auth;
@ -67,7 +68,7 @@ void SapphireLogin::registerAccount(const QString &lobbyUrl, const LoginInformat
LoginAuth auth;
auth.SID = document["sId"_L1].toString();
auth.lobbyhost = document["lobbyHost"_L1].toString();
auth.lobbyHost = document["lobbyHost"_L1].toString();
auth.frontierHost = document["frontierHost"_L1].toString();
auth.region = 3;

View file

@ -71,6 +71,13 @@ QCoro::Task<std::optional<LoginAuth>> SquareEnixLogin::login(LoginInformation *i
co_return std::nullopt;
}
// Inject custom game server if set
if (!m_launcher.settings()->customGameServer().isEmpty()) {
m_auth.frontierHost = m_launcher.settings()->customGameServer();
m_auth.lobbyHost = m_launcher.settings()->customGameServer();
m_auth.lobbyHostPort = m_launcher.settings()->customGameServerPort();
}
co_return m_auth;
}

View file

@ -180,5 +180,33 @@ FormCard.FormCardPage {
text: LauncherCore.settings.mainServer
onTextChanged: LauncherCore.settings.mainServer = text
}
FormCard.FormDelegateSeparator {
above: mainServerDelegate
below: gameServerDelegate
}
FormCard.FormTextFieldDelegate {
id: gameServerDelegate
label: i18n("Game Server (leave blank for default)")
text: LauncherCore.settings.customGameServer
onTextChanged: LauncherCore.settings.customGameServer = text
}
FormCard.FormDelegateSeparator {
above: gameServerDelegate
below: gameServerPortDelegate
}
FormCard.FormSpinBoxDelegate {
id: gameServerPortDelegate
label: i18n("Game Server Port")
value: LauncherCore.settings.customGameServerPort
onValueChanged: LauncherCore.settings.customGameServerPort = value
from: 1
to: 999999
}
}
}