Avoid crash if networking was selected, but not actually started.

This commit is contained in:
hiker
2015-11-21 12:20:05 +11:00
parent e804fc281a
commit 093283c5b0
2 changed files with 6 additions and 2 deletions

View File

@@ -1518,7 +1518,7 @@ int main(int argc, char *argv[] )
StateManager::get()->resetActivePlayers();
if(input_manager) delete input_manager; // if early crash avoid delete NULL
if(NetworkConfig::get()->isNetworking())
if(NetworkConfig::get()->isNetworking() && STKHost::existHost())
STKHost::get()->abort();
cleanSuperTuxKart();
@@ -1628,7 +1628,7 @@ static void cleanSuperTuxKart()
// FIXME: do we need to wait for threads there, can they be
// moved further up?
ServersManager::deallocate();
if(NetworkConfig::get()->isNetworking())
if(NetworkConfig::get()->isNetworking() && STKHost::existHost())
STKHost::destroy();
cleanUserConfig();

View File

@@ -97,8 +97,12 @@ public:
/** Set that this is a LAN networked game. */
void setIsLAN() { m_network_type = NETWORK_LAN; }
// ------------------------------------------------------------------------
/** Set that this is a WAN networked game. */
void setIsWAN() { m_network_type = NETWORK_WAN; }
// ------------------------------------------------------------------------
/** Set that this is not a networked game. */
void unsetNetworking() { m_network_type = NETWORK_NONE; }
// ------------------------------------------------------------------------
/** Sets the maximum number of players for this server. */
void setMaxPlayers(int n) { m_max_players = n; }
// --------------------------------------------------------------------