From 41cb1603e165c58be8b6f9daf784804900f673d0 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Fri, 20 Dec 2013 15:00:48 +0000 Subject: [PATCH] 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 --- client/CAdvmapInterface.cpp | 8 ++++++++ client/CPlayerInterface.cpp | 23 +++++++++++++---------- client/mapHandler.cpp | 6 ++++-- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/client/CAdvmapInterface.cpp b/client/CAdvmapInterface.cpp index 9279c0e99..2948416f2 100644 --- a/client/CAdvmapInterface.cpp +++ b/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); diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 59141c4ea..58db0bb8a 100644 --- a/client/CPlayerInterface.cpp +++ b/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 diff --git a/client/mapHandler.cpp b/client/mapHandler.cpp index bce08ad84..06dbe9a33 100644 --- a/client/mapHandler.cpp +++ b/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 {