Bugfix: Fixed deadlock occurring when the server reaches the character
selection screen before a client has selected the number of players. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2252 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a4ce04aaf7
commit
10915df3bb
@ -43,10 +43,6 @@ enum WidgetTokens
|
||||
|
||||
MainMenu::MainMenu()
|
||||
{
|
||||
// Reset the state of the network manager to none (which is correct
|
||||
// independent if it is a client, server, or no networking
|
||||
network_manager->setState(NetworkManager::NS_NONE);
|
||||
|
||||
widget_manager->switchOrder();
|
||||
|
||||
const int WIDTH=30;
|
||||
|
@ -2,6 +2,7 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2008 Joerg Henrichs
|
||||
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
@ -120,8 +121,7 @@ void NetworkGUI::select()
|
||||
widget_manager->hideWgt(WTOK_CONNECT, WTOK_SERVER_ADDRESS);
|
||||
break;
|
||||
case WTOK_SERVER:
|
||||
network_manager->setMode(NetworkManager::NW_SERVER);
|
||||
network_manager->setState(NetworkManager::NS_ACCEPT_CONNECTIONS);
|
||||
network_manager->becomeServer();
|
||||
widget_manager->hideWgt(WTOK_MESSAGE);
|
||||
widget_manager->resizeWgtToText(WTOK_MESSAGE);
|
||||
widget_manager->showWgt(WTOK_MESSAGE);
|
||||
@ -172,7 +172,7 @@ void NetworkGUI::update(float dt)
|
||||
// called before the blocking initialiseConnection call).
|
||||
if(m_state==NGS_CONNECT_DOIT)
|
||||
{
|
||||
network_manager->setMode(NetworkManager::NW_CLIENT);
|
||||
network_manager->becomeClient();
|
||||
if(!network_manager->initialiseConnections())
|
||||
{
|
||||
widget_manager->setWgtText(WTOK_MESSAGE, _("Can't connect to server"));
|
||||
|
@ -97,6 +97,8 @@ bool NetworkManager::initServer()
|
||||
} // initServer
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** Initialises the client. This function tries to connect to the server.
|
||||
*/
|
||||
bool NetworkManager::initClient()
|
||||
{
|
||||
m_host = enet_host_create (NULL /* create a client host */,
|
||||
@ -145,6 +147,27 @@ bool NetworkManager::initClient()
|
||||
return true;
|
||||
} // initClient
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Switches the network manager to client mode. This function sets the state
|
||||
* to waiting_for_chars (so that the message from the server containing all
|
||||
* available characters can be received).
|
||||
*/
|
||||
void NetworkManager::becomeClient()
|
||||
{
|
||||
m_mode = NW_CLIENT;
|
||||
m_state = NS_WAIT_FOR_AVAILABLE_CHARACTERS;
|
||||
} // becomeClient
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Switches the network manager to server mode. This function sets the state
|
||||
* to accepting connections.
|
||||
*/
|
||||
void NetworkManager::becomeServer()
|
||||
{
|
||||
m_mode = NW_SERVER;
|
||||
m_state = NS_ACCEPT_CONNECTIONS;
|
||||
} // becomeServer
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Called in case of an error, to switch back to non-networking mode.
|
||||
*/
|
||||
|
@ -80,6 +80,8 @@ public:
|
||||
~NetworkManager();
|
||||
void setMode(NetworkMode m) {m_mode = m; }
|
||||
NetworkMode getMode() const {return m_mode; }
|
||||
void becomeServer();
|
||||
void becomeClient();
|
||||
void setState(NetworkState s) {m_state = s; }
|
||||
NetworkState getState() const {return m_state; }
|
||||
int getMyHostId() const {return m_host_id; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user