|
@@ -493,12 +493,15 @@ void VCAI::showThievesGuildWindow (const CGObjectInstance * obj)
|
|
|
NET_EVENT_HANDLER;
|
|
|
}
|
|
|
|
|
|
-void VCAI::playerBlocked(int reason)
|
|
|
+void VCAI::playerBlocked(int reason, bool start)
|
|
|
{
|
|
|
- LOG_TRACE_PARAMS(logAi, "reason '%i'", reason);
|
|
|
+ LOG_TRACE_PARAMS(logAi, "reason '%i', start '%i'", reason % start);
|
|
|
NET_EVENT_HANDLER;
|
|
|
- if (reason == PlayerBlocked::UPCOMING_BATTLE)
|
|
|
+ if (start && reason == PlayerBlocked::UPCOMING_BATTLE)
|
|
|
status.setBattle(UPCOMING_BATTLE);
|
|
|
+
|
|
|
+ if(reason == PlayerBlocked::ONGOING_MOVEMENT)
|
|
|
+ status.setMove(start);
|
|
|
}
|
|
|
|
|
|
void VCAI::showPuzzleMap()
|
|
@@ -571,15 +574,17 @@ void VCAI::artifactDisassembled(const ArtifactLocation &al)
|
|
|
|
|
|
void VCAI::heroVisit(const CGHeroInstance *visitor, const CGObjectInstance *visitedObj, bool start)
|
|
|
{
|
|
|
- LOG_TRACE_PARAMS(logAi, "start '%i'", start);
|
|
|
+ LOG_TRACE_PARAMS(logAi, "start '%i'; obj '%s'", start % (visitedObj ? visitedObj->hoverName : std::string("n/a")));
|
|
|
NET_EVENT_HANDLER;
|
|
|
- if (start)
|
|
|
+ if(start)
|
|
|
{
|
|
|
markObjectVisited (visitedObj);
|
|
|
erase_if_present(reservedObjs, visitedObj); //unreserve objects
|
|
|
erase_if_present(reservedHeroesMap[visitor], visitedObj);
|
|
|
completeGoal (CGoal(GET_OBJ).sethero(visitor)); //we don't need to visit in anymore
|
|
|
}
|
|
|
+
|
|
|
+ status.heroVisit(visitedObj, start);
|
|
|
}
|
|
|
|
|
|
void VCAI::availableArtifactsChanged(const CGBlackMarket *bm /*= nullptr*/)
|
|
@@ -2701,7 +2706,7 @@ void AIStatus::madeTurn()
|
|
|
void AIStatus::waitTillFree()
|
|
|
{
|
|
|
boost::unique_lock<boost::mutex> lock(mx);
|
|
|
- while(battle != NO_BATTLE || remainingQueries.size())
|
|
|
+ while(battle != NO_BATTLE || remainingQueries.size() || objectsBeingVisited.size() || ongoingHeroMovement)
|
|
|
cv.wait(lock);
|
|
|
}
|
|
|
|
|
@@ -2738,6 +2743,26 @@ void AIStatus::receivedAnswerConfirmation(int answerRequestID, int result)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void AIStatus::heroVisit(const CGObjectInstance *obj, bool started)
|
|
|
+{
|
|
|
+ boost::unique_lock<boost::mutex> lock(mx);
|
|
|
+ if(started)
|
|
|
+ objectsBeingVisited.push_back(obj);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ assert(objectsBeingVisited.size() == 1);
|
|
|
+ objectsBeingVisited.clear();
|
|
|
+ }
|
|
|
+ cv.notify_all();
|
|
|
+}
|
|
|
+
|
|
|
+void AIStatus::setMove(bool ongoing)
|
|
|
+{
|
|
|
+ boost::unique_lock<boost::mutex> lock(mx);
|
|
|
+ ongoingHeroMovement = ongoing;
|
|
|
+ cv.notify_all();
|
|
|
+}
|
|
|
+
|
|
|
int3 whereToExplore(HeroPtr h)
|
|
|
{
|
|
|
//TODO it's stupid and ineffective, write sth better
|