瀏覽代碼

Fixed crash on battle end.

Michał W. Urbańczyk 15 年之前
父節點
當前提交
7ad7a36363
共有 2 個文件被更改,包括 6 次插入5 次删除
  1. 4 4
      client/CBattleInterface.cpp
  2. 2 1
      client/CBattleInterface.h

+ 4 - 4
client/CBattleInterface.cpp

@@ -1101,8 +1101,8 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
 	curInt->battleInt = this;
 
 	//initializing armies
-	this->army1 = army1;
-	this->army2 = army2;
+	this->army1 = *army1;
+	this->army2 = *army2;
 	std::map<int, CStack> stacks = curInt->cb->battleGetStacks();
 	for(std::map<int, CStack>::iterator b=stacks.begin(); b!=stacks.end(); ++b)
 	{
@@ -3638,7 +3638,7 @@ CBattleResultWindow::CBattleResultWindow(const BattleResult &br, const SDL_Rect
 	{
 		int bestMonsterID = -1;
 		int bestPower = 0;
-		for(TSlots::const_iterator it = owner->army1->Slots().begin(); it!=owner->army1->Slots().end(); ++it)
+		for(TSlots::const_iterator it = owner->army1.Slots().begin(); it!=owner->army1.Slots().end(); ++it)
 		{
 			if( it->second.type->AIValue > bestPower)
 			{
@@ -3660,7 +3660,7 @@ CBattleResultWindow::CBattleResultWindow(const BattleResult &br, const SDL_Rect
 	{
 		int bestMonsterID = -1;
 		int bestPower = 0;
-		for(TSlots::const_iterator it = owner->army2->Slots().begin(); it!=owner->army2->Slots().end(); ++it)
+		for(TSlots::const_iterator it = owner->army2.Slots().begin(); it!=owner->army2.Slots().end(); ++it)
 		{
 			if( it->second.type->AIValue > bestPower)
 			{

+ 2 - 1
client/CBattleInterface.h

@@ -4,6 +4,7 @@
 #include "../global.h"
 #include <list>
 #include "GUIBase.h"
+#include "../lib/CCreatureSet.h"
 
 /*
  * CBattleInterface.h, part of VCMI engine
@@ -382,7 +383,7 @@ private:
 	CBattleConsole * console;
 	CBattleHero * attackingHero, * defendingHero; //fighting heroes
 	CStackQueue *queue;
-	const CCreatureSet * army1, * army2; //fighting armies
+	CCreatureSet army1, army2; //copy of initial armies (for result window)
 	CGHeroInstance * attackingHeroInstance, * defendingHeroInstance;
 	std::map< int, CCreatureAnimation * > creAnims; //animations of creatures from fighting armies (order by BattleInfo's stacks' ID)
 	std::map< int, CDefHandler * > idToProjectile; //projectiles of creatures (creatureID, defhandler)