|
@@ -72,7 +72,6 @@
|
|
|
#include "../lib/CStopWatch.h"
|
|
|
#include "../lib/CThreadHelper.h"
|
|
|
#include "../lib/CTownHandler.h"
|
|
|
-#include "../lib/CondSh.h"
|
|
|
#include "../lib/GameConstants.h"
|
|
|
#include "../lib/RoadHandler.h"
|
|
|
#include "../lib/StartInfo.h"
|
|
@@ -140,7 +139,7 @@ CPlayerInterface::CPlayerInterface(PlayerColor Player):
|
|
|
battleInt = nullptr;
|
|
|
castleInt = nullptr;
|
|
|
makingTurn = false;
|
|
|
- showingDialog = new CondSh<bool>(false);
|
|
|
+ showingDialog = new ConditionalWait();
|
|
|
cingconsole = new CInGameConsole();
|
|
|
firstCall = 1; //if loading will be overwritten in serialize
|
|
|
autosaveCount = 0;
|
|
@@ -1005,7 +1004,7 @@ void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector
|
|
|
if (makingTurn && GH.windows().count() > 0 && LOCPLINT == this)
|
|
|
{
|
|
|
CCS->soundh->playSound(static_cast<soundBase::soundID>(soundID));
|
|
|
- showingDialog->set(true);
|
|
|
+ showingDialog->setBusy();
|
|
|
movementController->requestMovementAbort(); // interrupt movement to show dialog
|
|
|
GH.windows().pushWindow(temp);
|
|
|
}
|
|
@@ -1028,7 +1027,7 @@ void CPlayerInterface::showInfoDialogAndWait(std::vector<Component> & components
|
|
|
void CPlayerInterface::showYesNoDialog(const std::string &text, CFunctionList<void()> onYes, CFunctionList<void()> onNo, const std::vector<std::shared_ptr<CComponent>> & components)
|
|
|
{
|
|
|
movementController->requestMovementAbort();
|
|
|
- LOCPLINT->showingDialog->setn(true);
|
|
|
+ LOCPLINT->showingDialog->setBusy();
|
|
|
CInfoWindow::showYesNoDialog(text, components, onYes, onNo, playerID);
|
|
|
}
|
|
|
|
|
@@ -1217,7 +1216,7 @@ void CPlayerInterface::loadGame( BinaryDeserializer & h )
|
|
|
void CPlayerInterface::moveHero( const CGHeroInstance *h, const CGPath& path )
|
|
|
{
|
|
|
assert(h);
|
|
|
- assert(!showingDialog->get());
|
|
|
+ assert(!showingDialog->isBusy());
|
|
|
assert(dialogs.empty());
|
|
|
|
|
|
LOG_TRACE(logGlobal);
|
|
@@ -1227,7 +1226,7 @@ void CPlayerInterface::moveHero( const CGHeroInstance *h, const CGPath& path )
|
|
|
return; //can't find hero
|
|
|
|
|
|
//It shouldn't be possible to move hero with open dialog (or dialog waiting in bg)
|
|
|
- if (showingDialog->get() || !dialogs.empty())
|
|
|
+ if (showingDialog->isBusy() || !dialogs.empty())
|
|
|
return;
|
|
|
|
|
|
if (localState->isHeroSleeping(h))
|
|
@@ -1395,9 +1394,7 @@ void CPlayerInterface::waitWhileDialog()
|
|
|
}
|
|
|
|
|
|
auto unlockInterface = vstd::makeUnlockGuard(GH.interfaceMutex);
|
|
|
- boost::unique_lock<boost::mutex> un(showingDialog->mx);
|
|
|
- while(showingDialog->data)
|
|
|
- showingDialog->cond.wait(un);
|
|
|
+ showingDialog->waitWhileBusy();
|
|
|
}
|
|
|
|
|
|
void CPlayerInterface::showShipyardDialog(const IShipyard *obj)
|
|
@@ -1502,9 +1499,9 @@ void CPlayerInterface::update()
|
|
|
return;
|
|
|
|
|
|
//if there are any waiting dialogs, show them
|
|
|
- if ((CSH->howManyPlayerInterfaces() <= 1 || makingTurn) && !dialogs.empty() && !showingDialog->get())
|
|
|
+ if ((CSH->howManyPlayerInterfaces() <= 1 || makingTurn) && !dialogs.empty() && !showingDialog->isBusy())
|
|
|
{
|
|
|
- showingDialog->set(true);
|
|
|
+ showingDialog->setBusy();
|
|
|
GH.windows().pushWindow(dialogs.front());
|
|
|
dialogs.pop_front();
|
|
|
}
|
|
@@ -1516,6 +1513,11 @@ void CPlayerInterface::update()
|
|
|
GH.windows().simpleRedraw();
|
|
|
}
|
|
|
|
|
|
+void CPlayerInterface::endNetwork()
|
|
|
+{
|
|
|
+ showingDialog->requestTermination();
|
|
|
+}
|
|
|
+
|
|
|
int CPlayerInterface::getLastIndex( std::string namePrefix)
|
|
|
{
|
|
|
using namespace boost::filesystem;
|