diff --git a/sources.cmake b/sources.cmake index 3e53f13e9..3b80aee29 100644 --- a/sources.cmake +++ b/sources.cmake @@ -1,5 +1,5 @@ # Modify this file to change the last-modified date when you add/remove a file. -# This will then trigger a new cmake run automatically. +# This will then trigger a new cmake run automatically. file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp") file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp") file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*") diff --git a/src/network/protocols/client_lobby.cpp b/src/network/protocols/client_lobby.cpp index 672bd2025..c0628b3d8 100644 --- a/src/network/protocols/client_lobby.cpp +++ b/src/network/protocols/client_lobby.cpp @@ -24,7 +24,7 @@ #include "network/network_config.hpp" #include "network/network_player_profile.hpp" #include "network/protocol_manager.hpp" -#include "network/protocols/synchronization_protocol.hpp" +#include "network/protocols/latency_protocol.hpp" #include "network/race_event_manager.hpp" #include "network/stk_host.hpp" #include "network/stk_peer.hpp" @@ -318,9 +318,9 @@ void ClientLobby::update(float dt) screen->push(); m_state = SELECTING_KARTS; - Protocol *p = new SynchronizationProtocol(); + Protocol *p = new LatencyProtocol(); p->requestStart(); - Log::info("LobbyProtocol", "SynchronizationProtocol started."); + Log::info("LobbyProtocol", "LatencyProtocol started."); } break; case SELECTING_KARTS: @@ -617,7 +617,7 @@ void ClientLobby::startingRaceNow() NetworkString *ns = getNetworkString(2); ns->addUInt8(LE_STARTED_RACE); sendToServer(ns, /*reliable*/true); - terminateSynchronizationProtocol(); + terminateLatencyProtocol(); } // startingRaceNow //----------------------------------------------------------------------------- diff --git a/src/network/protocols/synchronization_protocol.cpp b/src/network/protocols/latency_protocol.cpp similarity index 88% rename from src/network/protocols/synchronization_protocol.cpp rename to src/network/protocols/latency_protocol.cpp index 9127f3775..a84a2d6fe 100644 --- a/src/network/protocols/synchronization_protocol.cpp +++ b/src/network/protocols/latency_protocol.cpp @@ -1,4 +1,4 @@ -#include "network/protocols/synchronization_protocol.hpp" +#include "network/protocols/latency_protocol.hpp" #include "network/event.hpp" #include "network/network_config.hpp" @@ -17,8 +17,8 @@ * for a message requires the protocol lock) - causing at least two frames * of significanlty delayed pings :( */ -SynchronizationProtocol::SynchronizationProtocol() - : Protocol(PROTOCOL_SYNCHRONIZATION) +LatencyProtocol::LatencyProtocol() + : Protocol(PROTOCOL_SYNCHRONIZATION) { unsigned int size = STKHost::get()->getPeerCount(); m_pings.resize(size, std::map()); @@ -26,17 +26,17 @@ SynchronizationProtocol::SynchronizationProtocol() m_total_diff.resize(size, 0); m_average_ping.resize(size, 0); m_pings_count = 0; -} // SynchronizationProtocol +} // LatencyProtocol //----------------------------------------------------------------------------- -SynchronizationProtocol::~SynchronizationProtocol() +LatencyProtocol::~LatencyProtocol() { -} // ~SynchronizationProtocol +} // ~LatencyProtocol //----------------------------------------------------------------------------- -void SynchronizationProtocol::setup() +void LatencyProtocol::setup() { - Log::info("SynchronizationProtocol", "Ready !"); + Log::info("LatencyProtocol", "Ready !"); } // setup //----------------------------------------------------------------------------- @@ -45,7 +45,7 @@ void SynchronizationProtocol::setup() * is a reply to a previous ping request. The server will keep track of * average latency. */ -bool SynchronizationProtocol::notifyEventAsynchronous(Event* event) +bool LatencyProtocol::notifyEventAsynchronous(Event* event) { if (event->getType() != EVENT_TYPE_MESSAGE) return true; @@ -80,7 +80,7 @@ bool SynchronizationProtocol::notifyEventAsynchronous(Event* event) response->addUInt8(0).addUInt32(sequence); event->getPeer()->sendPacket(response, false); delete response; - Log::verbose("SynchronizationProtocol", "Answering sequence %u at %lf", + Log::verbose("LatencyProtocol", "Answering sequence %u at %lf", sequence, StkTime::getRealTime()); } else // receive response to a ping request @@ -89,7 +89,7 @@ bool SynchronizationProtocol::notifyEventAsynchronous(Event* event) assert(NetworkConfig::get()->isServer()); if (sequence >= m_pings[peer_id].size()) { - Log::warn("SynchronizationProtocol", + Log::warn("LatencyProtocol", "The sequence# %u isn't known.", sequence); return true; } @@ -99,7 +99,7 @@ bool SynchronizationProtocol::notifyEventAsynchronous(Event* event) m_average_ping[peer_id] = (int)((m_total_diff[peer_id]/m_successed_pings[peer_id])*1000.0); - Log::debug("SynchronizationProtocol", + Log::debug("LatencyProtocol", "Peer %d sequence %d ping %u average %u at %lf", peer_id, sequence, (unsigned int)((current_time - m_pings[peer_id][sequence])*1000), @@ -120,7 +120,7 @@ bool SynchronizationProtocol::notifyEventAsynchronous(Event* event) * started. The measured times can be used later to estimate the latency * between server and client. */ -void SynchronizationProtocol::asynchronousUpdate() +void LatencyProtocol::asynchronousUpdate() { float current_time = float(StkTime::getRealTime()); if (NetworkConfig::get()->isServer() && current_time > m_last_time+1) @@ -131,7 +131,7 @@ void SynchronizationProtocol::asynchronousUpdate() NetworkString *ping_request = getNetworkString(5); ping_request->addUInt8(1).addUInt32(m_pings[i].size()); - Log::verbose("SynchronizationProtocol", + Log::verbose("LatencyProtocol", "Added sequence number %u for peer %d at %lf", m_pings[i].size(), i, StkTime::getRealTime()); m_pings[i] [ m_pings_count ] = current_time; diff --git a/src/network/protocols/synchronization_protocol.hpp b/src/network/protocols/latency_protocol.hpp similarity index 72% rename from src/network/protocols/synchronization_protocol.hpp rename to src/network/protocols/latency_protocol.hpp index 6a1b453c9..1ef1ded7c 100644 --- a/src/network/protocols/synchronization_protocol.hpp +++ b/src/network/protocols/latency_protocol.hpp @@ -1,5 +1,5 @@ -#ifndef SYNCHRONIZATION_PROTOCOL_HPP -#define SYNCHRONIZATION_PROTOCOL_HPP +#ifndef LATENCY_PROTOCOL_HPP +#define LATENCY_PROTOCOL_HPP #include "network/protocol.hpp" #include "utils/cpp2011.hpp" @@ -7,7 +7,7 @@ #include #include -class SynchronizationProtocol : public Protocol +class LatencyProtocol : public Protocol { private: std::vector > m_pings; @@ -23,8 +23,8 @@ private: public: - SynchronizationProtocol(); - virtual ~SynchronizationProtocol(); + LatencyProtocol(); + virtual ~LatencyProtocol(); virtual bool notifyEventAsynchronous(Event* event) OVERRIDE; virtual void setup() OVERRIDE; @@ -33,6 +33,6 @@ public: // ------------------------------------------------------------------------ virtual void update(float dt) OVERRIDE {} -}; // class SynchronizationProtocol +}; // class LatencyProtocol -#endif // SYNCHRONIZATION_PROTOCOL_HPP +#endif // LATENCY_PROTOCOL_HPP diff --git a/src/network/protocols/lobby_protocol.cpp b/src/network/protocols/lobby_protocol.cpp index 1accbc301..d6c3cc5f8 100644 --- a/src/network/protocols/lobby_protocol.cpp +++ b/src/network/protocols/lobby_protocol.cpp @@ -27,7 +27,7 @@ #include "network/protocols/controller_events_protocol.hpp" #include "network/protocols/game_events_protocol.hpp" #include "network/protocols/kart_update_protocol.hpp" -#include "network/protocols/synchronization_protocol.hpp" +#include "network/protocols/latency_protocol.hpp" #include "network/race_event_manager.hpp" #include "network/stk_host.hpp" #include "race/race_manager.hpp" @@ -131,13 +131,13 @@ void LobbyProtocol::loadWorld() } // loadWorld // ---------------------------------------------------------------------------- -/** Terminates the SynchronizationProtocol. +/** Terminates the LatencyProtocol. */ -void LobbyProtocol::terminateSynchronizationProtocol() +void LobbyProtocol::terminateLatencyProtocol() { Protocol *p = ProtocolManager::getInstance() ->getProtocol(PROTOCOL_SYNCHRONIZATION); - SynchronizationProtocol *sp = dynamic_cast(p); + LatencyProtocol *sp = dynamic_cast(p); if (sp) sp->requestTerminate(); -} // stopSynchronizationProtocol +} // stopLatencyProtocol diff --git a/src/network/protocols/lobby_protocol.hpp b/src/network/protocols/lobby_protocol.hpp index 963cf7c3d..8b00cbb7f 100644 --- a/src/network/protocols/lobby_protocol.hpp +++ b/src/network/protocols/lobby_protocol.hpp @@ -95,7 +95,7 @@ public: virtual void update(float dt) = 0; virtual void finishedLoadingWorld() = 0; virtual void loadWorld(); - void terminateSynchronizationProtocol(); + void terminateLatencyProtocol(); virtual void requestKartSelection(uint8_t player_id, const std::string &kart_name) { diff --git a/src/network/protocols/server_lobby.cpp b/src/network/protocols/server_lobby.cpp index 0548b4fa4..9f8997fa6 100644 --- a/src/network/protocols/server_lobby.cpp +++ b/src/network/protocols/server_lobby.cpp @@ -26,7 +26,7 @@ #include "network/network_player_profile.hpp" #include "network/protocols/get_public_address.hpp" #include "network/protocols/connect_to_peer.hpp" -#include "network/protocols/synchronization_protocol.hpp" +#include "network/protocols/latency_protocol.hpp" #include "network/protocol_manager.hpp" #include "network/race_event_manager.hpp" #include "network/stk_host.hpp" @@ -365,9 +365,9 @@ void ServerLobby::startSelection(const Event *event) m_state = SELECTING; WaitingForOthersScreen::getInstance()->push(); - Protocol *p = new SynchronizationProtocol(); + Protocol *p = new LatencyProtocol(); p->requestStart(); - Log::info("LobbyProtocol", "SynchronizationProtocol started."); + Log::info("LobbyProtocol", "LatencyProtocol started."); } // startSelection @@ -913,7 +913,7 @@ void ServerLobby::startedRaceOnClient(Event *event) if (m_client_ready_count.getData() == m_game_setup->getPlayerCount()) { m_state = DELAY_SERVER; - terminateSynchronizationProtocol(); + terminateLatencyProtocol(); } m_client_ready_count.unlock(); } // startedRaceOnClient diff --git a/src/network/stk_host.cpp b/src/network/stk_host.cpp index 3fa3f92f8..9eb856489 100644 --- a/src/network/stk_host.cpp +++ b/src/network/stk_host.cpp @@ -217,13 +217,13 @@ void STKHost::create() * LocalPlayerController for each kart. Each remote player gets a * NULL ActivePlayer (the ActivePlayer is only used for assigning the input * device to each kart, achievements and highscores, so it's not needed for - * remote players). It will also start the SynchronizationProtocol, + * remote players). It will also start the LatencyProtocol, * RaceEventManager and then load the world. * TODO: * Once the server has received all * messages in notifyEventAsynchronous(), it will call startCountdown() - * in the SynchronizationProtocol. The SynchronizationProtocol is + * in the LatencyProtocol. The LatencyProtocol is * sending regular (once per second) pings to the clients and measure * the averate latency. Upon starting the countdown this information * is included in the ping request, so the clients can start the countdown @@ -231,7 +231,7 @@ void STKHost::create() * * Once the countdown is 0 (or below), the Synchronization Protocol will * start the protocols: KartUpdateProtocol, ControllerEventsProtocol, - * GameEventsProtocol. Then the SynchronizationProtocol is terminated + * GameEventsProtocol. Then the LatencyProtocol is terminated * which indicates to the main loop to start the actual game. */