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

@ -221,7 +221,9 @@ void CClient::endGame( bool closeConnection /*= true*/ )
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;
@ -238,8 +240,8 @@ void CClient::endGame( bool closeConnection /*= true*/ )
battleints.clear(); battleints.clear();
callbacks.clear(); callbacks.clear();
battleCallbacks.clear(); battleCallbacks.clear();
CGObelisk::reset();
logNetwork->infoStream() << "Deleted playerInts."; logNetwork->infoStream() << "Deleted playerInts.";
logNetwork->infoStream() << "Client stopped."; logNetwork->infoStream() << "Client stopped.";
} }

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)
{ {