trying to fix a bug concerning the state modification during asynchronous messages
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13266 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
93bad9b586
commit
8edf1b6f9e
Binary file not shown.
@ -62,11 +62,11 @@ ProtocolManager::ProtocolManager()
|
||||
|
||||
pthread_mutex_lock(&m_exit_mutex); // will let the update function run
|
||||
/// FIXME used on server because mainloop never running
|
||||
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);
|
||||
}
|
||||
}*/
|
||||
// always run this one
|
||||
m_asynchronous_update_thread = (pthread_t*)(malloc(sizeof(pthread_t)));
|
||||
pthread_create(m_asynchronous_update_thread, NULL, protocolManagerAsynchronousUpdate, this);
|
||||
@ -208,10 +208,10 @@ void ProtocolManager::requestTerminate(Protocol* protocol)
|
||||
|
||||
void ProtocolManager::startProtocol(ProtocolInfo protocol)
|
||||
{
|
||||
Log::info("ProtocolManager", "A %s protocol with id=%u has been started. There are %ld protocols running.", typeid(*protocol.protocol).name(), protocol.id, m_protocols.size()+1);
|
||||
// add the protocol to the protocol vector so that it's updated
|
||||
pthread_mutex_lock(&m_protocols_mutex);
|
||||
pthread_mutex_lock(&m_asynchronous_protocols_mutex);
|
||||
Log::info("ProtocolManager", "A %s protocol with id=%u has been started. There are %ld protocols running.", typeid(*protocol.protocol).name(), protocol.id, m_protocols.size()+1);
|
||||
m_protocols.push_back(protocol);
|
||||
pthread_mutex_unlock(&m_protocols_mutex);
|
||||
pthread_mutex_unlock(&m_asynchronous_protocols_mutex);
|
||||
|
@ -60,7 +60,8 @@ void StartGameProtocol::notifyEvent(Event* event)
|
||||
{
|
||||
protocol->startCountdown(5000); // 5 seconds countdown
|
||||
Log::info("StartGameProtocol", "All players ready, starting countdown.");
|
||||
m_state = READY;
|
||||
m_ready = true;
|
||||
return;
|
||||
}
|
||||
else
|
||||
Log::error("StartGameProtocol", "The Synchronization protocol hasn't been started.");
|
||||
@ -77,6 +78,7 @@ void StartGameProtocol::setup()
|
||||
{
|
||||
m_state = NONE;
|
||||
m_ready_count = 0;
|
||||
m_ready = false;
|
||||
Log::info("SynchronizationProtocol", "Ready !");
|
||||
}
|
||||
|
||||
@ -165,6 +167,10 @@ void StartGameProtocol::update()
|
||||
}
|
||||
else if (m_state == LOADING)
|
||||
{
|
||||
if (m_ready)
|
||||
{
|
||||
m_state = READY;
|
||||
}
|
||||
}
|
||||
else if (m_state == READY)
|
||||
{
|
||||
@ -182,6 +188,7 @@ void StartGameProtocol::ready() // on clients, means the loading is finished
|
||||
Log::info("StartGameProtocol", "Player ready, notifying server.");
|
||||
m_listener->sendMessage(this, ns, true);
|
||||
m_state = READY;
|
||||
return;
|
||||
}
|
||||
else // on the server
|
||||
{
|
||||
|
@ -18,6 +18,7 @@ class StartGameProtocol : public Protocol
|
||||
double m_sending_time;
|
||||
|
||||
STATE m_state;
|
||||
bool m_ready;
|
||||
|
||||
public:
|
||||
StartGameProtocol(GameSetup* game_setup);
|
||||
|
Loading…
x
Reference in New Issue
Block a user