fix Lobby timer
This commit is contained in:
@@ -46,20 +46,26 @@ void Lobby::Tick() {
|
||||
}
|
||||
|
||||
void Lobby::SendTimeRemaining() {
|
||||
protocol::UpdateLobbyTimePacket packet(m_StartTime); // converting second to millis
|
||||
protocol::UpdateLobbyTimePacket packet(m_StartTime);
|
||||
m_Server->BroadcastPacket(&packet);
|
||||
}
|
||||
|
||||
void Lobby::OnPlayerJoin(std::uint8_t playerID) {
|
||||
if (m_GameStarted)
|
||||
return;
|
||||
|
||||
utils::LOG("(Server) Player Joined Lobby !");
|
||||
m_Players.push_back(playerID);
|
||||
|
||||
if (m_Players.size() == MIN_PLAYER_WAITING) { // start timer if a second player join the match
|
||||
m_StartTime = utils::GetTime() + static_cast<std::uint64_t>(LobbyWaitingTime);
|
||||
m_Timer.Reset();
|
||||
SendTimeRemaining();
|
||||
}
|
||||
|
||||
// notify player that just arrived
|
||||
protocol::UpdateLobbyTimePacket packet(m_StartTime);
|
||||
m_Server->GetConnexions().at(playerID).SendPacket(&packet);
|
||||
}
|
||||
|
||||
void Lobby::OnPlayerLeave(std::uint8_t playerID) {
|
||||
|
||||
Reference in New Issue
Block a user