From 72210afc926a386639a115063d0ebe8a64d45400 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Thu, 27 Jul 2023 15:51:38 +0300 Subject: [PATCH] Do not attempt to reset movement for inactive heroes in pool --- lib/gameState/TavernHeroesPool.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/gameState/TavernHeroesPool.cpp b/lib/gameState/TavernHeroesPool.cpp index 895c052e2..f5e5a6138 100644 --- a/lib/gameState/TavernHeroesPool.cpp +++ b/lib/gameState/TavernHeroesPool.cpp @@ -109,12 +109,18 @@ CGHeroInstance * TavernHeroesPool::takeHeroFromPool(HeroTypeID hero) void TavernHeroesPool::onNewDay() { + auto unusedHeroes = unusedHeroesFromPool(); + for(auto & hero : heroesPool) { assert(hero.second); if(!hero.second) continue; + // do not access heroes who are not present in tavern of any players + if (vstd::contains(unusedHeroes, hero.first)) + continue; + hero.second->setMovementPoints(hero.second->movementPointsLimit(true)); hero.second->mana = hero.second->manaLimit(); }