summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2015-10-29 15:29:08 +0100
committerMarkus Mittendrein <git@maxmitti.tk>2015-10-31 01:52:09 +0100
commit00a8804ab8cc0bfd7b67a3c947f5d0de0eb958dc (patch)
tree9d491b86a0264b11be107a87c2fa1252bb5fd051 /src
parent920a7f8d46f62b06812145fa3b350f3eb6f1af80 (diff)
downloadmanager-00a8804ab8cc0bfd7b67a3c947f5d0de0eb958dc.tar.gz
manager-00a8804ab8cc0bfd7b67a3c947f5d0de0eb958dc.zip
Add 5 minute hosting timeout on a failure while registering a game at
the masterserver
Diffstat (limited to 'src')
-rw-r--r--src/crsm.cpp73
-rw-r--r--src/crsm.hpp5
2 files changed, 72 insertions, 6 deletions
diff --git a/src/crsm.cpp b/src/crsm.cpp
index ac2ea04..c1fa131 100644
--- a/src/crsm.cpp
+++ b/src/crsm.cpp
@@ -278,10 +278,37 @@ void CRSM::readServerOutput()
{
Session.CountDown = -1;
}
+
+ static QRegExp gameRegisterFailExp(R"(^(?:Spiel konnte nicht registriert werden|Could not register game): (.*))");
+ if(gameRegisterFailExp.exactMatch(what))
+ {
+ QString reason = gameRegisterFailExp.cap(1);
+ userlist.clear();
+ if(autoHost && !hostingIsErrorDeactivated)
+ {
+ hostingIsErrorDeactivated = true;
+ gameRegisterFailTimer.singleShot(5*60*1000, this, SLOT(enableAutoHosting()));
+ }
+ autoHost = false;
+ static const QString gameRegisterFailMessage = "Aufgrund eines Problems beim Registrieren des Spiels am Masterserver (%1) wird Hosting temporär (für 5 Minuten) deaktiviert.\n";
+ out(gameRegisterFailMessage.arg(reason));
+ if(Config.IRC.Use)
+ {
+ connection->sendCommand(IrcCommand::createMessage(Config.IRC.Channel, gameRegisterFailMessage.arg(reason)));
+ if(Config.IRC.UseIngameChat)
+ {
+ connection->sendCommand(IrcCommand::createMessage(Config.IRC.IngameChannel, gameRegisterFailMessage.arg(reason)));
+ }
+ }
+ }
}
void CRSM::nextScen()
{
+ if(hostingIsErrorDeactivated)
+ {
+ return;
+ }
if(userlist.length()>0)
{
startScen(userlist.at(0), args);
@@ -1351,6 +1378,7 @@ void CRSM::setupCmds()
addCommandGroup("packs", Management, UserType::Max, "Über die packs-Befehlsgruppe lassen sich mehrere Versionen eines Objektpakets für unterschiedliche Szenarien verwalten.");
addCommand("packs list", &CRSM::packsList, Management, UserType::Max, "Listet alle bekannten Packs und ihre Versionen auf.");
+ addCommand("packs directory", &CRSM::packsDirectory, Management, UserType::Max, "Fragt den aktuellen Unterordner für Packversionen ab, bzw. setzt ihn auf <Directory>.", "[Directory]");
addCommandGroup("packs versions", Management, UserType::Max, "Über die packs versions-Befehlsgruppe werden die einzelnen bekannten Packs und vorhandenen Versionen verwaltet.");
addCommand("packs versions add", &CRSM::packsVersionsAdd, Management, UserType::Max, "Fügt eine neue <Packversion> für das <Pack> hinzu.", "<Packversion> = <Pack>");
addCommand("packs versions delete", &CRSM::packsVersionsDelete, Management, UserType::Max, "Löscht eine <Packversion>.", "<Packversion>");
@@ -1557,6 +1585,18 @@ void CRSM::reconnectIrc()
prepareAndConnectIrc();
}
+void CRSM::enableAutoHosting()
+{
+ gameRegisterFailTimer.stop();
+ hostingIsErrorDeactivated = false;
+
+ autoHost = true;
+ if(Session.State == CRSMSession::None)
+ {
+ nextScen();
+ }
+}
+
ClientInfo &CRSM::getClientInfo(const QString &pcName, int cuid, const QString &user)
{
if(!Session.Clonk.Clients.contains(pcName))
@@ -1812,7 +1852,12 @@ CMD_FUNCTION_IMPL(admin)
}
CMD_FUNCTION_IMPL(host)
- if(userlist.length() >= Config.Hosting.UserListLength)
+ if(hostingIsErrorDeactivated)
+ {
+ respond(client, "Hosting ist aufgrund eines Problems temporär deaktiviert.\n");
+ return Success;
+ }
+ else if(userlist.length() >= Config.Hosting.UserListLength)
respond(client, "Maximale Warteschlangenlänge von " + QString::number(Config.Hosting.UserListLength) + " erreicht!\n");
else
{
@@ -1887,16 +1932,13 @@ CMD_FUNCTION_IMPL(ircchat)
CMD_FUNCTION_IMPL(autohost)
if(cmd == "autohost")
{
- autoHost = true;
respond(client, "Automatisches Hosting aktiviert.\n");
- if(Session.State == CRSMSession::None)
- {
- nextScen();
- }
+ enableAutoHosting();
}
else if(cmd == "noautohost")
{
autoHost = false;
+ gameRegisterFailTimer.stop();
respond(client, "Automatisches Hosting deaktiviert.\n");
}
return Success;
@@ -2420,6 +2462,25 @@ CMD_FUNCTION_IMPL(packsList)
return Success;
}
+CMD_FUNCTION_IMPL(packsDirectory)
+ if(args.isEmpty())
+ {
+ respond(client, "Das aktuelle PacksDirectory ist \"" + Packs.PacksDirectory + "\".\n");
+ return Success;
+ }
+ else
+ {
+ Packs.PacksDirectory = args;
+ QString response = Packs.applyConfig();
+ if(response.isEmpty())
+ {
+ response = "Das PackDirectory wurde erfolgreich geändert.\n";
+ }
+ respond(client, response);
+ return Success;
+ }
+}
+
CMD_FUNCTION_IMPL(packsVersionsAdd)
const QStringList& argList = Util::splitEscaped(args, '=');
if(argList.length() != 2)
diff --git a/src/crsm.hpp b/src/crsm.hpp
index 7c3c34f..18a3b7c 100644
--- a/src/crsm.hpp
+++ b/src/crsm.hpp
@@ -17,6 +17,7 @@
#include <QSignalMapper>
#include <QTcpServer>
#include <QTcpSocket>
+#include <QTimer>
#include "CmdFunctionRef.hpp"
#include "ProcessManager.hpp"
@@ -136,6 +137,7 @@ private slots:
void updateNextAutoScens();
void reconnectIrc();
+ void enableAutoHosting();
private:
CRSMConfig Config;
@@ -221,8 +223,10 @@ private:
ProcessManager* processManager = nullptr;
QTcpServer managementServer;
QMap<QTcpSocket*, ManagementConnection> managementConnections;
+ QTimer gameRegisterFailTimer;
bool ok = false;
+ bool hostingIsErrorDeactivated = false;
void startScen(const ScenarioSettings& scen, QStringList);
void readConfig();
@@ -333,6 +337,7 @@ private:
CMD_FUNCTION(ircWatch);
CMD_FUNCTION(packsList);
+ CMD_FUNCTION(packsDirectory);
CMD_FUNCTION(packsVersionsAdd);
CMD_FUNCTION(packsVersionsDelete);
CMD_FUNCTION(packsVersionsDefault);