1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Simplified connection logic

This commit is contained in:
Ivan Savenko
2023-12-25 22:56:55 +02:00
parent 8ea69e457a
commit 5694777a96
4 changed files with 15 additions and 42 deletions

View File

@@ -611,31 +611,10 @@ void CSimpleJoinScreen::startConnection(const std::string & addr, ui16 port)
CVCMIServer::reuseClientJNIEnv(SDL_AndroidGetJNIEnv());
#endif
auto const & onConnected = [this]()
{
// async call to prevent thread race
GH.dispatchMainThread([this](){
// FIXME: this enum value is never set!!!
if(CSH->state == EClientState::CONNECTION_FAILED)
{
CInfoWindow::showInfoDialog(CGI->generaltexth->translate("vcmi.mainMenu.serverConnectionFailed"), {});
textTitle->setText(CGI->generaltexth->translate("vcmi.mainMenu.serverAddressEnter"));
GH.startTextInput(inputAddress->pos);
buttonOk->block(false);
}
if(GH.windows().isTopWindow(this))
{
close();
}
});
};
if(addr.empty())
CSH->startLocalServerAndConnect(onConnected);
CSH->startLocalServerAndConnect();
else
CSH->justConnectToServer(addr, port, onConnected);
CSH->justConnectToServer(addr, port);
}
CLoadingScreen::CLoadingScreen()