1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

revert file name without 2 to make it easier to compare new vs old

This commit is contained in:
Mircea TheHonestCTO
2025-08-13 17:10:29 +02:00
parent fec11fc9f5
commit 7f2c3ba556
20 changed files with 187 additions and 187 deletions

View File

@@ -75,7 +75,7 @@ AIGateway::AIGateway()
LOG_TRACE(logAi);
destinationTeleport = ObjectInstanceID();
destinationTeleportPos = int3(-1);
nullkiller2.reset(new Nullkiller2());
nullkiller.reset(new Nullkiller());
asyncTasks = std::make_unique<AsyncRunner>();
}
@@ -83,7 +83,7 @@ AIGateway::~AIGateway()
{
LOG_TRACE(logAi);
finish();
nullkiller2.reset();
nullkiller.reset();
}
void AIGateway::availableCreaturesChanged(const CGDwelling * town)
@@ -102,7 +102,7 @@ void AIGateway::heroMoved(const TryMoveHero & details, bool verbose)
if(!hero)
validateObject(details.id); //enemy hero may have left visible area
nullkiller2->invalidatePathfinderData();
nullkiller->invalidatePathfinderData();
const int3 from = hero ? hero->convertToVisitablePos(details.start) : (details.start - int3(0,1,0));
const int3 to = hero ? hero->convertToVisitablePos(details.end) : (details.end - int3(0,1,0));
@@ -120,7 +120,7 @@ void AIGateway::heroMoved(const TryMoveHero & details, bool verbose)
{
if(o1->ID == Obj::SUBTERRANEAN_GATE && o1->ID == o2->ID) // We need to only add subterranean gates in knownSubterraneanGates. Used for features not yet ported to use teleport channels
{
nullkiller2->memory->addSubterraneanGate(o1, o2);
nullkiller->memory->addSubterraneanGate(o1, o2);
}
}
}
@@ -221,7 +221,7 @@ void AIGateway::gameOver(PlayerColor player, const EVictoryLossCheckResult & vic
logAi->debug("AIGateway: Player %d (%s) lost. It's me. What a disappointment! :(", player, player.toString());
}
nullkiller2->makingTurnInterrupption.interruptThread();
nullkiller->makingTurnInterrupption.interruptThread();
}
}
@@ -250,8 +250,8 @@ void AIGateway::heroVisit(const CGHeroInstance * visitor, const CGObjectInstance
if(start && visitedObj) //we can end visit with null object, anyway
{
nullkiller2->memory->markObjectVisited(visitedObj);
nullkiller2->objectClusterizer->invalidate(visitedObj->id);
nullkiller->memory->markObjectVisited(visitedObj);
nullkiller->objectClusterizer->invalidate(visitedObj->id);
}
status.heroVisit(visitedObj, start);
@@ -274,7 +274,7 @@ void AIGateway::tileHidden(const FowTilesType & pos)
LOG_TRACE(logAi);
NET_EVENT_HANDLER;
nullkiller2->memory->removeInvisibleObjects(myCb.get());
nullkiller->memory->removeInvisibleObjects(myCb.get());
}
void AIGateway::tileRevealed(const FowTilesType & pos)
@@ -287,8 +287,8 @@ void AIGateway::tileRevealed(const FowTilesType & pos)
addVisitableObj(obj);
}
if (nullkiller2->settings->isUpdateHitmapOnTileReveal() && !pos.empty())
nullkiller2->dangerHitMap->resetTileOwners();
if (nullkiller->settings->isUpdateHitmapOnTileReveal() && !pos.empty())
nullkiller->dangerHitMap->resetTileOwners();
}
void AIGateway::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID query)
@@ -317,7 +317,7 @@ void AIGateway::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID her
}
else
{
if(nullkiller2->isActive(firstHero))
if(nullkiller->isActive(firstHero))
transferFrom2to1(secondHero, firstHero);
else
transferFrom2to1(firstHero, secondHero);
@@ -368,7 +368,7 @@ void AIGateway::newObject(const CGObjectInstance * obj)
{
LOG_TRACE(logAi);
NET_EVENT_HANDLER;
nullkiller2->invalidatePathfinderData();
nullkiller->invalidatePathfinderData();
if(obj->isVisitable())
addVisitableObj(obj);
}
@@ -380,15 +380,15 @@ void AIGateway::objectRemoved(const CGObjectInstance * obj, const PlayerColor &
LOG_TRACE(logAi);
NET_EVENT_HANDLER;
if(!nullkiller2) // crash protection
if(!nullkiller) // crash protection
return;
nullkiller2->memory->removeFromMemory(obj);
nullkiller2->objectClusterizer->onObjectRemoved(obj->id);
nullkiller->memory->removeFromMemory(obj);
nullkiller->objectClusterizer->onObjectRemoved(obj->id);
if(nullkiller2->baseGraph && nullkiller2->isObjectGraphAllowed())
if(nullkiller->baseGraph && nullkiller->isObjectGraphAllowed())
{
nullkiller2->baseGraph->removeObject(obj);
nullkiller->baseGraph->removeObject(obj);
}
if(obj->ID == Obj::HERO && obj->tempOwner == playerID)
@@ -397,10 +397,10 @@ void AIGateway::objectRemoved(const CGObjectInstance * obj, const PlayerColor &
}
if(obj->ID == Obj::HERO && cb->getPlayerRelations(obj->tempOwner, playerID) == PlayerRelations::ENEMIES)
nullkiller2->dangerHitMap->resetHitmap();
nullkiller->dangerHitMap->resetHitmap();
if(obj->ID == Obj::TOWN)
nullkiller2->dangerHitMap->resetTileOwners();
nullkiller->dangerHitMap->resetTileOwners();
}
void AIGateway::showHillFortWindow(const CGObjectInstance * object, const CGHeroInstance * visitor)
@@ -419,7 +419,7 @@ void AIGateway::heroCreated(const CGHeroInstance * h)
{
LOG_TRACE(logAi);
NET_EVENT_HANDLER;
nullkiller2->invalidatePathfinderData(); // new hero needs to look around
nullkiller->invalidatePathfinderData(); // new hero needs to look around
}
void AIGateway::advmapSpellCast(const CGHeroInstance * caster, SpellID spellID)
@@ -503,7 +503,7 @@ void AIGateway::objectPropertyChanged(const SetObjectProperty * sop)
auto relations = myCb->getPlayerRelations(playerID, sop->identifier.as<PlayerColor>());
auto obj = myCb->getObj(sop->id, false);
if(!nullkiller2) // crash protection
if(!nullkiller) // crash protection
return;
if(obj)
@@ -512,12 +512,12 @@ void AIGateway::objectPropertyChanged(const SetObjectProperty * sop)
{
//we want to visit objects owned by oppponents
//addVisitableObj(obj); // TODO: Remove once save compatibility broken. In past owned objects were removed from this set
nullkiller2->memory->markObjectUnvisited(obj);
nullkiller->memory->markObjectUnvisited(obj);
}
else if(relations == PlayerRelations::SAME_PLAYER && obj->ID == Obj::TOWN)
{
// reevaluate defence for a new town
nullkiller2->dangerHitMap->resetHitmap();
nullkiller->dangerHitMap->resetHitmap();
}
}
}
@@ -565,7 +565,7 @@ std::optional<BattleAction> AIGateway::makeSurrenderRetreatDecision(const Battle
double fightRatio = ourStrength / (double)battleState.getEnemyStrength();
// if we have no towns - things are already bad, so retreat is not an option.
if(cb->getTownsInfo().size() && ourStrength < nullkiller2->settings->getRetreatThresholdAbsolute() && fightRatio < nullkiller2->settings->getRetreatThresholdRelative() && battleState.canFlee)
if(cb->getTownsInfo().size() && ourStrength < nullkiller->settings->getRetreatThresholdAbsolute() && fightRatio < nullkiller->settings->getRetreatThresholdRelative() && battleState.canFlee)
{
return BattleAction::makeRetreat(battleState.ourSide);
}
@@ -585,8 +585,8 @@ void AIGateway::initGameInterface(std::shared_ptr<Environment> env, std::shared_
playerID = *myCb->getPlayerID();
myCb->waitTillRealize = true;
nullkiller2->init(CB, this);
nullkiller->init(CB, this);
retrieveVisitableObjs();
}
@@ -594,12 +594,12 @@ void AIGateway::yourTurn(QueryID queryID)
{
LOG_TRACE_PARAMS(logAi, "queryID '%i'", queryID);
NET_EVENT_HANDLER;
nullkiller2->invalidatePathfinderData();
nullkiller->invalidatePathfinderData();
status.addQuery(queryID, "YourTurn");
executeActionAsync("yourTurn", [this, queryID](){ answerQuery(queryID, 0); });
status.startedTurn();
nullkiller2->makingTurnInterrupption.reset();
nullkiller->makingTurnInterrupption.reset();
asyncTasks->run([this]()
{
@@ -617,16 +617,16 @@ void AIGateway::heroGotLevel(const CGHeroInstance * hero, PrimarySkill pskill, s
HeroPtr hPtr = hero;
executeActionAsync("heroGotLevel", [this, hPtr, skills, queryID]()
{
{
int sel = 0;
if(hPtr.validAndSet())
{
std::unique_lock lockGuard(nullkiller2->aiStateMutex);
std::unique_lock lockGuard(nullkiller->aiStateMutex);
nullkiller2->heroManager->update();
nullkiller->heroManager->update();
sel = nullkiller2->heroManager->selectBestSkill(hPtr, skills);
sel = nullkiller->heroManager->selectBestSkill(hPtr, skills);
}
answerQuery(queryID, sel);
@@ -648,8 +648,8 @@ void AIGateway::showBlockingDialog(const std::string & text, const std::vector<C
status.addQuery(askID, boost::str(boost::format("Blocking dialog query with %d components - %s")
% components.size() % text));
auto hero = nullkiller2->getActiveHero();
auto target = nullkiller2->getTargetTile();
auto hero = nullkiller->getActiveHero();
auto target = nullkiller->getTargetTile();
if(!selection && cancel)
{
@@ -663,18 +663,18 @@ void AIGateway::showBlockingDialog(const std::string & text, const std::vector<C
{
auto topObj = objects.front()->id == hero->id ? objects.back() : objects.front();
auto objType = topObj->ID; // top object should be our hero
auto goalObjectID = nullkiller2->getTargetObject();
auto danger = nullkiller2->dangerEvaluator->evaluateDanger(target, hero.get());
auto goalObjectID = nullkiller->getTargetObject();
auto danger = nullkiller->dangerEvaluator->evaluateDanger(target, hero.get());
auto ratio = static_cast<float>(danger) / hero->getTotalStrength();
answer = true;
if(topObj->id != goalObjectID && nullkiller2->dangerEvaluator->evaluateDanger(topObj) > 0)
if(topObj->id != goalObjectID && nullkiller->dangerEvaluator->evaluateDanger(topObj) > 0)
{
// no if we do not aim to visit this object
answer = false;
}
logAi->trace("Query hook: %s(%s) by %s danger ratio %f", target.toString(), topObj->getObjectName(), hero.name(), ratio);
if(cb->getObj(goalObjectID, false))
@@ -689,7 +689,7 @@ void AIGateway::showBlockingDialog(const std::string & text, const std::vector<C
else if(objType == Obj::ARTIFACT || objType == Obj::RESOURCE)
{
bool dangerUnknown = danger == 0;
bool dangerTooHigh = ratio * nullkiller2->settings->getSafeAttackRatio() > 1;
bool dangerTooHigh = ratio * nullkiller->settings->getSafeAttackRatio() > 1;
answer = !dangerUnknown && !dangerTooHigh;
}
@@ -709,14 +709,14 @@ void AIGateway::showBlockingDialog(const std::string & text, const std::vector<C
sel = components.size();
{
std::unique_lock mxLock(nullkiller2->aiStateMutex);
std::unique_lock mxLock(nullkiller->aiStateMutex);
// TODO: Find better way to understand it is Chest of Treasures
if(hero.validAndSet()
&& components.size() == 2
&& components.front().type == ComponentType::RESOURCE
&& (nullkiller2->heroManager->getHeroRole(hero) != HeroRole::MAIN
|| nullkiller2->buildAnalyzer->isGoldPressureHigh()))
&& (nullkiller->heroManager->getHeroRole(hero) != HeroRole::MAIN
|| nullkiller->buildAnalyzer->isGoldPressureHigh()))
{
sel = 1;
}
@@ -734,7 +734,7 @@ void AIGateway::showTeleportDialog(const CGHeroInstance * hero, TeleportChannelI
int chosenExit = -1;
if(impassable)
{
nullkiller2->memory->knownTeleportChannels[channel]->passability = TeleportChannel::IMPASSABLE;
nullkiller->memory->knownTeleportChannels[channel]->passability = TeleportChannel::IMPASSABLE;
}
else if(destinationTeleport != ObjectInstanceID() && destinationTeleportPos.isValid())
{
@@ -782,7 +782,7 @@ void AIGateway::showGarrisonDialog(const CArmedInstance * up, const CGHeroInstan
//you can't request action from action-response thread
executeActionAsync("showGarrisonDialog", [this, up, down, removableUnits, queryID]()
{
if(removableUnits && up->tempOwner == down->tempOwner && nullkiller2->settings->isGarrisonTroopsUsageAllowed() && !cb->getStartInfo()->restrictedGarrisonsForAI())
if(removableUnits && up->tempOwner == down->tempOwner && nullkiller->settings->isGarrisonTroopsUsageAllowed() && !cb->getStartInfo()->restrictedGarrisonsForAI())
{
pickBestCreatures(down, up);
}
@@ -825,7 +825,7 @@ bool AIGateway::makePossibleUpgrades(const CArmedInstance * obj)
int oldValue = s->getCreature()->getAIValue();
int newValue = upgID.toCreature()->getAIValue();
if(newValue > oldValue && nullkiller2->getFreeResources().canAfford(upgradeInfo.getUpgradeCostsFor(upgID) * s->getCount()))
if(newValue > oldValue && nullkiller->getFreeResources().canAfford(upgradeInfo.getUpgradeCostsFor(upgID) * s->getCount()))
{
myCb->upgradeCreature(obj, SlotID(i), upgID);
upgraded = true;
@@ -853,7 +853,7 @@ void AIGateway::makeTurn()
std::shared_lock gsLock(CGameState::mutex);
if(nullkiller2->isOpenMap())
if(nullkiller->isOpenMap())
{
cb->sendMessage("vcmieagles");
}
@@ -862,11 +862,11 @@ void AIGateway::makeTurn()
if(cb->getDate(Date::DAY_OF_WEEK) == 1)
{
for(const CGObjectInstance * obj : nullkiller2->memory->visitableObjs)
for(const CGObjectInstance * obj : nullkiller->memory->visitableObjs)
{
if(isWeeklyRevisitable(nullkiller2.get(), obj))
if(isWeeklyRevisitable(nullkiller.get(), obj))
{
nullkiller2->memory->markObjectUnvisited(obj);
nullkiller->memory->markObjectUnvisited(obj);
}
}
}
@@ -875,7 +875,7 @@ void AIGateway::makeTurn()
try
{
#endif
nullkiller2->makeTurn();
nullkiller->makeTurn();
//for debug purpose
for (auto h : cb->getHeroesInfo())
@@ -917,13 +917,13 @@ void AIGateway::performObjectInteraction(const CGObjectInstance * obj, HeroPtr h
{
makePossibleUpgrades(h.get());
std::unique_lock lockGuard(nullkiller2->aiStateMutex);
std::unique_lock lockGuard(nullkiller->aiStateMutex);
if(!h->getVisitedTown()->getGarrisonHero() || !nullkiller2->isHeroLocked(h->getVisitedTown()->getGarrisonHero()))
if(!h->getVisitedTown()->getGarrisonHero() || !nullkiller->isHeroLocked(h->getVisitedTown()->getGarrisonHero()))
moveCreaturesToHero(h->getVisitedTown());
if(nullkiller2->heroManager->getHeroRole(h) == HeroRole::MAIN && !h->hasSpellbook()
&& nullkiller2->getFreeGold() >= GameConstants::SPELLBOOK_GOLD_COST)
if(nullkiller->heroManager->getHeroRole(h) == HeroRole::MAIN && !h->hasSpellbook()
&& nullkiller->getFreeGold() >= GameConstants::SPELLBOOK_GOLD_COST)
{
if(h->getVisitedTown()->hasBuilt(BuildingID::MAGES_GUILD_1))
cb->buyArtifact(h.get(), ArtifactID::SPELLBOOK);
@@ -951,7 +951,7 @@ void AIGateway::pickBestCreatures(const CArmedInstance * destinationArmy, const
const CArmedInstance * armies[] = {destinationArmy, source};
auto bestArmy = nullkiller2->armyManager->getBestArmy(destinationArmy, destinationArmy, source, myCb->getTile(source->visitablePos())->getTerrainID());
auto bestArmy = nullkiller->armyManager->getBestArmy(destinationArmy, destinationArmy, source, myCb->getTile(source->visitablePos())->getTerrainID());
for(auto army : armies)
{
@@ -1005,8 +1005,8 @@ void AIGateway::pickBestCreatures(const CArmedInstance * destinationArmy, const
&& source->stacksCount() == 1
&& (!destinationArmy->hasStackAtSlot(i) || destinationArmy->getCreature(i) == targetCreature))
{
auto weakest = nullkiller2->armyManager->getBestUnitForScout(bestArmy, myCb->getTile(source->visitablePos())->getTerrainID());
auto weakest = nullkiller->armyManager->getBestUnitForScout(bestArmy, myCb->getTile(source->visitablePos())->getTerrainID());
if(weakest->creature == targetCreature)
{
if(1 == source->getStackCount(j))
@@ -1147,7 +1147,7 @@ void AIGateway::pickBestArtifacts(const CGHeroInstance * h, const CGHeroInstance
{
ArtifactLocation destLocation(target->id, slot);
ArtifactLocation backpack(artHolder->id, ArtifactPosition::BACKPACK_START);
cb->swapArtifacts(destLocation, backpack);
cb->swapArtifacts(location, destLocation);
}
@@ -1193,7 +1193,7 @@ void AIGateway::recruitCreatures(const CGDwelling * d, const CArmedInstance * re
{
if(!stack.second->getType())
continue;
auto duplicatingSlot = recruiter->getSlotFor(stack.second->getCreature());
if(duplicatingSlot != stack.first)
@@ -1268,7 +1268,7 @@ void AIGateway::retrieveVisitableObjs()
std::vector<const CGObjectInstance *> AIGateway::getFlaggedObjects() const
{
std::vector<const CGObjectInstance *> ret;
for(const CGObjectInstance * obj : nullkiller2->memory->visitableObjs)
for(const CGObjectInstance * obj : nullkiller->memory->visitableObjs)
{
if(obj->tempOwner == playerID)
ret.push_back(obj);
@@ -1281,11 +1281,11 @@ void AIGateway::addVisitableObj(const CGObjectInstance * obj)
if(obj->ID == Obj::EVENT)
return;
nullkiller2->memory->addVisitableObject(obj);
nullkiller->memory->addVisitableObject(obj);
if(obj->ID == Obj::HERO && cb->getPlayerRelations(obj->tempOwner, playerID) == PlayerRelations::ENEMIES)
{
nullkiller2->dangerHitMap->resetHitmap();
nullkiller->dangerHitMap->resetHitmap();
}
}
@@ -1329,7 +1329,7 @@ bool AIGateway::moveHeroToTile(int3 dst, HeroPtr h)
else
{
CGPath path;
nullkiller2->getPathsInfo(h.get())->getPath(path, dst);
nullkiller->getPathsInfo(h.get())->getPath(path, dst);
if(path.nodes.empty())
{
logAi->error("Hero %s cannot reach %s.", h->getNameTranslated(), dst.toString());
@@ -1379,7 +1379,7 @@ bool AIGateway::moveHeroToTile(int3 dst, HeroPtr h)
{
if(cb->getObj(exitId) && cb->getObj(exitId)->ID == Obj::WHIRLPOOL)
{
nullkiller2->armyFormation->rearrangeArmyForWhirlpool(*h);
nullkiller->armyFormation->rearrangeArmyForWhirlpool(*h);
}
destinationTeleport = exitId;
@@ -1436,7 +1436,7 @@ bool AIGateway::moveHeroToTile(int3 dst, HeroPtr h)
doTeleportMovement(destTeleportObj->id, nextCoord);
if(teleportChannelProbingList.size())
doChannelProbing();
nullkiller2->memory->markObjectVisited(destTeleportObj); //FIXME: Monoliths are not correctly visited
nullkiller->memory->markObjectVisited(destTeleportObj); //FIXME: Monoliths are not correctly visited
continue;
}
@@ -1612,7 +1612,7 @@ void AIGateway::buildArmyIn(const CGTownInstance * t)
void AIGateway::finish()
{
nullkiller2->makingTurnInterrupption.interruptThread();
nullkiller->makingTurnInterrupption.interruptThread();
if (asyncTasks)
{
@@ -1638,7 +1638,7 @@ void AIGateway::executeActionAsync(const std::string & description, const std::f
void AIGateway::lostHero(HeroPtr h)
{
logAi->debug("I lost my hero %s. It's best to forget and move on.", h.name());
nullkiller2->invalidatePathfinderData();
nullkiller->invalidatePathfinderData();
}
void AIGateway::answerQuery(QueryID queryID, int selection)
@@ -1681,7 +1681,7 @@ void AIGateway::validateObject(ObjectIdRef obj)
{
if(!obj)
{
nullkiller2->memory->removeFromMemory(obj);
nullkiller->memory->removeFromMemory(obj);
}
}
@@ -1770,7 +1770,7 @@ void AIStatus::waitTillFree()
while(battle != NO_BATTLE || !remainingQueries.empty() || !objectsBeingVisited.empty() || ongoingHeroMovement)
{
cv.wait_for(lock, std::chrono::milliseconds(10));
gateway->nullkiller2->makingTurnInterrupption.interruptionPoint();
gateway->nullkiller->makingTurnInterrupption.interruptionPoint();
}
}
@@ -1846,7 +1846,7 @@ bool AIStatus::channelProbing()
void AIGateway::invalidatePaths()
{
nullkiller2->invalidatePaths();
nullkiller->invalidatePaths();
}
}

View File

@@ -80,7 +80,7 @@ public:
public:
ObjectInstanceID selectedObject;
std::unique_ptr<Nullkiller> nullkiller2;
std::unique_ptr<Nullkiller> nullkiller;
AIGateway();
~AIGateway();

View File

@@ -36,7 +36,7 @@ void BuyArmy::accept(AIGateway * ai)
auto upgradeSuccessful = ai->makePossibleUpgrades(town);
auto armyToBuy = ai->nullkiller2->armyManager->getArmyAvailableToBuy(town->getUpperArmy(), town);
auto armyToBuy = ai->nullkiller->armyManager->getArmyAvailableToBuy(town->getUpperArmy(), town);
if(armyToBuy.empty())
{

View File

@@ -74,7 +74,7 @@ void ExchangeSwapTownHeroes::accept(AIGateway * ai)
}
ai->buildArmyIn(town);
ai->nullkiller2->unlockHero(currentGarrisonHero);
ai->nullkiller->unlockHero(currentGarrisonHero);
logAi->debug("Extracted hero %s from garrison of %s", currentGarrisonHero->getNameTranslated(), town->getNameTranslated());
return;
@@ -103,12 +103,12 @@ void ExchangeSwapTownHeroes::accept(AIGateway * ai)
if(lockingReason != HeroLockedReason::NOT_LOCKED)
{
ai->nullkiller2->lockHero(getGarrisonHero(), lockingReason);
ai->nullkiller->lockHero(getGarrisonHero(), lockingReason);
}
if(town->getVisitingHero() && town->getVisitingHero() != getGarrisonHero())
{
ai->nullkiller2->unlockHero(town->getVisitingHero());
ai->nullkiller->unlockHero(town->getVisitingHero());
ai->makePossibleUpgrades(town->getVisitingHero());
}

View File

@@ -84,9 +84,9 @@ void ExecuteHeroChain::accept(AIGateway * ai)
{
logAi->debug("Executing hero chain towards %s. Path %s", targetName, chainPath.toString());
ai->nullkiller2->setActive(chainPath.targetHero, tile);
ai->nullkiller2->setTargetObject(objid);
ai->nullkiller2->objectClusterizer->reset();
ai->nullkiller->setActive(chainPath.targetHero, tile);
ai->nullkiller->setTargetObject(objid);
ai->nullkiller->objectClusterizer->reset();
auto targetObject = ai->myCb->getObj(static_cast<ObjectInstanceID>(objid), false);
@@ -96,7 +96,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
if(relations == PlayerRelations::ENEMIES)
{
ai->nullkiller2->armyFormation->rearrangeArmyForSiege(
ai->nullkiller->armyFormation->rearrangeArmyForSiege(
dynamic_cast<const CGTownInstance *>(targetObject),
chainPath.targetHero);
}
@@ -126,7 +126,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
if(vstd::contains(blockedIndexes, i))
{
blockedIndexes.insert(node->parentIndex);
ai->nullkiller2->lockHero(hero, HeroLockedReason::HERO_CHAIN);
ai->nullkiller->lockHero(hero, HeroLockedReason::HERO_CHAIN);
continue;
}
@@ -137,7 +137,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
{
if(hero->movementPointsRemaining() > 0)
{
ai->nullkiller2->setActive(hero, node->coord);
ai->nullkiller->setActive(hero, node->coord);
if(node->specialAction)
{
@@ -155,7 +155,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
return;
}
}
else if(i > 0 && ai->nullkiller2->isObjectGraphAllowed())
else if(i > 0 && ai->nullkiller->isObjectGraphAllowed())
{
auto chainMask = i < chainPath.nodes.size() - 1 ? chainPath.nodes[i + 1].chainMask : node->chainMask;
@@ -166,7 +166,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
if(nextNode.specialAction || nextNode.chainMask != chainMask)
break;
auto targetNode = ai->nullkiller2->getPathsInfo(hero)->getPathInfo(nextNode.coord);
auto targetNode = ai->nullkiller->getPathsInfo(hero)->getPathInfo(nextNode.coord);
if(!targetNode->reachable()
|| targetNode->getCost() > nextNode.cost)
@@ -182,7 +182,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
if(node->turns == 0 && node->coord != hero->visitablePos())
{
auto targetNode = ai->nullkiller2->getPathsInfo(hero)->getPathInfo(node->coord);
auto targetNode = ai->nullkiller->getPathsInfo(hero)->getPathInfo(node->coord);
if(targetNode->accessible == EPathAccessibility::NOT_SET
|| targetNode->accessible == EPathAccessibility::BLOCKED
@@ -239,13 +239,13 @@ void ExecuteHeroChain::accept(AIGateway * ai)
if(hero->movementPointsRemaining() > 0)
{
CGPath path;
bool isOk = ai->nullkiller2->getPathsInfo(hero)->getPath(path, node->coord);
bool isOk = ai->nullkiller->getPathsInfo(hero)->getPath(path, node->coord);
if(isOk && path.nodes.back().turns > 0)
{
logAi->warn("Hero %s has %d mp which is not enough to continue his way towards %s.", hero->getNameTranslated(), hero->movementPointsRemaining(), node->coord.toString());
ai->nullkiller2->lockHero(hero, HeroLockedReason::HERO_CHAIN);
ai->nullkiller->lockHero(hero, HeroLockedReason::HERO_CHAIN);
return;
}
}
@@ -270,7 +270,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
}
// no exception means we were not able to reach the tile
ai->nullkiller2->lockHero(hero, HeroLockedReason::HERO_CHAIN);
ai->nullkiller->lockHero(hero, HeroLockedReason::HERO_CHAIN);
blockedIndexes.insert(node->parentIndex);
}
catch(const goalFulfilledException &)

View File

@@ -26,7 +26,7 @@ bool ExploreNeighbourTile::operator==(const ExploreNeighbourTile & other) const
void ExploreNeighbourTile::accept(AIGateway * ai)
{
ExplorationHelper h(hero, ai->nullkiller2.get(), true);
ExplorationHelper h(hero, ai->nullkiller.get(), true);
for(int i = 0; i < tilesToExplore && ai->myCb->getObj(hero->id, false) && hero->movementPointsRemaining() > 0; i++)
{
@@ -35,7 +35,7 @@ void ExploreNeighbourTile::accept(AIGateway * ai)
int3 target = int3(-1);
foreach_neighbour(pos, [&](int3 tile)
{
auto pathInfo = ai->nullkiller2->getPathsInfo(hero)->getPathInfo(tile);
auto pathInfo = ai->nullkiller->getPathsInfo(hero)->getPathInfo(tile);
if(pathInfo->turns > 0)
return;
@@ -59,7 +59,7 @@ void ExploreNeighbourTile::accept(AIGateway * ai)
return;
}
auto danger = ai->nullkiller2->dangerEvaluator->evaluateDanger(target, hero, true);
auto danger = ai->nullkiller->dangerEvaluator->evaluateDanger(target, hero, true);
if(danger > 0 || !ai->moveHeroToTile(target, hero))
{

View File

@@ -70,10 +70,10 @@ void RecruitHero::accept(AIGateway * ai)
cb->recruitHero(t, heroToHire);
{
std::unique_lock lockGuard(ai->nullkiller2->aiStateMutex);
std::unique_lock lockGuard(ai->nullkiller->aiStateMutex);
ai->nullkiller2->heroManager->update();
ai->nullkiller2->objectClusterizer->reset();
ai->nullkiller->heroManager->update();
ai->nullkiller->objectClusterizer->reset();
}
}

View File

@@ -24,7 +24,7 @@ bool SaveResources::operator==(const SaveResources & other) const
void SaveResources::accept(AIGateway * ai)
{
ai->nullkiller2->lockResources(resources);
ai->nullkiller->lockResources(resources);
logAi->debug("Locked %s resources", resources.toString());

View File

@@ -42,7 +42,7 @@ std::string StayAtTown::toString() const
void StayAtTown::accept(AIGateway * ai)
{
ai->nullkiller2->lockHero(hero, HeroLockedReason::DEFENCE);
ai->nullkiller->lockHero(hero, HeroLockedReason::DEFENCE);
}
}

View File

@@ -23,7 +23,7 @@ std::shared_ptr<WhirlpoolAction> WhirlpoolAction::instance = std::make_shared<Wh
void WhirlpoolAction::execute(AIGateway * ai, const CGHeroInstance * hero) const
{
ai->nullkiller2->armyFormation->rearrangeArmyForWhirlpool(hero);
ai->nullkiller->armyFormation->rearrangeArmyForWhirlpool(hero);
}
std::string WhirlpoolAction::toString() const

View File

@@ -75,7 +75,7 @@ AIGateway::AIGateway()
LOG_TRACE(logAi);
destinationTeleport = ObjectInstanceID();
destinationTeleportPos = int3(-1);
nullkiller2.reset(new Nullkiller2());
nullkiller.reset(new Nullkiller());
asyncTasks = std::make_unique<AsyncRunner>();
}
@@ -83,7 +83,7 @@ AIGateway::~AIGateway()
{
LOG_TRACE(logAi);
finish();
nullkiller2.reset();
nullkiller.reset();
}
void AIGateway::availableCreaturesChanged(const CGDwelling * town)
@@ -102,7 +102,7 @@ void AIGateway::heroMoved(const TryMoveHero & details, bool verbose)
if(!hero)
validateObject(details.id); //enemy hero may have left visible area
nullkiller2->invalidatePathfinderData();
nullkiller->invalidatePathfinderData();
const int3 from = hero ? hero->convertToVisitablePos(details.start) : (details.start - int3(0,1,0));
const int3 to = hero ? hero->convertToVisitablePos(details.end) : (details.end - int3(0,1,0));
@@ -120,7 +120,7 @@ void AIGateway::heroMoved(const TryMoveHero & details, bool verbose)
{
if(o1->ID == Obj::SUBTERRANEAN_GATE && o1->ID == o2->ID) // We need to only add subterranean gates in knownSubterraneanGates. Used for features not yet ported to use teleport channels
{
nullkiller2->memory->addSubterraneanGate(o1, o2);
nullkiller->memory->addSubterraneanGate(o1, o2);
}
}
}
@@ -221,7 +221,7 @@ void AIGateway::gameOver(PlayerColor player, const EVictoryLossCheckResult & vic
logAi->debug("AIGateway: Player %d (%s) lost. It's me. What a disappointment! :(", player, player.toString());
}
nullkiller2->makingTurnInterrupption.interruptThread();
nullkiller->makingTurnInterrupption.interruptThread();
}
}
@@ -250,8 +250,8 @@ void AIGateway::heroVisit(const CGHeroInstance * visitor, const CGObjectInstance
if(start && visitedObj) //we can end visit with null object, anyway
{
nullkiller2->memory->markObjectVisited(visitedObj);
nullkiller2->objectClusterizer->invalidate(visitedObj->id);
nullkiller->memory->markObjectVisited(visitedObj);
nullkiller->objectClusterizer->invalidate(visitedObj->id);
}
status.heroVisit(visitedObj, start);
@@ -274,7 +274,7 @@ void AIGateway::tileHidden(const FowTilesType & pos)
LOG_TRACE(logAi);
NET_EVENT_HANDLER;
nullkiller2->memory->removeInvisibleObjects(myCb.get());
nullkiller->memory->removeInvisibleObjects(myCb.get());
}
void AIGateway::tileRevealed(const FowTilesType & pos)
@@ -287,8 +287,8 @@ void AIGateway::tileRevealed(const FowTilesType & pos)
addVisitableObj(obj);
}
if (nullkiller2->settings->isUpdateHitmapOnTileReveal() && !pos.empty())
nullkiller2->dangerHitMap->resetTileOwners();
if (nullkiller->settings->isUpdateHitmapOnTileReveal() && !pos.empty())
nullkiller->dangerHitMap->resetTileOwners();
}
void AIGateway::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID query)
@@ -317,7 +317,7 @@ void AIGateway::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID her
}
else
{
if(nullkiller2->isActive(firstHero))
if(nullkiller->isActive(firstHero))
transferFrom2to1(secondHero, firstHero);
else
transferFrom2to1(firstHero, secondHero);
@@ -368,7 +368,7 @@ void AIGateway::newObject(const CGObjectInstance * obj)
{
LOG_TRACE(logAi);
NET_EVENT_HANDLER;
nullkiller2->invalidatePathfinderData();
nullkiller->invalidatePathfinderData();
if(obj->isVisitable())
addVisitableObj(obj);
}
@@ -380,15 +380,15 @@ void AIGateway::objectRemoved(const CGObjectInstance * obj, const PlayerColor &
LOG_TRACE(logAi);
NET_EVENT_HANDLER;
if(!nullkiller2) // crash protection
if(!nullkiller) // crash protection
return;
nullkiller2->memory->removeFromMemory(obj);
nullkiller2->objectClusterizer->onObjectRemoved(obj->id);
nullkiller->memory->removeFromMemory(obj);
nullkiller->objectClusterizer->onObjectRemoved(obj->id);
if(nullkiller2->baseGraph && nullkiller2->isObjectGraphAllowed())
if(nullkiller->baseGraph && nullkiller->isObjectGraphAllowed())
{
nullkiller2->baseGraph->removeObject(obj);
nullkiller->baseGraph->removeObject(obj);
}
if(obj->ID == Obj::HERO && obj->tempOwner == playerID)
@@ -397,10 +397,10 @@ void AIGateway::objectRemoved(const CGObjectInstance * obj, const PlayerColor &
}
if(obj->ID == Obj::HERO && cb->getPlayerRelations(obj->tempOwner, playerID) == PlayerRelations::ENEMIES)
nullkiller2->dangerHitMap->resetHitmap();
nullkiller->dangerHitMap->resetHitmap();
if(obj->ID == Obj::TOWN)
nullkiller2->dangerHitMap->resetTileOwners();
nullkiller->dangerHitMap->resetTileOwners();
}
void AIGateway::showHillFortWindow(const CGObjectInstance * object, const CGHeroInstance * visitor)
@@ -419,7 +419,7 @@ void AIGateway::heroCreated(const CGHeroInstance * h)
{
LOG_TRACE(logAi);
NET_EVENT_HANDLER;
nullkiller2->invalidatePathfinderData(); // new hero needs to look around
nullkiller->invalidatePathfinderData(); // new hero needs to look around
}
void AIGateway::advmapSpellCast(const CGHeroInstance * caster, SpellID spellID)
@@ -503,7 +503,7 @@ void AIGateway::objectPropertyChanged(const SetObjectProperty * sop)
auto relations = myCb->getPlayerRelations(playerID, sop->identifier.as<PlayerColor>());
auto obj = myCb->getObj(sop->id, false);
if(!nullkiller2) // crash protection
if(!nullkiller) // crash protection
return;
if(obj)
@@ -512,12 +512,12 @@ void AIGateway::objectPropertyChanged(const SetObjectProperty * sop)
{
//we want to visit objects owned by oppponents
//addVisitableObj(obj); // TODO: Remove once save compatibility broken. In past owned objects were removed from this set
nullkiller2->memory->markObjectUnvisited(obj);
nullkiller->memory->markObjectUnvisited(obj);
}
else if(relations == PlayerRelations::SAME_PLAYER && obj->ID == Obj::TOWN)
{
// reevaluate defence for a new town
nullkiller2->dangerHitMap->resetHitmap();
nullkiller->dangerHitMap->resetHitmap();
}
}
}
@@ -565,7 +565,7 @@ std::optional<BattleAction> AIGateway::makeSurrenderRetreatDecision(const Battle
double fightRatio = ourStrength / (double)battleState.getEnemyStrength();
// if we have no towns - things are already bad, so retreat is not an option.
if(cb->getTownsInfo().size() && ourStrength < nullkiller2->settings->getRetreatThresholdAbsolute() && fightRatio < nullkiller2->settings->getRetreatThresholdRelative() && battleState.canFlee)
if(cb->getTownsInfo().size() && ourStrength < nullkiller->settings->getRetreatThresholdAbsolute() && fightRatio < nullkiller->settings->getRetreatThresholdRelative() && battleState.canFlee)
{
return BattleAction::makeRetreat(battleState.ourSide);
}
@@ -585,7 +585,7 @@ void AIGateway::initGameInterface(std::shared_ptr<Environment> env, std::shared_
playerID = *myCb->getPlayerID();
myCb->waitTillRealize = true;
nullkiller2->init(CB, this);
nullkiller->init(CB, this);
retrieveVisitableObjs();
}
@@ -594,12 +594,12 @@ void AIGateway::yourTurn(QueryID queryID)
{
LOG_TRACE_PARAMS(logAi, "queryID '%i'", queryID);
NET_EVENT_HANDLER;
nullkiller2->invalidatePathfinderData();
nullkiller->invalidatePathfinderData();
status.addQuery(queryID, "YourTurn");
executeActionAsync("yourTurn", [this, queryID](){ answerQuery(queryID, 0); });
status.startedTurn();
nullkiller2->makingTurnInterrupption.reset();
nullkiller->makingTurnInterrupption.reset();
asyncTasks->run([this]()
{
@@ -622,11 +622,11 @@ void AIGateway::heroGotLevel(const CGHeroInstance * hero, PrimarySkill pskill, s
if(hPtr.validAndSet())
{
std::unique_lock lockGuard(nullkiller2->aiStateMutex);
std::unique_lock lockGuard(nullkiller->aiStateMutex);
nullkiller2->heroManager->update();
nullkiller->heroManager->update();
sel = nullkiller2->heroManager->selectBestSkill(hPtr, skills);
sel = nullkiller->heroManager->selectBestSkill(hPtr, skills);
}
answerQuery(queryID, sel);
@@ -648,8 +648,8 @@ void AIGateway::showBlockingDialog(const std::string & text, const std::vector<C
status.addQuery(askID, boost::str(boost::format("Blocking dialog query with %d components - %s")
% components.size() % text));
auto hero = nullkiller2->getActiveHero();
auto target = nullkiller2->getTargetTile();
auto hero = nullkiller->getActiveHero();
auto target = nullkiller->getTargetTile();
if(!selection && cancel)
{
@@ -663,13 +663,13 @@ void AIGateway::showBlockingDialog(const std::string & text, const std::vector<C
{
auto topObj = objects.front()->id == hero->id ? objects.back() : objects.front();
auto objType = topObj->ID; // top object should be our hero
auto goalObjectID = nullkiller2->getTargetObject();
auto danger = nullkiller2->dangerEvaluator->evaluateDanger(target, hero.get());
auto goalObjectID = nullkiller->getTargetObject();
auto danger = nullkiller->dangerEvaluator->evaluateDanger(target, hero.get());
auto ratio = static_cast<float>(danger) / hero->getTotalStrength();
answer = true;
if(topObj->id != goalObjectID && nullkiller2->dangerEvaluator->evaluateDanger(topObj) > 0)
if(topObj->id != goalObjectID && nullkiller->dangerEvaluator->evaluateDanger(topObj) > 0)
{
// no if we do not aim to visit this object
answer = false;
@@ -689,7 +689,7 @@ void AIGateway::showBlockingDialog(const std::string & text, const std::vector<C
else if(objType == Obj::ARTIFACT || objType == Obj::RESOURCE)
{
bool dangerUnknown = danger == 0;
bool dangerTooHigh = ratio * nullkiller2->settings->getSafeAttackRatio() > 1;
bool dangerTooHigh = ratio * nullkiller->settings->getSafeAttackRatio() > 1;
answer = !dangerUnknown && !dangerTooHigh;
}
@@ -709,14 +709,14 @@ void AIGateway::showBlockingDialog(const std::string & text, const std::vector<C
sel = components.size();
{
std::unique_lock mxLock(nullkiller2->aiStateMutex);
std::unique_lock mxLock(nullkiller->aiStateMutex);
// TODO: Find better way to understand it is Chest of Treasures
if(hero.validAndSet()
&& components.size() == 2
&& components.front().type == ComponentType::RESOURCE
&& (nullkiller2->heroManager->getHeroRole(hero) != HeroRole::MAIN
|| nullkiller2->buildAnalyzer->isGoldPressureHigh()))
&& (nullkiller->heroManager->getHeroRole(hero) != HeroRole::MAIN
|| nullkiller->buildAnalyzer->isGoldPressureHigh()))
{
sel = 1;
}
@@ -734,7 +734,7 @@ void AIGateway::showTeleportDialog(const CGHeroInstance * hero, TeleportChannelI
int chosenExit = -1;
if(impassable)
{
nullkiller2->memory->knownTeleportChannels[channel]->passability = TeleportChannel::IMPASSABLE;
nullkiller->memory->knownTeleportChannels[channel]->passability = TeleportChannel::IMPASSABLE;
}
else if(destinationTeleport != ObjectInstanceID() && destinationTeleportPos.isValid())
{
@@ -782,7 +782,7 @@ void AIGateway::showGarrisonDialog(const CArmedInstance * up, const CGHeroInstan
//you can't request action from action-response thread
executeActionAsync("showGarrisonDialog", [this, up, down, removableUnits, queryID]()
{
if(removableUnits && up->tempOwner == down->tempOwner && nullkiller2->settings->isGarrisonTroopsUsageAllowed() && !cb->getStartInfo()->restrictedGarrisonsForAI())
if(removableUnits && up->tempOwner == down->tempOwner && nullkiller->settings->isGarrisonTroopsUsageAllowed() && !cb->getStartInfo()->restrictedGarrisonsForAI())
{
pickBestCreatures(down, up);
}
@@ -825,7 +825,7 @@ bool AIGateway::makePossibleUpgrades(const CArmedInstance * obj)
int oldValue = s->getCreature()->getAIValue();
int newValue = upgID.toCreature()->getAIValue();
if(newValue > oldValue && nullkiller2->getFreeResources().canAfford(upgradeInfo.getUpgradeCostsFor(upgID) * s->getCount()))
if(newValue > oldValue && nullkiller->getFreeResources().canAfford(upgradeInfo.getUpgradeCostsFor(upgID) * s->getCount()))
{
myCb->upgradeCreature(obj, SlotID(i), upgID);
upgraded = true;
@@ -853,7 +853,7 @@ void AIGateway::makeTurn()
std::shared_lock gsLock(CGameState::mutex);
if(nullkiller2->isOpenMap())
if(nullkiller->isOpenMap())
{
cb->sendMessage("vcmieagles");
}
@@ -862,11 +862,11 @@ void AIGateway::makeTurn()
if(cb->getDate(Date::DAY_OF_WEEK) == 1)
{
for(const CGObjectInstance * obj : nullkiller2->memory->visitableObjs)
for(const CGObjectInstance * obj : nullkiller->memory->visitableObjs)
{
if(isWeeklyRevisitable(nullkiller2.get(), obj))
if(isWeeklyRevisitable(nullkiller.get(), obj))
{
nullkiller2->memory->markObjectUnvisited(obj);
nullkiller->memory->markObjectUnvisited(obj);
}
}
}
@@ -875,7 +875,7 @@ void AIGateway::makeTurn()
try
{
#endif
nullkiller2->makeTurn();
nullkiller->makeTurn();
//for debug purpose
for (auto h : cb->getHeroesInfo())
@@ -917,13 +917,13 @@ void AIGateway::performObjectInteraction(const CGObjectInstance * obj, HeroPtr h
{
makePossibleUpgrades(h.get());
std::unique_lock lockGuard(nullkiller2->aiStateMutex);
std::unique_lock lockGuard(nullkiller->aiStateMutex);
if(!h->getVisitedTown()->getGarrisonHero() || !nullkiller2->isHeroLocked(h->getVisitedTown()->getGarrisonHero()))
if(!h->getVisitedTown()->getGarrisonHero() || !nullkiller->isHeroLocked(h->getVisitedTown()->getGarrisonHero()))
moveCreaturesToHero(h->getVisitedTown());
if(nullkiller2->heroManager->getHeroRole(h) == HeroRole::MAIN && !h->hasSpellbook()
&& nullkiller2->getFreeGold() >= GameConstants::SPELLBOOK_GOLD_COST)
if(nullkiller->heroManager->getHeroRole(h) == HeroRole::MAIN && !h->hasSpellbook()
&& nullkiller->getFreeGold() >= GameConstants::SPELLBOOK_GOLD_COST)
{
if(h->getVisitedTown()->hasBuilt(BuildingID::MAGES_GUILD_1))
cb->buyArtifact(h.get(), ArtifactID::SPELLBOOK);
@@ -951,7 +951,7 @@ void AIGateway::pickBestCreatures(const CArmedInstance * destinationArmy, const
const CArmedInstance * armies[] = {destinationArmy, source};
auto bestArmy = nullkiller2->armyManager->getBestArmy(destinationArmy, destinationArmy, source, myCb->getTile(source->visitablePos())->getTerrainID());
auto bestArmy = nullkiller->armyManager->getBestArmy(destinationArmy, destinationArmy, source, myCb->getTile(source->visitablePos())->getTerrainID());
for(auto army : armies)
{
@@ -1005,7 +1005,7 @@ void AIGateway::pickBestCreatures(const CArmedInstance * destinationArmy, const
&& source->stacksCount() == 1
&& (!destinationArmy->hasStackAtSlot(i) || destinationArmy->getCreature(i) == targetCreature))
{
auto weakest = nullkiller2->armyManager->getBestUnitForScout(bestArmy, myCb->getTile(source->visitablePos())->getTerrainID());
auto weakest = nullkiller->armyManager->getBestUnitForScout(bestArmy, myCb->getTile(source->visitablePos())->getTerrainID());
if(weakest->creature == targetCreature)
{
@@ -1268,7 +1268,7 @@ void AIGateway::retrieveVisitableObjs()
std::vector<const CGObjectInstance *> AIGateway::getFlaggedObjects() const
{
std::vector<const CGObjectInstance *> ret;
for(const CGObjectInstance * obj : nullkiller2->memory->visitableObjs)
for(const CGObjectInstance * obj : nullkiller->memory->visitableObjs)
{
if(obj->tempOwner == playerID)
ret.push_back(obj);
@@ -1281,11 +1281,11 @@ void AIGateway::addVisitableObj(const CGObjectInstance * obj)
if(obj->ID == Obj::EVENT)
return;
nullkiller2->memory->addVisitableObject(obj);
nullkiller->memory->addVisitableObject(obj);
if(obj->ID == Obj::HERO && cb->getPlayerRelations(obj->tempOwner, playerID) == PlayerRelations::ENEMIES)
{
nullkiller2->dangerHitMap->resetHitmap();
nullkiller->dangerHitMap->resetHitmap();
}
}
@@ -1329,7 +1329,7 @@ bool AIGateway::moveHeroToTile(int3 dst, HeroPtr h)
else
{
CGPath path;
nullkiller2->getPathsInfo(h.get())->getPath(path, dst);
nullkiller->getPathsInfo(h.get())->getPath(path, dst);
if(path.nodes.empty())
{
logAi->error("Hero %s cannot reach %s.", h->getNameTranslated(), dst.toString());
@@ -1379,7 +1379,7 @@ bool AIGateway::moveHeroToTile(int3 dst, HeroPtr h)
{
if(cb->getObj(exitId) && cb->getObj(exitId)->ID == Obj::WHIRLPOOL)
{
nullkiller2->armyFormation->rearrangeArmyForWhirlpool(*h);
nullkiller->armyFormation->rearrangeArmyForWhirlpool(*h);
}
destinationTeleport = exitId;
@@ -1436,7 +1436,7 @@ bool AIGateway::moveHeroToTile(int3 dst, HeroPtr h)
doTeleportMovement(destTeleportObj->id, nextCoord);
if(teleportChannelProbingList.size())
doChannelProbing();
nullkiller2->memory->markObjectVisited(destTeleportObj); //FIXME: Monoliths are not correctly visited
nullkiller->memory->markObjectVisited(destTeleportObj); //FIXME: Monoliths are not correctly visited
continue;
}
@@ -1612,7 +1612,7 @@ void AIGateway::buildArmyIn(const CGTownInstance * t)
void AIGateway::finish()
{
nullkiller2->makingTurnInterrupption.interruptThread();
nullkiller->makingTurnInterrupption.interruptThread();
if (asyncTasks)
{
@@ -1638,7 +1638,7 @@ void AIGateway::executeActionAsync(const std::string & description, const std::f
void AIGateway::lostHero(HeroPtr h)
{
logAi->debug("I lost my hero %s. It's best to forget and move on.", h.name());
nullkiller2->invalidatePathfinderData();
nullkiller->invalidatePathfinderData();
}
void AIGateway::answerQuery(QueryID queryID, int selection)
@@ -1681,7 +1681,7 @@ void AIGateway::validateObject(ObjectIdRef obj)
{
if(!obj)
{
nullkiller2->memory->removeFromMemory(obj);
nullkiller->memory->removeFromMemory(obj);
}
}
@@ -1770,7 +1770,7 @@ void AIStatus::waitTillFree()
while(battle != NO_BATTLE || !remainingQueries.empty() || !objectsBeingVisited.empty() || ongoingHeroMovement)
{
cv.wait_for(lock, std::chrono::milliseconds(10));
gateway->nullkiller2->makingTurnInterrupption.interruptionPoint();
gateway->nullkiller->makingTurnInterrupption.interruptionPoint();
}
}
@@ -1846,7 +1846,7 @@ bool AIStatus::channelProbing()
void AIGateway::invalidatePaths()
{
nullkiller2->invalidatePaths();
nullkiller->invalidatePaths();
}
}

View File

@@ -80,7 +80,7 @@ public:
public:
ObjectInstanceID selectedObject;
std::unique_ptr<Nullkiller> nullkiller2;
std::unique_ptr<Nullkiller> nullkiller;
AIGateway();
~AIGateway();

View File

@@ -36,7 +36,7 @@ void BuyArmy::accept(AIGateway * ai)
auto upgradeSuccessful = ai->makePossibleUpgrades(town);
auto armyToBuy = ai->nullkiller2->armyManager->getArmyAvailableToBuy(town->getUpperArmy(), town);
auto armyToBuy = ai->nullkiller->armyManager->getArmyAvailableToBuy(town->getUpperArmy(), town);
if(armyToBuy.empty())
{

View File

@@ -74,7 +74,7 @@ void ExchangeSwapTownHeroes::accept(AIGateway * ai)
}
ai->buildArmyIn(town);
ai->nullkiller2->unlockHero(currentGarrisonHero);
ai->nullkiller->unlockHero(currentGarrisonHero);
logAi->debug("Extracted hero %s from garrison of %s", currentGarrisonHero->getNameTranslated(), town->getNameTranslated());
return;
@@ -103,12 +103,12 @@ void ExchangeSwapTownHeroes::accept(AIGateway * ai)
if(lockingReason != HeroLockedReason::NOT_LOCKED)
{
ai->nullkiller2->lockHero(getGarrisonHero(), lockingReason);
ai->nullkiller->lockHero(getGarrisonHero(), lockingReason);
}
if(town->getVisitingHero() && town->getVisitingHero() != getGarrisonHero())
{
ai->nullkiller2->unlockHero(town->getVisitingHero());
ai->nullkiller->unlockHero(town->getVisitingHero());
ai->makePossibleUpgrades(town->getVisitingHero());
}

View File

@@ -84,9 +84,9 @@ void ExecuteHeroChain::accept(AIGateway * ai)
{
logAi->debug("Executing hero chain towards %s. Path %s", targetName, chainPath.toString());
ai->nullkiller2->setActive(chainPath.targetHero, tile);
ai->nullkiller2->setTargetObject(objid);
ai->nullkiller2->objectClusterizer->reset();
ai->nullkiller->setActive(chainPath.targetHero, tile);
ai->nullkiller->setTargetObject(objid);
ai->nullkiller->objectClusterizer->reset();
auto targetObject = ai->myCb->getObj(static_cast<ObjectInstanceID>(objid), false);
@@ -96,7 +96,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
if(relations == PlayerRelations::ENEMIES)
{
ai->nullkiller2->armyFormation->rearrangeArmyForSiege(
ai->nullkiller->armyFormation->rearrangeArmyForSiege(
dynamic_cast<const CGTownInstance *>(targetObject),
chainPath.targetHero);
}
@@ -126,7 +126,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
if(vstd::contains(blockedIndexes, i))
{
blockedIndexes.insert(node->parentIndex);
ai->nullkiller2->lockHero(hero, HeroLockedReason::HERO_CHAIN);
ai->nullkiller->lockHero(hero, HeroLockedReason::HERO_CHAIN);
continue;
}
@@ -137,7 +137,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
{
if(hero->movementPointsRemaining() > 0)
{
ai->nullkiller2->setActive(hero, node->coord);
ai->nullkiller->setActive(hero, node->coord);
if(node->specialAction)
{
@@ -155,7 +155,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
return;
}
}
else if(i > 0 && ai->nullkiller2->isObjectGraphAllowed())
else if(i > 0 && ai->nullkiller->isObjectGraphAllowed())
{
auto chainMask = i < chainPath.nodes.size() - 1 ? chainPath.nodes[i + 1].chainMask : node->chainMask;
@@ -166,7 +166,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
if(nextNode.specialAction || nextNode.chainMask != chainMask)
break;
auto targetNode = ai->nullkiller2->getPathsInfo(hero)->getPathInfo(nextNode.coord);
auto targetNode = ai->nullkiller->getPathsInfo(hero)->getPathInfo(nextNode.coord);
if(!targetNode->reachable()
|| targetNode->getCost() > nextNode.cost)
@@ -182,7 +182,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
if(node->turns == 0 && node->coord != hero->visitablePos())
{
auto targetNode = ai->nullkiller2->getPathsInfo(hero)->getPathInfo(node->coord);
auto targetNode = ai->nullkiller->getPathsInfo(hero)->getPathInfo(node->coord);
if(targetNode->accessible == EPathAccessibility::NOT_SET
|| targetNode->accessible == EPathAccessibility::BLOCKED
@@ -239,13 +239,13 @@ void ExecuteHeroChain::accept(AIGateway * ai)
if(hero->movementPointsRemaining() > 0)
{
CGPath path;
bool isOk = ai->nullkiller2->getPathsInfo(hero)->getPath(path, node->coord);
bool isOk = ai->nullkiller->getPathsInfo(hero)->getPath(path, node->coord);
if(isOk && path.nodes.back().turns > 0)
{
logAi->warn("Hero %s has %d mp which is not enough to continue his way towards %s.", hero->getNameTranslated(), hero->movementPointsRemaining(), node->coord.toString());
ai->nullkiller2->lockHero(hero, HeroLockedReason::HERO_CHAIN);
ai->nullkiller->lockHero(hero, HeroLockedReason::HERO_CHAIN);
return;
}
}
@@ -270,7 +270,7 @@ void ExecuteHeroChain::accept(AIGateway * ai)
}
// no exception means we were not able to reach the tile
ai->nullkiller2->lockHero(hero, HeroLockedReason::HERO_CHAIN);
ai->nullkiller->lockHero(hero, HeroLockedReason::HERO_CHAIN);
blockedIndexes.insert(node->parentIndex);
}
catch(const goalFulfilledException &)

View File

@@ -26,7 +26,7 @@ bool ExploreNeighbourTile::operator==(const ExploreNeighbourTile & other) const
void ExploreNeighbourTile::accept(AIGateway * ai)
{
ExplorationHelper h(hero, ai->nullkiller2.get(), true);
ExplorationHelper h(hero, ai->nullkiller.get(), true);
for(int i = 0; i < tilesToExplore && ai->myCb->getObj(hero->id, false) && hero->movementPointsRemaining() > 0; i++)
{
@@ -35,7 +35,7 @@ void ExploreNeighbourTile::accept(AIGateway * ai)
int3 target = int3(-1);
foreach_neighbour(pos, [&](int3 tile)
{
auto pathInfo = ai->nullkiller2->getPathsInfo(hero)->getPathInfo(tile);
auto pathInfo = ai->nullkiller->getPathsInfo(hero)->getPathInfo(tile);
if(pathInfo->turns > 0)
return;
@@ -59,7 +59,7 @@ void ExploreNeighbourTile::accept(AIGateway * ai)
return;
}
auto danger = ai->nullkiller2->dangerEvaluator->evaluateDanger(target, hero, true);
auto danger = ai->nullkiller->dangerEvaluator->evaluateDanger(target, hero, true);
if(danger > 0 || !ai->moveHeroToTile(target, hero))
{

View File

@@ -70,10 +70,10 @@ void RecruitHero::accept(AIGateway * ai)
cb->recruitHero(t, heroToHire);
{
std::unique_lock lockGuard(ai->nullkiller2->aiStateMutex);
std::unique_lock lockGuard(ai->nullkiller->aiStateMutex);
ai->nullkiller2->heroManager->update();
ai->nullkiller2->objectClusterizer->reset();
ai->nullkiller->heroManager->update();
ai->nullkiller->objectClusterizer->reset();
}
}

View File

@@ -24,7 +24,7 @@ bool SaveResources::operator==(const SaveResources & other) const
void SaveResources::accept(AIGateway * ai)
{
ai->nullkiller2->lockResources(resources);
ai->nullkiller->lockResources(resources);
logAi->debug("Locked %s resources", resources.toString());

View File

@@ -42,7 +42,7 @@ std::string StayAtTown::toString() const
void StayAtTown::accept(AIGateway * ai)
{
ai->nullkiller2->lockHero(hero, HeroLockedReason::DEFENCE);
ai->nullkiller->lockHero(hero, HeroLockedReason::DEFENCE);
}
}

View File

@@ -23,7 +23,7 @@ std::shared_ptr<WhirlpoolAction> WhirlpoolAction::instance = std::make_shared<Wh
void WhirlpoolAction::execute(AIGateway * ai, const CGHeroInstance * hero) const
{
ai->nullkiller2->armyFormation->rearrangeArmyForWhirlpool(hero);
ai->nullkiller->armyFormation->rearrangeArmyForWhirlpool(hero);
}
std::string WhirlpoolAction::toString() const