1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Makes player interface recreate advmap instead of reusing existing instance;

This commit is contained in:
Fay 2015-02-16 21:45:16 +01:00
parent 58b96cdd0a
commit 116e1d62a1
3 changed files with 7 additions and 16 deletions

View File

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

View File

@ -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()

View File

@ -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);
};