1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-05 00:49:09 +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

@ -29,6 +29,7 @@ void LobbyDatabase::createTables()
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
roomID TEXT,
hostAccountID TEXT,
description TEXT NOT NULL DEFAULT '',
status INTEGER NOT NULL DEFAULT 0,
playerLimit INTEGER NOT NULL,
creationTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
@ -155,6 +156,12 @@ void LobbyDatabase::prepareStatements()
WHERE accountID = ?
)";
static const std::string updateRoomDescriptionText = R"(
UPDATE gameRooms
SET description = ?
WHERE roomID = ?
)";
// SELECT FROM
static const std::string getRecentMessageHistoryText = R"(
@ -194,7 +201,7 @@ void LobbyDatabase::prepareStatements()
)";
static const std::string getActiveGameRoomsText = R"(
SELECT roomID, hostAccountID, displayName, status, playerLimit
SELECT roomID, hostAccountID, displayName, description, status, playerLimit
FROM gameRooms
LEFT JOIN accounts ON hostAccountID = accountID
WHERE status = 1
@ -270,6 +277,7 @@ void LobbyDatabase::prepareStatements()
setAccountOnlineStatement = database->prepare(setAccountOnlineText);
setGameRoomStatusStatement = database->prepare(setGameRoomStatusText);
updateAccountLoginTimeStatement = database->prepare(updateAccountLoginTimeText);
updateRoomDescriptionStatement = database->prepare(updateRoomDescriptionText);
getRecentMessageHistoryStatement = database->prepare(getRecentMessageHistoryText);
getIdleGameRoomStatement = database->prepare(getIdleGameRoomText);
@ -392,6 +400,11 @@ void LobbyDatabase::updateAccountLoginTime(const std::string & accountID)
updateAccountLoginTimeStatement->executeOnce(accountID);
}
void LobbyDatabase::updateRoomDescription(const std::string & gameRoomID, const std::string & description)
{
updateRoomDescriptionStatement->executeOnce(description, gameRoomID);
}
std::string LobbyDatabase::getAccountDisplayName(const std::string & accountID)
{
std::string result;
@ -486,7 +499,7 @@ std::vector<LobbyGameRoom> LobbyDatabase::getActiveGameRooms()
while(getActiveGameRoomsStatement->execute())
{
LobbyGameRoom entry;
getActiveGameRoomsStatement->getColumns(entry.roomID, entry.hostAccountID, entry.hostAccountDisplayName, entry.roomStatus, entry.playersLimit);
getActiveGameRoomsStatement->getColumns(entry.roomID, entry.hostAccountID, entry.hostAccountDisplayName, entry.description, entry.roomStatus, entry.playersLimit);
result.push_back(entry);
}
getActiveGameRoomsStatement->reset();