Fix crash if connection has failed

This commit is contained in:
Koncord 2016-12-03 23:36:53 +08:00
parent 75061e2504
commit 753dc50131
4 changed files with 5 additions and 4 deletions

View file

@ -632,6 +632,8 @@ private:
void OMW::Engine::go() void OMW::Engine::go()
{ {
assert (!mContentFiles.empty()); assert (!mContentFiles.empty());
if(!mwmp::Main::init(mContentFiles))
return;
mViewer = new osgViewer::Viewer; mViewer = new osgViewer::Viewer;
@ -660,7 +662,6 @@ void OMW::Engine::go()
ToUTF8::Utf8Encoder encoder (mEncoding); ToUTF8::Utf8Encoder encoder (mEncoding);
mEncoder = &encoder; mEncoder = &encoder;
mwmp::Main::init(mContentFiles);
prepareEngine (settings); prepareEngine (settings);
mwmp::Main::postInit(); mwmp::Main::postInit();
mSkipMenu = true; mSkipMenu = true;

View file

@ -113,7 +113,7 @@ void RestoreMgr(Settings::Manager &mgr)
mgr.mChangedSettings = saveChangedSettings; mgr.mChangedSettings = saveChangedSettings;
} }
void Main::init(std::vector<std::string> &content) bool Main::init(std::vector<std::string> &content)
{ {
assert(!pMain); assert(!pMain);
pMain = new Main(); pMain = new Main();
@ -138,6 +138,7 @@ void Main::init(std::vector<std::string> &content)
pMain->mNetworking->connect(pMain->server, pMain->port); pMain->mNetworking->connect(pMain->server, pMain->port);
RestoreMgr(mgr); RestoreMgr(mgr);
return pMain->mNetworking->isConnected();
} }
void Main::postInit() void Main::postInit()

View file

@ -15,7 +15,7 @@ namespace mwmp
static void optionsDesc(boost::program_options::options_description *desc); static void optionsDesc(boost::program_options::options_description *desc);
static void configure(const boost::program_options::variables_map &variables); static void configure(const boost::program_options::variables_map &variables);
static void init(std::vector<std::string> &content); static bool init(std::vector<std::string> &content);
static void postInit(); static void postInit();
static void destroy(); static void destroy();
static const Main &get(); static const Main &get();

View file

@ -170,7 +170,6 @@ void Networking::connect(const std::string &ip, unsigned short port)
{ {
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, errmsg.c_str()); LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, errmsg.c_str());
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "tes3mp", errmsg.c_str(), 0); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "tes3mp", errmsg.c_str(), 0);
MWBase::Environment::get().getStateManager()->requestQuit();
} }
} }