From 2b64bf29ed13a96e652e23746564022f8f65f7a1 Mon Sep 17 00:00:00 2001 From: Henning Koehler Date: Fri, 23 Mar 2018 00:14:43 +1300 Subject: [PATCH] Fix Issue 2214 (#437) CGameInfoCallback::getAvailableHeroes: add checks for tavern --- lib/CGameInfoCallback.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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; }