1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +02:00

Implemented room description display (map/template name)

This commit is contained in:
Ivan Savenko
2024-03-11 19:47:35 +02:00
parent 69236b73ca
commit 715e094f5c
10 changed files with 73 additions and 11 deletions

View File

@ -47,8 +47,7 @@ void GlobalLobbyProcessor::onDisconnected(const std::shared_ptr<INetworkConnecti
message["type"].String() = "leaveGameRoom";
message["accountID"].String() = proxy.first;
assert(JsonUtils::validate(message, "vcmi:lobbyProtocol/" + message["type"].String(), message["type"].String() + " pack"));
controlConnection->sendPacket(message.toBytes());
sendMessage(controlConnection, message);
break;
}
}
@ -127,8 +126,7 @@ void GlobalLobbyProcessor::onConnectionEstablished(const std::shared_ptr<INetwor
toSend["accountCookie"] = settings["lobby"]["accountCookie"];
toSend["version"].String() = VCMI_VERSION_STRING;
assert(JsonUtils::validate(toSend, "vcmi:lobbyProtocol/" + toSend["type"].String(), toSend["type"].String() + " pack"));
connection->sendPacket(toSend.toBytes());
sendMessage(connection, toSend);
}
else
{
@ -144,10 +142,24 @@ void GlobalLobbyProcessor::onConnectionEstablished(const std::shared_ptr<INetwor
toSend["guestAccountID"].String() = guestAccountID;
toSend["accountCookie"] = settings["lobby"]["accountCookie"];
assert(JsonUtils::validate(toSend, "vcmi:lobbyProtocol/" + toSend["type"].String(), toSend["type"].String() + " pack"));
connection->sendPacket(toSend.toBytes());
sendMessage(connection, toSend);
proxyConnections[guestAccountID] = connection;
owner.onNewConnection(connection);
}
}
void GlobalLobbyProcessor::sendChangeRoomDescription(const std::string & description)
{
JsonNode toSend;
toSend["type"].String() = "changeRoomDescription";
toSend["description"].String() = description;
sendMessage(controlConnection, toSend);
}
void GlobalLobbyProcessor::sendMessage(const NetworkConnectionPtr & targetConnection, const JsonNode & toSend)
{
assert(JsonUtils::validate(toSend, "vcmi:lobbyProtocol/" + toSend["type"].String(), toSend["type"].String() + " pack"));
targetConnection->sendPacket(toSend.toBytes());
}