correcting a bug in events propagation
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13250 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
e954bde7ee
commit
dc3b5fe35c
@ -19,7 +19,7 @@ void NetworkWorld::update(float dt)
|
||||
ProtocolManager::getInstance()->getProtocol(PROTOCOL_SYNCHRONIZATION));
|
||||
if (protocol) // if this protocol exists, that's that we play online
|
||||
{
|
||||
Log::info("NetworkWorld", "Coutdown value is %lf", protocol->getCountdown());
|
||||
Log::debug("NetworkWorld", "Coutdown value is %f", protocol->getCountdown());
|
||||
if (protocol->getCountdown() > 0.0)
|
||||
{
|
||||
return;
|
||||
|
@ -34,6 +34,7 @@ void* protocolManagerUpdate(void* data)
|
||||
while(!manager->exit())
|
||||
{
|
||||
manager->update();
|
||||
irr_driver->getDevice()->sleep(20);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -98,20 +99,10 @@ ProtocolManager::~ProtocolManager()
|
||||
|
||||
void ProtocolManager::notifyEvent(Event* event)
|
||||
{
|
||||
pthread_mutex_lock(&m_events_mutex);
|
||||
Event* event2 = new Event(*event);
|
||||
int result = pthread_mutex_trylock(&m_protocols_mutex);
|
||||
if (result == 0) // locked successfully
|
||||
{
|
||||
// if we can propagate the event now, do so:
|
||||
propagateEvent(event2);
|
||||
pthread_mutex_unlock(&m_protocols_mutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
pthread_mutex_lock(&m_events_mutex);
|
||||
m_events_to_process.push_back(event2); // add the event to the queue
|
||||
pthread_mutex_unlock(&m_events_mutex);
|
||||
}
|
||||
m_events_to_process.push_back(event2); // add the event to the queue
|
||||
pthread_mutex_unlock(&m_events_mutex);
|
||||
}
|
||||
|
||||
void ProtocolManager::sendMessage(Protocol* sender, const NetworkString& message, bool reliable)
|
||||
@ -270,6 +261,7 @@ void ProtocolManager::propagateEvent(Event* event)
|
||||
{
|
||||
searchedProtocol = PROTOCOL_CONNECTION;
|
||||
}
|
||||
Log::info("ProtocolManager", "Received event for protocols of type %d", searchedProtocol);
|
||||
for (unsigned int i = 0; i < m_protocols.size() ; i++)
|
||||
{
|
||||
if (m_protocols[i].protocol->getProtocolType() == searchedProtocol || event->type == EVENT_TYPE_DISCONNECTED) // pass data to protocols even when paused
|
||||
@ -277,7 +269,7 @@ void ProtocolManager::propagateEvent(Event* event)
|
||||
}
|
||||
if (searchedProtocol == PROTOCOL_NONE) // no protocol was aimed, show the msg to debug
|
||||
{
|
||||
Log::debug("ProtocolManager", "Message is \"%s\"", event->data.c_str());
|
||||
Log::debug("ProtocolManager", "NO PROTOCOL : Message is \"%s\"", event->data.c_str());
|
||||
}
|
||||
|
||||
// because we made a copy of the event
|
||||
|
@ -110,7 +110,7 @@ void StartGameProtocol::update()
|
||||
int new_player_id = StateManager::get()->createActivePlayer( profileToUse, device );
|
||||
// self config
|
||||
}
|
||||
Log::info("StartGameProtocol", "Players config ready. Starting single race now.");
|
||||
Log::info("StartGameProtocol", "Players config ready.");
|
||||
m_state = SYNCHRONIZATION_WAIT;
|
||||
/*
|
||||
KartSelectionScreen* s = KartSelectionScreen::getInstance();
|
||||
@ -126,6 +126,7 @@ void StartGameProtocol::update()
|
||||
{
|
||||
// now the synchronization protocol exists.
|
||||
race_manager->startSingleRace("jungle", 1, false);
|
||||
Log::info("StartGameProtocol", "Starting the race loading.");
|
||||
m_state = LOADING;
|
||||
}
|
||||
}
|
||||
|
@ -111,6 +111,7 @@ void SynchronizationProtocol::asynchronousUpdate()
|
||||
{
|
||||
m_countdown -= (current_time - m_last_countdown_update);
|
||||
m_last_countdown_update = current_time;
|
||||
Log::info("SynchronizationProtocol", "Update! Countdown remaining : %f", m_countdown);
|
||||
}
|
||||
if (current_time > timer+0.1)
|
||||
{
|
||||
@ -123,7 +124,7 @@ void SynchronizationProtocol::asynchronousUpdate()
|
||||
if (m_countdown_activated)
|
||||
{
|
||||
ns.ai16(m_countdown);
|
||||
Log::info("SynchronizationProtocol", "Countdown value : %d", m_countdown);
|
||||
Log::info("SynchronizationProtocol", "CNTActivated: Countdown value : %f", m_countdown);
|
||||
}
|
||||
Log::verbose("SynchronizationProtocol", "Added sequence number %u for peer %d", m_pings[i].size(), i);
|
||||
timer = current_time;
|
||||
@ -132,7 +133,6 @@ void SynchronizationProtocol::asynchronousUpdate()
|
||||
m_pings_count[i]++;
|
||||
}
|
||||
}
|
||||
Log::info("SynchronizationProtocol", "Update! Countdown remaining : %lf", m_countdown);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user