Skip to content

Commit

Permalink
Improved formatting, fixed mistakenly-added local variable
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltyson committed Apr 23, 2024
1 parent 835cc29 commit ab7db2b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
7 changes: 5 additions & 2 deletions launcher/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
{ { "s", "server" }, "Join the specified server on launch (only valid in combination with --launch)", "address" },
{ { "a", "profile" }, "Use the account specified by its profile name (only valid in combination with --launch)", "profile" },
{ { "o", "offline" }, "Launch offline (only valid in combination with --launch)", "offline" },
{ { "n", "name" }, "When launching offline, use specified name (only makes sense in combination with --launch and --offline)", "name" },
{ { "n", "name" },
"When launching offline, use specified name (only makes sense in combination with --launch and --offline)",
"name" },
{ "alive", "Write a small '" + liveCheckFile + "' file after the launcher starts" },
{ { "I", "import" }, "Import instance or resource from specified local path or URL", "url" },
{ "show", "Opens the window for the specified instance (by instance ID)", "show" } });
Expand Down Expand Up @@ -270,7 +272,8 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
}

// error if --launch is missing with --server or --profile
if ((!m_serverToJoin.isEmpty() || !m_profileToUse.isEmpty() || m_offline || !m_offlineName.isEmpty()) && m_instanceIdToLaunch.isEmpty()) {
if ((!m_serverToJoin.isEmpty() || !m_profileToUse.isEmpty() || m_offline || !m_offlineName.isEmpty()) &&
m_instanceIdToLaunch.isEmpty()) {
std::cerr << "--server, --profile, --offline and --name can only be used in combination with --launch!" << std::endl;
m_status = Application::Failed;
return;
Expand Down
2 changes: 1 addition & 1 deletion launcher/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class Application : public QApplication {
bool demo = false,
MinecraftServerTargetPtr serverToJoin = nullptr,
MinecraftAccountPtr accountToUse = nullptr,
const QString &offlineName = QString());
const QString& offlineName = QString());
bool kill(InstancePtr instance);
void closeCurrentWindow();

Expand Down
7 changes: 3 additions & 4 deletions launcher/LaunchController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ void LaunchController::login()
}

QString usedname;
if(m_offlineName.isEmpty()) {
if (m_offlineName.isEmpty()) {
QString lastOfflinePlayerName = APPLICATION->settings()->get("LastOfflinePlayerName").toString();
QString usedname = lastOfflinePlayerName.isEmpty() ? m_session->player_name : lastOfflinePlayerName;
usedname = lastOfflinePlayerName.isEmpty() ? m_session->player_name : lastOfflinePlayerName;
QString name = QInputDialog::getText(m_parentWidget, tr("Player name"), message, QLineEdit::Normal, usedname, &ok);
if (!ok) {
tryagain = false;
Expand All @@ -200,8 +200,7 @@ void LaunchController::login()
usedname = name;
APPLICATION->settings()->set("LastOfflinePlayerName", usedname);
}
}
else {
} else {
usedname = m_offlineName;
}
m_session->MakeOffline(usedname);
Expand Down
4 changes: 2 additions & 2 deletions launcher/LaunchController.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ class LaunchController : public Task {
void executeTask() override;

LaunchController(QObject* parent = nullptr);
virtual ~LaunchController(){};
virtual ~LaunchController() {};

void setInstance(InstancePtr instance) { m_instance = instance; }

InstancePtr instance() { return m_instance; }

void setOnline(bool online) { m_online = online; }

void setOfflineName(const QString &offlineName) { m_offlineName = offlineName; }
void setOfflineName(const QString& offlineName) { m_offlineName = offlineName; }

void setDemo(bool demo) { m_demo = demo; }

Expand Down

0 comments on commit ab7db2b

Please sign in to comment.