mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-12 13:00:01 -08:00
Read 'n' as neutral gender in user database
This commit is contained in:
parent
aa2265b343
commit
44f197e8da
1 changed files with 39 additions and 35 deletions
|
|
@ -251,47 +251,51 @@ bool Servatrice_DatabaseInterface::isInIgnoreList(const QString &whoseList, cons
|
||||||
|
|
||||||
ServerInfo_User Servatrice_DatabaseInterface::evalUserQueryResult(const QSqlQuery &query, bool complete, bool withId)
|
ServerInfo_User Servatrice_DatabaseInterface::evalUserQueryResult(const QSqlQuery &query, bool complete, bool withId)
|
||||||
{
|
{
|
||||||
ServerInfo_User result;
|
ServerInfo_User result;
|
||||||
|
|
||||||
if (withId)
|
if (withId)
|
||||||
result.set_id(query.value(0).toInt());
|
result.set_id(query.value(0).toInt());
|
||||||
result.set_name(query.value(1).toString().toStdString());
|
result.set_name(query.value(1).toString().toStdString());
|
||||||
|
|
||||||
const QString country = query.value(5).toString();
|
const QString country = query.value(5).toString();
|
||||||
if (!country.isEmpty())
|
if (!country.isEmpty())
|
||||||
result.set_country(country.toStdString());
|
result.set_country(country.toStdString());
|
||||||
|
|
||||||
if (complete) {
|
if (complete) {
|
||||||
const QByteArray avatarBmp = query.value(6).toByteArray();
|
const QByteArray avatarBmp = query.value(6).toByteArray();
|
||||||
if (avatarBmp.size())
|
if (avatarBmp.size())
|
||||||
result.set_avatar_bmp(avatarBmp.data(), avatarBmp.size());
|
result.set_avatar_bmp(avatarBmp.data(), avatarBmp.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString genderStr = query.value(4).toString();
|
const QString genderStr = query.value(4).toString();
|
||||||
if (genderStr == "m")
|
if (genderStr == "m")
|
||||||
result.set_gender(ServerInfo_User::Male);
|
result.set_gender(ServerInfo_User::Male);
|
||||||
else if (genderStr == "f")
|
else if (genderStr == "f")
|
||||||
result.set_gender(ServerInfo_User::Female);
|
result.set_gender(ServerInfo_User::Female);
|
||||||
|
else if (genderStr == "n")
|
||||||
const int is_admin = query.value(2).toInt();
|
result.set_gender(ServerInfo_User::Neutral);
|
||||||
int userLevel = ServerInfo_User::IsUser | ServerInfo_User::IsRegistered;
|
else
|
||||||
if (is_admin == 1)
|
result.set_gender(ServerInfo_User::Unknown);
|
||||||
userLevel |= ServerInfo_User::IsAdmin | ServerInfo_User::IsModerator;
|
|
||||||
else if (is_admin == 2)
|
const int is_admin = query.value(2).toInt();
|
||||||
userLevel |= ServerInfo_User::IsModerator;
|
int userLevel = ServerInfo_User::IsUser | ServerInfo_User::IsRegistered;
|
||||||
result.set_user_level(userLevel);
|
if (is_admin == 1)
|
||||||
|
userLevel |= ServerInfo_User::IsAdmin | ServerInfo_User::IsModerator;
|
||||||
const QString realName = query.value(3).toString();
|
else if (is_admin == 2)
|
||||||
if (!realName.isEmpty())
|
userLevel |= ServerInfo_User::IsModerator;
|
||||||
result.set_real_name(realName.toStdString());
|
result.set_user_level(userLevel);
|
||||||
|
|
||||||
|
const QString realName = query.value(3).toString();
|
||||||
|
if (!realName.isEmpty())
|
||||||
|
result.set_real_name(realName.toStdString());
|
||||||
|
|
||||||
const QDateTime regDate = query.value(7).toDateTime();
|
const QDateTime regDate = query.value(7).toDateTime();
|
||||||
if(!regDate.toString(Qt::ISODate).isEmpty()) {
|
if(!regDate.toString(Qt::ISODate).isEmpty()) {
|
||||||
qint64 accountAgeInSeconds = regDate.secsTo(QDateTime::currentDateTime());
|
qint64 accountAgeInSeconds = regDate.secsTo(QDateTime::currentDateTime());
|
||||||
result.set_accountage_secs(accountAgeInSeconds);
|
result.set_accountage_secs(accountAgeInSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerInfo_User Servatrice_DatabaseInterface::getUserData(const QString &name, bool withId)
|
ServerInfo_User Servatrice_DatabaseInterface::getUserData(const QString &name, bool withId)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue