mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Fixed check for number of players in the room
This commit is contained in:
@ -272,13 +272,19 @@ void LobbyDatabase::prepareStatements()
|
|||||||
ORDER BY secondsElapsed ASC
|
ORDER BY secondsElapsed ASC
|
||||||
)");
|
)");
|
||||||
|
|
||||||
countRoomUsedSlotsStatement = database->prepare(R"(
|
getGameRoomPlayersStatement = database->prepare(R"(
|
||||||
SELECT a.accountID, a.displayName
|
SELECT a.accountID, a.displayName
|
||||||
FROM gameRoomPlayers grp
|
FROM gameRoomPlayers grp
|
||||||
LEFT JOIN accounts a ON a.accountID = grp.accountID
|
LEFT JOIN accounts a ON a.accountID = grp.accountID
|
||||||
WHERE roomID = ?
|
WHERE roomID = ?
|
||||||
)");
|
)");
|
||||||
|
|
||||||
|
countRoomUsedSlotsStatement = database->prepare(R"(
|
||||||
|
SELECT COUNT(grp.accountID)
|
||||||
|
FROM gameRoomPlayers grp
|
||||||
|
WHERE roomID = ?
|
||||||
|
)");
|
||||||
|
|
||||||
countRoomTotalSlotsStatement = database->prepare(R"(
|
countRoomTotalSlotsStatement = database->prepare(R"(
|
||||||
SELECT playerLimit
|
SELECT playerLimit
|
||||||
FROM gameRooms
|
FROM gameRooms
|
||||||
@ -566,14 +572,14 @@ std::vector<LobbyGameRoom> LobbyDatabase::getActiveGameRooms()
|
|||||||
|
|
||||||
for (auto & room : result)
|
for (auto & room : result)
|
||||||
{
|
{
|
||||||
countRoomUsedSlotsStatement->setBinds(room.roomID);
|
getGameRoomPlayersStatement->setBinds(room.roomID);
|
||||||
while(countRoomUsedSlotsStatement->execute())
|
while(getGameRoomPlayersStatement->execute())
|
||||||
{
|
{
|
||||||
LobbyAccount account;
|
LobbyAccount account;
|
||||||
countRoomUsedSlotsStatement->getColumns(account.accountID, account.displayName);
|
getGameRoomPlayersStatement->getColumns(account.accountID, account.displayName);
|
||||||
room.participants.push_back(account);
|
room.participants.push_back(account);
|
||||||
}
|
}
|
||||||
countRoomUsedSlotsStatement->reset();
|
getGameRoomPlayersStatement->reset();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -593,14 +599,14 @@ std::vector<LobbyGameRoom> LobbyDatabase::getAccountGameHistory(const std::strin
|
|||||||
|
|
||||||
for (auto & room : result)
|
for (auto & room : result)
|
||||||
{
|
{
|
||||||
countRoomUsedSlotsStatement->setBinds(room.roomID);
|
getGameRoomPlayersStatement->setBinds(room.roomID);
|
||||||
while(countRoomUsedSlotsStatement->execute())
|
while(getGameRoomPlayersStatement->execute())
|
||||||
{
|
{
|
||||||
LobbyAccount account;
|
LobbyAccount account;
|
||||||
countRoomUsedSlotsStatement->getColumns(account.accountID, account.displayName);
|
getGameRoomPlayersStatement->getColumns(account.accountID, account.displayName);
|
||||||
room.participants.push_back(account);
|
room.participants.push_back(account);
|
||||||
}
|
}
|
||||||
countRoomUsedSlotsStatement->reset();
|
getGameRoomPlayersStatement->reset();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ class LobbyDatabase
|
|||||||
SQLiteStatementPtr getAccountInviteStatusStatement;
|
SQLiteStatementPtr getAccountInviteStatusStatement;
|
||||||
SQLiteStatementPtr getAccountGameRoomStatement;
|
SQLiteStatementPtr getAccountGameRoomStatement;
|
||||||
SQLiteStatementPtr getAccountDisplayNameStatement;
|
SQLiteStatementPtr getAccountDisplayNameStatement;
|
||||||
|
SQLiteStatementPtr getGameRoomPlayersStatement;
|
||||||
SQLiteStatementPtr countRoomUsedSlotsStatement;
|
SQLiteStatementPtr countRoomUsedSlotsStatement;
|
||||||
SQLiteStatementPtr countRoomTotalSlotsStatement;
|
SQLiteStatementPtr countRoomTotalSlotsStatement;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user