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

Merge pull request #3699 from IvanSavenko/lobby_tweaks

Minor tweaks for most noticeable issues with new lobby
This commit is contained in:
Ivan Savenko 2024-03-30 00:13:14 +02:00 committed by GitHub
commit acd2352653
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 132 additions and 39 deletions

View File

@ -3,7 +3,7 @@
sudo apt-get update sudo apt-get update
# Dependencies # Dependencies
sudo apt-get install libboost-all-dev \ sudo apt-get install libboost-dev libboost-filesystem-dev libboost-system-dev libboost-thread-dev libboost-program-options-dev libboost-locale-dev \
libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev \ libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev \
qt6-base-dev qt6-base-dev-tools qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools \ qt6-base-dev qt6-base-dev-tools qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools \
ninja-build zlib1g-dev libavformat-dev libswscale-dev libtbb-dev libluajit-5.1-dev \ ninja-build zlib1g-dev libavformat-dev libswscale-dev libtbb-dev libluajit-5.1-dev \

View File

@ -3,7 +3,7 @@
sudo apt-get update sudo apt-get update
# Dependencies # Dependencies
sudo apt-get install libboost-all-dev \ sudo apt-get install libboost-dev libboost-filesystem-dev libboost-system-dev libboost-thread-dev libboost-program-options-dev libboost-locale-dev \
libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev \ libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev \
qtbase5-dev \ qtbase5-dev \
ninja-build zlib1g-dev libavformat-dev libswscale-dev libtbb-dev libluajit-5.1-dev \ ninja-build zlib1g-dev libavformat-dev libswscale-dev libtbb-dev libluajit-5.1-dev \

View File

@ -79,6 +79,7 @@
"vcmi.lobby.login.error" : "Connection error: %s", "vcmi.lobby.login.error" : "Connection error: %s",
"vcmi.lobby.login.create" : "New Account", "vcmi.lobby.login.create" : "New Account",
"vcmi.lobby.login.login" : "Login", "vcmi.lobby.login.login" : "Login",
"vcmi.lobby.login.as" : "Login as %s",
"vcmi.lobby.header.rooms" : "Game Rooms - %d", "vcmi.lobby.header.rooms" : "Game Rooms - %d",
"vcmi.lobby.header.channels" : "Chat Channels", "vcmi.lobby.header.channels" : "Chat Channels",
"vcmi.lobby.header.chat.global" : "Global Game Chat - %s", // %s -> language name "vcmi.lobby.header.chat.global" : "Global Game Chat - %s", // %s -> language name

View File

@ -78,6 +78,7 @@
"vcmi.lobby.login.error" : "Помилка з'єднання: %s", "vcmi.lobby.login.error" : "Помилка з'єднання: %s",
"vcmi.lobby.login.create" : "Створити акаунт", "vcmi.lobby.login.create" : "Створити акаунт",
"vcmi.lobby.login.login" : "Увійти", "vcmi.lobby.login.login" : "Увійти",
"vcmi.lobby.login.as" : "Увійти як %s",
"vcmi.lobby.header.rooms" : "Активні кімнати - %d", "vcmi.lobby.header.rooms" : "Активні кімнати - %d",
"vcmi.lobby.header.channels" : "Канали чату", "vcmi.lobby.header.channels" : "Канали чату",
"vcmi.lobby.header.chat.global" : "Глобальний ігровий чат - %s", // %s -> language name "vcmi.lobby.header.chat.global" : "Глобальний ігровий чат - %s", // %s -> language name

View File

