Ver código fonte

Remove access to hero name translation

Ivan Savenko 1 ano atrás
pai
commit
24b77b0972

+ 2 - 2
AI/Nullkiller/AIGateway.cpp

@@ -649,7 +649,7 @@ void AIGateway::showBlockingDialog(const std::string & text, const std::vector<C
 				auto ratio = static_cast<float>(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<void()> 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)

+ 8 - 1
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 "<NO HERO>";
+}
+
 const CGHeroInstance * HeroPtr::get(bool doWeExpectNull) const
 {
 	return get(cb, doWeExpectNull);

+ 1 - 3
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;
 	}
 };
 

+ 1 - 1
AI/Nullkiller/Analyzers/HeroManager.cpp

@@ -176,7 +176,7 @@ int HeroManager::selectBestSkill(const HeroPtr & hero, const std::vector<Seconda
 
 		logAi->trace(
 			"Hero %s is proposed to learn %d with score %f",
-			hero.name,
+			hero.name(),
 			skills[i].toEnum(),
 			score);
 	}

+ 4 - 4
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;
 			}