浏览代码

Fix for #1624 :
- recreate adventure map interface on each scenario (to make sure that
there is no garbage data from prev. game)
- added check to avoid such situations in future

Ivan Savenko 12 年之前
父节点
当前提交
41cb1603e1
共有 3 个文件被更改,包括 25 次插入12 次删除
  1. 8 0
      client/CAdvmapInterface.cpp
  2. 13 10
      client/CPlayerInterface.cpp
  3. 4 2
      client/mapHandler.cpp

+ 8 - 0
client/CAdvmapInterface.cpp

@@ -403,6 +403,7 @@ infoBar(Rect(ADVOPT.infoboxX, ADVOPT.infoboxY, 192, 192) )
 	pos.x = pos.y = 0;
 	pos.w = screen->w;
 	pos.h = screen->h;
+	position = int3(0,0,0);
 	selection = nullptr;
 	townList.onSelect = boost::bind(&CAdvMapInt::selectionChanged,this);
 	adventureInt=this;
@@ -747,6 +748,13 @@ void CAdvMapInt::show(SDL_Surface * to)
 	}
 	if(updateScreen)
 	{
+		int3 betterPos = LOCPLINT->repairScreenPos(position);
+		if (betterPos != position)
+		{
+			logGlobal->warnStream() << "Incorrect position for adventure map!";
+			position = betterPos;
+		}
+
 		terrain.show(to);
 		for(int i=0;i<4;i++)
 			blitAt(gems[i]->ourImages[LOCPLINT->playerID.getNum()].bitmap,ADVOPT.gemX[i],ADVOPT.gemY[i],to);

+ 13 - 10
client/CPlayerInterface.cpp

@@ -2117,6 +2117,19 @@ void CPlayerInterface::gameOver(PlayerColor player, const EVictoryLossCheckResul
 
 		--howManyPeople;
 
+		if(howManyPeople == 0) //all human players eliminated
+		{
+			if(adventureInt)
+			{
+				terminate_cond.setn(true);
+				adventureInt->deactivate();
+				if(GH.topInt() == adventureInt)
+					GH.popInt(adventureInt);
+				delete adventureInt;
+				adventureInt = nullptr;
+			}
+		}
+
 		if(cb->getStartInfo()->mode == StartInfo::CAMPAIGN)
 		{
 			// if you lose the campaign go back to the main menu
@@ -2127,16 +2140,6 @@ void CPlayerInterface::gameOver(PlayerColor player, const EVictoryLossCheckResul
 		{
 			if(howManyPeople == 0) //all human players eliminated
 			{
-				if(adventureInt)
-				{
-					terminate_cond.setn(true);
-					adventureInt->deactivate();
-					if(GH.topInt() == adventureInt)
-						GH.popInt(adventureInt);
-					delete adventureInt;
-					adventureInt = nullptr;
-				}
-
 				requestReturningToMainMenu();
 			}
 			else if(victoryLossCheckResult.victory() && LOCPLINT == this) // end game if current human player has won

+ 4 - 2
client/mapHandler.cpp

@@ -680,10 +680,12 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
 			if (pos.x < 0 || pos.x >= sizes.x ||
 				pos.y < 0 || pos.y >= sizes.y)
 			{
+				// outside of the map - print borders
 				SDL_Rect temp_rect = genRect(sr.h, sr.w, 0, 0);
+				SDL_Surface * src = ttiles[pos.x][pos.y][top_tile.z].terbitmap;
+				assert(src);
 
-				CSDL_Ext::blitSurface(ttiles[pos.x][pos.y][top_tile.z].terbitmap,
-								&temp_rect,extSurf,&sr);
+				CSDL_Ext::blitSurface(src, &temp_rect,extSurf,&sr);
 			}
 			else 
 			{