mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-15 00:05:02 +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:
@ -974,10 +974,26 @@ void CVCMIServer::optionSetBonus(PlayerColor player, PlayerStartingBonus id)
|
||||
|
||||
bool CVCMIServer::canUseThisHero(PlayerColor player, HeroTypeID ID)
|
||||
{
|
||||
return VLC->heroh->size() > ID
|
||||
&& si->playerInfos[player].castle == VLC->heroh->objects[ID]->heroClass->faction
|
||||
&& !vstd::contains(getUsedHeroes(), ID)
|
||||
&& mi->mapHeader->allowedHeroes.count(ID);
|
||||
if (!ID.hasValue())
|
||||
return false;
|
||||
|
||||
if (ID >= VLC->heroh->size())
|
||||
return false;
|
||||
|
||||
if (si->playerInfos[player].castle != VLC->heroh->objects[ID]->heroClass->faction)
|
||||
return false;
|
||||
|
||||
if (vstd::contains(getUsedHeroes(), ID))
|
||||
return false;
|
||||
|
||||
if (!mi->mapHeader->allowedHeroes.count(ID))
|
||||
return false;
|
||||
|
||||
for (const auto & disposedHero : mi->mapHeader->disposedHeroes)
|
||||
if (disposedHero.heroId == ID && !disposedHero.players.count(player))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<HeroTypeID> CVCMIServer::getUsedHeroes()
|
||||
|
Reference in New Issue
Block a user