From c3edb96a1c7feadba2a7c8449f9090c0d84c7e8f Mon Sep 17 00:00:00 2001 From: Persson-dev Date: Thu, 2 Sep 2021 19:12:01 +0200 Subject: [PATCH] fix: lobby timer --- src/game/client/ClientGame.cpp | 2 +- src/game/server/Lobby.cpp | 1 + src/render/gui/TowerGui.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/game/client/ClientGame.cpp b/src/game/client/ClientGame.cpp index 33e7cd3..521189e 100644 --- a/src/game/client/ClientGame.cpp +++ b/src/game/client/ClientGame.cpp @@ -27,7 +27,7 @@ ClientGame::~ClientGame(){ void ClientGame::tick(std::uint64_t delta){ game::Game::tick(delta); m_WorldRenderer.update(); - if (m_GameState == game::GameState::Lobby && m_Players.size() >= 2){ + if (m_GameState == game::GameState::Lobby && m_LobbyTime > 0){ m_LobbyTime -= delta; } } diff --git a/src/game/server/Lobby.cpp b/src/game/server/Lobby.cpp index 41cb119..bac381a 100644 --- a/src/game/server/Lobby.cpp +++ b/src/game/server/Lobby.cpp @@ -54,6 +54,7 @@ void Lobby::OnPlayerJoin(std::uint8_t playerID){ if (m_Players.size() == 2){ // start timer if a second player join the match m_StartTimerTime = utils::getTime(); m_Timer.reset(); + sendTimeRemaining(); } } diff --git a/src/render/gui/TowerGui.cpp b/src/render/gui/TowerGui.cpp index 3c54e93..f42ddf3 100644 --- a/src/render/gui/TowerGui.cpp +++ b/src/render/gui/TowerGui.cpp @@ -205,7 +205,7 @@ void showTeamSelection(){ void showLobbyProgress(){ const int timePassed = LOBBY_WAITING_TIME - client->getGame().getLobbyTime(); const float progress = (float)timePassed / (float)(LOBBY_WAITING_TIME); - if (progress > 0 && progress < 1 && client->getGame().getPlayers().size() >= 2){ + if (progress > 0 && progress < 1){ ImGui::ProgressBar(progress, ImVec2(0.0f, 0.0f), std::string(std::to_string(client->getGame().getLobbyTime() / 1000) + "s").c_str()); ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); ImGui::Text("Time Remaining");