summaryrefslogtreecommitdiffstats
path: root/src/crsm.cpp
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2015-09-22 17:27:43 +0200
committerMarkus Mittendrein <git@maxmitti.tk>2015-09-22 17:51:43 +0200
commitb9a818bebcfc6e261959c4df95330594e9cbcffc (patch)
treebb789f6f6fcbcc41515e8a69ebe219a31e9b9474 /src/crsm.cpp
parent72e324a6d8f12a4b170a78eb9cc14b695147233f (diff)
downloadmanager-b9a818bebcfc6e261959c4df95330594e9cbcffc.tar.gz
manager-b9a818bebcfc6e261959c4df95330594e9cbcffc.zip
Remove unnecessary commented out code and restore needed code of
CRSM::readConfig.
Diffstat (limited to 'src/crsm.cpp')
-rw-r--r--src/crsm.cpp176
1 files changed, 34 insertions, 142 deletions
diff --git a/src/crsm.cpp b/src/crsm.cpp
index 0b22d72..1390692 100644
--- a/src/crsm.cpp
+++ b/src/crsm.cpp
@@ -68,10 +68,8 @@ CRSM::CRSM(QObject *parent) :
autoHost = Config.Hosting.Auto;
connect(processManager, SIGNAL(readyRead()), this, SLOT(readServerOutput()));
- //connect(processManager, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError()));
+
connect(processManager, SIGNAL(finished(int)), this, SLOT(scenarioFinished()));
- //QSocketNotifier *inNotifier = new QSocketNotifier(STDIN_FILENO, QSocketNotifier::Read,this);
- //connect(inNotifier, SIGNAL(activated(int)), this, SLOT(readInput()));
QFile *reallog = new QFile(Config.Auto.Volatile.Clonk.Directory + "CRSM.log");
reallog->open(QIODevice::Append | QIODevice::Text);
@@ -273,11 +271,6 @@ void CRSM::readServerOutput()
}
}
-/*void CRSM::processError()
-{
- *qout << processManager->errorString() << endl;
-}*/
-
void CRSM::readInput()
{
QString what(qin->readLine());
@@ -683,7 +676,7 @@ void CRSM::startScen(const ScenarioSettings &scen, QStringList argList)
filename = scen.name;
while(Config.Hosting.Alias.contains(filename))
filename = Config.Hosting.Alias.value(filename);
- //processManager->setWorkingDirectory(QDir::currentPath());
+
if(scen.league)
{
argList << "/league";
@@ -702,112 +695,39 @@ void CRSM::readConfig()
{
Config.clear();
out(Config.read(CONFIG_FILE_NAME));
+ args = Config.Clonk.Server.Arguments.split(" ");
+ args << "/config:" + Config.Clonk.Server.Config;
+ Config.Auto.Volatile.Clonk.Directory = QFileInfo(Config.Clonk.Server.Executable).absoluteDir().absolutePath() + QDir::separator();
+
+ QFile clonkConfig(Config.Clonk.Server.Config);
+ if(!clonkConfig.exists())
+ {
+ out("WARNING: Clonk's config file is not existing!");
+ }
+ else
+ {
+ clonkConfig.open(QFile::ReadOnly);
+ static QRegExp nickExp(R"_(^\s*Nick="(.*)"\s*$)_");
+ static QRegExp pcNameExp(R"_(^\s*LocalName="(.*)"\s*$)_");
+ foreach(const QString &line, QString(clonkConfig.readAll().trimmed()).split("\n"))
+ {
+ if(nickExp.exactMatch(line.trimmed()))
+ {
+ Config.Auto.Volatile.Clonk.ServerNick = nickExp.cap(1);
+ continue;
+ }
+ else if(pcNameExp.exactMatch(line.trimmed()))
+ {
+ Config.Auto.Volatile.Clonk.ServerPCName = pcNameExp.cap(1);
+ continue;
+ }
+ }
+ }
+ if((ushort)Config.CRSM.ManagementPort == 0)
+ {
+ Config.CRSM.ManagementPort = 9372;
+ }
return;
-// settings["IrcReconnectDelay"] = "10";
-// settings["EmptyTimer"] = "60";
-// settings["MaxUserWishes"] = "2";
-// settings["MaxScenWishes"] = "2";
-// settings["AntiFloodCount"] = "5";
-// settings["AntiFloodTime"] = "3";
-// settings["RegainAdminTime"] = "120";
-// settings["ServerExecutable"] = "clonk-server";
-// settings["Arguments"] = "/fullscreen /lobby:300 /nosignup Objects.c4d";
-// settings["ClonkConfig"] = "config";
-// settings["UserListLength"] ="5";
-// settings["ManagementPort"] = "9372";
-
-// QFile config(CONFIG_FILE_NAME);
-// if(!config.exists())
-// {
-// config.open(QIODevice::WriteOnly | QIODevice::Text);
-// writeConfig();
-// }
-// else if(config.open(QIODevice::ReadOnly | QIODevice::Text))
-// {
-// QRegExp confExp("^([^=]+)=(.*)$");
-// QRegExp confPlusExp("^([^=]+)\\+=(.*)$");
-// QRegExp confMapExp("^([^\\[]+)\\[([^\\]]+)\\]\\s*=\\s*(.*)$");
-// QString line;
-// for(;;)
-// {
-// line = config.readLine().trimmed();
-// if(confPlusExp.exactMatch(line))
-// {
-// lists[confPlusExp.cap(1).trimmed()].push_back(confPlusExp.cap(2).trimmed());
-// }
-// else if(confMapExp.exactMatch(line))
-// {
-// maps[confMapExp.cap(1).trimmed()][confMapExp.cap(2).trimmed()] = confMapExp.cap(3).trimmed();
-// }
-// else if(confExp.exactMatch(line))
-// {
-// settings.insert(confExp.cap(1).trimmed(),confExp.cap(2).trimmed());
-// }
-// if(config.atEnd())
-// break;
-// }
-// }
-
-// out("config:\n");
-// foreach(const QString &key, settings.keys())
-// {
-// out(key + " = " + settings.value(key) + "\n");
-// }
-// out("\n");
-// foreach(const QString &key, lists.keys())
-// {
-// out(key + ":\n");
-// foreach(const QString &val, lists.value(key))
-// {
-// out("\t" + val + "\n");
-// }
-// }
-// out("\n");
-// foreach(const QString &key, maps.keys())
-// {
-// out(key + ":\n");
-// foreach(const QString &mapkey, maps.value(key).keys())
-// {
-// out("\t[" + mapkey + "]" + " = " + maps.value(key).value(mapkey) + "\n");
-// }
-// }
-// out("\n");
-// args = settings["Arguments"].split(" ");
-// args << "/config:"+settings["ClonkConfig"];
-// settings["ClonkDirectory"] = QFileInfo(settings["ServerExecutable"]).absoluteDir().absolutePath()+QDir::separator();
-
-// QFile clonkconfig(settings["ClonkConfig"]);
-// if(!clonkconfig.exists())
-// out("WARNING: Clonk's config file is not existing!");
-// else
-// {
-// clonkconfig.open(QFile::ReadOnly);
-// QRegExp nickExp("^\\s*Nick=\"(.*)\"\\s*$");
-// QRegExp pcNameExp("^\\s*LocalName=\"(.*)\"\\s*$");
-// foreach(const QString &line, QString(clonkconfig.readAll().trimmed()).split("\n"))
-// {
-// if(nickExp.exactMatch(line))
-// {
-// settings["ServerNick"] = nickExp.cap(1);
-// break;
-// }
-// else if(pcNameExp.exactMatch(line))
-// {
-// settings["ServerPCName"] = pcNameExp.cap(1);
-// break;
-// }
-// }
-// out("\n");
-// out("ClonkDirectory = " + settings.value("ClonkDirectory") + "\n");
-// out("ServerNick = " + settings.value("ServerNick") + "\n");
-// }
-// out("\n");
-// bool ok;
-// ushort mgmtPort = settings["ManagementPort"].toUShort(&ok);
-// if(!ok || mgmtPort == 0)
-// {
-// settings["ManagementPort"] = "9372";
-// }
}
@@ -1125,34 +1045,6 @@ void CRSM::writeToServer(const QString &message)
void CRSM::writeConfig()
{
Config.write(CONFIG_FILE_NAME);
- /*QFile config(CONFIG_FILE_NAME);
- config.open(QFile::WriteOnly);
-
- QTextStream configStream(&config);
-
- foreach(const QString &key, settings.keys())
- {
- configStream << key << " = " << settings.value(key) << endl;
- }
- configStream << endl;
- foreach(const QString &key, lists.keys())
- {
- foreach(const QString &val, lists.value(key))
- {
- configStream << key << " += " << val << endl;
- }
- }
- configStream << endl;
- foreach(const QString &key, maps.keys())
- {
- foreach(const QString &mapkey, maps.value(key).keys())
- {
- configStream << key << "[" << mapkey << "]" << " = " << maps.value(key).value(mapkey) << endl;
- }
- }
- configStream << endl;
-
- config.close();*/
}
QString CRSM::addAliasWish(const QString &param)