Browse Source

Merge pull request #91 from Fayth/fix-advmap-restoring

Short and clear code is always welcome.
DjWarmonger 10 years ago
parent
commit
5d1fbedf85

+ 4 - 4
client/CPlayerInterface.cpp

@@ -141,10 +141,10 @@ void CPlayerInterface::init(shared_ptr<CCallback> CB)
 	if(!towns.size() && !wanderingHeroes.size())
 		initializeHeroTownList();
 
-	if(!adventureInt)
-		adventureInt = new CAdvMapInt();
-	else
-		adventureInt->restoreState();
+	// always recreate advmap interface to avoid possible memory-corruption bugs
+	if(adventureInt)
+		delete adventureInt;
+	adventureInt = new CAdvMapInt();
 }
 void CPlayerInterface::yourTurn()
 {

+ 3 - 9
client/windows/CAdvmapInterface.cpp

@@ -550,20 +550,14 @@ CAdvMapInt::CAdvMapInt():
 											Colors::WHITE, CGI->generaltexth->allTexts[618]));
 
 	activeMapPanel = panelMain;
-	restoreState();
-
-	addUsedEvents(MOVE);
-}
-
-void CAdvMapInt::restoreState()
-{
+	
 	changeMode(EAdvMapMode::NORMAL);
 
 	underground->block(!CGI->mh->map->twoLevel);
 	questlog->block(!CGI->mh->map->quests.size());
 	worldViewUnderground->block(!CGI->mh->map->twoLevel);
-	
-	terrain.currentPath = nullptr; // invalidate previously visible path after game reload
+
+	addUsedEvents(MOVE);
 }
 
 CAdvMapInt::~CAdvMapInt()

+ 0 - 3
client/windows/CAdvmapInterface.h

@@ -208,9 +208,6 @@ public:
 	void updateMoveHero(const CGHeroInstance *h, tribool hasPath = boost::logic::indeterminate);
 	void updateNextHero(const CGHeroInstance *h);
 
-	/// called by player interface if it wants to reuse this object for new/loaded map
-	void restoreState();
-
 	/// changes current adventure map mode; used to switch between default view and world view; scale is ignored if EAdvMapMode == NORMAL
 	void changeMode(EAdvMapMode newMode, float newScale = 0.36f);
 };