From 0a2b04709fdf35b359884c33253f63c9dd7b84d5 Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Fri, 9 Feb 2018 22:12:21 +0300 Subject: [PATCH] Fixed https://bugs.vcmi.eu/view.php?id=2873 --- AI/VCAI/Goals.cpp | 11 +++++---- AI/VCAI/VCAI.cpp | 13 ++++++----- client/windows/CKingdomInterface.cpp | 34 ++++++++++++++++------------ 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/AI/VCAI/Goals.cpp b/AI/VCAI/Goals.cpp index 3909182b5..b134eb53c 100644 --- a/AI/VCAI/Goals.cpp +++ b/AI/VCAI/Goals.cpp @@ -62,11 +62,12 @@ std::string Goals::AbstractGoal::name() const //TODO: virtualize desc = "GATHER TROOPS"; break; case GET_OBJ: - { - auto obj = cb->getObjInstance(ObjectInstanceID(objid)); - if (obj) - desc = "GET OBJ " + obj->getObjectName(); - } + { + auto obj = cb->getObjInstance(ObjectInstanceID(objid)); + if(obj) + desc = "GET OBJ " + obj->getObjectName(); + } + break; case FIND_OBJ: desc = "FIND OBJ " + boost::lexical_cast(objid); break; diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index 263c0258c..e2a5c1c47 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -3310,12 +3310,13 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj) case Obj::PRISON: return ai->myCb->getHeroesInfo().size() < VLC->modh->settings.MAX_HEROES_ON_MAP_PER_PLAYER; case Obj::TAVERN: - {//TODO: make AI actually recruit heroes - //TODO: only on request - if ((ai->myCb->getHeroesInfo().size() >= VLC->modh->settings.MAX_HEROES_ON_MAP_PER_PLAYER) || - (ai->myCb->getResourceAmount()[Res::GOLD] - GOLD_RESERVE < GameConstants::HERO_GOLD_COST)) - return false; - } + {//TODO: make AI actually recruit heroes + //TODO: only on request + if((ai->myCb->getHeroesInfo().size() >= VLC->modh->settings.MAX_HEROES_ON_MAP_PER_PLAYER) || + (ai->myCb->getResourceAmount()[Res::GOLD] - GOLD_RESERVE < GameConstants::HERO_GOLD_COST)) + return false; + } + break; case Obj::BOAT: return false; //Boats are handled by pathfinder diff --git a/client/windows/CKingdomInterface.cpp b/client/windows/CKingdomInterface.cpp index cf13b17a0..a8b351ca5 100644 --- a/client/windows/CKingdomInterface.cpp +++ b/client/windows/CKingdomInterface.cpp @@ -303,19 +303,21 @@ int InfoBoxHeroData::getSubID() { switch(type) { - case HERO_PRIMARY_SKILL: - return index; - case HERO_SECONDARY_SKILL: - if (hero->secSkills.size() > index) - return hero->secSkills[index].first; - case HERO_SPECIAL: - return hero->type->ID.getNum(); - case HERO_MANA: - case HERO_EXPERIENCE: - return 0; - default: - assert(0); + case HERO_PRIMARY_SKILL: + return index; + case HERO_SECONDARY_SKILL: + if(hero->secSkills.size() > index) + return hero->secSkills[index].first; + else return 0; + case HERO_SPECIAL: + return hero->type->ID.getNum(); + case HERO_MANA: + case HERO_EXPERIENCE: + return 0; + default: + assert(0); + return 0; } } @@ -330,10 +332,12 @@ si64 InfoBoxHeroData::getValue() case HERO_EXPERIENCE: return hero->exp; case HERO_SECONDARY_SKILL: - if (hero->secSkills.size() > index) + if(hero->secSkills.size() > index) return hero->secSkills[index].second; - case HERO_SPECIAL: + else return 0; + case HERO_SPECIAL: + return 0; default: assert(0); return 0; @@ -353,7 +357,6 @@ std::string InfoBoxHeroData::getHoverText() case HERO_SPECIAL: return CGI->generaltexth->heroscrn[27]; case HERO_SECONDARY_SKILL: - { if (hero->secSkills.size() > index) { std::string level = CGI->generaltexth->levels[hero->secSkills[index].second-1]; @@ -361,6 +364,7 @@ std::string InfoBoxHeroData::getHoverText() return boost::str(boost::format(CGI->generaltexth->heroscrn[21]) % level % skill); } else + { return ""; } default: