diff --git a/AI/Nullkiller/AIGateway.cpp b/AI/Nullkiller/AIGateway.cpp index 9ce3ddeba..10ea97081 100644 --- a/AI/Nullkiller/AIGateway.cpp +++ b/AI/Nullkiller/AIGateway.cpp @@ -649,7 +649,7 @@ void AIGateway::showBlockingDialog(const std::string & text, const std::vector(danger) / hero->getTotalStrength(); answer = topObj->id == goalObjectID; // no if we do not aim to visit this object - logAi->trace("Query hook: %s(%s) by %s danger ratio %f", target.toString(), topObj->getObjectName(), hero.name, ratio); + logAi->trace("Query hook: %s(%s) by %s danger ratio %f", target.toString(), topObj->getObjectName(), hero.name(), ratio); if(cb->getObj(goalObjectID, false)) { @@ -1574,7 +1574,7 @@ void AIGateway::requestActionASAP(std::function whatToDo) void AIGateway::lostHero(HeroPtr h) { - logAi->debug("I lost my hero %s. It's best to forget and move on.", h.name); + logAi->debug("I lost my hero %s. It's best to forget and move on.", h.name()); } void AIGateway::answerQuery(QueryID queryID, int selection) diff --git a/AI/Nullkiller/AIUtility.cpp b/AI/Nullkiller/AIUtility.cpp index 462c56112..ae14897ac 100644 --- a/AI/Nullkiller/AIUtility.cpp +++ b/AI/Nullkiller/AIUtility.cpp @@ -67,7 +67,6 @@ HeroPtr::HeroPtr(const CGHeroInstance * H) } h = H; - name = h->getNameTranslated(); hid = H->id; // infosCount[ai->playerID][hid]++; } @@ -89,6 +88,14 @@ bool HeroPtr::operator<(const HeroPtr & rhs) const return hid < rhs.hid; } +std::string HeroPtr::name() const +{ + if (h) + return h->getNameTextID(); + else + return ""; +} + const CGHeroInstance * HeroPtr::get(bool doWeExpectNull) const { return get(cb, doWeExpectNull); diff --git a/AI/Nullkiller/AIUtility.h b/AI/Nullkiller/AIUtility.h index ceba7909e..98e234247 100644 --- a/AI/Nullkiller/AIUtility.h +++ b/AI/Nullkiller/AIUtility.h @@ -87,8 +87,7 @@ struct DLL_EXPORT HeroPtr ObjectInstanceID hid; public: - std::string name; - + std::string name() const; HeroPtr(); HeroPtr(const CGHeroInstance * H); @@ -117,7 +116,6 @@ public: { handler & h; handler & hid; - handler & name; } }; diff --git a/AI/Nullkiller/Analyzers/HeroManager.cpp b/AI/Nullkiller/Analyzers/HeroManager.cpp index 674463341..aa4292fea 100644 --- a/AI/Nullkiller/Analyzers/HeroManager.cpp +++ b/AI/Nullkiller/Analyzers/HeroManager.cpp @@ -176,7 +176,7 @@ int HeroManager::selectBestSkill(const HeroPtr & hero, const std::vectortrace( "Hero %s is proposed to learn %d with score %f", - hero.name, + hero.name(), skills[i].toEnum(), score); } diff --git a/AI/Nullkiller/Goals/ExecuteHeroChain.cpp b/AI/Nullkiller/Goals/ExecuteHeroChain.cpp index d7b1025da..5d8975d0b 100644 --- a/AI/Nullkiller/Goals/ExecuteHeroChain.cpp +++ b/AI/Nullkiller/Goals/ExecuteHeroChain.cpp @@ -106,7 +106,7 @@ void ExecuteHeroChain::accept(AIGateway * ai) if(!heroPtr.validAndSet()) { - logAi->error("Hero %s was lost. Exit hero chain.", heroPtr.name); + logAi->error("Hero %s was lost. Exit hero chain.", heroPtr.name()); return; } @@ -143,7 +143,7 @@ void ExecuteHeroChain::accept(AIGateway * ai) if(!heroPtr.validAndSet()) { - logAi->error("Hero %s was lost trying to execute special action. Exit hero chain.", heroPtr.name); + logAi->error("Hero %s was lost trying to execute special action. Exit hero chain.", heroPtr.name()); return; } @@ -204,7 +204,7 @@ void ExecuteHeroChain::accept(AIGateway * ai) { if(!heroPtr.validAndSet()) { - logAi->error("Hero %s was lost. Exit hero chain.", heroPtr.name); + logAi->error("Hero %s was lost. Exit hero chain.", heroPtr.name()); return; } @@ -250,7 +250,7 @@ void ExecuteHeroChain::accept(AIGateway * ai) { if(!heroPtr.validAndSet()) { - logAi->debug("Hero %s was killed while attempting to reach %s", heroPtr.name, node->coord.toString()); + logAi->debug("Hero %s was killed while attempting to reach %s", heroPtr.name(), node->coord.toString()); return; }