diff --git a/lib/CGameInfoCallback.cpp b/lib/CGameInfoCallback.cpp index 2341df890..b5f23dc81 100644 --- a/lib/CGameInfoCallback.cpp +++ b/lib/CGameInfoCallback.cpp @@ -477,8 +477,14 @@ std::vector CGameInfoCallback::getAvailableHeroes(const std::vector ret; //ERROR_RET_VAL_IF(!isOwnedOrVisited(townOrTavern), "Town or tavern must be owned or visited!", ret); //TODO: town needs to be owned, advmap tavern needs to be visited; to be reimplemented when visit tracking is done - range::copy(gs->players[*player].availableHeroes, std::back_inserter(ret)); - vstd::erase_if(ret, [](const CGHeroInstance *h) { return h == nullptr; }); + const CGTownInstance * town = getTown(townOrTavern->id); + if(townOrTavern->ID == Obj::TAVERN || (town && town->hasBuilt(BuildingID::TAVERN))) + { + range::copy(gs->players[*player].availableHeroes, std::back_inserter(ret)); + vstd::erase_if(ret, [](const CGHeroInstance * h) { + return h == nullptr; + }); + } return ret; }