1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-13 01:20:34 +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)
{
emit text("Error: " + socket->errorString());
emit disconnect();
}
}

View File

@ -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();

View File

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

View File

@ -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) {

View File

@ -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>

View File

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

View File

@ -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);