Parcourir la source

Disconnection on error

nordsoft il y a 2 ans
Parent
commit
4527bd1a61

+ 1 - 0
launcher/lobby/lobby.cpp

@@ -30,6 +30,7 @@ void SocketLobby::connectServer(const QString & host, int port, const QString &
 	if(!socket->waitForDisconnected(timeout) && !isConnected)
 	{
 		emit text("Error: " + socket->errorString());
+		emit disconnect();
 	}
 }
 

+ 9 - 0
launcher/lobby/lobby_moc.cpp

@@ -40,6 +40,8 @@ void Lobby::serverCommand(const ServerCommand & command) try
 	case SRVERROR:
 		protocolAssert(args.size());
 		chatMessage("System error", args[0], true);
+		if(authentificationStatus == 0)
+			authentificationStatus = 2;
 		break;
 
 	case CREATED:
@@ -138,6 +140,11 @@ void Lobby::serverCommand(const ServerCommand & command) try
 		chatMessage(args[0], msg);
 		break;
 	}
+
+	if(authentificationStatus == 2)
+		socketLobby.disconnectServer();
+	else
+		authentificationStatus = 1;
 }
 catch(const ProtocolError & e)
 {
@@ -170,6 +177,7 @@ catch(const ProtocolError & e)
 
 void Lobby::onDisconnected()
 {
+	authentificationStatus = 0;
 	ui->stackedWidget->setCurrentWidget(ui->sessionsPage);
 	ui->connectButton->setChecked(false);
 }
@@ -209,6 +217,7 @@ void Lobby::on_connectButton_toggled(bool checked)
 {
 	if(checked)
 	{
+		authentificationStatus = 0;
 		username = ui->userEdit->text();
 		const int connectionTimeout = settings["launcher"]["connectionTimeout"].Integer();
 

+ 2 - 0
launcher/lobby/lobby_moc.h

@@ -42,6 +42,8 @@ private:
 	QString username;
 	QStringList gameArgs;
 
+	int authentificationStatus = 0;
+
 private:
 	void protocolAssert(bool);
 };

+ 2 - 2
launcher/mainwindow_moc.cpp

@@ -85,9 +85,9 @@ MainWindow::MainWindow(QWidget * parent)
 	}
 	ui->tabListWidget->setCurrentIndex(0);
 
-	ui->settingsView->isExtraResolutionsModEnabled = ui->stackedWidgetPage2->isExtraResolutionsModEnabled();
+	ui->settingsView->isExtraResolutionsModEnabled = ui->modlistView->isExtraResolutionsModEnabled();
 	ui->settingsView->setDisplayList();
-	connect(ui->stackedWidgetPage2, &CModListView::extraResolutionsEnabledChanged,
+	connect(ui->modlistView, &CModListView::extraResolutionsEnabledChanged,
 		ui->settingsView, &CSettingsView::fillValidResolutions);
 
 	connect(ui->tabSelectList, &QListWidget::currentRowChanged, [this](int i) {

+ 2 - 2
launcher/mainwindow_moc.ui

@@ -152,9 +152,9 @@
        </sizepolicy>
       </property>
       <property name="currentIndex">
-       <number>2</number>
+       <number>0</number>
       </property>
-      <widget class="CModListView" name="stackedWidgetPage2"/>
+      <widget class="CModListView" name="modlistView"/>
       <widget class="CSettingsView" name="settingsView"/>
       <widget class="Lobby" name="lobbyView"/>
      </widget>

+ 6 - 0
launcher/modManager/cmodlistview_moc.cpp

@@ -825,3 +825,9 @@ void CModListView::on_showInfoButton_clicked()
 {
 	showModInfo();
 }
+
+const CModList & CModListView::getModList() const
+{
+	assert(modModel);
+	return *modModel;
+}

+ 3 - 0
launcher/modManager/cmodlistview_moc.h

@@ -18,6 +18,7 @@ class CModListView;
 }
 
 class CModManager;
+class CModList;
 class CModListModel;
 class CModFilterModel;
 class CDownloadManager;
@@ -80,6 +81,8 @@ public:
 	void selectMod(const QModelIndex & index);
 	bool isExtraResolutionsModEnabled() const;
 
+	const CModList & getModList() const;
+
 private slots:
 	void dataChanged(const QModelIndex & topleft, const QModelIndex & bottomRight);
 	void modSelected(const QModelIndex & current, const QModelIndex & previous);