Forráskód Böngészése

Few more freeze-related fixes.

Michał W. Urbańczyk 12 éve
szülő
commit
c6c53a5b1e
4 módosított fájl, 7 hozzáadás és 3 törlés
  1. 2 1
      AI/VCAI/VCAI.cpp
  2. 1 1
      client/NetPacksClient.cpp
  3. 2 1
      lib/NetPacks.h
  4. 2 0
      server/CGameHandler.cpp

+ 2 - 1
AI/VCAI/VCAI.cpp

@@ -2634,6 +2634,7 @@ AIStatus::AIStatus()
 {
 	battle = NO_BATTLE;
 	havingTurn = false;
+	ongoingHeroMovement = false;
 }
 
 AIStatus::~AIStatus()
@@ -2707,7 +2708,7 @@ void AIStatus::waitTillFree()
 {
 	boost::unique_lock<boost::mutex> lock(mx);
 	while(battle != NO_BATTLE || remainingQueries.size() || objectsBeingVisited.size() || ongoingHeroMovement)
-		cv.wait(lock);
+		cv.timed_wait(lock, boost::posix_time::milliseconds(100));
 }
 
 bool AIStatus::haveTurn()

+ 1 - 1
client/NetPacksClient.cpp

@@ -246,7 +246,7 @@ void DisassembledArtifact::applyCl( CClient *cl )
 void HeroVisit::applyCl( CClient *cl )
 {
 	assert(hero);
-	INTERFACE_CALL_IF_PRESENT(hero->tempOwner, heroVisit, hero, obj, starting);
+	INTERFACE_CALL_IF_PRESENT(player, heroVisit, hero, obj, starting);
 }
 
 void NewTurn::applyCl( CClient *cl )

+ 2 - 1
lib/NetPacks.h

@@ -1092,6 +1092,7 @@ struct HeroVisit : CPackForClient //531
 {
 	const CGHeroInstance *hero;
 	const CGObjectInstance *obj;
+	PlayerColor player; //if hero was killed during the visit, its color is already reset
 	bool starting; //false -> ending
 
 	void applyCl(CClient *cl);
@@ -1099,7 +1100,7 @@ struct HeroVisit : CPackForClient //531
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
-		h & hero & obj & starting;
+		h & hero & obj & player & starting;
 	}
 };
 

+ 2 - 0
server/CGameHandler.cpp

@@ -4961,6 +4961,7 @@ void CGameHandler::objectVisited( const CGObjectInstance * obj, const CGHeroInst
 	HeroVisit hv;
 	hv.obj = obj;
 	hv.hero = h;
+	hv.player = h->tempOwner;
 	hv.starting = true;
 	sendAndApply(&hv);
 
@@ -4974,6 +4975,7 @@ void CGameHandler::objectVisitEnded(const CObjectVisitQuery &query)
 	logGlobal->traceStream() << query.visitingHero->nodeName() << " visit ends.\n";
 
 	HeroVisit hv;
+	hv.player = query.players.front();
 	hv.obj = nullptr; //not necessary, moreover may have been deleted in the meantime
 	hv.hero = query.visitingHero;
 	assert(hv.hero);