summaryrefslogtreecommitdiffstats
path: root/logic/MinecraftProcess.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'logic/MinecraftProcess.cpp')
-rw-r--r--logic/MinecraftProcess.cpp44
1 files changed, 26 insertions, 18 deletions
diff --git a/logic/MinecraftProcess.cpp b/logic/MinecraftProcess.cpp
index ff122628..e4a26054 100644
--- a/logic/MinecraftProcess.cpp
+++ b/logic/MinecraftProcess.cpp
@@ -59,12 +59,12 @@ MinecraftProcess::MinecraftProcess(BaseInstance *inst) : m_instance(inst)
connect(this, SIGNAL(readyReadStandardOutput()), SLOT(on_stdOut()));
}
-void MinecraftProcess::setMinecraftArguments(QStringList args)
+void MinecraftProcess::setArguments(QStringList args)
{
m_args = args;
}
-void MinecraftProcess::setMinecraftWorkdir(QString path)
+void MinecraftProcess::setWorkdir(QString path)
{
QDir mcDir(path);
this->setWorkingDirectory(mcDir.absolutePath());
@@ -101,7 +101,7 @@ void MinecraftProcess::on_stdOut()
for (int i = 0; i < lines.size() - 1; i++)
{
QString &line = lines[i];
- emit log(line /*.replace(username, "<Username>").replace(sessionID, "<Session ID>")*/,
+ emit log(line.replace(username, "<Username>").replace(sessionID, "<Session ID>"),
getLevel(line, MessageLevel::Message));
}
if (!complete)
@@ -111,19 +111,24 @@ void MinecraftProcess::on_stdOut()
// exit handler
void MinecraftProcess::finish(int code, ExitStatus status)
{
- if (status != NormalExit)
+ if (!killed)
{
- // TODO: error handling
+ if (status == NormalExit)
+ {
+ //: Message displayed on instance exit
+ emit log(tr("Minecraft exited with exitcode %1.").arg(code));
+ }
+ else
+ {
+ //: Message displayed on instance crashed
+ emit log(tr("Minecraft crashed with exitcode %1.").arg(code));
+ }
}
-
- // TODO: Localization
-
- if (!killed)
- //: Message displayed on instance exit
- emit log(tr("Minecraft exited with exitcode %1.").arg(status));
else
+ {
//: Message displayed after the instance exits due to kill request
emit log(tr("Minecraft was killed by user."), MessageLevel::Error);
+ }
m_prepostlaunchprocess.processEnvironment().insert("INST_EXITCODE", QString(code));
@@ -134,11 +139,12 @@ void MinecraftProcess::finish(int code, ExitStatus status)
m_prepostlaunchprocess.waitForFinished();
if (m_prepostlaunchprocess.exitStatus() != NormalExit)
{
- // TODO: error handling
+ emit postlaunch_failed(m_instance, m_prepostlaunchprocess.exitCode(),
+ m_prepostlaunchprocess.exitStatus());
}
}
m_instance->cleanupAfterRun();
- emit ended(m_instance);
+ emit ended(m_instance, code, status);
}
void MinecraftProcess::killMinecraft()
@@ -155,7 +161,9 @@ void MinecraftProcess::launch()
m_prepostlaunchprocess.waitForFinished();
if (m_prepostlaunchprocess.exitStatus() != NormalExit)
{
- // TODO: error handling
+ m_instance->cleanupAfterRun();
+ emit prelaunch_failed(m_instance, m_prepostlaunchprocess.exitCode(),
+ m_prepostlaunchprocess.exitStatus());
return;
}
}
@@ -166,15 +174,15 @@ void MinecraftProcess::launch()
QString JavaPath = m_instance->settings().get("JavaPath").toString();
emit log(QString("Java path: '%1'").arg(JavaPath));
emit log(QString("Arguments: '%1'").arg(
- m_args.join("' '") /*.replace(username, "<Username>").replace(sessionID, "<Session
-ID>")*/));
+ m_args.join("' '").replace(username, "<Username>").replace(sessionID, "<Session ID>")));
start(JavaPath, m_args);
if (!waitForStarted())
{
//: Error message displayed if instace can't start
- emit log(tr("Could not launch minecraft!"));
+ emit log(tr("Could not launch minecraft!"), MessageLevel::Error);
+ m_instance->cleanupAfterRun();
+ emit launch_failed(m_instance);
return;
- // TODO: error handling
}
}