Browse Source

Fixed the stables crash #799.

Michał W. Urbańczyk 14 years ago
parent
commit
5072bda7e6
1 changed files with 8 additions and 7 deletions
  1. 8 7
      lib/CObjectHandler.cpp

+ 8 - 7
lib/CObjectHandler.cpp

@@ -4789,23 +4789,24 @@ void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const
 		break;
 		break;
 	case 94: //Stables
 	case 94: //Stables
 		sound = soundBase::horse20;
 		sound = soundBase::horse20;
-		CCreatureSet creatures;
+		bool someUpgradeDone = false;
+
 		for (TSlots::const_iterator i = h->Slots().begin(); i != h->Slots().end(); ++i)
 		for (TSlots::const_iterator i = h->Slots().begin(); i != h->Slots().end(); ++i)
 		{
 		{
 			if(i->second->type->idNumber == 10)
 			if(i->second->type->idNumber == 10)
-				creatures.stacks.insert(*i);
+			{
+				cb->changeStackType(StackLocation(h, i->first), VLC->creh->creatures[11]);
+				someUpgradeDone = true;
+			}
 		}
 		}
-		if (creatures.stacks.size())
+		if (someUpgradeDone)
 		{
 		{
 			messageID = 138;
 			messageID = 138;
 			iw.components.push_back(Component(Component::CREATURE,11,0,1));
 			iw.components.push_back(Component(Component::CREATURE,11,0,1));
-			for (TSlots::const_iterator i = creatures.stacks.begin(); i != creatures.stacks.end(); ++i)
-			{
-				cb->changeStackType(StackLocation(h, i->first), VLC->creh->creatures[11]);
-			}
 		}
 		}
 		else
 		else
 			messageID = 137;
 			messageID = 137;
+
 		gbonus.bonus.type = Bonus::LAND_MOVEMENT;
 		gbonus.bonus.type = Bonus::LAND_MOVEMENT;
 		gbonus.bonus.val = 600;
 		gbonus.bonus.val = 600;
 		bonusMove = 600;
 		bonusMove = 600;