mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Add custom server-side pawn colors (#5543)
This commit is contained in:
parent
0fc05e15cd
commit
95cea0f191
23 changed files with 1748 additions and 49 deletions
8
servatrice/migrations/servatrice_0033_to_0034.sql
Normal file
8
servatrice/migrations/servatrice_0033_to_0034.sql
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
-- Servatrice db migration from version 33 to version 34
|
||||
|
||||
ALTER TABLE cockatrice_users ADD COLUMN leftPawnColorOverride varchar(255);
|
||||
ALTER TABLE cockatrice_users ADD COLUMN rightPawnColorOverride varchar(255);
|
||||
|
||||
ALTER TABLE cockatrice_users ADD INDEX `idx_pawnColorOverrides` (`leftPawnColorOverride`, `rightPawnColorOverride`);
|
||||
|
||||
UPDATE cockatrice_schema_version SET version=34 WHERE version=33;
|
||||
|
|
@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `cockatrice_schema_version` (
|
|||
PRIMARY KEY (`version`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
INSERT INTO cockatrice_schema_version VALUES(33);
|
||||
INSERT INTO cockatrice_schema_version VALUES(34);
|
||||
|
||||
-- users and user data tables
|
||||
CREATE TABLE IF NOT EXISTS `cockatrice_users` (
|
||||
|
|
@ -41,6 +41,8 @@ CREATE TABLE IF NOT EXISTS `cockatrice_users` (
|
|||
`privlevelStartDate` datetime NOT NULL,
|
||||
`privlevelEndDate` datetime NOT NULL,
|
||||
`passwordLastChangedDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`leftPawnColorOverride` varchar(255),
|
||||
`rightPawnColorOverride` varchar(255),
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name` (`name`),
|
||||
KEY `token` (`token`),
|
||||
|
|
@ -48,7 +50,8 @@ CREATE TABLE IF NOT EXISTS `cockatrice_users` (
|
|||
INDEX `idx_admin` (`admin`),
|
||||
INDEX `idx_active` (`active`),
|
||||
INDEX `idx_privlevel` (`privlevel`),
|
||||
INDEX `idx_clientid` (`clientid`)
|
||||
INDEX `idx_clientid` (`clientid`),
|
||||
INDEX `idx_pawnColorOverrides` (`leftPawnColorOverride`, `rightPawnColorOverride`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `cockatrice_decklist_files` (
|
||||
|
|
|
|||
|
|
@ -615,27 +615,36 @@ ServerInfo_User Servatrice_DatabaseInterface::evalUserQueryResult(const QSqlQuer
|
|||
if (!privlevel.isEmpty())
|
||||
result.set_privlevel(privlevel.toStdString());
|
||||
|
||||
const auto &pawn_left_override = query->value(5).toString();
|
||||
const auto &pawn_right_override = query->value(6).toString();
|
||||
if (!pawn_left_override.isEmpty()) {
|
||||
result.mutable_pawn_colors()->set_left_side(pawn_left_override.toStdString());
|
||||
}
|
||||
if (!pawn_right_override.isEmpty()) {
|
||||
result.mutable_pawn_colors()->set_right_side(pawn_right_override.toStdString());
|
||||
}
|
||||
|
||||
if (complete) {
|
||||
const QString realName = query->value(5).toString();
|
||||
const QString realName = query->value(7).toString();
|
||||
if (!realName.isEmpty())
|
||||
result.set_real_name(realName.toStdString());
|
||||
|
||||
const QByteArray avatarBmp = query->value(6).toByteArray();
|
||||
const QByteArray avatarBmp = query->value(8).toByteArray();
|
||||
if (avatarBmp.size())
|
||||
result.set_avatar_bmp(avatarBmp.data(), avatarBmp.size());
|
||||
|
||||
const QDateTime regDate = query->value(7).toDateTime();
|
||||
const QDateTime regDate = query->value(9).toDateTime();
|
||||
if (!regDate.toString(Qt::ISODate).isEmpty()) {
|
||||
// the registration date is in utc
|
||||
qint64 accountAgeInSeconds = regDate.secsTo(QDateTime::currentDateTimeUtc());
|
||||
result.set_accountage_secs(accountAgeInSeconds);
|
||||
}
|
||||
|
||||
const QString email = query->value(8).toString();
|
||||
const QString email = query->value(10).toString();
|
||||
if (!email.isEmpty())
|
||||
result.set_email(email.toStdString());
|
||||
|
||||
const QString clientid = query->value(9).toString();
|
||||
const QString clientid = query->value(11).toString();
|
||||
if (!clientid.isEmpty())
|
||||
result.set_clientid(clientid.toStdString());
|
||||
}
|
||||
|
|
@ -652,9 +661,10 @@ ServerInfo_User Servatrice_DatabaseInterface::getUserData(const QString &name, b
|
|||
if (!checkSql())
|
||||
return result;
|
||||
|
||||
QSqlQuery *query =
|
||||
prepareQuery("select id, name, admin, country, privlevel, realname, avatar_bmp, registrationDate, "
|
||||
"email, clientid from {prefix}_users where name = :name and active = 1");
|
||||
QSqlQuery *query = prepareQuery("select id, name, admin, country, privlevel, leftPawnColorOverride, "
|
||||
"rightPawnColorOverride, realname, avatar_bmp, registrationDate, "
|
||||
"email, clientid from {prefix}_users where "
|
||||
"name = :name and active = 1");
|
||||
query->bindValue(":name", name);
|
||||
if (!execSqlQuery(query))
|
||||
return result;
|
||||
|
|
@ -751,7 +761,8 @@ QMap<QString, ServerInfo_User> Servatrice_DatabaseInterface::getBuddyList(const
|
|||
if (server->getAuthenticationMethod() == Servatrice::AuthenticationSql) {
|
||||
checkSql();
|
||||
|
||||
QSqlQuery *query = prepareQuery("select a.id, a.name, a.admin, a.country, a.privlevel from {prefix}_users a "
|
||||
QSqlQuery *query = prepareQuery("select a.id, a.name, a.admin, a.country, a.privlevel, "
|
||||
"a.leftPawnColorOverride, a.rightPawnColorOverride from {prefix}_users a "
|
||||
"left join {prefix}_buddylist b on a.id = b.id_user2 left join {prefix}_users "
|
||||
"c on b.id_user1 = c.id where c.name = :name");
|
||||
query->bindValue(":name", name);
|
||||
|
|
@ -773,7 +784,8 @@ QMap<QString, ServerInfo_User> Servatrice_DatabaseInterface::getIgnoreList(const
|
|||
if (server->getAuthenticationMethod() == Servatrice::AuthenticationSql) {
|
||||
checkSql();
|
||||
|
||||
QSqlQuery *query = prepareQuery("select a.id, a.name, a.admin, a.country, a.privlevel from {prefix}_users a "
|
||||
QSqlQuery *query = prepareQuery("select a.id, a.name, a.admin, a.country, a.privlevel, "
|
||||
"a.leftPawnColorOverride, a.rightPawnColorOverride from {prefix}_users a "
|
||||
"left join {prefix}_ignorelist b on a.id = b.id_user2 left join {prefix}_users "
|
||||
"c on b.id_user1 = c.id where c.name = :name");
|
||||
query->bindValue(":name", name);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include <QObject>
|
||||
#include <QSqlDatabase>
|
||||
|
||||
#define DATABASE_SCHEMA_VERSION 33
|
||||
#define DATABASE_SCHEMA_VERSION 34
|
||||
|
||||
class Servatrice;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue