1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Better handling other players for turn timer

This commit is contained in:
nordsoft 2023-08-20 04:06:52 +04:00
parent 314a17cdd9
commit a09cb23a85
2 changed files with 17 additions and 12 deletions

View File

@ -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<CLabel>("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);
}
}

View File

@ -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;
}
}
}