@ -85,14 +85,9 @@ void GlobalLobbyClient::receiveAccountCreated(const JsonNode & json)
throw std::runtime_error("lobby connection finished without active login window!"); throw std::runtime_error("lobby connection finished without active login window!");
{ {
Settings configID = settings.write["lobby"]["accountID"]; setAccountID(json["accountID"].String());
configID->String() = json["accountID"].String(); setAccountDisplayName(json["displayName"].String());
setAccountCookie(json["accountCookie"].String());
Settings configName = settings.write["lobby"]["displayName"];
configName->String() = json["displayName"].String();
Settings configCookie = settings.write["lobby"]["accountCookie"];
configCookie->String() = json["accountCookie"].String();
} }
sendClientLogin(); sendClientLogin();
@ -105,17 +100,15 @@ void GlobalLobbyClient::receiveOperationFailed(const JsonNode & json)
if(loginWindowPtr) if(loginWindowPtr)
loginWindowPtr->onConnectionFailed(json["reason"].String()); loginWindowPtr->onConnectionFailed(json["reason"].String());
logGlobal->warn("Operation failed! Reason: %s", json["reason"].String());
// TODO: handle errors in lobby menu // TODO: handle errors in lobby menu
} }
void GlobalLobbyClient::receiveClientLoginSuccess(const JsonNode & json) void GlobalLobbyClient::receiveClientLoginSuccess(const JsonNode & json)
{ {
{ {
Settings configCookie = settings.write["lobby"]["accountCookie"]; setAccountDisplayName(json["displayName"].String());
configCookie->String() = json["accountCookie"].String(); setAccountCookie(json["accountCookie"].String());
Settings configName = settings.write["lobby"]["displayName"];
configName->String() = json["displayName"].String();
} }
auto loginWindowPtr = loginWindow.lock(); auto loginWindowPtr = loginWindow.lock();
@ -288,8 +281,8 @@ void GlobalLobbyClient::receiveJoinRoomSuccess(const JsonNode & json)
CSH->resetStateForLobby(EStartMode::NEW_GAME, ESelectionScreen::newGame, EServerMode::LOBBY_GUEST, {}); CSH->resetStateForLobby(EStartMode::NEW_GAME, ESelectionScreen::newGame, EServerMode::LOBBY_GUEST, {});
CSH->loadMode = ELoadMode::MULTI; CSH->loadMode = ELoadMode::MULTI;
std::string hostname = settings["lobby"]["hostname"].String(); std::string hostname = getServerHost();
uint16_t port = settings["lobby"]["port"].Integer(); uint16_t port = getServerPort();
CSH->connectToServer(hostname, port); CSH->connectToServer(hostname, port);
} }
@ -324,8 +317,8 @@ void GlobalLobbyClient::sendClientLogin()
{ {
JsonNode toSend; JsonNode toSend;
toSend["type"].String() = "clientLogin"; toSend["type"].String() = "clientLogin";
toSend["accountID"] = settings["lobby"]["accountID"]; toSend["accountID"].String() = getAccountID();
toSend["accountCookie"] = settings["lobby"]["accountCookie"]; toSend["accountCookie"].String() = getAccountCookie();
toSend["language"].String() = CGI->generaltexth->getPreferredLanguage(); toSend["language"].String() = CGI->generaltexth->getPreferredLanguage();
toSend["version"].String() = VCMI_VERSION_STRING; toSend["version"].String() = VCMI_VERSION_STRING;
sendMessage(toSend); sendMessage(toSend);
@ -370,7 +363,7 @@ void GlobalLobbyClient::sendOpenRoom(const std::string & mode, int playerLimit)
{ {
JsonNode toSend; JsonNode toSend;
toSend["type"].String() = "activateGameRoom"; toSend["type"].String() = "activateGameRoom";
toSend["hostAccountID"] = settings["lobby"]["accountID"]; toSend["hostAccountID"].String() = getAccountID();
toSend["roomType"].String() = mode; toSend["roomType"].String() = mode;
toSend["playerLimit"].Integer() = playerLimit; toSend["playerLimit"].Integer() = playerLimit;
sendMessage(toSend); sendMessage(toSend);
@ -378,8 +371,8 @@ void GlobalLobbyClient::sendOpenRoom(const std::string & mode, int playerLimit)
void GlobalLobbyClient::connect() void GlobalLobbyClient::connect()
{ {
std::string hostname = settings["lobby"]["hostname"].String(); std::string hostname = getServerHost();
uint16_t port = settings["lobby"]["port"].Integer(); uint16_t port = getServerPort();
CSH->getNetworkHandler().connectToRemote(*this, hostname, port); CSH->getNetworkHandler().connectToRemote(*this, hostname, port);
} }
@ -479,12 +472,55 @@ void GlobalLobbyClient::activateRoomInviteInterface()
GH.windows().createAndPushWindow<GlobalLobbyInviteWindow>(); GH.windows().createAndPushWindow<GlobalLobbyInviteWindow>();
} }
void GlobalLobbyClient::setAccountID(const std::string & accountID)
{
Settings configID = persistentStorage.write["lobby"][getServerHost()]["accountID"];
configID->String() = accountID;
}
void GlobalLobbyClient::setAccountCookie(const std::string & accountCookie)
{
Settings configCookie = persistentStorage.write["lobby"][getServerHost()]["accountCookie"];
configCookie->String() = accountCookie;
}
void GlobalLobbyClient::setAccountDisplayName(const std::string & accountDisplayName)
{
Settings configName = persistentStorage.write["lobby"][getServerHost()]["displayName"];
configName->String() = accountDisplayName;
}
const std::string & GlobalLobbyClient::getAccountID() const
{
return persistentStorage["lobby"][getServerHost()]["accountID"].String();
}
const std::string & GlobalLobbyClient::getAccountCookie() const
{
return persistentStorage["lobby"][getServerHost()]["accountCookie"].String();
}
const std::string & GlobalLobbyClient::getAccountDisplayName() const
{
return persistentStorage["lobby"][getServerHost()]["displayName"].String();
}
const std::string & GlobalLobbyClient::getServerHost() const
{
return settings["lobby"]["hostname"].String();
}
uint16_t GlobalLobbyClient::getServerPort() const
{
return settings["lobby"]["port"].Integer();
}
void GlobalLobbyClient::sendProxyConnectionLogin(const NetworkConnectionPtr & netConnection) void GlobalLobbyClient::sendProxyConnectionLogin(const NetworkConnectionPtr & netConnection)
{ {
JsonNode toSend; JsonNode toSend;
toSend["type"].String() = "clientProxyLogin"; toSend["type"].String() = "clientProxyLogin";
toSend["accountID"] = settings["lobby"]["accountID"]; toSend["accountID"].String() = getAccountID();
toSend["accountCookie"] = settings["lobby"]["accountCookie"]; toSend["accountCookie"].String() = getAccountCookie();
toSend["gameRoomID"].String() = currentGameRoomUUID; toSend["gameRoomID"].String() = currentGameRoomUUID;
assert(JsonUtils::validate(toSend, "vcmi:lobbyProtocol/" + toSend["type"].String(), toSend["type"].String() + " pack")); assert(JsonUtils::validate(toSend, "vcmi:lobbyProtocol/" + toSend["type"].String(), toSend["type"].String() + " pack"));
@ -510,6 +546,8 @@ void GlobalLobbyClient::sendMatchChatMessage(const std::string & messageText)
toSend["channelName"].String() = currentGameRoomUUID; toSend["channelName"].String() = currentGameRoomUUID;
toSend["messageText"].String() = messageText; toSend["messageText"].String() = messageText;
assert(TextOperations::isValidUnicodeString(messageText));
CSH->getGlobalLobby().sendMessage(toSend); CSH->getGlobalLobby().sendMessage(toSend);
} }

View File

@ -58,6 +58,10 @@ class GlobalLobbyClient final : public INetworkClientListener, boost::noncopyabl
std::shared_ptr<GlobalLobbyLoginWindow> createLoginWindow(); std::shared_ptr<GlobalLobbyLoginWindow> createLoginWindow();
std::shared_ptr<GlobalLobbyWindow> createLobbyWindow(); std::shared_ptr<GlobalLobbyWindow> createLobbyWindow();
void setAccountID(const std::string & accountID);
void setAccountCookie(const std::string & accountCookie);
void setAccountDisplayName(const std::string & accountDisplayName);
public: public:
explicit GlobalLobbyClient(); explicit GlobalLobbyClient();
~GlobalLobbyClient(); ~GlobalLobbyClient();
@ -68,6 +72,12 @@ public:
const std::vector<GlobalLobbyRoom> & getMatchesHistory() const; const std::vector<GlobalLobbyRoom> & getMatchesHistory() const;
const std::vector<GlobalLobbyChannelMessage> & getChannelHistory(const std::string & channelType, const std::string & channelName) const; const std::vector<GlobalLobbyChannelMessage> & getChannelHistory(const std::string & channelType, const std::string & channelName) const;
const std::string & getAccountID() const;
const std::string & getAccountCookie() const;
const std::string & getAccountDisplayName() const;
const std::string & getServerHost() const;
uint16_t getServerPort() const;
/// Activate interface and pushes lobby UI as top window /// Activate interface and pushes lobby UI as top window
void activateInterface(); void activateInterface();
void activateRoomInviteInterface(); void activateRoomInviteInterface();

View File

@ -36,9 +36,14 @@ GlobalLobbyLoginWindow::GlobalLobbyLoginWindow()
pos.w = 284; pos.w = 284;
pos.h = 220; pos.h = 220;
MetaString loginAs;
loginAs.appendTextID("vcmi.lobby.login.as");
loginAs.replaceTextID(CSH->getGlobalLobby().getAccountDisplayName());
filledBackground = std::make_shared<FilledTexturePlayerColored>(ImagePath::builtin("DiBoxBck"), Rect(0, 0, pos.w, pos.h)); filledBackground = std::make_shared<FilledTexturePlayerColored>(ImagePath::builtin("DiBoxBck"), Rect(0, 0, pos.w, pos.h));
labelTitle = std::make_shared<CLabel>( pos.w / 2, 20, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->translate("vcmi.lobby.login.title")); labelTitle = std::make_shared<CLabel>( pos.w / 2, 20, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->translate("vcmi.lobby.login.title"));
labelUsername = std::make_shared<CLabel>( 10, 65, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->translate("vcmi.lobby.login.username")); labelUsernameTitle = std::make_shared<CLabel>( 10, 65, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->translate("vcmi.lobby.login.username"));
labelUsername = std::make_shared<CLabel>( 10, 65, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, loginAs.toString());
backgroundUsername = std::make_shared<TransparentFilledRectangle>(Rect(10, 90, 264, 20), ColorRGBA(0,0,0,128), ColorRGBA(64,64,64,64)); backgroundUsername = std::make_shared<TransparentFilledRectangle>(Rect(10, 90, 264, 20), ColorRGBA(0,0,0,128), ColorRGBA(64,64,64,64));
inputUsername = std::make_shared<CTextInput>(Rect(15, 93, 260, 16), FONT_SMALL, nullptr, ETextAlignment::TOPLEFT, true); inputUsername = std::make_shared<CTextInput>(Rect(15, 93, 260, 16), FONT_SMALL, nullptr, ETextAlignment::TOPLEFT, true);
buttonLogin = std::make_shared<CButton>(Point(10, 180), AnimationPath::builtin("MuBchck"), CButton::tooltip(), [this](){ onLogin(); }); buttonLogin = std::make_shared<CButton>(Point(10, 180), AnimationPath::builtin("MuBchck"), CButton::tooltip(), [this](){ onLogin(); });
@ -56,7 +61,7 @@ GlobalLobbyLoginWindow::GlobalLobbyLoginWindow()
toggleMode->setSelected(settings["lobby"]["roomType"].Integer()); toggleMode->setSelected(settings["lobby"]["roomType"].Integer());
toggleMode->addCallback([this](int index){onLoginModeChanged(index);}); toggleMode->addCallback([this](int index){onLoginModeChanged(index);});
if (settings["lobby"]["accountID"].String().empty()) if (CSH->getGlobalLobby().getAccountID().empty())
{ {
buttonLogin->block(true); buttonLogin->block(true);
toggleMode->setSelected(0); toggleMode->setSelected(0);
@ -77,12 +82,19 @@ void GlobalLobbyLoginWindow::onLoginModeChanged(int value)
{ {
if (value == 0) if (value == 0)
{ {
inputUsername->setText(""); inputUsername->enable();
backgroundUsername->enable();
labelUsernameTitle->enable();
labelUsername->disable();
} }
else else
{ {
inputUsername->setText(settings["lobby"]["displayName"].String()); inputUsername->disable();
backgroundUsername->disable();
labelUsernameTitle->disable();
labelUsername->enable();
} }
redraw();
} }
void GlobalLobbyLoginWindow::onClose() void GlobalLobbyLoginWindow::onClose()
@ -104,7 +116,7 @@ void GlobalLobbyLoginWindow::onLogin()
void GlobalLobbyLoginWindow::onConnectionSuccess() void GlobalLobbyLoginWindow::onConnectionSuccess()
{ {
std::string accountID = settings["lobby"]["accountID"].String(); std::string accountID = CSH->getGlobalLobby().getAccountID();
if(toggleMode->getSelected() == 0) if(toggleMode->getSelected() == 0)
CSH->getGlobalLobby().sendClientRegister(inputUsername->getText()); CSH->getGlobalLobby().sendClientRegister(inputUsername->getText());

View File

@ -23,6 +23,7 @@ class GlobalLobbyLoginWindow : public CWindowObject
{ {
std::shared_ptr<FilledTexturePlayerColored> filledBackground; std::shared_ptr<FilledTexturePlayerColored> filledBackground;
std::shared_ptr<CLabel> labelTitle; std::shared_ptr<CLabel> labelTitle;
std::shared_ptr<CLabel> labelUsernameTitle;
std::shared_ptr<CLabel> labelUsername; std::shared_ptr<CLabel> labelUsername;
std::shared_ptr<CTextBox> labelStatus; std::shared_ptr<CTextBox> labelStatus;
std::shared_ptr<TransparentFilledRectangle> backgroundUsername; std::shared_ptr<TransparentFilledRectangle> backgroundUsername;

View File

@ -272,7 +272,7 @@ GlobalLobbyMatchCard::GlobalLobbyMatchCard(GlobalLobbyWindow * window, const Glo
if (matchDescription.participants.size() == 2) if (matchDescription.participants.size() == 2)
{ {
std::string ourAccountID = settings["lobby"]["accountID"].String(); std::string ourAccountID = CSH->getGlobalLobby().getAccountID();
opponentDescription.appendTextID("vcmi.lobby.match.duel"); opponentDescription.appendTextID("vcmi.lobby.match.duel");
// Find display name of our one and only opponent in this game // Find display name of our one and only opponent in this game

View File

@ -24,6 +24,7 @@
#include "../../lib/CConfigHandler.h" #include "../../lib/CConfigHandler.h"
#include "../../lib/Languages.h" #include "../../lib/Languages.h"
#include "../../lib/MetaString.h" #include "../../lib/MetaString.h"
#include "../../lib/TextOperations.h"
GlobalLobbyWindow::GlobalLobbyWindow() GlobalLobbyWindow::GlobalLobbyWindow()
: CWindowObject(BORDERED) : CWindowObject(BORDERED)
@ -33,7 +34,7 @@ GlobalLobbyWindow::GlobalLobbyWindow()
pos = widget->pos; pos = widget->pos;
center(); center();
widget->getAccountNameLabel()->setText(settings["lobby"]["displayName"].String()); widget->getAccountNameLabel()->setText(CSH->getGlobalLobby().getAccountDisplayName());
doOpenChannel("global", "english", Languages::getLanguageOptions("english").nameNative); doOpenChannel("global", "english", Languages::getLanguageOptions("english").nameNative);
widget->getChannelListHeader()->setText(MetaString::createFromTextID("vcmi.lobby.header.channels").toString()); widget->getChannelListHeader()->setText(MetaString::createFromTextID("vcmi.lobby.header.channels").toString());
@ -54,7 +55,7 @@ void GlobalLobbyWindow::doOpenChannel(const std::string & channelType, const std
auto history = CSH->getGlobalLobby().getChannelHistory(channelType, channelName); auto history = CSH->getGlobalLobby().getChannelHistory(channelType, channelName);
for (auto const & entry : history) for(const auto & entry : history)
onGameChatMessage(entry.displayName, entry.messageText, entry.timeFormatted, channelType, channelName); onGameChatMessage(entry.displayName, entry.messageText, entry.timeFormatted, channelType, channelName);
MetaString text; MetaString text;
@ -80,6 +81,8 @@ void GlobalLobbyWindow::doSendChatMessage()
toSend["channelName"].String() = currentChannelName; toSend["channelName"].String() = currentChannelName;
toSend["messageText"].String() = messageText; toSend["messageText"].String() = messageText;
assert(TextOperations::isValidUnicodeString(messageText));
CSH->getGlobalLobby().sendMessage(toSend); CSH->getGlobalLobby().sendMessage(toSend);
widget->getMessageInput()->setText(""); widget->getMessageInput()->setText("");

View File

@ -18,7 +18,6 @@ set(lib_SRCS
json/JsonNode.cpp json/JsonNode.cpp
json/JsonParser.cpp json/JsonParser.cpp
json/JsonRandom.cpp
json/JsonUtils.cpp json/JsonUtils.cpp
json/JsonValidator.cpp json/JsonValidator.cpp
json/JsonWriter.cpp json/JsonWriter.cpp
@ -89,6 +88,7 @@ set(lib_MAIN_SRCS
events/TurnStarted.cpp events/TurnStarted.cpp
json/JsonBonus.cpp json/JsonBonus.cpp
json/JsonRandom.cpp
gameState/CGameState.cpp gameState/CGameState.cpp
gameState/CGameStateCampaign.cpp gameState/CGameStateCampaign.cpp
@ -315,11 +315,9 @@ set(lib_HEADERS
filesystem/MinizipExtensions.h filesystem/MinizipExtensions.h
filesystem/ResourcePath.h filesystem/ResourcePath.h
json/JsonBonus.h
json/JsonFormatException.h json/JsonFormatException.h
json/JsonNode.h json/JsonNode.h
json/JsonParser.h json/JsonParser.h
json/JsonRandom.h
json/JsonUtils.h json/JsonUtils.h
json/JsonValidator.h json/JsonValidator.h
json/JsonWriter.h json/JsonWriter.h
@ -441,6 +439,9 @@ set(lib_MAIN_HEADERS
events/PlayerGotTurn.h events/PlayerGotTurn.h
events/TurnStarted.h events/TurnStarted.h
json/JsonBonus.h
json/JsonRandom.h
gameState/CGameState.h gameState/CGameState.h
gameState/CGameStateCampaign.h gameState/CGameStateCampaign.h
gameState/EVictoryLossCheckResult.h gameState/EVictoryLossCheckResult.h

View File

@ -489,7 +489,7 @@ void LobbyServer::receiveSendChatMessage(const NetworkConnectionPtr & connection
std::string channelName = json["channelName"].String(); std::string channelName = json["channelName"].String();
std::string displayName = database->getAccountDisplayName(senderAccountID); std::string displayName = database->getAccountDisplayName(senderAccountID);
if(TextOperations::isValidUnicodeString(messageText)) if(!TextOperations::isValidUnicodeString(messageText))
return sendOperationFailed(connection, "String contains invalid characters!"); return sendOperationFailed(connection, "String contains invalid characters!");
std::string messageTextClean = sanitizeChatMessage(messageText); std::string messageTextClean = sanitizeChatMessage(messageText);
@ -595,6 +595,7 @@ void LobbyServer::receiveClientLogin(const NetworkConnectionPtr & connection, co
activeAccounts[connection] = accountID; activeAccounts[connection] = accountID;
logGlobal->info("%s: Logged in as %s", accountID, displayName);
sendClientLoginSuccess(connection, accountCookie, displayName); sendClientLoginSuccess(connection, accountCookie, displayName);
sendRecentChatHistory(connection, "global", "english"); sendRecentChatHistory(connection, "global", "english");
if (language != "english") if (language != "english")

View File

@ -122,8 +122,8 @@ void GlobalLobbyProcessor::onConnectionEstablished(const std::shared_ptr<INetwor
JsonNode toSend; JsonNode toSend;
toSend["type"].String() = "serverLogin"; toSend["type"].String() = "serverLogin";
toSend["gameRoomID"].String() = owner.uuid; toSend["gameRoomID"].String() = owner.uuid;
toSend["accountID"] = settings["lobby"]["accountID"]; toSend["accountID"].String() = getHostAccountID();
toSend["accountCookie"] = settings["lobby"]["accountCookie"]; toSend["accountCookie"].String() = getHostAccountCookie();
toSend["version"].String() = VCMI_VERSION_STRING; toSend["version"].String() = VCMI_VERSION_STRING;
sendMessage(connection, toSend); sendMessage(connection, toSend);
@ -140,7 +140,7 @@ void GlobalLobbyProcessor::onConnectionEstablished(const std::shared_ptr<INetwor
toSend["type"].String() = "serverProxyLogin"; toSend["type"].String() = "serverProxyLogin";
toSend["gameRoomID"].String() = owner.uuid; toSend["gameRoomID"].String() = owner.uuid;
toSend["guestAccountID"].String() = guestAccountID; toSend["guestAccountID"].String() = guestAccountID;
toSend["accountCookie"] = settings["lobby"]["accountCookie"]; toSend["accountCookie"].String() = getHostAccountCookie();
sendMessage(connection, toSend); sendMessage(connection, toSend);
@ -170,3 +170,24 @@ void GlobalLobbyProcessor::sendMessage(const NetworkConnectionPtr & targetConnec
assert(JsonUtils::validate(toSend, "vcmi:lobbyProtocol/" + toSend["type"].String(), toSend["type"].String() + " pack")); assert(JsonUtils::validate(toSend, "vcmi:lobbyProtocol/" + toSend["type"].String(), toSend["type"].String() + " pack"));
targetConnection->sendPacket(toSend.toBytes()); targetConnection->sendPacket(toSend.toBytes());
} }
//FIXME: consider whether these methods should be replaced with some other way to define our account ID / account cookie
static const std::string & getServerHost()
{
return settings["lobby"]["hostname"].String();
}
const std::string & GlobalLobbyProcessor::getHostAccountID() const
{
return persistentStorage["lobby"][getServerHost()]["accountID"].String();
}
const std::string & GlobalLobbyProcessor::getHostAccountCookie() const
{
return persistentStorage["lobby"][getServerHost()]["accountCookie"].String();
}
const std::string & GlobalLobbyProcessor::getHostAccountDisplayName() const
{
return persistentStorage["lobby"][getServerHost()]["displayName"].String();
}

View File

@ -35,6 +35,10 @@ class GlobalLobbyProcessor : public INetworkClientListener
void establishNewConnection(); void establishNewConnection();
void sendMessage(const NetworkConnectionPtr & targetConnection, const JsonNode & payload); void sendMessage(const NetworkConnectionPtr & targetConnection, const JsonNode & payload);
const std::string & getHostAccountID() const;
const std::string & getHostAccountCookie() const;
const std::string & getHostAccountDisplayName() const;
public: public:
void sendChangeRoomDescription(const std::string & description); void sendChangeRoomDescription(const std::string & description);
void sendGameStarted(); void sendGameStarted();