Let player connecting in the middle of count down know
This commit is contained in:
parent
644d1b1521
commit
5e3a482588
@ -440,8 +440,8 @@ void ClientLobby::disconnectedPlayer(Event* event)
|
||||
*/
|
||||
void ClientLobby::connectionAccepted(Event* event)
|
||||
{
|
||||
// At least 4 bytes should remain now
|
||||
if (!checkDataSize(event, 4)) return;
|
||||
// At least 8 bytes should remain now
|
||||
if (!checkDataSize(event, 8)) return;
|
||||
|
||||
NetworkString &data = event->data();
|
||||
// Accepted
|
||||
@ -450,6 +450,9 @@ void ClientLobby::connectionAccepted(Event* event)
|
||||
STKHost::get()->setMyHostId(data.getUInt32());
|
||||
assert(!NetworkConfig::get()->isAddingNetworkPlayers());
|
||||
m_state.store(CONNECTED);
|
||||
float auto_start_timer = data.getFloat();
|
||||
if (auto_start_timer != std::numeric_limits<float>::max())
|
||||
NetworkingLobby::getInstance()->setStartingTimerTo(auto_start_timer);
|
||||
} // connectionAccepted
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -1340,19 +1340,24 @@ void ServerLobby::handleUnencryptedConnection(std::shared_ptr<STKPeer> peer,
|
||||
}
|
||||
|
||||
peer->setValidated();
|
||||
// send a message to the one that asked to connect
|
||||
NetworkString* message_ack = getNetworkString(4);
|
||||
message_ack->setSynchronous(true);
|
||||
// connection success -- return the host id of peer
|
||||
message_ack->addUInt8(LE_CONNECTION_ACCEPTED).addUInt32(peer->getHostId());
|
||||
peer->sendPacket(message_ack);
|
||||
delete message_ack;
|
||||
|
||||
// send a message to the one that asked to connect
|
||||
NetworkString* server_info = getNetworkString();
|
||||
server_info->setSynchronous(true);
|
||||
server_info->addUInt8(LE_SERVER_INFO);
|
||||
m_game_setup->addServerInfo(server_info);
|
||||
peer->sendPacket(server_info);
|
||||
|
||||
NetworkString* message_ack = getNetworkString(4);
|
||||
message_ack->setSynchronous(true);
|
||||
// connection success -- return the host id of peer
|
||||
float auto_start_timer = m_timeout.load();
|
||||
message_ack->addUInt8(LE_CONNECTION_ACCEPTED).addUInt32(peer->getHostId())
|
||||
.addFloat(auto_start_timer == std::numeric_limits<float>::max() ?
|
||||
auto_start_timer : auto_start_timer - (float)StkTime::getRealTime());
|
||||
peer->sendPacket(message_ack);
|
||||
delete message_ack;
|
||||
|
||||
// Make sure it will always ping at least the frequency of state exchange
|
||||
// so enet will not ping when we exchange state but keep ping elsewhere
|
||||
// then in lobby the ping seen will be correct
|
||||
|
@ -228,7 +228,7 @@ void NetworkingLobby::onUpdate(float delta)
|
||||
m_cur_starting_timer = 0.0f;
|
||||
//I18N: In the networking lobby, display the starting timeout
|
||||
//for owner-less server
|
||||
core::stringw msg = _("Game will start after %d second",
|
||||
core::stringw msg = _("Game will start after %d second(s).",
|
||||
(int)m_cur_starting_timer);
|
||||
m_timeout_message->setText(msg, true);
|
||||
}
|
||||
|
@ -132,6 +132,8 @@ public:
|
||||
uint32_t getServerPing() const;
|
||||
void initAutoStartTimer(bool grand_prix_started, float start_threshold,
|
||||
float start_timeout, unsigned server_max_player);
|
||||
void setStartingTimerTo(float t) { m_cur_starting_timer = t; }
|
||||
|
||||
}; // class NetworkingLobby
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user