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

Reset obelisks upon game end

Otherwise, the static variables are preserved and lead to wrong values in next new game.
This commit is contained in:
Vadim Markovtsev 2016-01-20 13:02:52 +03:00
parent 1a2cd36df8
commit e8db456beb
3 changed files with 40 additions and 31 deletions

View File

@ -219,18 +219,20 @@ void CClient::endGame( bool closeConnection /*= true*/ )
GH.curInt = nullptr; GH.curInt = nullptr;
{ {
boost::unique_lock<boost::recursive_mutex> un(*LOCPLINT->pim); boost::unique_lock<boost::recursive_mutex> un(*LOCPLINT->pim);
logNetwork->infoStream() << "Ending current game!"; logNetwork->infoStream() << "Ending current game!";
if(GH.topInt()) if(GH.topInt())
{
GH.topInt()->deactivate(); GH.topInt()->deactivate();
}
GH.listInt.clear(); GH.listInt.clear();
GH.objsToBlit.clear(); GH.objsToBlit.clear();
GH.statusbar = nullptr; GH.statusbar = nullptr;
logNetwork->infoStream() << "Removed GUI."; logNetwork->infoStream() << "Removed GUI.";
vstd::clear_pointer(const_cast<CGameInfo*>(CGI)->mh); vstd::clear_pointer(const_cast<CGameInfo*>(CGI)->mh);
vstd::clear_pointer(gs); vstd::clear_pointer(gs);
logNetwork->infoStream() << "Deleted mapHandler and gameState."; logNetwork->infoStream() << "Deleted mapHandler and gameState.";
LOCPLINT = nullptr; LOCPLINT = nullptr;
} }
@ -238,9 +240,9 @@ void CClient::endGame( bool closeConnection /*= true*/ )
battleints.clear(); battleints.clear();
callbacks.clear(); callbacks.clear();
battleCallbacks.clear(); battleCallbacks.clear();
logNetwork->infoStream() << "Deleted playerInts."; CGObelisk::reset();
logNetwork->infoStream() << "Deleted playerInts.";
logNetwork->infoStream() << "Client stopped."; logNetwork->infoStream() << "Client stopped.";
} }
#if 1 #if 1

View File

@ -1867,6 +1867,12 @@ void CGObelisk::initObj()
obeliskCount++; obeliskCount++;
} }
void CGObelisk::reset()
{
obeliskCount = 0;
visited.clear();
}
std::string CGObelisk::getHoverText(PlayerColor player) const std::string CGObelisk::getHoverText(PlayerColor player) const
{ {
return getObjectName() + " " + visitedTxt(wasVisited(player)); return getObjectName() + " " + visitedTxt(wasVisited(player));

View File

@ -460,6 +460,7 @@ public:
void onHeroVisit(const CGHeroInstance * h) const override; void onHeroVisit(const CGHeroInstance * h) const override;
void initObj() override; void initObj() override;
std::string getHoverText(PlayerColor player) const override; std::string getHoverText(PlayerColor player) const override;
static void reset();
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {