mirror of
https://github.com/vcmi/vcmi.git
synced 2026-06-19 22:57:37 +02:00
Set room status to "In Game" once gameplay starts
This commit is contained in:
@@ -196,7 +196,7 @@ void LobbyDatabase::prepareStatements()
|
||||
SELECT grp.roomID
|
||||
FROM gameRoomPlayers grp
|
||||
LEFT JOIN gameRooms gr ON gr.roomID = grp.roomID
|
||||
WHERE accountID = ? AND status IN (1, 2)
|
||||
WHERE accountID = ? AND status IN (1, 2, 3)
|
||||
LIMIT 1
|
||||
)";
|
||||
|
||||
@@ -210,7 +210,7 @@ void LobbyDatabase::prepareStatements()
|
||||
SELECT roomID, hostAccountID, displayName, description, status, playerLimit
|
||||
FROM gameRooms
|
||||
LEFT JOIN accounts ON hostAccountID = accountID
|
||||
WHERE status IN (1, 2)
|
||||
WHERE status IN (1, 2, 3)
|
||||
)";
|
||||
|
||||
static const std::string countRoomUsedSlotsText = R"(
|
||||
@@ -248,14 +248,14 @@ void LobbyDatabase::prepareStatements()
|
||||
SELECT COUNT(accountID)
|
||||
FROM gameRoomPlayers grp
|
||||
LEFT JOIN gameRooms gr ON gr.roomID = grp.roomID
|
||||
WHERE accountID = ? AND grp.roomID = ? AND status IN (1, 2)
|
||||
WHERE accountID = ? AND grp.roomID = ? AND status IN (1, 2, 3)
|
||||
)";
|
||||
|
||||
static const std::string isPlayerInAnyGameRoomText = R"(
|
||||
SELECT COUNT(accountID)
|
||||
FROM gameRoomPlayers grp
|
||||
LEFT JOIN gameRooms gr ON gr.roomID = grp.roomID
|
||||
WHERE accountID = ? AND status IN (1, 2)
|
||||
WHERE accountID = ? AND status IN (1, 2, 3)
|
||||
)";
|
||||
|
||||
static const std::string isAccountIDExistsText = R"(
|
||||
|
||||
@@ -60,6 +60,8 @@ NetworkConnectionPtr LobbyServer::findGameRoom(const std::string & gameRoomID) c
|
||||
|
||||
void LobbyServer::sendMessage(const NetworkConnectionPtr & target, const JsonNode & json)
|
||||
{
|
||||
logGlobal->info("Sending message of type %s", json["type"].String());
|
||||
|
||||
assert(JsonUtils::validate(json, "vcmi:lobbyProtocol/" + json["type"].String(), json["type"].String() + " pack"));
|
||||
target->sendPacket(json.toBytes());
|
||||
}
|
||||
@@ -342,6 +344,9 @@ void LobbyServer::onPacketReceived(const NetworkConnectionPtr & connection, cons
|
||||
if(messageType == "changeRoomDescription")
|
||||
return receiveChangeRoomDescription(connection, json);
|
||||
|
||||
if(messageType == "gameStarted")
|
||||
return receiveGameStarted(connection, json);
|
||||
|
||||
if(messageType == "leaveGameRoom")
|
||||
return receiveLeaveGameRoom(connection, json);
|
||||
|
||||
@@ -597,6 +602,14 @@ void LobbyServer::receiveChangeRoomDescription(const NetworkConnectionPtr & conn
|
||||
broadcastActiveGameRooms();
|
||||
}
|
||||
|
||||
void LobbyServer::receiveGameStarted(const NetworkConnectionPtr & connection, const JsonNode & json)
|
||||
{
|
||||
std::string gameRoomID = activeGameRooms[connection];
|
||||
|
||||
database->setGameRoomStatus(gameRoomID, LobbyRoomState::BUSY);
|
||||
broadcastActiveGameRooms();
|
||||
}
|
||||
|
||||
void LobbyServer::receiveLeaveGameRoom(const NetworkConnectionPtr & connection, const JsonNode & json)
|
||||
{
|
||||
std::string accountID = json["accountID"].String();
|
||||
|
||||
@@ -86,6 +86,7 @@ class LobbyServer final : public INetworkServerListener
|
||||
void receiveJoinGameRoom(const NetworkConnectionPtr & connection, const JsonNode & json);
|
||||
void receiveLeaveGameRoom(const NetworkConnectionPtr & connection, const JsonNode & json);
|
||||
void receiveChangeRoomDescription(const NetworkConnectionPtr & connection, const JsonNode & json);
|
||||
void receiveGameStarted(const NetworkConnectionPtr & connection, const JsonNode & json);
|
||||
void receiveSendInvite(const NetworkConnectionPtr & connection, const JsonNode & json);
|
||||
void receiveDeclineInvite(const NetworkConnectionPtr & connection, const JsonNode & json);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user