fix a bug that was making the game freeze (one protocol asked to start a protocol, and before the start of this protocol, was making infinite loop depending on the latter's existence)

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13235 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hilnius 2013-07-15 12:43:39 +00:00
parent d3ac41f984
commit cebbfdeb06
4 changed files with 17 additions and 8 deletions

View File

@ -51,7 +51,7 @@ ProtocolManager::ProtocolManager()
pthread_mutex_lock(&m_exit_mutex); // will let the update function run
/// NOT USED on client but updated in main loop (because of GUI crash)
if (NetworkManager::getInstance()->isServer)
if (NetworkManager::getInstance()->isServer())
{
m_update_thread = (pthread_t*)(malloc(sizeof(pthread_t)));
pthread_create(m_update_thread, NULL, protocolManagerUpdate, this);

View File

@ -71,6 +71,7 @@ void StartGameProtocol::notifyEvent(Event* event)
void StartGameProtocol::setup()
{
m_state = NONE;
Log::info("SynchronizationProtocol", "Ready !");
}
void StartGameProtocol::update()
@ -78,9 +79,8 @@ void StartGameProtocol::update()
if (m_state == NONE)
{
// if no synchronization protocol exists, create one
SynchronizationProtocol* protocol = static_cast<SynchronizationProtocol*>(m_listener->getProtocol(PROTOCOL_SYNCHRONIZATION));
if (!protocol)
m_listener->requestStart(new SynchronizationProtocol());
m_listener->requestStart(new SynchronizationProtocol());
Log::info("StartGameProtocol", "SynchronizationProtocol started.");
// race startup sequence
@ -105,17 +105,25 @@ void StartGameProtocol::update()
// self config
}
Log::info("StartGameProtocol", "Players config ready. Starting single race now.");
race_manager->startSingleRace("jungle", 1, false);
m_state = LOADING;
m_state = SYNCHRONIZATION_WAIT;
/*
KartSelectionScreen* s = KartSelectionScreen::getInstance();
s->setMultiplayer(false);
s->setFromOverworld(false);
StateManager::get()->pushScreen( s );*/
}
else if (m_state == SYNCHRONIZATION_WAIT)
{
SynchronizationProtocol* protocol = static_cast<SynchronizationProtocol*>
(m_listener->getProtocol(PROTOCOL_SYNCHRONIZATION));
if (protocol)
{
race_manager->startSingleRace("jungle", 1, false);
m_state = LOADING;
}
}
else if (m_state == LOADING)
{
}
else if (m_state == READY)
{

View File

@ -10,7 +10,7 @@ class NetworkPlayerProfile;
class StartGameProtocol : public Protocol
{
protected:
enum STATE { NONE, LOADING, READY };
enum STATE { NONE, SYNCHRONIZATION_WAIT, LOADING, READY };
std::map<NetworkPlayerProfile*, STATE> m_player_states;
GameSetup* m_game_setup;

View File

@ -95,6 +95,7 @@ void SynchronizationProtocol::notifyEvent(Event* event)
void SynchronizationProtocol::setup()
{
Log::info("SynchronizationProtocol", "Ready !");
}
//-----------------------------------------------------------------------------