From 50d9907af2522a9a6e02a171b9a26938a743971c Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Thu, 24 Sep 2015 22:10:19 +0200 Subject: Save session to CrServerManager.session on detach and load it on reattaching --- src/crsm.hpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'src/crsm.hpp') diff --git a/src/crsm.hpp b/src/crsm.hpp index 43a15ae..b2f0671 100644 --- a/src/crsm.hpp +++ b/src/crsm.hpp @@ -23,6 +23,7 @@ #include "CRSMConfig.hpp" #define CONFIG_FILE_NAME "CrServerManager.conf" +#define SESSION_FILE_NAME "CrServerManager.session" #define CUR_SCEN_FILE_NAME "curscen.txt" #define LAST_SCEN_FILE_NAME "lastscen.txt" #define SCOREBOARD_FILE_NAME Config.Auto.Volatile.Clonk.Directory + "scoreboard.html" @@ -106,29 +107,46 @@ private: CRSMConfig Config; - struct CRSMSession { - bool League = false; + struct CRSMSession : public CRSMConfigBase { + Boolean League = false; enum {None = -1, Lobby = 0, Loading = 1, Running = 2} State = None; - bool UserWish = false; - int CountDown = -1; - QString ScenarioName = ""; + Boolean UserWish = false; + Integer CountDown = -1; + String ScenarioName = ""; struct { ClientInfo Admin; - QMap Clients; + Map(String, ClientInfo) Clients; QMap LeaveAdmins; } Clonk; struct { ClientInfo Admin; - bool UseIngameChat = false; + Boolean UseIngameChat = false; } IRC; void clear() { + auto configVals = configValues; *this = CRSMSession(); + configValues = configVals; } + + CRSMSession() : CRSMConfigBase::CRSMConfigBase({ + ConfigValue(League), + ConfigValue((Integer&)State), + ConfigValue(UserWish), + ConfigValue(CountDown), + ConfigValue(ScenarioName), + + ConfigValue(Clonk.Admin), + ConfigValue(Clonk.Clients), + ConfigValue(Clonk.Clients), + + ConfigValue(IRC.Admin), + ConfigValue(IRC.UseIngameChat), + }) {} } Session; QList userlist; -- cgit v1.2.3-54-g00ecf