Browse Source

consistent renaming of ai into aiGw or aiNk and cbc

Mircea TheHonestCTO 3 months ago
parent
commit
6b6298fa33

+ 3 - 3
AI/Nullkiller2/AIGateway.cpp

@@ -1507,8 +1507,8 @@ void AIGateway::validateObject(ObjectIdRef obj)
 	}
 }
 
-AIStatus::AIStatus(AIGateway * gateway)
-	: gateway(gateway)
+AIStatus::AIStatus(AIGateway * aiGw)
+	: aiGw(aiGw)
 {
 	battle = NO_BATTLE;
 	havingTurn = false;
@@ -1592,7 +1592,7 @@ void AIStatus::waitTillFree()
 	while(battle != NO_BATTLE || !remainingQueries.empty() || !objectsBeingVisited.empty() || ongoingHeroMovement)
 	{
 		cv.wait_for(lock, std::chrono::milliseconds(10));
-		gateway->nullkiller->makingTurnInterrupption.interruptionPoint();
+		aiGw->nullkiller->makingTurnInterrupption.interruptionPoint();
 	}
 }
 

+ 2 - 2
AI/Nullkiller2/AIGateway.h

@@ -30,7 +30,7 @@ namespace NK2AI
 
 class AIStatus
 {
-	AIGateway * gateway;
+	AIGateway * aiGw;
 	std::mutex mx;
 	std::condition_variable cv;
 
@@ -44,7 +44,7 @@ class AIStatus
 	bool havingTurn;
 
 public:
-	AIStatus(AIGateway * gateway);
+	AIStatus(AIGateway * aiGw);
 	~AIStatus();
 	void setBattle(BattleState BS);
 	void setMove(bool ongoing);

+ 4 - 4
AI/Nullkiller2/Engine/Nullkiller.cpp

@@ -66,11 +66,11 @@ bool canUseOpenMap(std::shared_ptr<CCallback> cb, PlayerColor playerID)
 	return !hasHumanInTeam;
 }
 
-void Nullkiller::init(std::shared_ptr<CCallback> cb, AIGateway * gateway)
+void Nullkiller::init(std::shared_ptr<CCallback> cb, AIGateway * aiGw)
 {
 	this->cbc = cb;
-	this->gateway = gateway;
-	this->playerID = gateway->playerID;
+	this->aiGw = aiGw;
+	this->playerID = aiGw->playerID;
 
 	settings = std::make_unique<Settings>(cb->getStartInfo()->difficulty);
 
@@ -562,7 +562,7 @@ bool Nullkiller::executeTask(Goals::TTask task)
 
 	try
 	{
-		task->accept(gateway);
+		task->accept(aiGw);
 		logAi->trace("Task %s completed in %lld", taskDescr, timeElapsed(start));
 	}
 	catch(goalFulfilledException &)

+ 2 - 2
AI/Nullkiller2/Engine/Nullkiller.h

@@ -84,7 +84,7 @@ private:
 	ScanDepth scanDepth;
 	TResources lockedResources;
 	bool useHeroChain;
-	AIGateway * gateway;
+	AIGateway * aiGw;
 	bool openMap;
 	bool useObjectGraph;
 	bool pathfinderInvalidated;
@@ -113,7 +113,7 @@ public:
 
 	Nullkiller();
 	~Nullkiller();
-	void init(std::shared_ptr<CCallback> cb, AIGateway * gateway);
+	void init(std::shared_ptr<CCallback> cb, AIGateway * aiGw);
 	void makeTurn();
 	bool makeTurnHelperPriorityPass(Goals::TGoalVec& tempResults, int passIndex);
 	bool isActive(const CGHeroInstance * hero) const { return activeHero == hero; }

+ 1 - 1
AI/Nullkiller2/Goals/AbstractGoal.h

@@ -172,7 +172,7 @@ namespace Goals
 
 		///Visitor pattern
 		//TODO: make accept work for std::shared_ptr... somehow
-		virtual void accept(AIGateway * ai) = 0; //unhandled goal will report standard error
+		virtual void accept(AIGateway * aiGw) = 0; //unhandled goal will report standard error
 		virtual std::string toString() const = 0;
 		virtual const CGHeroInstance * getHero() const = 0;
 		virtual ~ITask() {}

+ 2 - 2
AI/Nullkiller2/Goals/Composition.cpp

@@ -44,13 +44,13 @@ std::string Composition::toString() const
 	return result;
 }
 
