From 83d64e6fc24f8f34b7c408ebd8bf818c41cbb0ae Mon Sep 17 00:00:00 2001 From: hilnius Date: Mon, 15 Jul 2013 14:50:28 +0000 Subject: [PATCH] adding log git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13247 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/network/protocol_manager.cpp | 1 - src/network/protocols/start_game_protocol.cpp | 4 +++- src/network/protocols/synchronization_protocol.cpp | 13 +++++++------ src/race/race_manager.cpp | 5 +++++ 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/network/protocol_manager.cpp b/src/network/protocol_manager.cpp index 40d350fec..539535575 100644 --- a/src/network/protocol_manager.cpp +++ b/src/network/protocol_manager.cpp @@ -34,7 +34,6 @@ void* protocolManagerUpdate(void* data) while(!manager->exit()) { manager->update(); - irr_driver->getDevice()->sleep(20); } return NULL; } diff --git a/src/network/protocols/start_game_protocol.cpp b/src/network/protocols/start_game_protocol.cpp index f9beebb26..37032468e 100644 --- a/src/network/protocols/start_game_protocol.cpp +++ b/src/network/protocols/start_game_protocol.cpp @@ -3,6 +3,7 @@ #include "network/network_manager.hpp" #include "network/protocol_manager.hpp" #include "network/game_setup.hpp" +#include "network/network_world.hpp" #include "network/protocols/synchronization_protocol.hpp" #include "race/race_manager.hpp" #include "utils/log.hpp" @@ -88,7 +89,7 @@ void StartGameProtocol::update() Log::info("StartGameProtocol", "SynchronizationProtocol started."); // race startup sequence - + NetworkWorld::getInstance()->start(); // builds it and starts race_manager->setNumKarts(m_game_setup->getPlayerCount()); race_manager->setNumPlayers(m_game_setup->getPlayerCount()); race_manager->setNumLocalPlayers(1); @@ -145,6 +146,7 @@ void StartGameProtocol::ready() // on clients, means the loading is finished NetworkString ns; ns.ai32(NetworkManager::getInstance()->getPeers()[0]->getClientServerToken()).ai8(1); m_listener->sendMessage(this, ns, true); + Log::info("StartGameProtocol", "Player ready, sending message to server."); m_state = READY; } else // on the server diff --git a/src/network/protocols/synchronization_protocol.cpp b/src/network/protocols/synchronization_protocol.cpp index 8281f1906..d6f8d5f99 100644 --- a/src/network/protocols/synchronization_protocol.cpp +++ b/src/network/protocols/synchronization_protocol.cpp @@ -109,11 +109,6 @@ void SynchronizationProtocol::asynchronousUpdate() double current_time = Time::getRealTime(); if (current_time > timer+0.1) { - if (m_countdown_activated) - { - m_countdown -= (int)((current_time - m_last_countdown_update)*1000.0); - m_last_countdown_update = current_time; - } std::vector peers = NetworkManager::getInstance()->getPeers(); for (unsigned int i = 0; i < peers.size(); i++) { @@ -131,8 +126,14 @@ void SynchronizationProtocol::asynchronousUpdate() m_listener->sendMessage(this, peers[i], ns, false); m_pings_count[i]++; } - Log::info("SynchronizationProtocol", "Countdown remaining : %d", m_countdown); } + if (m_countdown_activated) + { + m_countdown -= (int)((current_time - m_last_countdown_update)*1000.0); + m_last_countdown_update = current_time; + } + Log::info("SynchronizationProtocol", "Update! Countdown remaining : %d", m_countdown); + } //----------------------------------------------------------------------------- diff --git a/src/race/race_manager.cpp b/src/race/race_manager.cpp index 87679b9e7..0830bc725 100644 --- a/src/race/race_manager.cpp +++ b/src/race/race_manager.cpp @@ -461,6 +461,11 @@ void RaceManager::startNextRace() m_kart_status[i].m_last_score = m_kart_status[i].m_score; m_kart_status[i].m_last_time = 0; } + + StartGameProtocol* protocol = static_cast( + ProtocolManager::getInstance()->getProtocol(PROTOCOL_SYNCHRONIZATION)); + if (protocol) + protocol->ready(); } // startNextRace //-----------------------------------------------------------------------------