diff --git a/src/game/server/Lobby.cpp b/src/game/server/Lobby.cpp index 1a3e7c3..05f8eb7 100644 --- a/src/game/server/Lobby.cpp +++ b/src/game/server/Lobby.cpp @@ -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(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) {