From 1ebfb61ce4c997e7fc2aa52ecc34e9dbe0a8968d Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Thu, 8 Oct 2015 20:48:57 +0200 Subject: Store UserWishes in Session-file --- src/crsm.hpp | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'src/crsm.hpp') diff --git a/src/crsm.hpp b/src/crsm.hpp index 9351db8..d9434d6 100644 --- a/src/crsm.hpp +++ b/src/crsm.hpp @@ -49,6 +49,39 @@ public: ScenarioSettings(const QString& name, bool league = false) : name(name), league(league) {} ScenarioSettings(const QString& name, const ClientInfo& client, bool league = false) : name(name), league(league), wishClient(client) {} + ScenarioSettings() {} + inline bool operator ==(const ScenarioSettings& other) const + { + return name == other.name && league == other.league && randomLeague == other.randomLeague && wishClient == other.wishClient; + } +}; + +template<> +class CRSMConfigValue : public CRSMConfigValueBase { + ScenarioSettings& config; + +public: + CRSMConfigValue(ScenarioSettings& config) : config(config) { } + + void setValue(const QString& val) + { + QStringList parts = val.split(':', QString::KeepEmptyParts); + if(parts.length() < 3) + { + throw CRSMConfigException("Cannot read corrupt ScenarioSettings"); + } + else + { + config.name = CRSMConfigValueBase::getValue(parts.first()); + parts.removeFirst(); + config.league = CRSMConfigValueBase::getValue(parts.first()); + parts.removeFirst(); + config.randomLeague = false; + config.wishClient = CRSMConfigValueBase::getValue(parts.join(':')); + } + } + + QString value() { return CRSMConfigValueBase::getStringValue(config.name) + ":" + CRSMConfigValueBase::getStringValue(config.league) + ":" + CRSMConfigValueBase::getStringValue(config.wishClient); } }; class CRSM : public QObject @@ -84,9 +117,9 @@ public: ~CRSM(); void start(); bool isOk(); - + signals: - + private slots: void readServerOutput(); void readInput(); @@ -147,7 +180,14 @@ private: ConfigValue(IRC.Admin), ConfigValue(IRC.UseIngameChat), }) {} - } Session; + + CRSMSession(CRSM* crsm) : CRSMSession() + { + addConfigValue("Hosting.UserWishes", mkConfigValue(crsm->userlist, false)); + } + }; + + CRSMSession Session; QList userlist; QList autolist; -- cgit v1.2.3-54-g00ecf