Ver código fonte

First batch of AI fixes:
- wiped not actually used set/get selection
- replaced isReachable with VCAI::isAccessible

Ivan Savenko 11 anos atrás
pai
commit
b67618ab53
5 arquivos alterados com 2 adições e 24 exclusões
  1. 0 1
      AI/VCAI/AIUtility.cpp
  2. 0 1
      AI/VCAI/Fuzzy.cpp
  3. 2 2
      AI/VCAI/Goals.cpp
  4. 0 16
      AI/VCAI/VCAI.cpp
  5. 0 4
      AI/VCAI/VCAI.h

+ 0 - 1
AI/VCAI/AIUtility.cpp

@@ -353,7 +353,6 @@ bool canBeEmbarkmentPoint(const TerrainTile *t, bool fromWater)
 int3 whereToExplore(HeroPtr h)
 {
 	TimeCheck tc ("where to explore");
-	ai->setSelection(*h);
 	int radius = h->getSightRadious();
 	int3 hpos = h->visitablePos();
 

+ 0 - 1
AI/VCAI/Fuzzy.cpp

@@ -405,7 +405,6 @@ float FuzzyHelper::evaluate (Goals::VisitTile & g)
 		return 0;
 
 	//assert(cb->isInTheMap(g.tile));
-	ai->setSelection (g.hero.h);
 	float turns = 0;
 	float distance = cb->getMovementCost(g.hero.h, g.tile);
 	if (!distance) //we stand on that tile

+ 2 - 2
AI/VCAI/Goals.cpp

@@ -353,7 +353,7 @@ TSubgoal FindObj::whatToDoToAchieve()
 			}
 		}
 	}
-	if (o)// FIXME: re-enable with *some* hero && isReachable(o)) //we don't use isAccessibleForHero as we don't know which hero it is
+	if (o && ai->isAccessible(o->pos)) //we don't use isAccessibleForHero as we don't know which hero it is
 		return sptr (Goals::GetObj(o->id.getNum()));
 	else
 		return sptr (Goals::Explore());
@@ -377,7 +377,7 @@ TSubgoal GetObj::whatToDoToAchieve()
 	}
 	else
 	{
-		//if (isReachable(obj)) //FIXME: re-enable with some hero
+		if (ai->isAccessible(obj->pos))
 			return sptr (Goals::VisitTile(pos).sethero(hero)); //we must visit object with same hero, if any
 	}
 	return sptr (Goals::ClearWayTo(pos).sethero(hero));

+ 0 - 16
AI/VCAI/VCAI.cpp

@@ -95,7 +95,6 @@ VCAI::VCAI(void)
 {
 	LOG_TRACE(logAi);
 	makingTurn = nullptr;
-	currentSelection = nullptr;
 }
 
 VCAI::~VCAI(void)
@@ -695,7 +694,6 @@ void VCAI::makeTurnInternal()
 				continue;
 			}
 
-			setSelection(hero.first.get());
 			std::vector<const CGObjectInstance *> vec(hero.second.begin(), hero.second.end());
 			boost::sort (vec, CDistanceSorter(hero.first.get()));
 			for (auto obj : vec)
@@ -1254,7 +1252,6 @@ bool VCAI::canRecruitAnyHero (const CGTownInstance * t) const
 
 void VCAI::wander(HeroPtr h)
 {
-	setSelection(*h);
 	//unclaim objects that are now dangerous for us
 	auto reservedObjsSetCopy = reservedHeroesMap[h];
 	for (auto obj : reservedObjsSetCopy)
@@ -1631,7 +1628,6 @@ bool VCAI::isAccessibleForHero(const int3 & pos, HeroPtr h, bool includeAllies /
 
 bool VCAI::moveHeroToTile(int3 dst, HeroPtr h)
 {
-	setSelection(h.h); //make sure we are using the RIGHT pathfinder
 	logAi->debugStream() << boost::format("Moving hero %s to tile %s") % h->name % dst;
 	int3 startHpos = h->visitablePos();
 	bool ret = false;
@@ -2185,16 +2181,6 @@ void VCAI::striveToQuest (const QuestInfo &q)
 	}
 }
 
-const CArmedInstance * VCAI::getSelection()
-{
-	return currentSelection;
-}
-
-void VCAI::setSelection(const CArmedInstance * obj)
-{
-	currentSelection = obj;
-}
-
 void VCAI::performTypicalActions()
 {
 	for(auto h : getUnblockedHeroes())
@@ -2250,7 +2236,6 @@ int3 VCAI::explorationBestNeighbour(int3 hpos, int radius, HeroPtr h)
 int3 VCAI::explorationNewPoint(HeroPtr h)
 {
     //logAi->debugStream() << "Looking for an another place for exploration...";
-	setSelection(h.h);
 	int radius = h->getSightRadious();
 
 	std::vector<std::vector<int3> > tiles; //tiles[distance_to_fow]
@@ -2658,7 +2643,6 @@ SectorMap::SectorMap()
 
 SectorMap::SectorMap(HeroPtr h)
 {
-	ai->setSelection(h.h);
 	update();
 	makeParentBFS(h->visitablePos());
 }

+ 0 - 4
AI/VCAI/VCAI.h

@@ -124,7 +124,6 @@ const BuildingID extra[] = {BuildingID::RESOURCE_SILO, BuildingID::SPECIAL_1, Bu
 
 class VCAI : public CAdventureAI
 {
-	const CArmedInstance * currentSelection;
 public:
 	//internal methods for town development
 
@@ -259,9 +258,6 @@ public:
 	void completeGoal (Goals::TSubgoal goal); //safely removes goal from reserved hero
 	void striveToQuest (const QuestInfo &q);
 
-	const CArmedInstance * getSelection();
-	void setSelection(const CArmedInstance * obj);
-
 	void recruitHero(const CGTownInstance * t, bool throwing = false);
 	bool isGoodForVisit(const CGObjectInstance *obj, HeroPtr h);
 	std::vector<const CGObjectInstance *> getPossibleDestinations(HeroPtr h);