mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-15 01:24:45 +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
|
||||
)");
|
||||
|
||||
countRoomUsedSlotsStatement = database->prepare(R"(
|
||||
getGameRoomPlayersStatement = database->prepare(R"(
|
||||
SELECT a.accountID, a.displayName
|
||||
FROM gameRoomPlayers grp
|
||||
LEFT JOIN accounts a ON a.accountID = grp.accountID
|
||||
WHERE roomID = ?
|
||||
)");
|
||||
|
||||
countRoomUsedSlotsStatement = database->prepare(R"(
|
||||
SELECT COUNT(grp.accountID)
|
||||
FROM gameRoomPlayers grp
|
||||
WHERE roomID = ?
|
||||
)");
|
||||
|
||||
countRoomTotalSlotsStatement = database->prepare(R"(
|
||||
SELECT playerLimit
|
||||
FROM gameRooms
|
||||
@ -566,14 +572,14 @@ std::vector<LobbyGameRoom> LobbyDatabase::getActiveGameRooms()
|
||||
|
||||
for (auto & room : result)
|
||||
{
|
||||
countRoomUsedSlotsStatement->setBinds(room.roomID);
|
||||
while(countRoomUsedSlotsStatement->execute())
|
||||
getGameRoomPlayersStatement->setBinds(room.roomID);
|
||||
while(getGameRoomPlayersStatement->execute())
|
||||
{
|
||||
LobbyAccount account;
|
||||
countRoomUsedSlotsStatement->getColumns(account.accountID, account.displayName);
|
||||
getGameRoomPlayersStatement->getColumns(account.accountID, account.displayName);
|
||||
room.participants.push_back(account);
|
||||
}
|
||||
countRoomUsedSlotsStatement->reset();
|
||||
getGameRoomPlayersStatement->reset();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -593,14 +599,14 @@ std::vector<LobbyGameRoom> LobbyDatabase::getAccountGameHistory(const std::strin
|
||||
|
||||
for (auto & room : result)
|
||||
{
|
||||
countRoomUsedSlotsStatement->setBinds(room.roomID);
|
||||
while(countRoomUsedSlotsStatement->execute())
|
||||
getGameRoomPlayersStatement->setBinds(room.roomID);
|
||||
while(getGameRoomPlayersStatement->execute())
|
||||
{
|
||||
LobbyAccount account;
|
||||
countRoomUsedSlotsStatement->getColumns(account.accountID, account.displayName);
|
||||
getGameRoomPlayersStatement->getColumns(account.accountID, account.displayName);
|
||||
room.participants.push_back(account);
|
||||
}
|
||||
countRoomUsedSlotsStatement->reset();
|
||||
getGameRoomPlayersStatement->reset();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user