1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Make possible to play with different timers independently

This commit is contained in:
nordsoft 2023-08-28 01:59:47 +04:00
parent 6226ddf4a7
commit 4ee47b01ae
3 changed files with 6 additions and 9 deletions

View File

@ -63,7 +63,7 @@ AdventureMapInterface::AdventureMapInterface():
shortcuts->setState(EAdventureState::MAKING_TURN);
widget->getMapView()->onViewMapActivated();
if(LOCPLINT->cb->getStartInfo()->turnTimerInfo.isEnabled())
if(LOCPLINT->cb->getStartInfo()->turnTimerInfo.isEnabled() || LOCPLINT->cb->getStartInfo()->turnTimerInfo.isBattleEnabled())
watches = std::make_shared<TurnTimerWidget>();
addUsedEvents(KEYBOARD | TIME);

View File

@ -14,12 +14,12 @@ VCMI_LIB_NAMESPACE_BEGIN
bool TurnTimerInfo::isEnabled() const
{
return turnTimer > 0;
return turnTimer > 0 || baseTimer > 0;
}
bool TurnTimerInfo::isBattleEnabled() const
{
return creatureTimer > 0;
return creatureTimer > 0 || battleTimer > 0;
}
VCMI_LIB_NAMESPACE_END

View File

@ -30,12 +30,9 @@ void TurnTimerHandler::onGameplayStart(PlayerColor player)
{
if(const auto * si = gameHandler.getStartInfo())
{
if(si->turnTimerInfo.isEnabled())
{
std::lock_guard<std::recursive_mutex> guard(mx);
timers[player] = si->turnTimerInfo;
timers[player].turnTimer = 0;
}
std::lock_guard<std::recursive_mutex> guard(mx);
timers[player] = si->turnTimerInfo;
timers[player].turnTimer = 0;
}
}