[Client] Ensure mwmp::Main is initialized before GUIController cleanup

Previously, certain errors early in the program's execution – such as an attempt to use two different packet processors for the same packet ID – would not be displayed because of a crash when attempting to get an uninitialized mwmp::Main in the Engine's destructor.
pull/556/head
David Cernat 5 years ago
parent 5b4db83d61
commit 270867a397

@ -345,8 +345,10 @@ OMW::Engine::~Engine()
/*
Start of tes3mp addition
Free up memory allocated by multiplayer's GUIController
Free up memory allocated by multiplayer's GUIController, but make sure
mwmp::Main has actually been initialized
*/
if (mwmp::Main::isInitialized())
mwmp::Main::get().getGUIController()->cleanUp();
/*
End of tes3mp addition

@ -163,6 +163,11 @@ void Main::postInit()
MWBase::Environment::get().getMechanicsManager()->toggleAI();
}
bool Main::isInitialized()
{
return pMain != nullptr;
}
void Main::destroy()
{
assert(pMain);

@ -23,6 +23,7 @@ namespace mwmp
static void configure(const boost::program_options::variables_map &variables);
static bool init(std::vector<std::string> &content, Files::Collections &collections);
static void postInit();
static bool isInitialized();
static void destroy();
static const Main &get();
static void frame(float dt);

Loading…
Cancel
Save