浏览代码

Fix broken popping of top interfaces when town was opened during multiplayer game

Dydzio 1 年之前
父节点
当前提交
e843af24bf
共有 3 个文件被更改,包括 4 次插入12 次删除
  1. 3 10
      client/CPlayerInterface.cpp
  2. 1 1
      client/gui/CIntObject.cpp
  3. 0 1
      client/gui/CIntObject.h

+ 3 - 10
client/CPlayerInterface.cpp

@@ -172,10 +172,11 @@ void CPlayerInterface::initGameInterface(std::shared_ptr<Environment> ENV, std::
 void CPlayerInterface::closeAllDialogs()
 void CPlayerInterface::closeAllDialogs()
 {
 {
 	// remove all active dialogs that do not expect query answer
 	// remove all active dialogs that do not expect query answer
-	for (;;)
+	while(true)
 	{
 	{
 		auto adventureWindow = GH.windows().topWindow<AdventureMapInterface>();
 		auto adventureWindow = GH.windows().topWindow<AdventureMapInterface>();
 		auto infoWindow = GH.windows().topWindow<CInfoWindow>();
 		auto infoWindow = GH.windows().topWindow<CInfoWindow>();
+		auto topWindow = GH.windows().topWindow<WindowBase>();
 
 
 		if(adventureWindow != nullptr)
 		if(adventureWindow != nullptr)
 			break;
 			break;
@@ -183,16 +184,8 @@ void CPlayerInterface::closeAllDialogs()
 		if(infoWindow && infoWindow->ID != QueryID::NONE)
 		if(infoWindow && infoWindow->ID != QueryID::NONE)
 			break;
 			break;
 
 
-		if (infoWindow)
-			infoWindow->close();
-		else
-			GH.windows().popWindows(1);
+		topWindow->close();
 	}
 	}
-
-	if(castleInt)
-		castleInt->close();
-
-	castleInt = nullptr;
 }
 }
 
 
 void CPlayerInterface::playerEndsTurn(PlayerColor player)
 void CPlayerInterface::playerEndsTurn(PlayerColor player)

+ 1 - 1
client/gui/CIntObject.cpp

@@ -341,6 +341,6 @@ WindowBase::WindowBase(int used_, Point pos_)
 void WindowBase::close()
 void WindowBase::close()
 {
 {
 	if(!GH.windows().isTopWindow(this))
 	if(!GH.windows().isTopWindow(this))
-		logGlobal->error("Only top interface must be closed");
+		throw std::runtime_error("Only top interface can be closed");
 	GH.windows().popWindows(1);
 	GH.windows().popWindows(1);
 }
 }

+ 0 - 1
client/gui/CIntObject.h

@@ -146,7 +146,6 @@ class WindowBase : public CIntObject
 {
 {
 public:
 public:
 	WindowBase(int used_ = 0, Point pos_ = Point());
 	WindowBase(int used_ = 0, Point pos_ = Point());
-protected:
 	virtual void close();
 	virtual void close();
 };
 };