mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-13 11:40:38 +02:00
Send list of active invites as part of room description
This commit is contained in:
parent
e12db20314
commit
a4ea74fbbc
@ -220,6 +220,15 @@ void GlobalLobbyClient::receiveActiveGameRooms(const JsonNode & json)
|
|||||||
account.displayName = jsonParticipant["displayName"].String();
|
account.displayName = jsonParticipant["displayName"].String();
|
||||||
room.participants.push_back(account);
|
room.participants.push_back(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(const auto & jsonParticipant : jsonEntry["invited"].Vector())
|
||||||
|
{
|
||||||
|
GlobalLobbyAccount account;
|
||||||
|
account.accountID = jsonParticipant["accountID"].String();
|
||||||
|
account.displayName = jsonParticipant["displayName"].String();
|
||||||
|
room.invited.push_back(account);
|
||||||
|
}
|
||||||
|
|
||||||
room.playerLimit = jsonEntry["playerLimit"].Integer();
|
room.playerLimit = jsonEntry["playerLimit"].Integer();
|
||||||
|
|
||||||
activeRooms.push_back(room);
|
activeRooms.push_back(room);
|
||||||
|
@ -29,6 +29,7 @@ struct GlobalLobbyRoom
|
|||||||
std::string startDateFormatted;
|
std::string startDateFormatted;
|
||||||
ModCompatibilityInfo modList;
|
ModCompatibilityInfo modList;
|
||||||
std::vector<GlobalLobbyAccount> participants;
|
std::vector<GlobalLobbyAccount> participants;
|
||||||
|
std::vector<GlobalLobbyAccount> invited;
|
||||||
int playerLimit;
|
int playerLimit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -65,6 +65,29 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"invited" :
|
||||||
|
{
|
||||||
|
"type" : "array",
|
||||||
|
"description" : "List of accounts that were invited to this room",
|
||||||
|
"items" :
|
||||||
|
{
|
||||||
|
"type" : "object",
|
||||||
|
"additionalProperties" : false,
|
||||||
|
"required" : [ "accountID", "displayName" ],
|
||||||
|
"properties" : {
|
||||||
|
"accountID" :
|
||||||
|
{
|
||||||
|
"type" : "string",
|
||||||
|
"description" : "Unique ID of an account"
|
||||||
|
},
|
||||||
|
"displayName" :
|
||||||
|
{
|
||||||
|
"type" : "string",
|
||||||
|
"description" : "Display name of an account"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"mods" :
|
"mods" :
|
||||||
{
|
{
|
||||||
"type" : "array",
|
"type" : "array",
|
||||||
|
@ -272,6 +272,13 @@ void LobbyDatabase::prepareStatements()
|
|||||||
ORDER BY secondsElapsed ASC
|
ORDER BY secondsElapsed ASC
|
||||||
)");
|
)");
|
||||||
|
|
||||||
|
getGameRoomInvitesStatement = database->prepare(R"(
|
||||||
|
SELECT a.accountID, a.displayName
|
||||||
|
FROM gameRoomInvites gri
|
||||||
|
LEFT JOIN accounts a ON a.accountID = gri.accountID
|
||||||
|
WHERE roomID = ?
|
||||||
|
)");
|
||||||
|
|
||||||
getGameRoomPlayersStatement = database->prepare(R"(
|
getGameRoomPlayersStatement = database->prepare(R"(
|
||||||
SELECT a.accountID, a.displayName
|
SELECT a.accountID, a.displayName
|
||||||
FROM gameRoomPlayers grp
|
FROM gameRoomPlayers grp
|
||||||
@ -581,6 +588,19 @@ std::vector<LobbyGameRoom> LobbyDatabase::getActiveGameRooms()
|
|||||||
}
|
}
|
||||||
getGameRoomPlayersStatement->reset();
|
getGameRoomPlayersStatement->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto & room : result)
|
||||||
|
{
|
||||||
|
getGameRoomInvitesStatement->setBinds(room.roomID);
|
||||||
|
while(getGameRoomInvitesStatement->execute())
|
||||||
|
{
|
||||||
|
LobbyAccount account;
|
||||||
|
getGameRoomInvitesStatement->getColumns(account.accountID, account.displayName);
|
||||||
|
room.invited.push_back(account);
|
||||||
|
}
|
||||||
|
getGameRoomInvitesStatement->reset();
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ class LobbyDatabase
|
|||||||
SQLiteStatementPtr getAccountGameRoomStatement;
|
SQLiteStatementPtr getAccountGameRoomStatement;
|
||||||
SQLiteStatementPtr getAccountDisplayNameStatement;
|
SQLiteStatementPtr getAccountDisplayNameStatement;
|
||||||
SQLiteStatementPtr getGameRoomPlayersStatement;
|
SQLiteStatementPtr getGameRoomPlayersStatement;
|
||||||
|
SQLiteStatementPtr getGameRoomInvitesStatement;
|
||||||
SQLiteStatementPtr countRoomUsedSlotsStatement;
|
SQLiteStatementPtr countRoomUsedSlotsStatement;
|
||||||
SQLiteStatementPtr countRoomTotalSlotsStatement;
|
SQLiteStatementPtr countRoomTotalSlotsStatement;
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ struct LobbyGameRoom
|
|||||||
std::string version;
|
std::string version;
|
||||||
std::string modsJson;
|
std::string modsJson;
|
||||||
std::vector<LobbyAccount> participants;
|
std::vector<LobbyAccount> participants;
|
||||||
|
std::vector<LobbyAccount> invited;
|
||||||
LobbyRoomState roomState;
|
LobbyRoomState roomState;
|
||||||
uint32_t playerLimit;
|
uint32_t playerLimit;
|
||||||
std::chrono::seconds age;
|
std::chrono::seconds age;
|
||||||
|
@ -218,6 +218,9 @@ static JsonNode loadLobbyGameRoomToJson(const LobbyGameRoom & gameRoom)
|
|||||||
for(const auto & account : gameRoom.participants)
|
for(const auto & account : gameRoom.participants)
|
||||||
jsonEntry["participants"].Vector().push_back(loadLobbyAccountToJson(account));
|
jsonEntry["participants"].Vector().push_back(loadLobbyAccountToJson(account));
|
||||||
|
|
||||||
|
for(const auto & account : gameRoom.invited)
|
||||||
|
jsonEntry["invited"].Vector().push_back(loadLobbyAccountToJson(account));
|
||||||
|
|
||||||
return jsonEntry;
|
return jsonEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user