diff --git a/client/CMT.cpp b/client/CMT.cpp index 64b2a4403..84d808dc5 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -486,7 +486,7 @@ static void quitApplication() std::cout << "Ending...\n"; // this method is always called from event/network threads, which keep interface mutex locked - // unlock it here to avoid assertion failure on GH descruction in exit() + // unlock it here to avoid assertion failure on GH destruction in exit() GH.interfaceMutex.unlock(); exit(0); } diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 54ea7a27d..6d03659f7 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -104,7 +104,7 @@ #include "../lib/spells/CSpellHandler.h" // The macro below is used to mark functions that are called by client when game state changes. -// They all assume that CPlayerInterface::pim mutex is locked. +// They all assume that interface mutex is locked. #define EVENT_HANDLER_CALLED_BY_CLIENT #define BATTLE_EVENT_POSSIBLE_RETURN \ @@ -751,7 +751,7 @@ void CPlayerInterface::activeStack(const BattleID & battleID, const CStack * sta { //FIXME: we want client rendering to proceed while AI is making actions // so unlock mutex while AI is busy since this might take quite a while, especially if hero has many spells - auto unlockPim = vstd::makeUnlockGuard(GH.interfaceMutex); + auto unlockInterface = vstd::makeUnlockGuard(GH.interfaceMutex); autofightingAI->activeStack(battleID, stack); return; } @@ -1339,7 +1339,7 @@ void CPlayerInterface::waitWhileDialog() return; } - auto unlock = vstd::makeUnlockGuard(GH.interfaceMutex); + auto unlockInterface = vstd::makeUnlockGuard(GH.interfaceMutex); boost::unique_lock un(showingDialog->mx); while(showingDialog->data) showingDialog->cond.wait(un); @@ -1378,7 +1378,7 @@ void CPlayerInterface::centerView (int3 pos, int focusTime) GH.windows().totalRedraw(); { IgnoreEvents ignore(*this); - auto unlockPim = vstd::makeUnlockGuard(GH.interfaceMutex); + auto unlockInterface = vstd::makeUnlockGuard(GH.interfaceMutex); boost::this_thread::sleep_for(boost::chrono::milliseconds(focusTime)); } } @@ -1815,7 +1815,7 @@ void CPlayerInterface::waitForAllDialogs() { while(!dialogs.empty()) { - auto unlock = vstd::makeUnlockGuard(GH.interfaceMutex); + auto unlockInterface = vstd::makeUnlockGuard(GH.interfaceMutex); boost::this_thread::sleep_for(boost::chrono::milliseconds(5)); } waitWhileDialog(); diff --git a/client/Client.cpp b/client/Client.cpp index 0dfa1b80b..cfc036fed 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -641,15 +641,17 @@ void CClient::battleFinished(const BattleID & battleID) void CClient::startPlayerBattleAction(const BattleID & battleID, PlayerColor color) { - assert(vstd::contains(battleints, color)); + auto battleint = battleints.at(color); - if(vstd::contains(battleints, color)) + if (!battleint->human) { // we want to avoid locking gamestate and causing UI to freeze while AI is making turn - auto unlock = vstd::makeUnlockGuardIf(GH.interfaceMutex, !battleints[color]->human); - - assert(vstd::contains(battleints, color)); - battleints[color]->activeStack(battleID, gs->getBattle(battleID)->battleGetStackByID(gs->getBattle(battleID)->activeStack, false)); + auto unlockInterface = vstd::makeUnlockGuard(GH.interfaceMutex); + battleint->activeStack(battleID, gs->getBattle(battleID)->battleGetStackByID(gs->getBattle(battleID)->activeStack, false)); + } + else + { + battleint->activeStack(battleID, gs->getBattle(battleID)->battleGetStackByID(gs->getBattle(battleID)->activeStack, false)); } } diff --git a/client/ClientCommandManager.h b/client/ClientCommandManager.h index 409ccc6ff..ecb555212 100644 --- a/client/ClientCommandManager.h +++ b/client/ClientCommandManager.h @@ -78,9 +78,6 @@ class ClientCommandManager //take mantis #2292 issue about account if thinking a // set - sets special temporary settings that reset on game quit. void handleSetCommand(std::istringstream& singleWordBuffer); - // Unlocks specific mutex known in VCMI code as "pim" - void handleUnlockCommand(std::istringstream& singleWordBuffer); - // Crashes the game forcing an exception void handleCrashCommand(); diff --git a/client/battle/BattleInterface.cpp b/client/battle/BattleInterface.cpp index 53b164184..b0e383a66 100644 --- a/client/battle/BattleInterface.cpp +++ b/client/battle/BattleInterface.cpp @@ -780,7 +780,7 @@ void BattleInterface::onAnimationsFinished() void BattleInterface::waitForAnimations() { { - auto unlockPim = vstd::makeUnlockGuard(GH.interfaceMutex); + auto unlockInterface = vstd::makeUnlockGuard(GH.interfaceMutex); ongoingAnimationsState.waitUntil(false); } diff --git a/client/mapView/mapHandler.cpp b/client/mapView/mapHandler.cpp index 2de09bf59..2b83b2fba 100644 --- a/client/mapView/mapHandler.cpp +++ b/client/mapView/mapHandler.cpp @@ -38,7 +38,7 @@ void CMapHandler::waitForOngoingAnimations() { while(CGI->mh->hasOngoingAnimations()) { - auto unlockPim = vstd::makeUnlockGuard(GH.interfaceMutex); + auto unlockInterface = vstd::makeUnlockGuard(GH.interfaceMutex); boost::this_thread::sleep_for(boost::chrono::milliseconds(1)); } }