From a09cb23a85172c29e1f7a55a848a9f74c87314f6 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Sun, 20 Aug 2023 04:06:52 +0400 Subject: [PATCH] Better handling other players for turn timer --- client/adventureMap/TurnTimerWidget.cpp | 22 +++++++++++++++------- server/TurnTimerHandler.cpp | 7 ++----- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/client/adventureMap/TurnTimerWidget.cpp b/client/adventureMap/TurnTimerWidget.cpp index de980863f..842aa168b 100644 --- a/client/adventureMap/TurnTimerWidget.cpp +++ b/client/adventureMap/TurnTimerWidget.cpp @@ -70,7 +70,9 @@ void TurnTimerWidget::show(Canvas & to) void TurnTimerWidget::setTime(int time) { int newTime = time / 1000; - if((newTime != turnTime) && notifications.count(newTime)) + if((LOCPLINT->cb->getCurrentPlayer() == LOCPLINT->playerID) + && (newTime != turnTime) + && notifications.count(newTime)) CCS->soundh->playSound(variables["notificationSound"].String()); turnTime = newTime; if(auto w = widget("timer")) @@ -108,14 +110,20 @@ void TurnTimerWidget::tick(uint32_t msPassed) else setTime(cachedTurnTime); }; - if(LOCPLINT->battleInt) + auto * playerInfo = LOCPLINT->cb->getPlayer(player); + if(playerInfo && playerInfo->isHuman()) { - if(time.isBattleEnabled()) - timeCheckAndUpdate(time.creatureTimer); + if(LOCPLINT->battleInt) + { + if(time.isBattleEnabled()) + timeCheckAndUpdate(time.creatureTimer); + } + else + { + timeCheckAndUpdate(time.turnTimer); + } } else - { - timeCheckAndUpdate(time.turnTimer); - } + timeCheckAndUpdate(0); } } diff --git a/server/TurnTimerHandler.cpp b/server/TurnTimerHandler.cpp index fa477094a..72cd002f2 100644 --- a/server/TurnTimerHandler.cpp +++ b/server/TurnTimerHandler.cpp @@ -28,11 +28,8 @@ void TurnTimerHandler::onGameplayStart(PlayerState & state) { if(si->turnTimerInfo.isEnabled()) { - TurnTimeUpdate ttu; - ttu.player = state.color; - ttu.turnTimer = si->turnTimerInfo; - ttu.turnTimer.turnTimer = 0; - gameHandler.sendAndApply(&ttu); + state.turnTimer = si->turnTimerInfo; + state.turnTimer.turnTimer = 0; } } }