-void Composition::accept(AIGateway * ai)
+void Composition::accept(AIGateway * aiGw)
 {
 	for(auto task : subtasks.back())
 	{
 		if(task->isElementar())
 		{
-			taskptr(*task)->accept(ai);
+			taskptr(*task)->accept(aiGw);
 		}
 		else
 		{

+ 1 - 1
AI/Nullkiller2/Goals/Composition.h

@@ -28,7 +28,7 @@ namespace Goals
 
 		bool operator==(const Composition & other) const override;
 		std::string toString() const override;
-		void accept(AIGateway * ai) override;
+		void accept(AIGateway * aiGw) override;
 		Composition & addNext(const AbstractGoal & goal);
 		Composition & addNext(TSubgoal goal);
 		Composition & addNextSequence(const TGoalVec & taskSequence);

+ 1 - 1
AI/Nullkiller2/Goals/DismissHero.cpp

@@ -21,7 +21,7 @@ bool DismissHero::operator==(const DismissHero & other) const
 	return hero == other.hero;
 }
 
-void DismissHero::accept(AIGateway * ai)
+void DismissHero::accept(AIGateway * aiGw)
 {
 	if(!hero)
 		throw cannotFulfillGoalException("Invalid hero!");

+ 1 - 1
AI/Nullkiller2/Goals/DismissHero.h

@@ -28,7 +28,7 @@ namespace Goals
 			heroName = hero->getNameTranslated();
 		}
 
-		void accept(AIGateway * ai) override;
+		void accept(AIGateway * aiGw) override;
 		std::string toString() const override;
 		bool operator==(const DismissHero & other) const override;
 	};

+ 1 - 1
AI/Nullkiller2/Goals/Invalid.h

@@ -42,7 +42,7 @@ namespace Goals
 			return "Invalid";
 		}
 
-		void accept(AIGateway * ai) override
+		void accept(AIGateway * aiGw) override
 		{
 			throw cannotFulfillGoalException("Can not fulfill Invalid goal!");
 		}

+ 2 - 2
AI/Nullkiller2/Pathfinding/Actions/AdventureSpellCastMovementActions.cpp

@@ -49,11 +49,11 @@ namespace AIPathfinding
 		dstNode->dayFlags = static_cast<DayFlags>(dstNode->dayFlags | flagsToAdd);
 	}
 
-	void AdventureCastAction::execute(AIGateway * ai, const CGHeroInstance * hero) const
+	void AdventureCastAction::execute(AIGateway * aiGw, const CGHeroInstance * hero) const
 	{
 		assert(hero == this->hero);
 
-		Goals::AdventureSpellCast(hero, spellToCast).accept(ai);
+		Goals::AdventureSpellCast(hero, spellToCast).accept(aiGw);
 	}
 
 	bool AdventureCastAction::canAct(const Nullkiller * ai, const AIPathNode * source) const

+ 1 - 1
AI/Nullkiller2/Pathfinding/Actions/AdventureSpellCastMovementActions.h

@@ -29,7 +29,7 @@ namespace AIPathfinding
 	public:
 		AdventureCastAction(SpellID spellToCast, const CGHeroInstance * hero, DayFlags flagsToAdd = DayFlags::NONE);
 
