1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Merge pull request #3703 from IvanSavenko/lobby_tweaks_2

Few more fixes for recently discovered lobby issues
This commit is contained in:
Ivan Savenko 2024-03-30 11:08:16 +02:00 committed by GitHub
commit 611b39a150
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 19 additions and 21 deletions

View File

@ -106,10 +106,9 @@ void GlobalLobbyClient::receiveOperationFailed(const JsonNode & json)
void GlobalLobbyClient::receiveClientLoginSuccess(const JsonNode & json)
{
{
setAccountDisplayName(json["displayName"].String());
setAccountCookie(json["accountCookie"].String());
}
accountLoggedIn = true;
setAccountDisplayName(json["displayName"].String());
setAccountCookie(json["accountCookie"].String());
auto loginWindowPtr = loginWindow.lock();
@ -343,6 +342,7 @@ void GlobalLobbyClient::onDisconnected(const std::shared_ptr<INetworkConnection>
assert(connection == networkConnection);
networkConnection.reset();
accountLoggedIn = false;
while (!GH.windows().findWindows<GlobalLobbyWindow>().empty())
{
@ -376,6 +376,11 @@ void GlobalLobbyClient::connect()
CSH->getNetworkHandler().connectToRemote(*this, hostname, port);
}
bool GlobalLobbyClient::isLoggedIn() const
{
return networkConnection != nullptr && accountLoggedIn;
}
bool GlobalLobbyClient::isConnected() const
{
return networkConnection != nullptr;
@ -461,7 +466,7 @@ void GlobalLobbyClient::activateInterface()
if (!GH.windows().findWindows<GlobalLobbyLoginWindow>().empty())
return;
if (isConnected())
if (isLoggedIn())
GH.windows().pushWindow(createLobbyWindow());
else
GH.windows().pushWindow(createLoginWindow());
@ -534,7 +539,7 @@ void GlobalLobbyClient::resetMatchState()
void GlobalLobbyClient::sendMatchChatMessage(const std::string & messageText)
{
if (!isConnected())
if (!isLoggedIn())
return; // we are not playing with lobby
if (currentGameRoomUUID.empty())

View File

@ -34,6 +34,7 @@ class GlobalLobbyClient final : public INetworkClientListener, boost::noncopyabl
std::shared_ptr<INetworkConnection> networkConnection;
std::string currentGameRoomUUID;
bool accountLoggedIn = false;
std::weak_ptr<GlobalLobbyLoginWindow> loginWindow;
std::weak_ptr<GlobalLobbyWindow> lobbyWindow;
@ -93,5 +94,6 @@ public:
void connect();
bool isConnected() const;
bool isLoggedIn() const;
bool isInvitedToRoom(const std::string & gameRoomID);
};

View File

@ -546,24 +546,12 @@
"type" : "object",
"additionalProperties" : false,
"default" : {},
"required" : [ "mapPreview", "accountID", "accountCookie", "displayName", "hostname", "port", "roomPlayerLimit", "roomType", "roomMode" ],
"required" : [ "mapPreview", "hostname", "port", "roomPlayerLimit", "roomType", "roomMode" ],
"properties" : {
"mapPreview" : {
"type" : "boolean",
"default" : true
},
"accountID" : {
"type" : "string",
"default" : ""
},
"accountCookie" : {
"type" : "string",
"default" : ""
},
"displayName" : {
"type" : "string",
"default" : ""
},
"hostname" : {
"type" : "string",
"default" : "beholder.vcmi.eu"

View File

@ -367,8 +367,9 @@ class IVCMIDirsUNIX : public IVCMIDirs
bool IVCMIDirsUNIX::developmentMode() const
{
// We want to be able to run VCMI from single directory. E.g to run from build output directory
const bool result = bfs::exists("AI") && bfs::exists("config") && bfs::exists("Mods") && bfs::exists("vcmiclient");
return result;
const bool hasConfigs = bfs::exists("config") && bfs::exists("Mods");
const bool hasBinaries = bfs::exists("vcmiclient") || bfs::exists("vcmiserver") || bfs::exists("vcmilobby");
return hasConfigs && hasBinaries;
}
bfs::path IVCMIDirsUNIX::clientPath() const { return binaryPath() / "vcmiclient"; }

View File

@ -293,6 +293,7 @@ void LobbyServer::onDisconnected(const NetworkConnectionPtr & connection, const
{
if(activeAccounts.count(connection))
{
logGlobal->info("Account %s disconnecting. Accounts online: %d", activeAccounts.at(connection), activeAccounts.size() - 1);
database->setAccountOnline(activeAccounts.at(connection), false);
activeAccounts.erase(connection);
}
@ -300,6 +301,7 @@ void LobbyServer::onDisconnected(const NetworkConnectionPtr & connection, const
if(activeGameRooms.count(connection))
{
std::string gameRoomID = activeGameRooms.at(connection);
logGlobal->info("Game room %s disconnecting. Rooms online: %d", gameRoomID, activeGameRooms.size() - 1);
if (database->getGameRoomStatus(gameRoomID) == LobbyRoomState::BUSY)
{