1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

Disconnection on error

This commit is contained in:
nordsoft
2022-11-16 23:53:54 +04:00
parent 179cdee424
commit 4527bd1a61
7 changed files with 25 additions and 4 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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