-		void execute(AIGateway * ai, const CGHeroInstance * hero) const override;
+		void execute(AIGateway * aiGw, const CGHeroInstance * hero) const override;
 
 		virtual void applyOnDestination(
 			const CGHeroInstance * hero,

+ 2 - 2
AI/Nullkiller2/Pathfinding/Actions/BoatActions.cpp

@@ -22,9 +22,9 @@ namespace NK2AI
 
 namespace AIPathfinding
 {
-	void BuildBoatAction::execute(AIGateway * ai, const CGHeroInstance * hero) const
+	void BuildBoatAction::execute(AIGateway * aiGw, const CGHeroInstance * hero) const
 	{
-		return Goals::BuildBoat(shipyard).accept(ai);
+		return Goals::BuildBoat(shipyard).accept(aiGw);
 	}
 
 	Goals::TSubgoal BuildBoatAction::decompose(const Nullkiller * aiNk, const CGHeroInstance * hero) const

+ 1 - 1
AI/Nullkiller2/Pathfinding/Actions/BoatActions.h

@@ -66,7 +66,7 @@ namespace AIPathfinding
 		bool canAct(const Nullkiller * ai, const AIPathNodeInfo & source) const override;
 		bool canAct(const Nullkiller * ai, const CGHeroInstance * hero, const TResources & reservedResources) const;
 
-		void execute(AIGateway * ai, const CGHeroInstance * hero) const override;
+		void execute(AIGateway * aiGw, const CGHeroInstance * hero) const override;
 
 		Goals::TSubgoal decompose(const Nullkiller * aiNk, const CGHeroInstance * hero) const override;
 

+ 3 - 3
AI/Nullkiller2/Pathfinding/Actions/SpecialAction.cpp

@@ -22,7 +22,7 @@ Goals::TSubgoal SpecialAction::decompose(const Nullkiller * ai, const CGHeroInst
 	return Goals::sptr(Goals::Invalid());
 }
 
-void SpecialAction::execute(AIGateway * ai, const CGHeroInstance * hero) const
+void SpecialAction::execute(AIGateway * aiGw, const CGHeroInstance * hero) const
 {
 	throw cannotFulfillGoalException("Can not execute " + toString());
 }
@@ -49,11 +49,11 @@ Goals::TSubgoal CompositeAction::decompose(const Nullkiller * ai, const CGHeroIn
 	return SpecialAction::decompose(ai, hero);
 }
 
-void CompositeAction::execute(AIGateway * ai, const CGHeroInstance * hero) const
+void CompositeAction::execute(AIGateway * aiGw, const CGHeroInstance * hero) const
 {
 	for(auto part : parts)
 	{
-		part->execute(ai, hero);
+		part->execute(aiGw, hero);
 	}
 }
 

+ 2 - 2
AI/Nullkiller2/Pathfinding/Actions/SpecialAction.h

@@ -42,7 +42,7 @@ public:
 
 	virtual Goals::TSubgoal decompose(const Nullkiller * ai, const CGHeroInstance * hero) const;
 
-	virtual void execute(AIGateway * ai, const CGHeroInstance * hero) const;
+	virtual void execute(AIGateway * aiGw, const CGHeroInstance * hero) const;
 
 	virtual void applyOnDestination(
 		const CGHeroInstance * hero,
@@ -77,7 +77,7 @@ public:
 	CompositeAction(std::vector<std::shared_ptr<const SpecialAction>> parts) : parts(parts) {}
 
 	bool canAct(const Nullkiller * ai, const AIPathNode * source) const override;
-	void execute(AIGateway * ai, const CGHeroInstance * hero) const override;
+	void execute(AIGateway * aiGw, const CGHeroInstance * hero) const override;
 	std::string toString() const override;
 	const CGObjectInstance * targetObject() const override;
 	Goals::TSubgoal decompose(const Nullkiller * ai, const CGHeroInstance * hero) const override;

+ 2 - 2
AI/Nullkiller2/Pathfinding/Actions/TownPortalAction.cpp

@@ -18,14 +18,14 @@ namespace NK2AI
 
 using namespace AIPathfinding;
 
-void TownPortalAction::execute(AIGateway * ai, const CGHeroInstance * hero) const
+void TownPortalAction::execute(AIGateway * aiGw, const CGHeroInstance * hero) const
 {
 	auto goal = Goals::AdventureSpellCast(hero, usedSpell);
 	
 	goal.town = target;
 	goal.tile = target->visitablePos();
 
-	goal.accept(ai);
+	goal.accept(aiGw);
 }
 
 std::string TownPortalAction::toString() const

+ 1 - 1
AI/Nullkiller2/Pathfinding/Actions/TownPortalAction.h

@@ -31,7 +31,7 @@ namespace AIPathfinding
 		{
 		}
 
-		void execute(AIGateway * ai, const CGHeroInstance * hero) const override;
+		void execute(AIGateway * aiGw, const CGHeroInstance * hero) const override;
 
 		std::string toString() const override;
 	};