1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Fix hero retreating handling & code cleanup

This commit is contained in:
Ivan Savenko
2023-07-12 12:29:05 +03:00
parent cb16636fce
commit 463efea7bb
12 changed files with 79 additions and 62 deletions

View File

@@ -385,7 +385,7 @@ int CGameState::getDate(Date::EDateType mode) const
CGameState::CGameState()
{
gs = this;
hpool = std::make_unique<TavernHeroesPool>();
heroesPool = std::make_unique<TavernHeroesPool>();
applier = std::make_shared<CApplier<CBaseForGSApply>>();
registerTypesClientPacks1(*applier);
registerTypesClientPacks2(*applier);
@@ -875,7 +875,7 @@ void CGameState::initHeroes()
if(!vstd::contains(heroesToCreate, HeroTypeID(ph->subID)))
continue;
ph->initHero(getRandomGenerator());
hpool->addHeroToPool(ph);
heroesPool->addHeroToPool(ph);
heroesToCreate.erase(ph->type->getId());
map->allHeroes[ph->subID] = ph;
@@ -888,11 +888,11 @@ void CGameState::initHeroes()
int typeID = htype.getNum();
map->allHeroes[typeID] = vhi;
hpool->addHeroToPool(vhi);
heroesPool->addHeroToPool(vhi);
}
for(auto & elem : map->disposedHeroes)
hpool->setAvailability(elem.heroId, elem.players);
heroesPool->setAvailability(elem.heroId, elem.players);
if (campaign)
campaign->initHeroes();