Replaced static with dynamic casts, fixed docu.

This commit is contained in:
hiker
2016-11-11 09:14:18 +11:00
parent 10575174fc
commit 10b7dac658
2 changed files with 11 additions and 5 deletions

View File

@@ -136,6 +136,12 @@ bool StartGameProtocol::notifyEventAsynchronous(Event* event)
if (NetworkConfig::get()->isServer() && ready) // on server, player is ready
{
Log::info("StartGameProtocol", "One of the players is ready.");
if (m_player_states[player_id] != LOADING)
{
Log::error("StartGameProtocol",
"Player %d send more than one ready message.",
player_id);
}
m_player_states[player_id] = READY;
m_ready_count++;
if (m_ready_count == m_game_setup->getPlayerCount())
@@ -159,7 +165,7 @@ void StartGameProtocol::startRace()
Protocol *p = ProtocolManager::getInstance()
->getProtocol(PROTOCOL_SYNCHRONIZATION);
SynchronizationProtocol* protocol =
static_cast<SynchronizationProtocol*>(p);
dynamic_cast<SynchronizationProtocol*>(p);
if (protocol)
{
protocol->startCountdown(5.0f); // 5 seconds countdown
@@ -185,7 +191,7 @@ void StartGameProtocol::update(float dt)
Protocol *p = ProtocolManager::getInstance()
->getProtocol(PROTOCOL_SYNCHRONIZATION);
SynchronizationProtocol* protocol =
static_cast<SynchronizationProtocol*>(p);
dynamic_cast<SynchronizationProtocol*>(p);
if (protocol)
{
// Now the synchronization protocol exists.

View File

@@ -184,7 +184,7 @@ void STKHost::create()
* This triggers the creation of the kart selection screen in
* CLR::startSelection / CLR::update for all clients. The clients create
* the ActivePlayer object (which stores which device is used by which
* plauyer). The kart selection in a client calls
* player). The kart selection in a client calls
* (NetworkKartSelection::playerConfirm) which calls CLR::requestKartSelection.
* This sends a message to SLR::kartSelectionRequested, which verifies the
* selected kart and sends this information to all clients (including the
@@ -219,7 +219,7 @@ void STKHost::create()
* 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.
* The StartGameProtocol has a callback ready which is called from world
* The StartGameProtocol has a callback ready() which is called from world
* when the world is loaded (i.e. track and all karts are ready). When
* this callback is invoked, each client will send a 'ready' message to
* the server's StartGameProtocol. Once the server has received all
@@ -228,7 +228,7 @@ void STKHost::create()
* 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
* at that stage as wellk.
* at that stage as well.
*
* Once the countdown is 0 (or below), the Synchronization Protocol will
* start the protocols: KartUpdateProtocol, ControllerEventsProtocol,