From 753dc5013141c5a2db26bd056cab558f981bf353 Mon Sep 17 00:00:00 2001 From: Koncord Date: Sat, 3 Dec 2016 23:36:53 +0800 Subject: [PATCH] Fix crash if connection has failed --- apps/openmw/engine.cpp | 3 ++- apps/openmw/mwmp/Main.cpp | 3 ++- apps/openmw/mwmp/Main.hpp | 2 +- apps/openmw/mwmp/Networking.cpp | 1 - 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 4a4f036bf..30b614f52 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -632,6 +632,8 @@ private: void OMW::Engine::go() { assert (!mContentFiles.empty()); + if(!mwmp::Main::init(mContentFiles)) + return; mViewer = new osgViewer::Viewer; @@ -660,7 +662,6 @@ void OMW::Engine::go() ToUTF8::Utf8Encoder encoder (mEncoding); mEncoder = &encoder; - mwmp::Main::init(mContentFiles); prepareEngine (settings); mwmp::Main::postInit(); mSkipMenu = true; diff --git a/apps/openmw/mwmp/Main.cpp b/apps/openmw/mwmp/Main.cpp index 5b952090d..8b9774428 100644 --- a/apps/openmw/mwmp/Main.cpp +++ b/apps/openmw/mwmp/Main.cpp @@ -113,7 +113,7 @@ void RestoreMgr(Settings::Manager &mgr) mgr.mChangedSettings = saveChangedSettings; } -void Main::init(std::vector &content) +bool Main::init(std::vector &content) { assert(!pMain); pMain = new Main(); @@ -138,6 +138,7 @@ void Main::init(std::vector &content) pMain->mNetworking->connect(pMain->server, pMain->port); RestoreMgr(mgr); + return pMain->mNetworking->isConnected(); } void Main::postInit() diff --git a/apps/openmw/mwmp/Main.hpp b/apps/openmw/mwmp/Main.hpp index 1e6a158e4..75b4b645e 100644 --- a/apps/openmw/mwmp/Main.hpp +++ b/apps/openmw/mwmp/Main.hpp @@ -15,7 +15,7 @@ namespace mwmp static void optionsDesc(boost::program_options::options_description *desc); static void configure(const boost::program_options::variables_map &variables); - static void init(std::vector &content); + static bool init(std::vector &content); static void postInit(); static void destroy(); static const Main &get(); diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index f2f4f1bbb..6b34a62a2 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -170,7 +170,6 @@ void Networking::connect(const std::string &ip, unsigned short port) { LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, errmsg.c_str()); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "tes3mp", errmsg.c_str(), 0); - MWBase::Environment::get().getStateManager()->requestQuit(); } }