Browse Source

Fixed major RMG bug.

DjWarmonger 11 years ago
parent
commit
5cb6eaa252
3 changed files with 11 additions and 10 deletions
  1. 3 2
      lib/CGameState.cpp
  2. 8 7
      lib/mapObjects/CGTownInstance.cpp
  3. 0 1
      lib/rmg/CRmgTemplateZone.cpp

+ 3 - 2
lib/CGameState.cpp

@@ -3281,6 +3281,7 @@ void CPathfinder::calculatePaths(int3 src /*= int3(-1,-1,-1)*/, int movement /*=
 {
 	assert(hero);
 	assert(hero == getHero(hero->id));
+
 	if(src.x < 0)
 		src = hero->getPosition(false);
 	if(movement < 0)
@@ -3303,9 +3304,9 @@ void CPathfinder::calculatePaths(int3 src /*= int3(-1,-1,-1)*/, int movement /*=
 		return;
 	}
 
+	//logGlobal->infoStream() << boost::format("Calculating paths for hero %s (adress  %d) of player %d") % hero->name % hero % hero->tempOwner;
 	initializeGraph();
 
-
 	//initial tile - set cost on 0 and add to the queue
 	CGPathNode &initialNode = *getNode(src);
 	initialNode.turns = 0;
@@ -3457,7 +3458,7 @@ CGPathNode::EAccessibility CPathfinder::evaluateAccessibility(const TerrainTile
 		{
 			for(const CGObjectInstance *obj : tinfo->visitableObjects)
 			{
-				if(obj->passableFor(hero->tempOwner)) //special object instance specific passableness flag - overwrites other accessibility flags
+				if (obj->passableFor(hero->tempOwner))
 				{
 					ret = CGPathNode::ACCESSIBLE;
 				}

+ 8 - 7
lib/mapObjects/CGTownInstance.cpp

@@ -525,7 +525,7 @@ void CGTownInstance::onHeroLeave(const CGHeroInstance * h) const
 	if (visitingHero == h)
 	{
 		cb->stopHeroVisitCastle(this, h);
-		logGlobal->warnStream() << h->name << " correctly left town " << name;
+		//logGlobal->warnStream() << h->name << " correctly left town " << name;
 	}
 	else
 		logGlobal->warnStream() << "Warning, " << h->name << " tries to leave the town " << name << " but hero is not inside.";
@@ -912,12 +912,13 @@ bool CGTownInstance::addBonusIfBuilt(BuildingID building, Bonus::BonusType type,
 
 void CGTownInstance::setVisitingHero(CGHeroInstance *h)
 {
-	if (!(!!visitingHero == !h))
-	{
-		logGlobal->warnStream() << boost::format("Hero visiting town %s is %s ") % name % (visitingHero.get() ? visitingHero->name : "NULL");
-		logGlobal->warnStream() << boost::format("New hero will be %s ") % (h ? h->name : "NULL");
-		assert(!!visitingHero == !h);
-	}
+	//if (!(!!visitingHero == !h))
+	//{
+	//	logGlobal->warnStream() << boost::format("Hero visiting town %s is %s ") % name % (visitingHero.get() ? visitingHero->name : "NULL");
+	//	logGlobal->warnStream() << boost::format("New hero will be %s ") % (h ? h->name : "NULL");
+	//	
+	//}
+	assert(!!visitingHero == !h);
 
 	if(h)
 	{

+ 0 - 1
lib/rmg/CRmgTemplateZone.cpp

@@ -1393,7 +1393,6 @@ void CRmgTemplateZone::checkAndPlaceObject(CMapGenerator* gen, CGObjectInstance*
 		object->appearance = templates.front();
 	}
 
-	gen->map->addBlockVisTiles(object);
 	gen->editManager->insertObject(object, pos);
 	//logGlobal->traceStream() << boost::format ("Successfully inserted object (%d,%d) at pos %s") %object->ID %object->subID %pos();
 }