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

Do not allow heroes banned for player as starting heroes

- `disposedHeroes` is now in map header, for use in map selection
- heroes that are marked as unavailable for player will now be hidden
from starting hero selection
This commit is contained in:
Ivan Savenko
2025-02-14 10:43:55 +00:00
parent 7e1ce095a1
commit 4b824d05e2
9 changed files with 67 additions and 43 deletions

View File

@@ -432,6 +432,12 @@ OptionsTab::SelectionWindow::SelectionWindow(const PlayerColor & color, SelType
unusableHeroes.insert(player.second.hero);
}
for (const auto & disposedHero : SEL->getMapInfo()->mapHeader->disposedHeroes)
{
if (!disposedHero.players.count(color))
allowedHeroes.erase(disposedHero.heroId);
}
allowedBonus.push_back(PlayerStartingBonus::RANDOM);
if(initialHero != HeroTypeID::NONE|| SEL->getPlayerInfo(color).heroesNames.size() > 0)
@@ -459,8 +465,10 @@ std::tuple<int, int> OptionsTab::SelectionWindow::calcLines(FactionID faction)
for(auto & elemh : allowedHeroes)
{
const CHero * type = elemh.toHeroType();
if(type->heroClass->faction == faction)
count++;
if(type->heroClass->faction != faction)
continue;
count++;
}
return std::make_tuple(