Fix ending STK when no STKHost exists.

This commit is contained in:
hiker 2015-11-01 21:28:39 +11:00
parent 1334a467e3
commit 15e3ac021f
2 changed files with 12 additions and 5 deletions

View File

@ -1508,7 +1508,9 @@ int main(int argc, char *argv[] )
// so we don't crash later when StateManager tries to access input devices.
StateManager::get()->resetActivePlayers();
if(input_manager) delete input_manager; // if early crash avoid delete NULL
STKHost::get()->abort();
if(STKHost::isNetworking())
STKHost::get()->abort();
cleanSuperTuxKart();
@ -1617,7 +1619,8 @@ static void cleanSuperTuxKart()
// FIXME: do we need to wait for threads there, can they be
// moved further up?
Online::ServersManager::deallocate();
STKHost::destroy();
if(STKHost::isNetworking())
STKHost::destroy();
cleanUserConfig();

View File

@ -46,6 +46,7 @@
#include "network/protocol_manager.hpp"
#include "network/network_world.hpp"
#include "network/protocols/start_game_protocol.hpp"
#include "network/stk_host.hpp"
#include "states_screens/grand_prix_cutscene.hpp"
#include "states_screens/grand_prix_lose.hpp"
#include "states_screens/grand_prix_win.hpp"
@ -511,10 +512,13 @@ void RaceManager::startNextRace()
m_kart_status[i].m_last_time = 0;
}
StartGameProtocol* protocol = static_cast<StartGameProtocol*>(
if(STKHost::isNetworking())
{
StartGameProtocol* protocol = static_cast<StartGameProtocol*>(
ProtocolManager::getInstance()->getProtocol(PROTOCOL_START_GAME));
if (protocol)
protocol->ready();
if (protocol)
protocol->ready();
}
} // startNextRace
//-----------------------------------------------------------------------------