diff --git a/client/adventureMap/TurnTimerWidget.cpp b/client/adventureMap/TurnTimerWidget.cpp index 7e655428c..aa5349eb7 100644 --- a/client/adventureMap/TurnTimerWidget.cpp +++ b/client/adventureMap/TurnTimerWidget.cpp @@ -68,6 +68,8 @@ TurnTimerWidget::TurnTimerWidget(const Point & position, PlayerColor player) pos.h += 16; playerLabelsUnit[player] = std::make_shared(pos.w / 2, pos.h - 8, FONT_BIG, ETextAlignment::CENTER, graphics->playerColors[player], ""); } + + updateTextLabel(player, LOCPLINT->cb->getPlayerTurnTime(player)); } else { @@ -86,6 +88,8 @@ TurnTimerWidget::TurnTimerWidget(const Point & position, PlayerColor player) pos.h += 16; playerLabelsMain[player] = std::make_shared(pos.w / 2, pos.h - 8, FONT_BIG, ETextAlignment::CENTER, graphics->playerColors[player], ""); + + updateTextLabel(player, LOCPLINT->cb->getPlayerTurnTime(player)); } } @@ -157,26 +161,13 @@ void TurnTimerWidget::updateTextLabel(PlayerColor player, const TurnTimerInfo & else mainLabel->setText(msToString(timer.baseTimer + timer.turnTimer)); } - } void TurnTimerWidget::updateTimer(PlayerColor player, uint32_t msPassed) { const auto & gamestateTimer = LOCPLINT->cb->getPlayerTurnTime(player); - - if (!(lastUpdateTimers[player] == gamestateTimer)) - { - lastUpdateTimers[player] = gamestateTimer; - countingDownTimers[player] = gamestateTimer; - } - - auto & countingDownTimer = countingDownTimers[player]; - - if(countingDownTimer.isActive && LOCPLINT->cb->isPlayerMakingTurn(player)) - countingDownTimer.substractTimer(msPassed); - - updateNotifications(player, countingDownTimer.valueMs()); - updateTextLabel(player, countingDownTimer); + updateNotifications(player, gamestateTimer.valueMs()); + updateTextLabel(player, gamestateTimer); } void TurnTimerWidget::tick(uint32_t msPassed) diff --git a/client/adventureMap/TurnTimerWidget.h b/client/adventureMap/TurnTimerWidget.h index 93ca09ea4..621f99c29 100644 --- a/client/adventureMap/TurnTimerWidget.h +++ b/client/adventureMap/TurnTimerWidget.h @@ -29,8 +29,6 @@ class TurnTimerWidget : public CIntObject bool isBattleMode; std::set notificationThresholds; - std::map lastUpdateTimers; - std::map countingDownTimers; std::map> playerLabelsMain; std::map> playerLabelsBattle; diff --git a/server/TurnTimerHandler.cpp b/server/TurnTimerHandler.cpp index 3d80fdd8f..7d20ac33b 100644 --- a/server/TurnTimerHandler.cpp +++ b/server/TurnTimerHandler.cpp @@ -105,11 +105,8 @@ bool TurnTimerHandler::timerCountDown(int & timer, int initialTimer, PlayerColor { timer -= waitTime; lastUpdate[player] += waitTime; - int frequency = (timer > turnTimePropagateThreshold - && initialTimer - timer > turnTimePropagateThreshold) - ? turnTimePropagateFrequency : turnTimePropagateFrequencyCrit; - if(lastUpdate[player] >= frequency) + if(lastUpdate[player] >= turnTimePropagateFrequency) sendTimerUpdate(player); return true; diff --git a/server/TurnTimerHandler.h b/server/TurnTimerHandler.h index a780b466c..c97eff721 100644 --- a/server/TurnTimerHandler.h +++ b/server/TurnTimerHandler.h @@ -25,9 +25,7 @@ class CGameHandler; class TurnTimerHandler { CGameHandler & gameHandler; - const int turnTimePropagateFrequency = 5000; - const int turnTimePropagateFrequencyCrit = 1000; - const int turnTimePropagateThreshold = 3000; + const int turnTimePropagateFrequency = 1000; std::map timers; std::map lastUpdate; std::map endTurnAllowed;