diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index 36d384d0..152e66df 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -845,6 +845,7 @@ void mainWindowImpl::callCreateNetworkGameDialog() { myServerGuiInterface.reset(new ServerGuiWrapper(myConfig, mySession->getGui(), mySession->getGui(), mySession->getGui())); { boost::shared_ptr session(new Session(myServerGuiInterface.get(), myConfig)); + session->init(mySession->getAvatarManager()); myServerGuiInterface->setSession(session); } } @@ -1151,9 +1152,9 @@ void mainWindowImpl::initGui(int speed) void mainWindowImpl::showClientDialog() { - if (mySession->GetGameType() == Session::GAME_TYPE_NETWORK) + if (mySession->getGameType() == Session::GAME_TYPE_NETWORK) showNetworkStartDialog(); - else if (mySession->GetGameType() == Session::GAME_TYPE_INTERNET) + else if (mySession->getGameType() == Session::GAME_TYPE_INTERNET) showLobbyDialog(); } diff --git a/src/session.cpp b/src/session.cpp index cd1bed56..fbbf7182 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -42,7 +42,6 @@ Session::Session(GuiInterface *g, ConfigFile *c) : currentGameID(0), myNetClient(NULL), myNetServer(NULL), myIrcThread(NULL), myGui(g), myConfig(c), myGameType(GAME_TYPE_NONE) { - myAvatarManager.reset(new AvatarManager); } @@ -56,9 +55,15 @@ Session::~Session() bool Session::init() { + myAvatarManager.reset(new AvatarManager); return myAvatarManager->Init(myConfig->readConfigString("AppDataDir"), myConfig->readConfigString("CacheDir")); } +void Session::init(boost::shared_ptr manager) +{ + myAvatarManager = manager; +} + void Session::startLocalGame(const GameData &gameData, const StartData &startData) { myGameType = GAME_TYPE_LOCAL; @@ -117,11 +122,16 @@ GuiInterface *Session::getGui() return myGui; } -Session::GameType Session::GetGameType() +Session::GameType Session::getGameType() { return myGameType; } +boost::shared_ptr Session::getAvatarManager() +{ + return myAvatarManager; +} + void Session::startInternetClient() { if (myNetClient || myIrcThread || !myGui) diff --git a/src/session.h b/src/session.h index 27b79eeb..2d732994 100755 --- a/src/session.h +++ b/src/session.h @@ -42,16 +42,18 @@ public: enum GameType { GAME_TYPE_NONE, GAME_TYPE_LOCAL, GAME_TYPE_NETWORK, GAME_TYPE_INTERNET }; + // Only one of the two inits should be called. bool init(); + void init(boost::shared_ptr manager); void startLocalGame(const GameData &gameData, const StartData &startData); void startClientGame(boost::shared_ptr game); Game *getCurrentGame(); - GuiInterface *getGui(); + GameType getGameType(); - GameType GetGameType(); + boost::shared_ptr getAvatarManager(); void startInternetClient(); void startNetworkClient(const std::string &serverAddress, unsigned serverPort, bool ipv6, bool sctp, const std::string &pwd);