From 3fe710cb029522b86ef27c322f0cb793b1368051 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Tue, 21 Mar 2017 22:00:59 +0100 Subject: Move Parser into own class --- src/crsm.hpp | 89 ++++++++++++++---------------------------------------------- 1 file changed, 20 insertions(+), 69 deletions(-) (limited to 'src/crsm.hpp') 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 : 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 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 userlist; QList autolist; QList nextAutoScens; -- cgit v1.2.3-54-g00ecf