aboutsummaryrefslogtreecommitdiff
path: root/launcher/Application.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/Application.cpp')
-rw-r--r--launcher/Application.cpp67
1 files changed, 19 insertions, 48 deletions
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index a3d6216e..e33df252 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -192,27 +192,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
#endif
startTime = QDateTime::currentDateTime();
-#ifdef Q_OS_LINUX
- {
- QFile osrelease("/proc/sys/kernel/osrelease");
- if (osrelease.open(QFile::ReadOnly | QFile::Text)) {
- QTextStream in(&osrelease);
- auto contents = in.readAll();
- if(
- contents.contains("WSL", Qt::CaseInsensitive) ||
- contents.contains("Microsoft", Qt::CaseInsensitive)
- ) {
- showFatalErrorMessage(
- "Unsupported system detected!",
- "Linux-on-Windows distributions are not supported.\n\n"
- "Please use the Windows binary when playing on Windows."
- );
- return;
- }
- }
- }
-#endif
-
// Don't quit on hiding the last window
this->setQuitOnLastWindowClosed(false);
@@ -285,12 +264,21 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
return;
}
}
+
m_instanceIdToLaunch = args["launch"].toString();
m_serverToJoin = args["server"].toString();
m_profileToUse = args["profile"].toString();
m_liveCheck = args["alive"].toBool();
m_zipToImport = args["import"].toUrl();
+ // error if --launch is missing with --server or --profile
+ if((!m_serverToJoin.isEmpty() || !m_profileToUse.isEmpty()) && m_instanceIdToLaunch.isEmpty())
+ {
+ std::cerr << "--server and --profile can only be used in combination with --launch!" << std::endl;
+ m_status = Application::Failed;
+ return;
+ }
+
QString origcwdPath = QDir::currentPath();
QString binPath = applicationDirPath();
QString adjustedBy;
@@ -359,20 +347,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
return;
}
- if(m_instanceIdToLaunch.isEmpty() && !m_serverToJoin.isEmpty())
- {
- std::cerr << "--server can only be used in combination with --launch!" << std::endl;
- m_status = Application::Failed;
- return;
- }
-
- if(m_instanceIdToLaunch.isEmpty() && !m_profileToUse.isEmpty())
- {
- std::cerr << "--account can only be used in combination with --launch!" << std::endl;
- m_status = Application::Failed;
- return;
- }
-
#if defined(Q_OS_MAC)
// move user data to new location if on macOS and it still exists in Contents/MacOS
QDir fi(applicationDirPath());
@@ -566,26 +540,23 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
qDebug() << "<> Paths set.";
}
- do // once
+ if(m_liveCheck)
{
- if(m_liveCheck)
+ QFile check(liveCheckFile);
+ if(check.open(QIODevice::WriteOnly | QIODevice::Truncate))
{
- QFile check(liveCheckFile);
- if(!check.open(QIODevice::WriteOnly | QIODevice::Truncate))
- {
- qWarning() << "Could not open" << liveCheckFile << "for writing!";
- break;
- }
auto payload = appID.toString().toUtf8();
- if(check.write(payload) != payload.size())
+ if(check.write(payload) == payload.size())
{
+ check.close();
+ } else {
qWarning() << "Could not write into" << liveCheckFile << "!";
- check.remove();
- break;
+ check.remove(); // also closes file!
}
- check.close();
+ } else {
+ qWarning() << "Could not open" << liveCheckFile << "for writing!";
}
- } while(false);
+ }
// Initialize application settings
{