Merge remote-tracking branch 'upstream/master' into no-overwrite-tokens-xml
Conflicts: cockatrice/src/carddatabase.cpp
This commit is contained in:
commit
c0d4669088
25 changed files with 135 additions and 56 deletions
|
@ -76,8 +76,19 @@ IF(MSVC)
|
||||||
#set(CMAKE_CXX_FLAGS_DEBUG "/Zi")
|
#set(CMAKE_CXX_FLAGS_DEBUG "/Zi")
|
||||||
ELSEIF (CMAKE_COMPILER_IS_GNUCXX)
|
ELSEIF (CMAKE_COMPILER_IS_GNUCXX)
|
||||||
# linux/gcc, bsd/gcc, windows/mingw
|
# linux/gcc, bsd/gcc, windows/mingw
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-s -O2")
|
set(CMAKE_CXX_FLAGS_RELEASE "-s -O2")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -O0 -Wall -Wextra -pedantic -Werror -Wcast-align -Wmissing-declarations -Winline -Wno-long-long -Wno-error=extra -Wno-error=unused-parameter -Wno-inline -Wno-error=delete-non-virtual-dtor -Wno-error=sign-compare -Wno-error=reorder -Wno-error=missing-declarations")
|
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -O0 -Wall -Wextra -pedantic -Werror")
|
||||||
|
|
||||||
|
set(ADDITIONAL_DEBUG_FLAGS -Wcast-align -Wmissing-declarations -Winline -Wno-long-long -Wno-error=extra -Wno-error=unused-parameter -Wno-inline -Wno-error=delete-non-virtual-dtor -Wno-error=sign-compare -Wno-error=reorder -Wno-error=missing-declarations)
|
||||||
|
|
||||||
|
FOREACH(FLAG ${ADDITIONAL_DEBUG_FLAGS})
|
||||||
|
CHECK_CXX_COMPILER_FLAG("${FLAG}" CXX_HAS_WARNING_${FLAG})
|
||||||
|
IF(CXX_HAS_WARNING_${FLAG})
|
||||||
|
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAG}")
|
||||||
|
ENDIF()
|
||||||
|
ENDFOREACH()
|
||||||
ELSE()
|
ELSE()
|
||||||
# other: osx/llvm, bsd/llvm
|
# other: osx/llvm, bsd/llvm
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
||||||
|
|
|
@ -34,8 +34,10 @@ To compile:
|
||||||
The following flags can be passed to `cmake`:
|
The following flags can be passed to `cmake`:
|
||||||
|
|
||||||
- `-DWITH_SERVER=1` Build the server
|
- `-DWITH_SERVER=1` Build the server
|
||||||
- `-DWITHOUT_CLIENT=1` Do not build the client
|
- `-DWITH_CLIENT=0` Do not build the client
|
||||||
|
- `-DWITH_ORACLE=0` Do not build Oracle
|
||||||
- `-DWITH_QT4=1` Force compilation to use Qt4 instead of Qt5.
|
- `-DWITH_QT4=1` Force compilation to use Qt4 instead of Qt5.
|
||||||
|
- `-DCMAKE_BUILD_TYPE=Debug` Compile in debug mode. Enables extra logging output, debug symbols, and much more verbose compiler warnings.
|
||||||
|
|
||||||
# Running
|
# Running
|
||||||
|
|
||||||
|
|
|
@ -129,8 +129,9 @@ void PictureLoader::processLoadQueue()
|
||||||
QString setName = ptl.getSetName();
|
QString setName = ptl.getSetName();
|
||||||
|
|
||||||
QImage image;
|
QImage image;
|
||||||
|
if (!image.load(QString("%1/%2/%3.full.jpg").arg(picsPath).arg("CUSTOM").arg(correctedName))) {
|
||||||
if (!image.load(QString("%1/%2/%3.full.jpg").arg(picsPath).arg(setName).arg(correctedName)))
|
if (!image.load(QString("%1/%2/%3.full.jpg").arg(picsPath).arg(setName).arg(correctedName)))
|
||||||
if (!image.load(QString("%1/%2/%3%4.full.jpg").arg(picsPath).arg(setName).arg(correctedName).arg(1)))
|
//if (!image.load(QString("%1/%2/%3%4.full.jpg").arg(picsPath).arg(setName).arg(correctedName).arg(1)))
|
||||||
if (!image.load(QString("%1/%2/%3/%4.full.jpg").arg(picsPath).arg("downloadedPics").arg(setName).arg(correctedName))) {
|
if (!image.load(QString("%1/%2/%3/%4.full.jpg").arg(picsPath).arg("downloadedPics").arg(setName).arg(correctedName))) {
|
||||||
if (picDownload) {
|
if (picDownload) {
|
||||||
cardsToDownload.append(ptl);
|
cardsToDownload.append(ptl);
|
||||||
|
@ -142,7 +143,7 @@ void PictureLoader::processLoadQueue()
|
||||||
else
|
else
|
||||||
emit imageLoaded(ptl.getCard(), QImage());
|
emit imageLoaded(ptl.getCard(), QImage());
|
||||||
}
|
}
|
||||||
continue;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit imageLoaded(ptl.getCard(), image);
|
emit imageLoaded(ptl.getCard(), image);
|
||||||
|
@ -153,9 +154,24 @@ QString PictureLoader::getPicUrl(CardInfo *card)
|
||||||
{
|
{
|
||||||
if (!picDownload) return 0;
|
if (!picDownload) return 0;
|
||||||
|
|
||||||
QString picUrl = picDownloadHq ? settingsCache->getPicUrlHq() : settingsCache->getPicUrl();
|
|
||||||
picUrl.replace("!name!", QUrl::toPercentEncoding(card->getCorrectedName()));
|
|
||||||
CardSet *set = card->getPreferredSet();
|
CardSet *set = card->getPreferredSet();
|
||||||
|
QString picUrl = QString("");
|
||||||
|
// first check if Hq is enabled and a custom Hq card url exists in cards.xml
|
||||||
|
if(picDownloadHq)
|
||||||
|
{
|
||||||
|
picUrl = card->getCustomPicURLHq(set->getShortName());
|
||||||
|
if (!picUrl.isEmpty())
|
||||||
|
return picUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// then, test for a custom, non-Hq card url in cards.xml
|
||||||
|
picUrl = card->getCustomPicURL(set->getShortName());
|
||||||
|
if (!picUrl.isEmpty())
|
||||||
|
return picUrl;
|
||||||
|
|
||||||
|
// otherwise, fallback to the default url
|
||||||
|
picUrl = picDownloadHq ? settingsCache->getPicUrlHq() : settingsCache->getPicUrl();
|
||||||
|
picUrl.replace("!name!", QUrl::toPercentEncoding(card->getCorrectedName()));
|
||||||
picUrl.replace("!setcode!", QUrl::toPercentEncoding(set->getShortName()));
|
picUrl.replace("!setcode!", QUrl::toPercentEncoding(set->getShortName()));
|
||||||
picUrl.replace("!setname!", QUrl::toPercentEncoding(set->getLongName()));
|
picUrl.replace("!setname!", QUrl::toPercentEncoding(set->getLongName()));
|
||||||
picUrl.replace("!cardid!", QUrl::toPercentEncoding(QString::number(card->getPreferredMuId())));
|
picUrl.replace("!cardid!", QUrl::toPercentEncoding(QString::number(card->getPreferredMuId())));
|
||||||
|
@ -275,6 +291,8 @@ CardInfo::CardInfo(CardDatabase *_db,
|
||||||
bool _cipt,
|
bool _cipt,
|
||||||
int _tableRow,
|
int _tableRow,
|
||||||
const SetList &_sets,
|
const SetList &_sets,
|
||||||
|
const QStringMap &_customPicURLs,
|
||||||
|
const QStringMap &_customPicURLsHq,
|
||||||
MuidMap _muIds)
|
MuidMap _muIds)
|
||||||
: db(_db),
|
: db(_db),
|
||||||
name(_name),
|
name(_name),
|
||||||
|
@ -286,6 +304,8 @@ CardInfo::CardInfo(CardDatabase *_db,
|
||||||
text(_text),
|
text(_text),
|
||||||
colors(_colors),
|
colors(_colors),
|
||||||
loyalty(_loyalty),
|
loyalty(_loyalty),
|
||||||
|
customPicURLs(_customPicURLs),
|
||||||
|
customPicURLsHq(_customPicURLsHq),
|
||||||
muIds(_muIds),
|
muIds(_muIds),
|
||||||
cipt(_cipt),
|
cipt(_cipt),
|
||||||
tableRow(_tableRow),
|
tableRow(_tableRow),
|
||||||
|
@ -464,6 +484,14 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
|
||||||
tmpSet=sets[i]->getShortName();
|
tmpSet=sets[i]->getShortName();
|
||||||
xml.writeAttribute("muId", QString::number(info->getMuId(tmpSet)));
|
xml.writeAttribute("muId", QString::number(info->getMuId(tmpSet)));
|
||||||
|
|
||||||
|
tmpString = info->getCustomPicURL(tmpSet);
|
||||||
|
if(!tmpString.isEmpty())
|
||||||
|
xml.writeAttribute("picURL", tmpString);
|
||||||
|
|
||||||
|
tmpString = info->getCustomPicURLHq(tmpSet);
|
||||||
|
if(!tmpString.isEmpty())
|
||||||
|
xml.writeAttribute("picURLHq", tmpString);
|
||||||
|
|
||||||
xml.writeCharacters(tmpSet);
|
xml.writeCharacters(tmpSet);
|
||||||
xml.writeEndElement();
|
xml.writeEndElement();
|
||||||
}
|
}
|
||||||
|
@ -628,6 +656,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
|
||||||
if (xml.name() == "card") {
|
if (xml.name() == "card") {
|
||||||
QString name, manacost, type, pt, text;
|
QString name, manacost, type, pt, text;
|
||||||
QStringList colors;
|
QStringList colors;
|
||||||
|
QStringMap customPicURLs, customPicURLsHq;
|
||||||
MuidMap muids;
|
MuidMap muids;
|
||||||
SetList sets;
|
SetList sets;
|
||||||
int tableRow = 0;
|
int tableRow = 0;
|
||||||
|
@ -654,6 +683,12 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
|
||||||
if (attrs.hasAttribute("muId")) {
|
if (attrs.hasAttribute("muId")) {
|
||||||
muids[setName] = attrs.value("muId").toString().toInt();
|
muids[setName] = attrs.value("muId").toString().toInt();
|
||||||
}
|
}
|
||||||
|
if (attrs.hasAttribute("picURL")) {
|
||||||
|
customPicURLs[setName] = attrs.value("picURL").toString();
|
||||||
|
}
|
||||||
|
if (attrs.hasAttribute("picURLHq")) {
|
||||||
|
customPicURLsHq[setName] = attrs.value("picURLHq").toString();
|
||||||
|
}
|
||||||
} else if (xml.name() == "color")
|
} else if (xml.name() == "color")
|
||||||
colors << xml.readElementText();
|
colors << xml.readElementText();
|
||||||
else if (xml.name() == "tablerow")
|
else if (xml.name() == "tablerow")
|
||||||
|
@ -667,7 +702,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isToken == tokens) {
|
if (isToken == tokens) {
|
||||||
addCard(new CardInfo(this, name, isToken, manacost, type, pt, text, colors, loyalty, cipt, tableRow, sets, muids));
|
addCard(new CardInfo(this, name, isToken, manacost, type, pt, text, colors, loyalty, cipt, tableRow, sets, customPicURLs, customPicURLsHq, muids));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,7 @@ private:
|
||||||
QString text;
|
QString text;
|
||||||
QStringList colors;
|
QStringList colors;
|
||||||
int loyalty;
|
int loyalty;
|
||||||
|
QStringMap customPicURLs, customPicURLsHq;
|
||||||
MuidMap muIds;
|
MuidMap muIds;
|
||||||
bool cipt;
|
bool cipt;
|
||||||
int tableRow;
|
int tableRow;
|
||||||
|
@ -128,6 +129,8 @@ public:
|
||||||
bool _cipt = false,
|
bool _cipt = false,
|
||||||
int _tableRow = 0,
|
int _tableRow = 0,
|
||||||
const SetList &_sets = SetList(),
|
const SetList &_sets = SetList(),
|
||||||
|
const QStringMap &_customPicURLs = QStringMap(),
|
||||||
|
const QStringMap &_customPicURLsHq = QStringMap(),
|
||||||
MuidMap muids = MuidMap());
|
MuidMap muids = MuidMap());
|
||||||
~CardInfo();
|
~CardInfo();
|
||||||
const QString &getName() const { return name; }
|
const QString &getName() const { return name; }
|
||||||
|
@ -145,12 +148,16 @@ public:
|
||||||
void setText(const QString &_text) { text = _text; emit cardInfoChanged(this); }
|
void setText(const QString &_text) { text = _text; emit cardInfoChanged(this); }
|
||||||
void setColors(const QStringList &_colors) { colors = _colors; emit cardInfoChanged(this); }
|
void setColors(const QStringList &_colors) { colors = _colors; emit cardInfoChanged(this); }
|
||||||
const QStringList &getColors() const { return colors; }
|
const QStringList &getColors() const { return colors; }
|
||||||
|
QString getCustomPicURL(const QString &set) const { return customPicURLs.value(set); }
|
||||||
|
QString getCustomPicURLHq(const QString &set) const { return customPicURLsHq.value(set); }
|
||||||
int getMuId(const QString &set) const { return muIds.value(set); }
|
int getMuId(const QString &set) const { return muIds.value(set); }
|
||||||
QString getMainCardType() const;
|
QString getMainCardType() const;
|
||||||
QString getCorrectedName() const;
|
QString getCorrectedName() const;
|
||||||
int getTableRow() const { return tableRow; }
|
int getTableRow() const { return tableRow; }
|
||||||
void setTableRow(int _tableRow) { tableRow = _tableRow; }
|
void setTableRow(int _tableRow) { tableRow = _tableRow; }
|
||||||
void setLoyalty(int _loyalty) { loyalty = _loyalty; emit cardInfoChanged(this); }
|
void setLoyalty(int _loyalty) { loyalty = _loyalty; emit cardInfoChanged(this); }
|
||||||
|
void setCustomPicURL(const QString &_set, const QString &_customPicURL) { customPicURLs.insert(_set, _customPicURL); }
|
||||||
|
void setCustomPicURLHq(const QString &_set, const QString &_customPicURL) { customPicURLsHq.insert(_set, _customPicURL); }
|
||||||
void setMuId(const QString &_set, const int &_muId) { muIds.insert(_set, _muId); }
|
void setMuId(const QString &_set, const int &_muId) { muIds.insert(_set, _muId); }
|
||||||
void addToSet(CardSet *set);
|
void addToSet(CardSet *set);
|
||||||
QPixmap *loadPixmap();
|
QPixmap *loadPixmap();
|
||||||
|
|
|
@ -113,7 +113,7 @@ DlgEditTokens::DlgEditTokens(CardDatabaseModel *_cardDatabaseModel, QWidget *par
|
||||||
setWindowTitle(tr("Edit tokens"));
|
setWindowTitle(tr("Edit tokens"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DlgEditTokens::tokenSelectionChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
void DlgEditTokens::tokenSelectionChanged(const QModelIndex ¤t, const QModelIndex & /* previous */)
|
||||||
{
|
{
|
||||||
const QModelIndex realIndex = cardDatabaseDisplayModel->mapToSource(current);
|
const QModelIndex realIndex = cardDatabaseDisplayModel->mapToSource(current);
|
||||||
CardInfo *cardInfo = current.row() >= 0 ? cardDatabaseModel->getCard(realIndex.row()) : cardDatabaseModel->getDatabase()->getCard();
|
CardInfo *cardInfo = current.row() >= 0 ? cardDatabaseModel->getCard(realIndex.row()) : cardDatabaseModel->getDatabase()->getCard();
|
||||||
|
|
|
@ -18,10 +18,10 @@ public:
|
||||||
virtual void enable() { enabled = true; nodeChanged(); }
|
virtual void enable() { enabled = true; nodeChanged(); }
|
||||||
virtual void disable() { enabled = false; nodeChanged(); }
|
virtual void disable() { enabled = false; nodeChanged(); }
|
||||||
virtual FilterTreeNode *parent() const { return NULL; }
|
virtual FilterTreeNode *parent() const { return NULL; }
|
||||||
virtual FilterTreeNode *nodeAt(int i) const { return NULL; }
|
virtual FilterTreeNode *nodeAt(int /* i */) const { return NULL; }
|
||||||
virtual void deleteAt(int i) {}
|
virtual void deleteAt(int /* i */) {}
|
||||||
virtual int childCount() const { return 0; }
|
virtual int childCount() const { return 0; }
|
||||||
virtual int childIndex(const FilterTreeNode *node) const { return -1; }
|
virtual int childIndex(const FilterTreeNode * /* node */) const { return -1; }
|
||||||
virtual int index() const { return (parent() != NULL)? parent()->childIndex(this) : -1; }
|
virtual int index() const { return (parent() != NULL)? parent()->childIndex(this) : -1; }
|
||||||
virtual QString text() const { return QString(textCStr()); }
|
virtual QString text() const { return QString(textCStr()); }
|
||||||
virtual bool isLeaf() const { return false; }
|
virtual bool isLeaf() const { return false; }
|
||||||
|
@ -48,7 +48,7 @@ class FilterTreeBranch : public FilterTreeNode {
|
||||||
protected:
|
protected:
|
||||||
QList<T> childNodes;
|
QList<T> childNodes;
|
||||||
public:
|
public:
|
||||||
~FilterTreeBranch();
|
virtual ~FilterTreeBranch();
|
||||||
FilterTreeNode *nodeAt(int i) const;
|
FilterTreeNode *nodeAt(int i) const;
|
||||||
void deleteAt(int i);
|
void deleteAt(int i);
|
||||||
int childCount() const { return childNodes.size(); }
|
int childCount() const { return childNodes.size(); }
|
||||||
|
@ -102,6 +102,7 @@ public:
|
||||||
|
|
||||||
FilterItem(QString trm, FilterItemList *parent)
|
FilterItem(QString trm, FilterItemList *parent)
|
||||||
: p(parent), term(trm) {}
|
: p(parent), term(trm) {}
|
||||||
|
virtual ~FilterItem() {};
|
||||||
|
|
||||||
CardFilter::Attr attr() const { return p->attr(); }
|
CardFilter::Attr attr() const { return p->attr(); }
|
||||||
CardFilter::Type type() const { return p->type; }
|
CardFilter::Type type() const { return p->type; }
|
||||||
|
|
|
@ -33,7 +33,7 @@ ServerInfo_User LocalServer_DatabaseInterface::getUserData(const QString &name,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthenticationResult LocalServer_DatabaseInterface::checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password, QString &reasonStr, int &secondsLeft)
|
AuthenticationResult LocalServer_DatabaseInterface::checkUserPassword(Server_ProtocolHandler * /* handler */, const QString & /* user */, const QString & /* password */, QString & /* reasonStr */, int & /* secondsLeft */)
|
||||||
{
|
{
|
||||||
return UnknownUser;
|
return UnknownUser;
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,6 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
qsrand(QDateTime::currentDateTime().toTime_t());
|
qsrand(QDateTime::currentDateTime().toTime_t());
|
||||||
|
|
||||||
bool startMainProgram = true;
|
|
||||||
#if QT_VERSION < 0x050000
|
#if QT_VERSION < 0x050000
|
||||||
const QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
const QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -178,5 +178,5 @@ void PlayerListWidget::showContextMenu(const QPoint &pos, const QModelIndex &ind
|
||||||
int playerId = index.sibling(index.row(), 4).data(Qt::UserRole + 1).toInt();
|
int playerId = index.sibling(index.row(), 4).data(Qt::UserRole + 1).toInt();
|
||||||
UserLevelFlags userLevel(index.sibling(index.row(), 3).data(Qt::UserRole).toInt());
|
UserLevelFlags userLevel(index.sibling(index.row(), 3).data(Qt::UserRole).toInt());
|
||||||
|
|
||||||
userContextMenu->showContextMenu(pos, userName, userLevel, playerId);
|
userContextMenu->showContextMenu(pos, userName, userLevel, true, playerId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ void ReplayTimelineWidget::setTimeline(const QList<int> &_replayTimeline)
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReplayTimelineWidget::paintEvent(QPaintEvent *event)
|
void ReplayTimelineWidget::paintEvent(QPaintEvent * /* event */)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.drawRect(0, 0, width() - 1, height() - 1);
|
painter.drawRect(0, 0, width() - 1, height() - 1);
|
||||||
|
|
|
@ -646,6 +646,7 @@ void TabDeckEditor::actDecrement()
|
||||||
void TabDeckEditor::setPriceTagFeatureEnabled(int enabled)
|
void TabDeckEditor::setPriceTagFeatureEnabled(int enabled)
|
||||||
{
|
{
|
||||||
aUpdatePrices->setVisible(enabled);
|
aUpdatePrices->setVisible(enabled);
|
||||||
|
deckModel->pricesUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabDeckEditor::actUpdatePrices()
|
void TabDeckEditor::actUpdatePrices()
|
||||||
|
|
|
@ -254,7 +254,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay)
|
||||||
|
|
||||||
// Create list: event number -> time [ms]
|
// Create list: event number -> time [ms]
|
||||||
// Distribute simultaneous events evenly across 1 second.
|
// Distribute simultaneous events evenly across 1 second.
|
||||||
int lastEventTimestamp = -1;
|
unsigned int lastEventTimestamp = 0;
|
||||||
const int eventCount = replay->event_list_size();
|
const int eventCount = replay->event_list_size();
|
||||||
for (int i = 0; i < eventCount; ++i) {
|
for (int i = 0; i < eventCount; ++i) {
|
||||||
int j = i + 1;
|
int j = i + 1;
|
||||||
|
|
|
@ -202,7 +202,7 @@ void TabReplays::actDownload()
|
||||||
client->sendCommand(pend);
|
client->sendCommand(pend);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabReplays::downloadFinished(const Response &r, const CommandContainer &commandContainer, const QVariant &extraData)
|
void TabReplays::downloadFinished(const Response &r, const CommandContainer & /* commandContainer */, const QVariant &extraData)
|
||||||
{
|
{
|
||||||
if (r.response_code() != Response::RespOk)
|
if (r.response_code() != Response::RespOk)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -76,7 +76,7 @@ void CloseButton::paintEvent(QPaintEvent * /*event*/)
|
||||||
}
|
}
|
||||||
|
|
||||||
TabSupervisor::TabSupervisor(AbstractClient *_client, QWidget *parent)
|
TabSupervisor::TabSupervisor(AbstractClient *_client, QWidget *parent)
|
||||||
: QTabWidget(parent), userInfo(0), client(_client), tabUserLists(0), tabServer(0), tabDeckStorage(0), tabAdmin(0), tabReplays(0)
|
: QTabWidget(parent), userInfo(0), client(_client), tabServer(0), tabUserLists(0), tabDeckStorage(0), tabReplays(0), tabAdmin(0)
|
||||||
{
|
{
|
||||||
tabChangedIcon = new QIcon(":/resources/icon_tab_changed.svg");
|
tabChangedIcon = new QIcon(":/resources/icon_tab_changed.svg");
|
||||||
setElideMode(Qt::ElideRight);
|
setElideMode(Qt::ElideRight);
|
||||||
|
|
|
@ -102,7 +102,7 @@ void UserContextMenu::banUser_dialogFinished()
|
||||||
client->sendCommand(client->prepareModeratorCommand(cmd));
|
client->sendCommand(client->prepareModeratorCommand(cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName, UserLevelFlags userLevel, int playerId)
|
void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName, UserLevelFlags userLevel, bool online, int playerId)
|
||||||
{
|
{
|
||||||
aUserName->setText(userName);
|
aUserName->setText(userName);
|
||||||
|
|
||||||
|
@ -132,7 +132,8 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
|
||||||
menu->addAction(aBan);
|
menu->addAction(aBan);
|
||||||
}
|
}
|
||||||
bool anotherUser = userName != QString::fromStdString(tabSupervisor->getUserInfo()->name());
|
bool anotherUser = userName != QString::fromStdString(tabSupervisor->getUserInfo()->name());
|
||||||
aChat->setEnabled(anotherUser);
|
aDetails->setEnabled(online);
|
||||||
|
aChat->setEnabled(anotherUser && online);
|
||||||
aShowGames->setEnabled(anotherUser);
|
aShowGames->setEnabled(anotherUser);
|
||||||
aAddToBuddyList->setEnabled(anotherUser);
|
aAddToBuddyList->setEnabled(anotherUser);
|
||||||
aRemoveFromBuddyList->setEnabled(anotherUser);
|
aRemoveFromBuddyList->setEnabled(anotherUser);
|
||||||
|
|
|
@ -36,7 +36,7 @@ private slots:
|
||||||
public:
|
public:
|
||||||
UserContextMenu(const TabSupervisor *_tabSupervisor, QWidget *_parent, TabGame *_game = 0);
|
UserContextMenu(const TabSupervisor *_tabSupervisor, QWidget *_parent, TabGame *_game = 0);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void showContextMenu(const QPoint &pos, const QString &userName, UserLevelFlags userLevel, int playerId = -1);
|
void showContextMenu(const QPoint &pos, const QString &userName, UserLevelFlags userLevel, bool online = true, int playerId = -1);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -311,8 +311,9 @@ void UserList::userClicked(QTreeWidgetItem *item, int /*column*/)
|
||||||
void UserList::showContextMenu(const QPoint &pos, const QModelIndex &index)
|
void UserList::showContextMenu(const QPoint &pos, const QModelIndex &index)
|
||||||
{
|
{
|
||||||
const ServerInfo_User &userInfo = static_cast<UserListTWI *>(userTree->topLevelItem(index.row()))->getUserInfo();
|
const ServerInfo_User &userInfo = static_cast<UserListTWI *>(userTree->topLevelItem(index.row()))->getUserInfo();
|
||||||
|
bool online = index.sibling(index.row(), 0).data(Qt::UserRole + 1).toBool();
|
||||||
|
|
||||||
userContextMenu->showContextMenu(pos, QString::fromStdString(userInfo.name()), UserLevelFlags(userInfo.user_level()));
|
userContextMenu->showContextMenu(pos, QString::fromStdString(userInfo.name()), UserLevelFlags(userInfo.user_level()), online);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserList::sortItems()
|
void UserList::sortItems()
|
||||||
|
|
|
@ -355,7 +355,8 @@ DeckList::DeckList()
|
||||||
|
|
||||||
// TODO: http://qt-project.org/doc/qt-4.8/qobject.html#no-copy-constructor-or-assignment-operator
|
// TODO: http://qt-project.org/doc/qt-4.8/qobject.html#no-copy-constructor-or-assignment-operator
|
||||||
DeckList::DeckList(const DeckList &other)
|
DeckList::DeckList(const DeckList &other)
|
||||||
: name(other.name),
|
: QObject(),
|
||||||
|
name(other.name),
|
||||||
comments(other.comments),
|
comments(other.comments),
|
||||||
deckHash(other.deckHash)
|
deckHash(other.deckHash)
|
||||||
{
|
{
|
||||||
|
|
|
@ -97,7 +97,7 @@ protected slots:
|
||||||
void externalGameEventContainerReceived(const GameEventContainer &cont, qint64 sessionId);
|
void externalGameEventContainerReceived(const GameEventContainer &cont, qint64 sessionId);
|
||||||
void externalResponseReceived(const Response &resp, qint64 sessionId);
|
void externalResponseReceived(const Response &resp, qint64 sessionId);
|
||||||
|
|
||||||
virtual void doSendIslMessage(const IslMessage &msg, int serverId) { }
|
virtual void doSendIslMessage(const IslMessage & /* msg */, int /* serverId */) { }
|
||||||
protected:
|
protected:
|
||||||
void prepareDestroy();
|
void prepareDestroy();
|
||||||
void setDatabaseInterface(Server_DatabaseInterface *_databaseInterface);
|
void setDatabaseInterface(Server_DatabaseInterface *_databaseInterface);
|
||||||
|
|
|
@ -12,18 +12,18 @@ public:
|
||||||
: QObject(parent) { }
|
: QObject(parent) { }
|
||||||
|
|
||||||
virtual AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password, QString &reasonStr, int &secondsLeft) = 0;
|
virtual AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password, QString &reasonStr, int &secondsLeft) = 0;
|
||||||
virtual bool userExists(const QString &user) { return false; }
|
virtual bool userExists(const QString & /* user */) { return false; }
|
||||||
virtual QMap<QString, ServerInfo_User> getBuddyList(const QString &name) { return QMap<QString, ServerInfo_User>(); }
|
virtual QMap<QString, ServerInfo_User> getBuddyList(const QString & /* name */) { return QMap<QString, ServerInfo_User>(); }
|
||||||
virtual QMap<QString, ServerInfo_User> getIgnoreList(const QString &name) { return QMap<QString, ServerInfo_User>(); }
|
virtual QMap<QString, ServerInfo_User> getIgnoreList(const QString & /* name */) { return QMap<QString, ServerInfo_User>(); }
|
||||||
virtual bool isInBuddyList(const QString &whoseList, const QString &who) { return false; }
|
virtual bool isInBuddyList(const QString & /* whoseList */, const QString & /* who */) { return false; }
|
||||||
virtual bool isInIgnoreList(const QString &whoseList, const QString &who) { return false; }
|
virtual bool isInIgnoreList(const QString & /* whoseList */, const QString & /* who */) { return false; }
|
||||||
virtual ServerInfo_User getUserData(const QString &name, bool withId = false) = 0;
|
virtual ServerInfo_User getUserData(const QString &name, bool withId = false) = 0;
|
||||||
virtual void storeGameInformation(const QString &roomName, const QStringList &roomGameTypes, const ServerInfo_Game &gameInfo, const QSet<QString> &allPlayersEver, const QSet<QString> &allSpectatorsEver, const QList<GameReplay *> &replayList) { }
|
virtual void storeGameInformation(const QString & /* roomName */, const QStringList & /* roomGameTypes */, const ServerInfo_Game & /* gameInfo */, const QSet<QString> & /* allPlayersEver */, const QSet<QString> & /* allSpectatorsEver */, const QList<GameReplay *> & /* replayList */) { }
|
||||||
virtual DeckList *getDeckFromDatabase(int deckId, int userId) { return 0; }
|
virtual DeckList *getDeckFromDatabase(int /* deckId */, int /* userId */) { return 0; }
|
||||||
|
|
||||||
virtual qint64 startSession(const QString &userName, const QString &address) { return 0; }
|
virtual qint64 startSession(const QString & /* userName */, const QString & /* address */) { return 0; }
|
||||||
public slots:
|
public slots:
|
||||||
virtual void endSession(qint64 sessionId) { }
|
virtual void endSession(qint64 /* sessionId */ ) { }
|
||||||
public:
|
public:
|
||||||
virtual int getNextGameId() = 0;
|
virtual int getNextGameId() = 0;
|
||||||
virtual int getNextReplayId() = 0;
|
virtual int getNextReplayId() = 0;
|
||||||
|
@ -31,7 +31,7 @@ public:
|
||||||
virtual void clearSessionTables() { }
|
virtual void clearSessionTables() { }
|
||||||
virtual void lockSessionTables() { }
|
virtual void lockSessionTables() { }
|
||||||
virtual void unlockSessionTables() { }
|
virtual void unlockSessionTables() { }
|
||||||
virtual bool userSessionExists(const QString &userName) { return false; }
|
virtual bool userSessionExists(const QString & /* userName */) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1594,7 +1594,7 @@ Response::ResponseCode Server_Player::cmdRevealCards(const Command_RevealCards &
|
||||||
return Response::RespOk;
|
return Response::RespOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
Response::ResponseCode Server_Player::cmdChangeZoneProperties(const Command_ChangeZoneProperties &cmd, ResponseContainer &rc, GameEventStorage &ges)
|
Response::ResponseCode Server_Player::cmdChangeZoneProperties(const Command_ChangeZoneProperties &cmd, ResponseContainer & /* rc */, GameEventStorage &ges)
|
||||||
{
|
{
|
||||||
Server_CardZone *zone = zones.value(QString::fromStdString(cmd.zone_name()));
|
Server_CardZone *zone = zones.value(QString::fromStdString(cmd.zone_name()));
|
||||||
if (!zone)
|
if (!zone)
|
||||||
|
|
|
@ -49,7 +49,7 @@ protected:
|
||||||
AuthenticationResult authState;
|
AuthenticationResult authState;
|
||||||
bool acceptsUserListChanges;
|
bool acceptsUserListChanges;
|
||||||
bool acceptsRoomListChanges;
|
bool acceptsRoomListChanges;
|
||||||
virtual void logDebugMessage(const QString &message) { }
|
virtual void logDebugMessage(const QString & /* message */) { }
|
||||||
private:
|
private:
|
||||||
QList<int> messageSizeOverTime, messageCountOverTime;
|
QList<int> messageSizeOverTime, messageCountOverTime;
|
||||||
int timeRunning, lastDataReceived;
|
int timeRunning, lastDataReceived;
|
||||||
|
@ -71,13 +71,13 @@ private:
|
||||||
Response::ResponseCode cmdJoinGame(const Command_JoinGame &cmd, Server_Room *room, ResponseContainer &rc);
|
Response::ResponseCode cmdJoinGame(const Command_JoinGame &cmd, Server_Room *room, ResponseContainer &rc);
|
||||||
|
|
||||||
Response::ResponseCode processSessionCommandContainer(const CommandContainer &cont, ResponseContainer &rc);
|
Response::ResponseCode processSessionCommandContainer(const CommandContainer &cont, ResponseContainer &rc);
|
||||||
virtual Response::ResponseCode processExtendedSessionCommand(int cmdType, const SessionCommand &cmd, ResponseContainer &rc) { return Response::RespFunctionNotAllowed; }
|
virtual Response::ResponseCode processExtendedSessionCommand(int /* cmdType */, const SessionCommand & /* cmd */, ResponseContainer & /* rc */) { return Response::RespFunctionNotAllowed; }
|
||||||
Response::ResponseCode processRoomCommandContainer(const CommandContainer &cont, ResponseContainer &rc);
|
Response::ResponseCode processRoomCommandContainer(const CommandContainer &cont, ResponseContainer &rc);
|
||||||
Response::ResponseCode processGameCommandContainer(const CommandContainer &cont, ResponseContainer &rc);
|
Response::ResponseCode processGameCommandContainer(const CommandContainer &cont, ResponseContainer &rc);
|
||||||
Response::ResponseCode processModeratorCommandContainer(const CommandContainer &cont, ResponseContainer &rc);
|
Response::ResponseCode processModeratorCommandContainer(const CommandContainer &cont, ResponseContainer &rc);
|
||||||
virtual Response::ResponseCode processExtendedModeratorCommand(int cmdType, const ModeratorCommand &cmd, ResponseContainer &rc) { return Response::RespFunctionNotAllowed; }
|
virtual Response::ResponseCode processExtendedModeratorCommand(int /* cmdType */, const ModeratorCommand & /* cmd */, ResponseContainer & /* rc */) { return Response::RespFunctionNotAllowed; }
|
||||||
Response::ResponseCode processAdminCommandContainer(const CommandContainer &cont, ResponseContainer &rc);
|
Response::ResponseCode processAdminCommandContainer(const CommandContainer &cont, ResponseContainer &rc);
|
||||||
virtual Response::ResponseCode processExtendedAdminCommand(int cmdType, const AdminCommand &cmd, ResponseContainer &rc) { return Response::RespFunctionNotAllowed; }
|
virtual Response::ResponseCode processExtendedAdminCommand(int /* cmdType */, const AdminCommand & /* cmd */, ResponseContainer & /* rc */) { return Response::RespFunctionNotAllowed; }
|
||||||
private slots:
|
private slots:
|
||||||
void pingClockTimeout();
|
void pingClockTimeout();
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -383,7 +383,7 @@ void SaveSetsPage::initializePage()
|
||||||
QMessageBox::critical(this, tr("Error"), tr("No set has been imported."));
|
QMessageBox::critical(this, tr("Error"), tr("No set has been imported."));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveSetsPage::updateTotalProgress(int cardsImported, int setIndex, const QString &setName)
|
void SaveSetsPage::updateTotalProgress(int cardsImported, int /* setIndex */, const QString &setName)
|
||||||
{
|
{
|
||||||
if (setName.isEmpty()) {
|
if (setName.isEmpty()) {
|
||||||
messageLog->append("<b>" + tr("Import finished: %1 cards.").arg(wizard()->importer->getCardList().size()) + "</b>");
|
messageLog->append("<b>" + tr("Import finished: %1 cards.").arg(wizard()->importer->getCardList().size()) + "</b>");
|
||||||
|
|
|
@ -37,6 +37,23 @@ RNG_Abstract *rng;
|
||||||
ServerLogger *logger;
|
ServerLogger *logger;
|
||||||
QThread *loggerThread;
|
QThread *loggerThread;
|
||||||
|
|
||||||
|
/* Prototypes */
|
||||||
|
|
||||||
|
void testRNG();
|
||||||
|
void testHash();
|
||||||
|
#if QT_VERSION < 0x050000
|
||||||
|
void myMessageOutput(QtMsgType type, const char *msg);
|
||||||
|
void myMessageOutput2(QtMsgType type, const char *msg);
|
||||||
|
#else
|
||||||
|
void myMessageOutput(QtMsgType type, const QMessageLogContext &, const QString &msg);
|
||||||
|
void myMessageOutput2(QtMsgType type, const QMessageLogContext &, const QString &msg);
|
||||||
|
#endif
|
||||||
|
#ifdef Q_OS_UNIX
|
||||||
|
void sigSegvHandler(int sig);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Implementations */
|
||||||
|
|
||||||
void testRNG()
|
void testRNG()
|
||||||
{
|
{
|
||||||
const int n = 500000;
|
const int n = 500000;
|
||||||
|
|
|
@ -18,12 +18,15 @@ QString PasswordHasher::computeHash(const QString &password, const QString &salt
|
||||||
|
|
||||||
QByteArray passwordBuffer = (salt + password).toUtf8();
|
QByteArray passwordBuffer = (salt + password).toUtf8();
|
||||||
int hashLen = gcry_md_get_algo_dlen(algo);
|
int hashLen = gcry_md_get_algo_dlen(algo);
|
||||||
char hash[hashLen], tmp[hashLen];
|
char *hash = new char[hashLen], *tmp = new char[hashLen];
|
||||||
gcry_md_hash_buffer(algo, hash, passwordBuffer.data(), passwordBuffer.size());
|
gcry_md_hash_buffer(algo, hash, passwordBuffer.data(), passwordBuffer.size());
|
||||||
for (int i = 1; i < rounds; ++i) {
|
for (int i = 1; i < rounds; ++i) {
|
||||||
memcpy(tmp, hash, hashLen);
|
memcpy(tmp, hash, hashLen);
|
||||||
gcry_md_hash_buffer(algo, hash, tmp, hashLen);
|
gcry_md_hash_buffer(algo, hash, tmp, hashLen);
|
||||||
}
|
}
|
||||||
return salt + QString(QByteArray(hash, hashLen).toBase64());
|
QString hashedPass = salt + QString(QByteArray(hash, hashLen).toBase64());
|
||||||
|
delete[] tmp;
|
||||||
|
delete[] hash;
|
||||||
|
return hashedPass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue