From 116e1d62a17824d1651386993d058549fe816388 Mon Sep 17 00:00:00 2001 From: Fay Date: Mon, 16 Feb 2015 21:45:16 +0100 Subject: [PATCH] Makes player interface recreate advmap instead of reusing existing instance; --- client/CPlayerInterface.cpp | 8 ++++---- client/windows/CAdvmapInterface.cpp | 12 +++--------- client/windows/CAdvmapInterface.h | 3 --- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 0fd4bf5b1..6cdef2322 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -141,10 +141,10 @@ void CPlayerInterface::init(shared_ptr 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() { diff --git a/client/windows/CAdvmapInterface.cpp b/client/windows/CAdvmapInterface.cpp index 3d2d9c332..5947da0d5 100644 --- a/client/windows/CAdvmapInterface.cpp +++ b/client/windows/CAdvmapInterface.cpp @@ -550,19 +550,13 @@ 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); worldViewUnderground->block(!CGI->mh->map->twoLevel); - - terrain.currentPath = nullptr; // invalidate previously visible path after game reload + + addUsedEvents(MOVE); } CAdvMapInt::~CAdvMapInt() diff --git a/client/windows/CAdvmapInterface.h b/client/windows/CAdvmapInterface.h index 98ccf4d4f..377f0f7d4 100644 --- a/client/windows/CAdvmapInterface.h +++ b/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); };