diff options
| author | Markus Mittendrein <git@maxmitti.tk> | 2017-03-21 22:00:59 +0100 |
|---|---|---|
| committer | Markus Mittendrein <git@maxmitti.tk> | 2017-04-06 12:00:13 +0200 |
| commit | 3fe710cb029522b86ef27c322f0cb793b1368051 (patch) | |
| tree | a927da96f3851f68e2b16d40f2d20b73d67cce1d /src/crsm.hpp | |
| parent | e56c72bf1a0edda6deb3da548923939a88fd930b (diff) | |
| download | manager-3fe710cb029522b86ef27c322f0cb793b1368051.tar.gz manager-3fe710cb029522b86ef27c322f0cb793b1368051.zip | |
Move Parser into own class
Diffstat (limited to 'src/crsm.hpp')
| -rw-r--r-- | src/crsm.hpp | 89 |
1 files changed, 20 insertions, 69 deletions
diff --git a/src/crsm.hpp b/src/crsm.hpp index 34b0cc8..87886c6 100644 --- a/src/crsm.hpp +++ b/src/crsm.hpp @@ -22,10 +22,14 @@ #include "CmdFunctionRef.hpp" #include "ProcessManager.hpp" #include "CRSMConfig.hpp" +#include "CRSMSession.hpp" #include "CRSMStats.hpp" #include "CRSMPackCompatibility.hpp" #include "CRSMLogging.hpp" +#include "ClonkInterface.hpp" +#include "PatchedClonkParser.hpp" + #define CONFIG_FILE_NAME "CrServerManager.conf" #define SESSION_FILE_NAME "CrServerManager.session" #define CUR_SCEN_FILE_NAME "curscen.txt" @@ -44,22 +48,6 @@ class CRSM; using IrcCheckCallback = void (CRSM::*)(const ClientInfo&, int, const ClientInfo&); -class ScenarioSettings { -public: - QString name; - ClientInfo wishClient; - bool league = false; - bool randomLeague = false; - - ScenarioSettings(const QString& name, bool league = false) : name(name), league(league) {} - ScenarioSettings(const QString& name, const ClientInfo& client, bool league = false) : name(name), wishClient(client), league(league) {} - ScenarioSettings() {} - inline bool operator ==(const ScenarioSettings& other) const - { - return name == other.name && league == other.league && randomLeague == other.randomLeague && wishClient == other.wishClient; - } -}; - template<> class ConfigValue<ScenarioSettings> : public ConfigValueBase { ScenarioSettings& config; @@ -88,8 +76,9 @@ public: QString value() { return Util::joinEscape({ConfigValueBase::getStringValue(config.name), ConfigValueBase::getStringValue(config.league), ConfigValueBase::getStringValue(config.wishClient)}, ':', '|'); } }; -class CRSM : public QObject +class CRSM : public QObject, public ClonkOutputInterface { + friend CRSMSession::CRSMSession(CRSM *crsm); private: enum IrcModOperations { ModCheck, @@ -122,6 +111,18 @@ public: void start(); bool isOk(); + void lobbyCountdown(unsigned int seconds); + void lobbyCountdownAborted(); + void watchdog(const QString &id); + void clientMessage(ClientInfo &client, const QString &message, ClonkOutputInterface::MessageType type, const QTime& time); + void clientConnected(const ClientInfo &client); + void clientRemoved(const ClientInfo &client, const QString& reason); + void gameLoading(); + void gameStarted(); + void masterserverError(const QString &msg); + void raw(const QString& line); + void rawTimed(const QString& line, const QTime& time); + void playerRemoved(const QString &name); signals: private slots: @@ -151,63 +152,13 @@ private slots: private: CRSMConfig Config; - - struct CRSMSession : public ConfigBase { - enum SessionState {None = -1, Lobby = 0, Loading = 1, Running = 2}; - - Boolean League = false; - SessionState State = None; - Boolean UserWish = false; - Boolean AfkAdmin = false; - Integer CountDown = -1; - ScenarioSettings Scenario; - - - struct { - ClientInfo Admin; - Map(String, ClientInfo) Clients; - ClientInfo Server; - QMap<ClientInfo, QDateTime> LeaveAdmins; - } Clonk; - - struct { - ClientInfo Admin; - Boolean UseIngameChat = false; - } IRC; - - void clear() - { - auto configVals = configValues; - *this = CRSMSession(); - configValues = configVals; - } - - CRSMSession() : ConfigBase::ConfigBase({ - ConfigVal(League), - ConfigVal(State), - ConfigVal(UserWish), - ConfigVal(CountDown), - ConfigVal(Scenario), - - ConfigVal(Clonk.Admin), - ConfigVal(Clonk.Clients), - ConfigVal(Clonk.Server), - - ConfigVal(IRC.Admin), - ConfigVal(IRC.UseIngameChat), - }) {} - - CRSMSession(CRSM* crsm) : CRSMSession() - { - addConfigValue("Hosting.UserWishes", mkConfigValue(crsm->userlist, false)); - } - }; - CRSMSession Session; CRSMStats Stats; CRSMPackCompatibility Packs; CRSMLogging Log; + PatchedClonkParser parser; + QList<ScenarioSettings> userlist; QList<ScenarioSettings> autolist; QList<ScenarioSettings> nextAutoScens; |
