Browse Source

Fixed #459 and #465.
Fixed crash on closing creature info window when upgrade was possible ( http://forum.vcmi.eu/viewtopic.php?p=4669#4669 ).

Michał W. Urbańczyk 15 years ago
parent
commit
abf54deaa3
4 changed files with 12 additions and 9 deletions
  1. 4 0
      client/CPlayerInterface.cpp
  2. 6 6
      client/GUIClasses.cpp
  3. 1 2
      hch/CObjectHandler.h
  4. 1 1
      lib/Connection.h

+ 4 - 0
client/CPlayerInterface.cpp

@@ -1268,6 +1268,10 @@ void CPlayerInterface::update()
 	if(terminate_cond.get())
 		return;
 
+	//in some conditions we may receive calls before selection is initialized - we must ignore them
+	if(!adventureInt->selection)
+		return;
+
 	//if there are any waiting dialogs, show them
 	if(dialogs.size() && !showingDialog->get())
 	{

+ 6 - 6
client/GUIClasses.cpp

@@ -2243,11 +2243,11 @@ CCreInfoWindow::CCreInfoWindow(const CStackInstance &st, int Type, boost::functi
 
 			if(enough)
 			{
-				CFunctionList<void()> fs[2];
-				fs[0] += Upg;
-				fs[0] += boost::bind(&CCreInfoWindow::close,this);
+				CFunctionList<void()> fs;
+				fs += Upg;
+				fs += boost::bind(&CCreInfoWindow::close,this);
 				CFunctionList<void()> cfl;
-				cfl = boost::bind(&CPlayerInterface::showYesNoDialog,LOCPLINT,CGI->generaltexth->allTexts[207],boost::ref(upgResCost),fs[0],fs[1],false);
+				cfl = boost::bind(&CPlayerInterface::showYesNoDialog, LOCPLINT, CGI->generaltexth->allTexts[207], boost::ref(upgResCost), fs, 0, false);
 				upgrade = new AdventureMapButton("",CGI->generaltexth->zelp[446].second,cfl,76,237,"IVIEWCR.DEF",SDLK_u);
 			}
 			else
@@ -2374,8 +2374,8 @@ CCreInfoWindow::CCreInfoWindow(int Cid, int Type, int creatureCount)
 CCreInfoWindow::~CCreInfoWindow()
 {
 	delete anim;
-	for(int i=0; i<upgResCost.size();i++)
-		delete upgResCost[i];
+// 	for(int i=0; i<upgResCost.size();i++)
+// 		delete upgResCost[i];
 }
 
 void CCreInfoWindow::activate()

+ 1 - 2
hch/CObjectHandler.h

@@ -310,8 +310,7 @@ public:
 	{
 		h & static_cast<CArmedInstance&>(*this);
 		h & exp & level & name & biography & portrait & mana & secSkills & movement
-			& sex & inTownGarrison & artifacts & artifWorn & spells & patrol & bonuses
-			& moveDir;
+			& sex & inTownGarrison & artifacts & artifWorn & spells & patrol & moveDir;
 
 		h & type;
 		//visitied town pointer will be restored by map serialization method

+ 1 - 1
lib/Connection.h

@@ -21,7 +21,7 @@
 #include <boost/mpl/int.hpp>
 #include <boost/mpl/identity.hpp>
 
-const ui32 version = 721;
+const ui32 version = 722;
 class CConnection;
 class CGObjectInstance;
 class CGameState;