mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-09 17:44:01 -07:00
[Fix-Warnings] Remove redundant parentheses
This commit is contained in:
parent
858361e6d3
commit
8ddbdf31f9
75 changed files with 269 additions and 269 deletions
|
|
@ -190,7 +190,7 @@ void StableReleaseChannel::tagListFinished()
|
|||
QString shortHash = lastRelease->getCommitHash().left(GIT_SHORT_HASH_LEN);
|
||||
QString myHash = QString(VERSION_COMMIT);
|
||||
qCInfo(ReleaseChannelLog) << "Current hash=" << myHash << "update hash=" << shortHash;
|
||||
const bool needToUpdate = (QString::compare(shortHash, myHash, Qt::CaseInsensitive) != 0);
|
||||
const bool needToUpdate = QString::compare(shortHash, myHash, Qt::CaseInsensitive) != 0;
|
||||
|
||||
emit finishedCheck(needToUpdate, lastRelease->isCompatibleVersionFound(), lastRelease);
|
||||
}
|
||||
|
|
@ -284,7 +284,7 @@ void BetaReleaseChannel::fileListFinished()
|
|||
QString myHash = QString(VERSION_COMMIT);
|
||||
qCInfo(ReleaseChannelLog) << "Current hash=" << myHash << "update hash=" << shortHash;
|
||||
|
||||
bool needToUpdate = (QString::compare(shortHash, myHash, Qt::CaseInsensitive) != 0);
|
||||
bool needToUpdate = QString::compare(shortHash, myHash, Qt::CaseInsensitive) != 0;
|
||||
bool compatibleVersion = false;
|
||||
|
||||
QStringList resultUrlList{};
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ QColor CardCounterSettings::color(int counterId) const
|
|||
defaultColor = QColor::fromHsv(counterId * 60, 150, 255);
|
||||
} else {
|
||||
// Future-proof support for more counters with pseudo-random colors
|
||||
int h = (counterId * 37) % 360;
|
||||
int s = 128 + 64 * qSin((counterId * 97) * 0.1); // 64-192
|
||||
int v = 196 + 32 * qSin((counterId * 101) * 0.07); // 164-228
|
||||
int h = counterId * 37 % 360;
|
||||
int s = 128 + 64 * qSin(counterId * 97 * 0.1); // 64-192
|
||||
int v = 196 + 32 * qSin(counterId * 101 * 0.07); // 164-228
|
||||
|
||||
defaultColor = QColor::fromHsv(h, s, v);
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ QString CardCounterSettings::displayName(int counterId) const
|
|||
str.resize(nChars);
|
||||
|
||||
for (auto it = str.rbegin(); it != str.rend(); ++it) {
|
||||
*it = QChar('A' + (counterId) % 26);
|
||||
*it = QChar('A' + counterId % 26);
|
||||
counterId /= 26;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -288,9 +288,9 @@ void AbstractCardItem::setFaceDown(bool _facedown)
|
|||
|
||||
void AbstractCardItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if ((event->modifiers() & Qt::AltModifier) && event->button() == Qt::LeftButton) {
|
||||
if (event->modifiers() & Qt::AltModifier && event->button() == Qt::LeftButton) {
|
||||
emit cardShiftClicked(cardRef.name);
|
||||
} else if ((event->modifiers() & Qt::ControlModifier)) {
|
||||
} else if (event->modifiers() & Qt::ControlModifier) {
|
||||
setSelected(!isSelected());
|
||||
} else if (!isSelected()) {
|
||||
scene()->clearSelection();
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ void AbstractCounter::setValue(int _value)
|
|||
void AbstractCounter::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (isUnderMouse() && player->getPlayerInfo()->getLocalOrJudge()) {
|
||||
if (event->button() == Qt::MiddleButton || (QApplication::keyboardModifiers() & Qt::ShiftModifier)) {
|
||||
if (event->button() == Qt::MiddleButton || QApplication::keyboardModifiers() & Qt::ShiftModifier) {
|
||||
if (menu)
|
||||
menu->exec(event->screenPos());
|
||||
event->accept();
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ void ArrowDragItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
if ((cursorItem != targetItem) && targetItem) {
|
||||
if (cursorItem != targetItem && targetItem) {
|
||||
targetItem->setBeingPointedAt(false);
|
||||
targetItem->removeArrowTo(this);
|
||||
}
|
||||
|
|
@ -213,7 +213,7 @@ void ArrowDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
if (!startItem)
|
||||
return;
|
||||
|
||||
if (targetItem && (targetItem != startItem)) {
|
||||
if (targetItem && targetItem != startItem) {
|
||||
CardZoneLogic *startZone = static_cast<CardItem *>(startItem)->getZone();
|
||||
// For now, we can safely assume that the start item is always a card.
|
||||
// The target item can be a player as well.
|
||||
|
|
@ -291,7 +291,7 @@ void ArrowAttachItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
if ((cursorItem != targetItem) && targetItem) {
|
||||
if (cursorItem != targetItem && targetItem) {
|
||||
targetItem->setBeingPointedAt(false);
|
||||
}
|
||||
if (!cursorItem) {
|
||||
|
|
@ -349,7 +349,7 @@ void ArrowAttachItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
child->setTargetLocked(true);
|
||||
}
|
||||
|
||||
if (targetItem && (targetItem != startItem)) {
|
||||
if (targetItem && targetItem != startItem) {
|
||||
auto startCard = qgraphicsitem_cast<CardItem *>(startItem);
|
||||
auto targetCard = qgraphicsitem_cast<CardItem *>(targetItem);
|
||||
if (startCard && targetCard) {
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ void CardDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
QList<CardDragItem *> dragItemList;
|
||||
CardZoneLogic *startZone = static_cast<CardItem *>(item)->getZone();
|
||||
if (currentZone && !(static_cast<CardItem *>(item)->getAttachedTo() && (startZone == currentZone->getLogic()))) {
|
||||
if (currentZone && !(static_cast<CardItem *>(item)->getAttachedTo() && startZone == currentZone->getLogic())) {
|
||||
if (!occupied) {
|
||||
dragItemList.append(this);
|
||||
}
|
||||
|
|
@ -118,7 +118,7 @@ void CardDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
for (int i = 0; i < childDrags.size(); i++) {
|
||||
CardDragItem *c = static_cast<CardDragItem *>(childDrags[i]);
|
||||
if (!occupied &&
|
||||
!(static_cast<CardItem *>(c->item)->getAttachedTo() && (startZone == currentZone->getLogic())) &&
|
||||
!(static_cast<CardItem *>(c->item)->getAttachedTo() && startZone == currentZone->getLogic()) &&
|
||||
!c->occupied) {
|
||||
dragItemList.append(c);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
int childIndex = 0;
|
||||
for (const auto &item : scene()->selectedItems()) {
|
||||
CardItem *card = static_cast<CardItem *>(item);
|
||||
if ((card == this) || (card->getZone() != zone))
|
||||
if (card == this || card->getZone() != zone)
|
||||
continue;
|
||||
++childIndex;
|
||||
QPointF childPos;
|
||||
|
|
@ -436,8 +436,8 @@ void CardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
return;
|
||||
}
|
||||
}
|
||||
} else if ((event->modifiers() != Qt::AltModifier) && (event->button() == Qt::LeftButton) &&
|
||||
(!SettingsCache::instance().getDoubleClickToPlay())) {
|
||||
} else if (event->modifiers() != Qt::AltModifier && event->button() == Qt::LeftButton &&
|
||||
!SettingsCache::instance().getDoubleClickToPlay()) {
|
||||
handleClickedToPlay(event->modifiers().testFlag(Qt::ShiftModifier));
|
||||
}
|
||||
|
||||
|
|
@ -449,8 +449,8 @@ void CardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
void CardItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if ((event->modifiers() != Qt::AltModifier) && (event->buttons() == Qt::LeftButton) &&
|
||||
(SettingsCache::instance().getDoubleClickToPlay())) {
|
||||
if (event->modifiers() != Qt::AltModifier && event->buttons() == Qt::LeftButton &&
|
||||
SettingsCache::instance().getDoubleClickToPlay()) {
|
||||
handleClickedToPlay(event->modifiers().testFlag(Qt::ShiftModifier));
|
||||
}
|
||||
event->accept();
|
||||
|
|
@ -464,11 +464,11 @@ bool CardItem::animationEvent()
|
|||
rotation *= -1;
|
||||
|
||||
tapAngle += rotation;
|
||||
if (tapped && (tapAngle > 90)) {
|
||||
if (tapped && tapAngle > 90) {
|
||||
tapAngle = 90;
|
||||
animationIncomplete = false;
|
||||
}
|
||||
if (!tapped && (tapAngle < 0)) {
|
||||
if (!tapped && tapAngle < 0) {
|
||||
tapAngle = 0;
|
||||
animationIncomplete = false;
|
||||
}
|
||||
|
|
@ -485,7 +485,7 @@ bool CardItem::animationEvent()
|
|||
|
||||
QVariant CardItem::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
if ((change == ItemSelectedHasChanged) && owner != nullptr) {
|
||||
if (change == ItemSelectedHasChanged && owner != nullptr) {
|
||||
if (value == true) {
|
||||
owner->getGame()->setActiveCard(this);
|
||||
owner->getPlayerMenu()->updateCardMenu(this);
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ void DeckViewCardContainer::rearrangeItems(const QList<QPair<int, int>> &rowsAnd
|
|||
std::sort(row.begin(), row.end(), DeckViewCardContainer::sortCardsByName);
|
||||
for (int j = 0; j < row.size(); ++j) {
|
||||
DeckViewCard *card = row[j];
|
||||
card->setPos(x + (j % tempCols) * CARD_WIDTH, yUntilNow + (j / tempCols) * CARD_HEIGHT);
|
||||
card->setPos(x + j % tempCols * CARD_WIDTH, yUntilNow + j / tempCols * CARD_HEIGHT);
|
||||
}
|
||||
yUntilNow += tempRows * CARD_HEIGHT + paddingY;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ void GameEventHandler::processGameEventContainer(const GameEventContainer &cont,
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
if ((game->getGameState()->getClients().size() > 1) && (playerId != -1))
|
||||
if (game->getGameState()->getClients().size() > 1 && playerId != -1)
|
||||
if (game->getGameState()->getClients().at(playerId) != client)
|
||||
continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ QSizeF GameScene::computeSceneSizeAndPlayerLayout(const QList<Player *> &players
|
|||
playersByColumn.append(QList<PlayerGraphicsItem *>());
|
||||
columnWidth.append(0);
|
||||
qreal thisColumnHeight = -playerAreaSpacing;
|
||||
int rowsInColumn = rows - (playersPlaying.size() % columns) * col; // Adjust rows for uneven columns
|
||||
int rowsInColumn = rows - playersPlaying.size() % columns * col; // Adjust rows for uneven columns
|
||||
|
||||
for (int j = 0; j < rowsInColumn; ++j) {
|
||||
Player *player = playersIter.next();
|
||||
|
|
@ -343,9 +343,9 @@ void GameScene::updateHover(const QPointF &scenePos)
|
|||
|
||||
void GameScene::updateHoveredCard(CardItem *newCard)
|
||||
{
|
||||
if (hoveredCard && (newCard != hoveredCard))
|
||||
if (hoveredCard && newCard != hoveredCard)
|
||||
hoveredCard->setHovered(false);
|
||||
if (newCard && (newCard != hoveredCard))
|
||||
if (newCard && newCard != hoveredCard)
|
||||
newCard->setHovered(true);
|
||||
hoveredCard = newCard;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ void MessageLogWidget::logMoveCard(Player *player,
|
|||
cardStr = cardLink(cardName);
|
||||
}
|
||||
|
||||
if (ownerChanged && (startZone->getPlayer() == player)) {
|
||||
if (ownerChanged && startZone->getPlayer() == player) {
|
||||
appendHtmlServerMessage(tr("%1 gives %2 control over %3.")
|
||||
.arg(sanitizeHtml(player->getPlayerInfo()->getName()))
|
||||
.arg(sanitizeHtml(targetZone->getPlayer()->getPlayerInfo()->getName()))
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ void PhaseButton::setWidth(double _width)
|
|||
|
||||
void PhaseButton::setActive(bool _active)
|
||||
{
|
||||
if ((active == _active) || !highlightable)
|
||||
if (active == _active || !highlightable)
|
||||
return;
|
||||
|
||||
active = _active;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ void PlayerActions::playCard(CardItem *card, bool faceDown)
|
|||
cmd.set_x(0);
|
||||
cmd.set_y(0);
|
||||
} else if (!faceDown &&
|
||||
((!playToStack && tableRow == 3) || ((playToStack && tableRow != 0) && currentZone != "stack"))) {
|
||||
((!playToStack && tableRow == 3) || playToStack && tableRow != 0 && currentZone != "stack")) {
|
||||
cmd.set_target_zone("stack");
|
||||
cmd.set_x(-1);
|
||||
cmd.set_y(0);
|
||||
|
|
@ -1188,7 +1188,7 @@ void PlayerActions::setCardAttrHelper(const GameEventContext &context,
|
|||
break;
|
||||
}
|
||||
case AttrDoesntUntap: {
|
||||
bool value = (avalue == "1");
|
||||
bool value = avalue == "1";
|
||||
emit logSetDoesntUntap(player, card, value);
|
||||
card->setDoesntUntap(value);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ void PlayerEventHandler::eventMoveCard(const Event_MoveCard &event, const GameEv
|
|||
card->setCardRef({name, providerId});
|
||||
}
|
||||
|
||||
if (card->getAttachedTo() && (startZone != targetZone)) {
|
||||
if (card->getAttachedTo() && startZone != targetZone) {
|
||||
CardItem *parentCard = card->getAttachedTo();
|
||||
card->setAttachedTo(nullptr);
|
||||
parentCard->getZone()->reorganizeCards();
|
||||
|
|
@ -313,7 +313,7 @@ void PlayerEventHandler::eventMoveCard(const Event_MoveCard &event, const GameEv
|
|||
QMapIterator<int, ArrowItem *> arrowIterator(p->getArrows());
|
||||
while (arrowIterator.hasNext()) {
|
||||
ArrowItem *arrow = arrowIterator.next().value();
|
||||
if ((arrow->getStartItem() == card) || (arrow->getTargetItem() == card)) {
|
||||
if (arrow->getStartItem() == card || arrow->getTargetItem() == card) {
|
||||
if (startZone == targetZone) {
|
||||
arrow->updatePath();
|
||||
} else {
|
||||
|
|
@ -409,7 +409,7 @@ void PlayerEventHandler::eventAttachCard(const Event_AttachCard &event)
|
|||
startCard->setAttachedTo(targetCard);
|
||||
|
||||
startZone->reorganizeCards();
|
||||
if ((startZone != targetZone) && targetZone) {
|
||||
if (startZone != targetZone && targetZone) {
|
||||
targetZone->reorganizeCards();
|
||||
}
|
||||
if (oldParent) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ bool PlayerListItemDelegate::editorEvent(QEvent *event,
|
|||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index)
|
||||
{
|
||||
if ((event->type() == QEvent::MouseButtonPress) && index.isValid()) {
|
||||
if (event->type() == QEvent::MouseButtonPress && index.isValid()) {
|
||||
auto *const mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
if (mouseEvent->button() == Qt::RightButton) {
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
|
|
@ -136,7 +136,8 @@ void PlayerListWidget::updatePlayerProperties(const ServerInfo_PlayerProperties
|
|||
player->setData(2, Qt::UserRole + 1, prop.ready_start());
|
||||
if (prop.has_conceded() || prop.has_ready_start())
|
||||
player->setIcon(2, gameStarted ? (prop.conceded() ? concededIcon : QIcon())
|
||||
: (prop.ready_start() ? readyIcon : notReadyIcon));
|
||||
: prop.ready_start() ? readyIcon
|
||||
: notReadyIcon);
|
||||
}
|
||||
if (prop.has_user_info()) {
|
||||
player->setData(3, Qt::UserRole, prop.user_info().user_level());
|
||||
|
|
|
|||
|
|
@ -75,18 +75,18 @@ void HandZone::reorganizeCards()
|
|||
qreal cardWidth = getLogic()->getCards().at(0)->boundingRect().width();
|
||||
const int xPadding = leftJustified ? cardWidth * 1.4 : 5;
|
||||
qreal totalWidth =
|
||||
leftJustified ? boundingRect().width() - (1 * xPadding) - 5 : boundingRect().width() - 2 * xPadding;
|
||||
leftJustified ? boundingRect().width() - 1 * xPadding - 5 : boundingRect().width() - 2 * xPadding;
|
||||
|
||||
for (int i = 0; i < cardCount; i++) {
|
||||
CardItem *c = getLogic()->getCards().at(i);
|
||||
// If the total width of the cards is smaller than the available width,
|
||||
// the cards do not need to overlap and are displayed in the center of the area.
|
||||
if (cardWidth * cardCount > totalWidth)
|
||||
c->setPos(xPadding + ((qreal)i) * (totalWidth - cardWidth) / (cardCount - 1), 5);
|
||||
c->setPos(xPadding + (qreal)i * (totalWidth - cardWidth) / (cardCount - 1), 5);
|
||||
else {
|
||||
qreal xPosition =
|
||||
leftJustified ? xPadding + ((qreal)i) * cardWidth
|
||||
: xPadding + ((qreal)i) * cardWidth + (totalWidth - cardCount * cardWidth) / 2;
|
||||
qreal xPosition = leftJustified
|
||||
? xPadding + (qreal)i * cardWidth
|
||||
: xPadding + (qreal)i * cardWidth + (totalWidth - cardCount * cardWidth) / 2;
|
||||
c->setPos(xPosition, 5);
|
||||
}
|
||||
c->setRealZValue(i);
|
||||
|
|
@ -100,7 +100,7 @@ void HandZone::reorganizeCards()
|
|||
|
||||
for (int i = 0; i < cardCount; i++) {
|
||||
CardItem *card = getLogic()->getCards().at(i);
|
||||
qreal x = (i % 2) ? x2 : x1;
|
||||
qreal x = i % 2 ? x2 : x1;
|
||||
qreal y = divideCardSpaceInZone(i, cardCount, boundingRect().height(),
|
||||
getLogic()->getCards().at(0)->boundingRect().height());
|
||||
card->setPos(x, y);
|
||||
|
|
|
|||
|
|
@ -174,41 +174,40 @@ QString CardZoneLogic::getTranslatedName(bool theirOwn, GrammaticalCase gc) cons
|
|||
{
|
||||
QString ownerName = player->getPlayerInfo()->getName();
|
||||
if (name == "hand")
|
||||
return (theirOwn ? tr("their hand", "nominative") : tr("%1's hand", "nominative").arg(ownerName));
|
||||
return theirOwn ? tr("their hand", "nominative") : tr("%1's hand", "nominative").arg(ownerName);
|
||||
else if (name == "deck")
|
||||
switch (gc) {
|
||||
case CaseLookAtZone:
|
||||
return (theirOwn ? tr("their library", "look at zone")
|
||||
: tr("%1's library", "look at zone").arg(ownerName));
|
||||
return theirOwn ? tr("their library", "look at zone")
|
||||
: tr("%1's library", "look at zone").arg(ownerName);
|
||||
case CaseTopCardsOfZone:
|
||||
return (theirOwn ? tr("of their library", "top cards of zone,")
|
||||
: tr("of %1's library", "top cards of zone").arg(ownerName));
|
||||
return theirOwn ? tr("of their library", "top cards of zone,")
|
||||
: tr("of %1's library", "top cards of zone").arg(ownerName);
|
||||
case CaseRevealZone:
|
||||
return (theirOwn ? tr("their library", "reveal zone")
|
||||
: tr("%1's library", "reveal zone").arg(ownerName));
|
||||
return theirOwn ? tr("their library", "reveal zone") : tr("%1's library", "reveal zone").arg(ownerName);
|
||||
case CaseShuffleZone:
|
||||
return (theirOwn ? tr("their library", "shuffle") : tr("%1's library", "shuffle").arg(ownerName));
|
||||
return theirOwn ? tr("their library", "shuffle") : tr("%1's library", "shuffle").arg(ownerName);
|
||||
default:
|
||||
return (theirOwn ? tr("their library", "nominative") : tr("%1's library", "nominative").arg(ownerName));
|
||||
return theirOwn ? tr("their library", "nominative") : tr("%1's library", "nominative").arg(ownerName);
|
||||
}
|
||||
else if (name == "grave")
|
||||
return (theirOwn ? tr("their graveyard", "nominative") : tr("%1's graveyard", "nominative").arg(ownerName));
|
||||
return theirOwn ? tr("their graveyard", "nominative") : tr("%1's graveyard", "nominative").arg(ownerName);
|
||||
else if (name == "rfg")
|
||||
return (theirOwn ? tr("their exile", "nominative") : tr("%1's exile", "nominative").arg(ownerName));
|
||||
return theirOwn ? tr("their exile", "nominative") : tr("%1's exile", "nominative").arg(ownerName);
|
||||
else if (name == "sb")
|
||||
switch (gc) {
|
||||
case CaseLookAtZone:
|
||||
return (theirOwn ? tr("their sideboard", "look at zone")
|
||||
: tr("%1's sideboard", "look at zone").arg(ownerName));
|
||||
return theirOwn ? tr("their sideboard", "look at zone")
|
||||
: tr("%1's sideboard", "look at zone").arg(ownerName);
|
||||
case CaseNominative:
|
||||
return (theirOwn ? tr("their sideboard", "nominative")
|
||||
: tr("%1's sideboard", "nominative").arg(ownerName));
|
||||
return theirOwn ? tr("their sideboard", "nominative")
|
||||
: tr("%1's sideboard", "nominative").arg(ownerName);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
else {
|
||||
return (theirOwn ? tr("their custom zone '%1'", "nominative").arg(name)
|
||||
: tr("%1's custom zone '%2'", "nominative").arg(ownerName).arg(name));
|
||||
return theirOwn ? tr("their custom zone '%1'", "nominative").arg(name)
|
||||
: tr("%1's custom zone '%2'", "nominative").arg(ownerName).arg(name);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
|
@ -103,8 +103,7 @@ void PileZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
bool faceDown = event->modifiers().testFlag(Qt::ShiftModifier);
|
||||
bool bottomCard = event->modifiers().testFlag(Qt::ControlModifier);
|
||||
CardItem *card = bottomCard ? getLogic()->getCards().last() : getLogic()->getCards().first();
|
||||
const int cardid =
|
||||
getLogic()->contentsKnown() ? card->getId() : (bottomCard ? getLogic()->getCards().size() - 1 : 0);
|
||||
const int cardid = getLogic()->contentsKnown() ? card->getId() : bottomCard ? getLogic()->getCards().size() - 1 : 0;
|
||||
CardDragItem *drag = card->createDragItem(cardid, event->pos(), event->scenePos(), faceDown);
|
||||
drag->grabMouse();
|
||||
setCursor(Qt::OpenHandCursor);
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ void StackZone::reorganizeCards()
|
|||
|
||||
for (int i = 0; i < cardCount; i++) {
|
||||
CardItem *card = getLogic()->getCards().at(i);
|
||||
qreal x = (i % 2) ? x2 : x1;
|
||||
qreal x = i % 2 ? x2 : x1;
|
||||
qreal y = divideCardSpaceInZone(i, cardCount, boundingRect().height(),
|
||||
getLogic()->getCards().at(0)->boundingRect().height());
|
||||
card->setPos(x, y);
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ QRectF TableZone::boundingRect() const
|
|||
|
||||
bool TableZone::isInverted() const
|
||||
{
|
||||
return ((getLogic()->getPlayer()->getGraphicsItem()->getMirrored() &&
|
||||
return (getLogic()->getPlayer()->getGraphicsItem()->getMirrored() &&
|
||||
!SettingsCache::instance().getInvertVerticalCoordinate()) ||
|
||||
(!getLogic()->getPlayer()->getGraphicsItem()->getMirrored() &&
|
||||
SettingsCache::instance().getInvertVerticalCoordinate()));
|
||||
SettingsCache::instance().getInvertVerticalCoordinate());
|
||||
}
|
||||
|
||||
void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
||||
|
|
@ -229,7 +229,7 @@ void TableZone::resizeToContents()
|
|||
|
||||
// Minimum width is the rightmost card position plus enough room for
|
||||
// another card with padding, then margin.
|
||||
currentMinimumWidth = xMax + (2 * CARD_WIDTH) + PADDING_X + MARGIN_RIGHT;
|
||||
currentMinimumWidth = xMax + 2 * CARD_WIDTH + PADDING_X + MARGIN_RIGHT;
|
||||
|
||||
if (currentMinimumWidth < MIN_WIDTH)
|
||||
currentMinimumWidth = MIN_WIDTH;
|
||||
|
|
@ -291,7 +291,7 @@ QPointF TableZone::mapFromGrid(QPoint gridPoint) const
|
|||
qreal x, y;
|
||||
|
||||
// Start with margin plus stacked card offset
|
||||
x = MARGIN_LEFT + (gridPoint.x() % 3) * STACKED_CARD_OFFSET_X;
|
||||
x = MARGIN_LEFT + gridPoint.x() % 3 * STACKED_CARD_OFFSET_X;
|
||||
|
||||
// Add in width of card stack plus padding for each column
|
||||
for (int i = 0; i < gridPoint.x() / 3; ++i) {
|
||||
|
|
@ -303,7 +303,7 @@ QPointF TableZone::mapFromGrid(QPoint gridPoint) const
|
|||
gridPoint.setY(TABLEROWS - 1 - gridPoint.y());
|
||||
|
||||
// Start with margin plus stacked card offset
|
||||
y = MARGIN_TOP + (gridPoint.x() % 3) * STACKED_CARD_OFFSET_Y;
|
||||
y = MARGIN_TOP + gridPoint.x() % 3 * STACKED_CARD_OFFSET_Y;
|
||||
|
||||
// Add in card size and padding for each row
|
||||
for (int i = 0; i < gridPoint.y(); ++i)
|
||||
|
|
@ -342,7 +342,7 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
|
|||
int xStack = 0;
|
||||
int xNextStack = 0;
|
||||
int nextStackCol = 0;
|
||||
while ((xNextStack <= x) && (xNextStack <= xMax)) {
|
||||
while (xNextStack <= x && xNextStack <= xMax) {
|
||||
xStack = xNextStack;
|
||||
const int key = getCardStackMapKey(nextStackCol, gridPointY);
|
||||
xNextStack += cardStackWidth.value(key, CARD_WIDTH) + PADDING_X;
|
||||
|
|
@ -362,7 +362,7 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
|
|||
QPointF TableZone::closestGridPoint(const QPointF &point)
|
||||
{
|
||||
QPoint gridPoint = mapToGrid(point);
|
||||
gridPoint.setX((gridPoint.x() / 3) * 3);
|
||||
gridPoint.setX(gridPoint.x() / 3 * 3);
|
||||
if (getCardFromGrid(gridPoint))
|
||||
gridPoint.setX(gridPoint.x() + 1);
|
||||
if (getCardFromGrid(gridPoint))
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ private:
|
|||
/*
|
||||
Minimum width of the table zone including margins.
|
||||
*/
|
||||
static const int MIN_WIDTH = MARGIN_LEFT + (5 * CARD_WIDTH) + MARGIN_RIGHT;
|
||||
static const int MIN_WIDTH = MARGIN_LEFT + 5 * CARD_WIDTH + MARGIN_RIGHT;
|
||||
|
||||
/*
|
||||
Offset sizes when cards are stacked on each other in the grid
|
||||
|
|
@ -196,7 +196,7 @@ private:
|
|||
*/
|
||||
[[nodiscard]] int getCardStackMapKey(int x, int y) const
|
||||
{
|
||||
return x + (y * 1000);
|
||||
return x + y * 1000;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ void ZoneViewZone::initializeCards(const QList<const ServerInfo_Card *> &cardLis
|
|||
getLogic()->getPlayer()->getPlayerActions()->sendGameCommand(pend);
|
||||
} else {
|
||||
const CardList &c = qobject_cast<ZoneViewZoneLogic *>(getLogic())->getOriginalZone()->getCards();
|
||||
int number = numberCards == -1 ? c.size() : (numberCards < c.size() ? numberCards : c.size());
|
||||
int number = numberCards == -1 ? c.size() : numberCards < c.size() ? numberCards : c.size();
|
||||
for (int i = 0; i < number; i++) {
|
||||
CardItem *card = c.at(i);
|
||||
getLogic()->addCard(new CardItem(getLogic()->getPlayer(), this, card->getCardRef(), card->getId()), false,
|
||||
|
|
@ -160,8 +160,8 @@ void ZoneViewZone::reorganizeCards()
|
|||
// determine bounding rect
|
||||
qreal aleft = 0;
|
||||
qreal atop = 0;
|
||||
qreal awidth = gridSize.cols * CARD_WIDTH + (CARD_WIDTH / 2) + HORIZONTAL_PADDING;
|
||||
qreal aheight = (gridSize.rows * CARD_HEIGHT) / 3 + CARD_HEIGHT * 1.3;
|
||||
qreal awidth = gridSize.cols * CARD_WIDTH + CARD_WIDTH / 2 + HORIZONTAL_PADDING;
|
||||
qreal aheight = gridSize.rows * CARD_HEIGHT / 3 + CARD_HEIGHT * 1.3;
|
||||
optimumRect = QRectF(aleft, atop, awidth, aheight);
|
||||
|
||||
updateGeometry();
|
||||
|
|
@ -232,8 +232,8 @@ ZoneViewZone::GridSize ZoneViewZone::positionCardsForDisplay(CardList &cards, Ca
|
|||
|
||||
for (int i = 0; i < cardCount; i++) {
|
||||
CardItem *c = cards.at(i);
|
||||
qreal x = (i / rows) * CARD_WIDTH;
|
||||
qreal y = (i % rows) * CARD_HEIGHT / 3;
|
||||
qreal x = i / rows * CARD_WIDTH;
|
||||
qreal y = i % rows * CARD_HEIGHT / 3;
|
||||
c->setPos(HORIZONTAL_PADDING + x, VERTICAL_PADDING + y);
|
||||
c->setRealZValue(i);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -386,9 +386,9 @@ void ZoneViewWidget::expandWindow()
|
|||
// reset window to initial max height if...
|
||||
bool doResetSize =
|
||||
// current height is less than that
|
||||
(height < maxInitialHeight) ||
|
||||
height < maxInitialHeight ||
|
||||
// current height is at expanded max height
|
||||
(height == maxExpandedHeight) ||
|
||||
height == maxExpandedHeight ||
|
||||
// current height is at actual max height, and actual max height is less than expanded max height
|
||||
(height == maxHeight && height > maxInitialHeight && height < maxExpandedHeight);
|
||||
|
||||
|
|
|
|||
|
|
@ -38,12 +38,14 @@ void AbstractGraphicsItem::paintNumberEllipse(int number,
|
|||
qreal yOffset = 20;
|
||||
qreal spacing = 2;
|
||||
if (position < 2)
|
||||
textRect = QRectF(count == 1 ? ((boundingRect().width() - w) / 2.0)
|
||||
: (position % 2 == 0 ? xOffset : (boundingRect().width() - xOffset - w)),
|
||||
textRect = QRectF(count == 1 ? (boundingRect().width() - w) / 2.0
|
||||
: position % 2 == 0 ? xOffset
|
||||
: boundingRect().width() - xOffset - w,
|
||||
yOffset, w, h);
|
||||
else
|
||||
textRect = QRectF(count == 3 ? ((boundingRect().width() - w) / 2.0)
|
||||
: (position % 2 == 0 ? xOffset : (boundingRect().width() - xOffset - w)),
|
||||
textRect = QRectF(count == 3 ? (boundingRect().width() - w) / 2.0
|
||||
: position % 2 == 0 ? xOffset
|
||||
: boundingRect().width() - xOffset - w,
|
||||
yOffset + (spacing + h) * (position / 2), w, h);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -307,8 +307,8 @@ QString DeckLoader::exportDeckToDecklist(const DeckList *deckList, DecklistWebsi
|
|||
sideBoardCards.chop(3);
|
||||
// if after we've called it for each card, and the strings are empty, we know that
|
||||
// there were no non-token cards in the deck, so show an error message.
|
||||
if ((QString::compare(mainBoardCards, "", Qt::CaseInsensitive) == 0) &&
|
||||
(QString::compare(sideBoardCards, "", Qt::CaseInsensitive) == 0)) {
|
||||
if (QString::compare(mainBoardCards, "", Qt::CaseInsensitive) == 0 &&
|
||||
QString::compare(sideBoardCards, "", Qt::CaseInsensitive) == 0) {
|
||||
return "";
|
||||
}
|
||||
// return a string with the url for decklist export
|
||||
|
|
@ -672,7 +672,7 @@ void DeckLoader::printDeckListNode(QTextCursor *cursor, InnerDecklistNode *node)
|
|||
|
||||
QTextTable *table = cursor->insertTable(1, totalColumns, tableFormat);
|
||||
for (int i = 0; i < node->size(); i++) {
|
||||
QTextCursor cellCursor = table->cellAt(0, (i * totalColumns) / node->size()).lastCursorPosition();
|
||||
QTextCursor cellCursor = table->cellAt(0, i * totalColumns / node->size()).lastCursorPosition();
|
||||
printDeckListNode(&cellCursor, dynamic_cast<InnerDecklistNode *>(node->at(i)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -575,7 +575,7 @@ int FlowLayout::count() const
|
|||
*/
|
||||
QLayoutItem *FlowLayout::itemAt(const int index) const
|
||||
{
|
||||
return (index >= 0 && index < items.size()) ? items.value(index) : nullptr;
|
||||
return index >= 0 && index < items.size() ? items.value(index) : nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -585,7 +585,7 @@ QLayoutItem *FlowLayout::itemAt(const int index) const
|
|||
*/
|
||||
QLayoutItem *FlowLayout::takeAt(const int index)
|
||||
{
|
||||
return (index >= 0 && index < items.size()) ? items.takeAt(index) : nullptr;
|
||||
return index >= 0 && index < items.size() ? items.takeAt(index) : nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -594,7 +594,7 @@ QLayoutItem *FlowLayout::takeAt(const int index)
|
|||
*/
|
||||
int FlowLayout::horizontalSpacing() const
|
||||
{
|
||||
return (horizontalMargin >= 0) ? horizontalMargin : smartSpacing(QStyle::PM_LayoutHorizontalSpacing);
|
||||
return horizontalMargin >= 0 ? horizontalMargin : smartSpacing(QStyle::PM_LayoutHorizontalSpacing);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -603,7 +603,7 @@ int FlowLayout::horizontalSpacing() const
|
|||
*/
|
||||
int FlowLayout::verticalSpacing() const
|
||||
{
|
||||
return (verticalMargin >= 0) ? verticalMargin : smartSpacing(QStyle::PM_LayoutVerticalSpacing);
|
||||
return verticalMargin >= 0 ? verticalMargin : smartSpacing(QStyle::PM_LayoutVerticalSpacing);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ int OverlapLayout::count() const
|
|||
*/
|
||||
QLayoutItem *OverlapLayout::itemAt(const int index) const
|
||||
{
|
||||
return (index >= 0 && index < itemList.size()) ? itemList.value(index) : nullptr;
|
||||
return index >= 0 && index < itemList.size() ? itemList.value(index) : nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -121,7 +121,7 @@ QLayoutItem *OverlapLayout::itemAt(const int index) const
|
|||
*/
|
||||
QLayoutItem *OverlapLayout::takeAt(const int index)
|
||||
{
|
||||
return (index >= 0 && index < itemList.size()) ? itemList.takeAt(index) : nullptr;
|
||||
return index >= 0 && index < itemList.size() ? itemList.takeAt(index) : nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -163,8 +163,8 @@ void OverlapLayout::setGeometry(const QRect &rect)
|
|||
}
|
||||
|
||||
// Calculate the overlap offsets based on the layout direction and overlap percentage.
|
||||
const int overlapOffsetWidth = (overlapDirection == Qt::Horizontal) ? (maxItemWidth * overlapPercentage / 100) : 0;
|
||||
const int overlapOffsetHeight = (overlapDirection == Qt::Vertical) ? (maxItemHeight * overlapPercentage / 100) : 0;
|
||||
const int overlapOffsetWidth = overlapDirection == Qt::Horizontal ? maxItemWidth * overlapPercentage / 100 : 0;
|
||||
const int overlapOffsetHeight = overlapDirection == Qt::Vertical ? maxItemHeight * overlapPercentage / 100 : 0;
|
||||
|
||||
// Determine the number of columns based on layout constraints and available space.
|
||||
int columns;
|
||||
|
|
@ -275,8 +275,8 @@ QSize OverlapLayout::calculatePreferredSize() const
|
|||
}
|
||||
|
||||
// Calculate the overlap offsets based on the layout direction and overlap percentage.
|
||||
const int overlapOffsetWidth = (overlapDirection == Qt::Horizontal) ? (maxItemWidth * overlapPercentage / 100) : 0;
|
||||
const int overlapOffsetHeight = (overlapDirection == Qt::Vertical) ? (maxItemHeight * overlapPercentage / 100) : 0;
|
||||
const int overlapOffsetWidth = overlapDirection == Qt::Horizontal ? maxItemWidth * overlapPercentage / 100 : 0;
|
||||
const int overlapOffsetHeight = overlapDirection == Qt::Vertical ? maxItemHeight * overlapPercentage / 100 : 0;
|
||||
|
||||
// Determine the number of columns based on layout constraints and available space.
|
||||
int columns;
|
||||
|
|
@ -321,11 +321,11 @@ QSize OverlapLayout::calculatePreferredSize() const
|
|||
}
|
||||
|
||||
if (overlapDirection == Qt::Horizontal) {
|
||||
return QSize(maxItemWidth + ((qCeil(itemList.size() / rows)) * (maxItemWidth - overlapOffsetWidth)),
|
||||
return QSize(maxItemWidth + qCeil(itemList.size() / rows) * (maxItemWidth - overlapOffsetWidth),
|
||||
rows * maxItemHeight);
|
||||
} else {
|
||||
return QSize(columns * maxItemWidth,
|
||||
maxItemHeight + ((qCeil(itemList.size() / columns)) * (maxItemHeight - overlapOffsetHeight)));
|
||||
maxItemHeight + qCeil(itemList.size() / columns) * (maxItemHeight - overlapOffsetHeight));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -467,7 +467,7 @@ int OverlapLayout::calculateMaxRows() const
|
|||
}
|
||||
|
||||
// Calculate the effective height of each item with the overlap applied
|
||||
const int overlapOffsetHeight = (maxItemHeight * (100 - overlapPercentage)) / 100;
|
||||
const int overlapOffsetHeight = maxItemHeight * (100 - overlapPercentage) / 100;
|
||||
const int availableHeight = parentWidget() ? parentWidget()->height() : 0;
|
||||
|
||||
// Determine the maximum number of rows that can fit
|
||||
|
|
|
|||
|
|
@ -125,10 +125,10 @@ QPixmap PingPixmapGenerator::generatePixmap(int size, int value, int max)
|
|||
pixmap.fill(Qt::transparent);
|
||||
QPainter painter(&pixmap);
|
||||
QColor color;
|
||||
if ((max == -1) || (value == -1))
|
||||
if (max == -1 || value == -1)
|
||||
color = Qt::black;
|
||||
else
|
||||
color.setHsv(120 * (1.0 - ((double)value / max)), 255, 255);
|
||||
color.setHsv(120 * (1.0 - (double)value / max), 255, 255);
|
||||
|
||||
QRadialGradient g(QPointF((double)pixmap.width() / 2, (double)pixmap.height() / 2),
|
||||
qMin(pixmap.width(), pixmap.height()) / 2.0);
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ void ColorIdentityWidget::resizeEvent(QResizeEvent *event)
|
|||
|
||||
int spacing = layout->spacing();
|
||||
int count = manaSymbols.size();
|
||||
int availableWidth = totalWidth - (spacing * (count - 1));
|
||||
int availableWidth = totalWidth - spacing * (count - 1);
|
||||
int iconSize = qMin(availableWidth / count, totalHeight); // Ensure icons fit within the new height
|
||||
|
||||
for (ManaSymbolWidget *manaSymbol : manaSymbols) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ void ManaCostWidget::resizeEvent(QResizeEvent *event)
|
|||
int count = manaSymbols.size();
|
||||
|
||||
// Available width minus total spacing
|
||||
int availableWidth = totalWidth - (spacing * (count - 1));
|
||||
int availableWidth = totalWidth - spacing * (count - 1);
|
||||
int iconSize = qMin(50, availableWidth / count);
|
||||
|
||||
for (ManaSymbolWidget *manaSymbol : manaSymbols) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ QVariant DeckListStyleProxy::data(const QModelIndex &index, int role) const
|
|||
if (isCard) {
|
||||
const bool legal =
|
||||
true; // TODO: Not implemented yet. QIdentityProxyModel::data(index, DeckRoles::IsLegalRole).toBool();
|
||||
int base = 255 - (index.row() % 2) * 30;
|
||||
int base = 255 - index.row() % 2 * 30;
|
||||
return legal ? QBrush(QColor(base, base, base)) : QBrush(QColor(255, base / 3, base / 3));
|
||||
} else {
|
||||
int depth = src.data(DeckRoles::DepthRole).toInt();
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ void DlgConnect::updateDisplayInfo(const QString &saveName)
|
|||
<< "";
|
||||
}
|
||||
|
||||
bool savePasswordStatus = (_data.at(5) == "1");
|
||||
bool savePasswordStatus = _data.at(5) == "1";
|
||||
|
||||
saveEdit->setText(_data.at(0));
|
||||
hostEdit->setText(_data.at(1));
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ void WndSets::actToggleButtons(const QItemSelection &selected, const QItemSelect
|
|||
aBottom->setDisabled(emptySelection || setOrderIsSorted);
|
||||
|
||||
int rows = view->selectionModel()->selectedRows().size();
|
||||
rebuildMainLayout((rows > 1) ? SOME_SETS_SELECTED : NO_SETS_SELECTED);
|
||||
rebuildMainLayout(rows > 1 ? SOME_SETS_SELECTED : NO_SETS_SELECTED);
|
||||
}
|
||||
|
||||
void WndSets::selectRows(QSet<int> rows)
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ void BannerWidget::paintEvent(QPaintEvent *event)
|
|||
QPainter painter(this);
|
||||
|
||||
// Calculate alpha based on transparency percentage
|
||||
int alpha = (255 * transparency) / 100;
|
||||
int alpha = 255 * transparency / 100;
|
||||
|
||||
// Determine gradient direction
|
||||
QLinearGradient gradient;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ QSize BarWidget::sizeHint() const
|
|||
int valueHeight = metrics.height();
|
||||
|
||||
// Calculate the height dynamically based on the total
|
||||
int barHeight = (total > 0) ? (value * 200 / total) : 20; // Scale height proportionally
|
||||
int barHeight = total > 0 ? value * 200 / total : 20; // Scale height proportionally
|
||||
int totalHeight = barHeight + labelHeight + valueHeight + 30; // Extra space for text
|
||||
return QSize(60, totalHeight); // Allow width to expand
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ void BarWidget::paintEvent(QPaintEvent *event)
|
|||
// Calculate bar dimensions
|
||||
int barWidth = widgetWidth * 0.8; // Use 80% of the available width
|
||||
int fullBarHeight = widgetHeight - 40; // Leave space for labels
|
||||
int valueBarHeight = (total > 0) ? (value * fullBarHeight / total) : 0;
|
||||
int valueBarHeight = total > 0 ? value * fullBarHeight / total : 0;
|
||||
|
||||
// Draw full bar background (gray)
|
||||
painter.setBrush(QColor(200, 200, 200));
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ float DynamicFontSizeLabel::getWidgetMaximumFontSize(QWidget *widget, const QStr
|
|||
}
|
||||
|
||||
/* Only stop when step is small enough and new size is smaller than QWidget */
|
||||
while (step > FONT_PRECISION || (currentHeight > widgetHeight) || (currentWidth > widgetWidth)) {
|
||||
while (step > FONT_PRECISION || currentHeight > widgetHeight || currentWidth > widgetWidth) {
|
||||
/* Keep last tested value */
|
||||
lastTestedSize = currentSize;
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ float DynamicFontSizeLabel::getWidgetMaximumFontSize(QWidget *widget, const QStr
|
|||
currentWidth = newFontSizeRect.width();
|
||||
|
||||
/* If new font size is too big, decrease it */
|
||||
if ((currentHeight > widgetHeight) || (currentWidth > widgetWidth)) {
|
||||
if (currentHeight > widgetHeight || currentWidth > widgetWidth) {
|
||||
// qDebug() << "-- contentsRect()" << label->contentsRect() << "rect"<< label->rect() << " newFontSizeRect"
|
||||
// << newFontSizeRect << "Tight" << text << currentSize;
|
||||
currentSize -= step;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ void PercentBarWidget::paintEvent(QPaintEvent *event)
|
|||
|
||||
const double halfWidth = rect.width() / 2.0;
|
||||
|
||||
const int barLength = static_cast<int>((qAbs(valueToDisplay) / 100.0) * halfWidth);
|
||||
const int barLength = static_cast<int>(qAbs(valueToDisplay) / 100.0 * halfWidth);
|
||||
|
||||
QRect fillRect;
|
||||
if (valueToDisplay > 0.0) {
|
||||
|
|
@ -40,7 +40,7 @@ void PercentBarWidget::paintEvent(QPaintEvent *event)
|
|||
const int tickHeight = 4;
|
||||
|
||||
for (int percent = -100; percent <= 100; percent += 10) {
|
||||
int x = midX + static_cast<int>((percent / 100.0) * halfWidth);
|
||||
int x = midX + static_cast<int>(percent / 100.0 * halfWidth);
|
||||
painter.drawLine(x, height - tickHeight, x, height);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ void PrintingSelectorCardOverlayWidget::updatePinBadgeVisibility()
|
|||
const auto &preferredProviderId =
|
||||
SettingsCache::instance().cardOverrides().getCardPreferenceOverride(rootCard.getName());
|
||||
const auto &cardProviderId = rootCard.getPrinting().getUuid();
|
||||
const bool isPinned = (!preferredProviderId.isEmpty() && preferredProviderId == cardProviderId);
|
||||
const bool isPinned = !preferredProviderId.isEmpty() && preferredProviderId == cardProviderId;
|
||||
|
||||
// Toggle the badge once; the pixmap was already rasterized in initializePinBadge().
|
||||
pinBadge->setVisible(isPinned);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ ReplayManager::ReplayManager(TabGame *parent, GameReplay *_replay)
|
|||
const int eventCount = replay->event_list_size();
|
||||
for (int i = 0; i < eventCount; ++i) {
|
||||
int j = i + 1;
|
||||
while ((j < eventCount) && (replay->event_list(j).seconds_elapsed() == lastEventTimestamp))
|
||||
while (j < eventCount && replay->event_list(j).seconds_elapsed() == lastEventTimestamp)
|
||||
++j;
|
||||
|
||||
const int numberEventsThisSecond = j - i;
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ void ReplayTimelineWidget::processNewEvents(PlaybackMode playbackMode)
|
|||
{
|
||||
currentProcessedTime = currentVisualTime;
|
||||
|
||||
while ((currentEvent < replayTimeline.size()) && (replayTimeline[currentEvent] < currentProcessedTime)) {
|
||||
while (currentEvent < replayTimeline.size() && replayTimeline[currentEvent] < currentProcessedTime) {
|
||||
EventProcessingOptions options;
|
||||
|
||||
// backwards skip => always skip reveal windows
|
||||
|
|
|
|||
|
|
@ -103,9 +103,8 @@ void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold,
|
|||
{
|
||||
bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
|
||||
|
||||
QString htmlText =
|
||||
"<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : serverMessageColor.name()) + ">" +
|
||||
QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + "</font>";
|
||||
QString htmlText = "<font color=" + (optionalFontColor.size() > 0 ? optionalFontColor : serverMessageColor.name()) +
|
||||
">" + QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + "</font>";
|
||||
|
||||
if (optionalIsBold)
|
||||
htmlText = "<b>" + htmlText + "</b>";
|
||||
|
|
@ -326,7 +325,7 @@ void ChatView::checkMention(QTextCursor &cursor, QString &message, const QString
|
|||
const static auto notALetterOrNumber = QRegularExpression("[^a-zA-Z0-9]");
|
||||
|
||||
int firstSpace = message.indexOf(' ');
|
||||
QString fullMentionUpToSpaceOrEnd = (firstSpace == -1) ? message.mid(1) : message.mid(1, firstSpace - 1);
|
||||
QString fullMentionUpToSpaceOrEnd = firstSpace == -1 ? message.mid(1) : message.mid(1, firstSpace - 1);
|
||||
QString mentionIntact = fullMentionUpToSpaceOrEnd;
|
||||
|
||||
while (fullMentionUpToSpaceOrEnd.size()) {
|
||||
|
|
@ -453,8 +452,8 @@ bool ChatView::isModeratorSendingGlobal(QFlags<ServerInfo_User::UserLevelFlag> u
|
|||
QStringList getAttentionList;
|
||||
getAttentionList << "/all"; // Send a message to all users
|
||||
|
||||
return (getAttentionList.contains(message) &&
|
||||
(userLevel & ServerInfo_User::IsModerator || userLevel & ServerInfo_User::IsAdmin));
|
||||
return getAttentionList.contains(message) &&
|
||||
(userLevel & ServerInfo_User::IsModerator || userLevel & ServerInfo_User::IsAdmin);
|
||||
}
|
||||
|
||||
void ChatView::actMessageClicked()
|
||||
|
|
@ -540,7 +539,7 @@ QTextFragment ChatView::getFragmentUnderMouse(const QPoint &pos) const
|
|||
QTextCursor cursor(cursorForPosition(pos));
|
||||
QTextBlock block(cursor.block());
|
||||
QTextBlock::iterator it;
|
||||
for (it = block.begin(); !(it.atEnd()); ++it) {
|
||||
for (it = block.begin(); !it.atEnd(); ++it) {
|
||||
QTextFragment frag = it.fragment();
|
||||
if (frag.contains(cursor.position()))
|
||||
return frag;
|
||||
|
|
@ -580,7 +579,7 @@ void ChatView::mousePressEvent(QMouseEvent *event)
|
|||
{
|
||||
switch (hoveredItemType) {
|
||||
case HoveredCard: {
|
||||
if ((event->button() == Qt::MiddleButton) || (event->button() == Qt::LeftButton))
|
||||
if (event->button() == Qt::MiddleButton || event->button() == Qt::LeftButton)
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
emit showCardInfoPopup(event->globalPosition().toPoint(), {hoveredContent});
|
||||
#else
|
||||
|
|
@ -623,15 +622,16 @@ void ChatView::mousePressEvent(QMouseEvent *event)
|
|||
|
||||
void ChatView::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if ((event->button() == Qt::MiddleButton) || (event->button() == Qt::LeftButton))
|
||||
if (event->button() == Qt::MiddleButton || event->button() == Qt::LeftButton) {
|
||||
emit deleteCardInfoPopup(QString("_"));
|
||||
}
|
||||
|
||||
QTextBrowser::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void ChatView::openLink(const QUrl &link)
|
||||
{
|
||||
if ((link.scheme() == "card") || (link.scheme() == "user"))
|
||||
if (link.scheme() == "card" || link.scheme() == "user")
|
||||
return;
|
||||
|
||||
QDesktopServices::openUrl(link);
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
|
|||
return index.row();
|
||||
if (role != Qt::DisplayRole && role != SORT_ROLE && role != Qt::DecorationRole && role != Qt::TextAlignmentRole)
|
||||
return QVariant();
|
||||
if ((index.row() >= gameList.size()) || (index.column() >= columnCount()))
|
||||
if (index.row() >= gameList.size() || index.column() >= columnCount())
|
||||
return QVariant();
|
||||
|
||||
const ServerInfo_Game &gameentry = gameList[index.row()];
|
||||
|
|
@ -212,7 +212,7 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
|
|||
|
||||
QVariant GamesModel::headerData(int section, Qt::Orientation /*orientation*/, int role) const
|
||||
{
|
||||
if ((role != Qt::DisplayRole) && (role != Qt::TextAlignmentRole))
|
||||
if (role != Qt::DisplayRole && role != Qt::TextAlignmentRole)
|
||||
return QVariant();
|
||||
switch (section) {
|
||||
case ROOM:
|
||||
|
|
|
|||
|
|
@ -191,8 +191,8 @@ void UserContextMenu::banUserHistory_processResponse(const Response &resp)
|
|||
}
|
||||
|
||||
table->resizeColumnsToContents();
|
||||
table->setMinimumSize(table->horizontalHeader()->length() + (table->columnCount() * 5),
|
||||
table->verticalHeader()->length() + (table->rowCount() * 3));
|
||||
table->setMinimumSize(table->horizontalHeader()->length() + table->columnCount() * 5,
|
||||
table->verticalHeader()->length() + table->rowCount() * 3);
|
||||
table->show();
|
||||
} else
|
||||
QMessageBox::information(static_cast<QWidget *>(parent()), tr("Ban History"),
|
||||
|
|
@ -227,8 +227,8 @@ void UserContextMenu::warnUserHistory_processResponse(const Response &resp)
|
|||
}
|
||||
|
||||
table->resizeColumnsToContents();
|
||||
table->setMinimumSize(table->horizontalHeader()->length() + (table->columnCount() * 5),
|
||||
table->verticalHeader()->length() + (table->rowCount() * 3));
|
||||
table->setMinimumSize(table->horizontalHeader()->length() + table->columnCount() * 5,
|
||||
table->verticalHeader()->length() + table->rowCount() * 3);
|
||||
table->show();
|
||||
} else
|
||||
QMessageBox::information(static_cast<QWidget *>(parent()), tr("Warning History"),
|
||||
|
|
@ -396,20 +396,20 @@ void UserContextMenu::showContextMenu(const QPoint &pos,
|
|||
|
||||
menu->addSeparator();
|
||||
if (userLevel.testFlag(ServerInfo_User::IsModerator) &&
|
||||
(tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsAdmin)) {
|
||||
tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsAdmin) {
|
||||
menu->addAction(aDemoteFromMod);
|
||||
|
||||
} else if (userLevel.testFlag(ServerInfo_User::IsRegistered) &&
|
||||
(tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsAdmin)) {
|
||||
tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsAdmin) {
|
||||
menu->addAction(aPromoteToMod);
|
||||
}
|
||||
|
||||
if (userLevel.testFlag(ServerInfo_User::IsJudge) &&
|
||||
(tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsAdmin)) {
|
||||
tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsAdmin) {
|
||||
menu->addAction(aDemoteFromJudge);
|
||||
|
||||
} else if (userLevel.testFlag(ServerInfo_User::IsRegistered) &&
|
||||
(tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsAdmin)) {
|
||||
tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsAdmin) {
|
||||
menu->addAction(aPromoteToJudge);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ QString BanDialog::getBanIP() const
|
|||
int BanDialog::getMinutes() const
|
||||
{
|
||||
return permanentRadio->isChecked() ? 0
|
||||
: (daysEdit->value() * 24 * 60 + hoursEdit->value() * 60 + minutesEdit->value());
|
||||
: daysEdit->value() * 24 * 60 + hoursEdit->value() * 60 + minutesEdit->value();
|
||||
}
|
||||
|
||||
QString BanDialog::getReason() const
|
||||
|
|
@ -320,7 +320,7 @@ bool UserListItemDelegate::editorEvent(QEvent *event,
|
|||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index)
|
||||
{
|
||||
if ((event->type() == QEvent::MouseButtonPress) && index.isValid()) {
|
||||
if (event->type() == QEvent::MouseButtonPress && index.isValid()) {
|
||||
QMouseEvent *const mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
if (mouseEvent->button() == Qt::RightButton) {
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
|
|
@ -514,7 +514,7 @@ void UserListWidget::setUserOnline(const QString &userName, bool online)
|
|||
void UserListWidget::updateCount()
|
||||
{
|
||||
QString str = titleStr;
|
||||
if ((type == BuddyList) || (type == IgnoreList))
|
||||
if (type == BuddyList || type == IgnoreList)
|
||||
str = str.arg(onlineCount);
|
||||
setTitle(str.arg(userTree->topLevelItemCount()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@
|
|||
|
||||
static bool canBeCommander(const CardInfoPtr &cardInfo)
|
||||
{
|
||||
return ((cardInfo->getCardType().contains("Legendary", Qt::CaseInsensitive) &&
|
||||
cardInfo->getCardType().contains("Creature", Qt::CaseInsensitive))) ||
|
||||
return (cardInfo->getCardType().contains("Legendary", Qt::CaseInsensitive) &&
|
||||
cardInfo->getCardType().contains("Creature", Qt::CaseInsensitive)) ||
|
||||
cardInfo->getText().contains("can be your commander", Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -132,9 +132,9 @@ void TabMessage::processUserMessageEvent(const Event_UserMessage &event)
|
|||
|
||||
bool TabMessage::shouldShowSystemPopup(const Event_UserMessage &event)
|
||||
{
|
||||
return (QApplication::activeWindow() == 0 || QApplication::focusWidget() == 0 ||
|
||||
return QApplication::activeWindow() == 0 || QApplication::focusWidget() == 0 ||
|
||||
(event.sender_name() == otherUserInfo->name() &&
|
||||
tabSupervisor->currentIndex() != tabSupervisor->indexOf(this)));
|
||||
tabSupervisor->currentIndex() != tabSupervisor->indexOf(this));
|
||||
}
|
||||
|
||||
void TabMessage::showSystemPopup(const Event_UserMessage &event)
|
||||
|
|
|
|||
|
|
@ -454,7 +454,7 @@ void TabSupervisor::startLocal(const QList<AbstractClient *> &_clients)
|
|||
*/
|
||||
void TabSupervisor::stop()
|
||||
{
|
||||
if ((!client) && localClients.isEmpty())
|
||||
if (!client && localClients.isEmpty())
|
||||
return;
|
||||
|
||||
resetTabsMenu();
|
||||
|
|
@ -655,7 +655,7 @@ void TabSupervisor::actTabAdmin(bool checked)
|
|||
|
||||
void TabSupervisor::openTabAdmin()
|
||||
{
|
||||
tabAdmin = new TabAdmin(this, client, (userInfo->user_level() & ServerInfo_User::IsAdmin));
|
||||
tabAdmin = new TabAdmin(this, client, userInfo->user_level() & ServerInfo_User::IsAdmin);
|
||||
connect(tabAdmin, &TabAdmin::adminLockChanged, this, &TabSupervisor::adminLockChanged);
|
||||
myAddTab(tabAdmin, aTabAdmin);
|
||||
connect(tabAdmin, &QObject::destroyed, this, [this] {
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ void LineEditCompleter::setCompletionList(QStringList completionList)
|
|||
return;
|
||||
|
||||
QStringListModel *model;
|
||||
model = (QStringListModel *)(c->model());
|
||||
model = (QStringListModel *)c->model();
|
||||
if (model == NULL)
|
||||
model = new QStringListModel();
|
||||
model->setStringList(completionList);
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ int SequenceEdit::translateModifiers(Qt::KeyboardModifiers state, const QString
|
|||
int result = 0;
|
||||
// The shift modifier only counts when it is not used to type a symbol
|
||||
// that is only reachable using the shift key anyway
|
||||
if ((state & Qt::ShiftModifier) &&
|
||||
if (state & Qt::ShiftModifier &&
|
||||
(text.isEmpty() || !text.at(0).isPrint() || text.at(0).isLetterOrNumber() || text.at(0).isSpace())) {
|
||||
result |= Qt::SHIFT;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@ void VisualDeckEditorWidget::updateZoneWidgets()
|
|||
void VisualDeckEditorWidget::updateDisplayType()
|
||||
{
|
||||
// Toggle the display type
|
||||
currentDisplayType = (currentDisplayType == DisplayType::Overlap) ? DisplayType::Flat : DisplayType::Overlap;
|
||||
currentDisplayType = currentDisplayType == DisplayType::Overlap ? DisplayType::Flat : DisplayType::Overlap;
|
||||
|
||||
// Update UI and emit signal
|
||||
switch (currentDisplayType) {
|
||||
|
|
|
|||
|
|
@ -480,18 +480,17 @@ QString MainWindow::extractInvalidUsernameMessage(QString &in)
|
|||
out += tr("Your username must respect these rules:") + "<ul>";
|
||||
|
||||
out += "<li>" + tr("is %1 - %2 characters long").arg(rules.at(0)).arg(rules.at(1)) + "</li>";
|
||||
out += "<li>" + tr("can %1 contain lowercase characters").arg((rules.at(2).toInt() > 0) ? "" : tr("NOT")) +
|
||||
"</li>";
|
||||
out += "<li>" + tr("can %1 contain uppercase characters").arg((rules.at(3).toInt() > 0) ? "" : tr("NOT")) +
|
||||
"</li>";
|
||||
out +=
|
||||
"<li>" + tr("can %1 contain numeric characters").arg((rules.at(4).toInt() > 0) ? "" : tr("NOT")) + "</li>";
|
||||
"<li>" + tr("can %1 contain lowercase characters").arg(rules.at(2).toInt() > 0 ? "" : tr("NOT")) + "</li>";
|
||||
out +=
|
||||
"<li>" + tr("can %1 contain uppercase characters").arg(rules.at(3).toInt() > 0 ? "" : tr("NOT")) + "</li>";
|
||||
out += "<li>" + tr("can %1 contain numeric characters").arg(rules.at(4).toInt() > 0 ? "" : tr("NOT")) + "</li>";
|
||||
|
||||
if (rules.at(6).size() > 0)
|
||||
out += "<li>" + tr("can contain the following punctuation: %1").arg(rules.at(6).toHtmlEscaped()) + "</li>";
|
||||
|
||||
out += "<li>" +
|
||||
tr("first character can %1 be a punctuation mark").arg((rules.at(5).toInt() > 0) ? "" : tr("NOT")) +
|
||||
tr("first character can %1 be a punctuation mark").arg(rules.at(5).toInt() > 0 ? "" : tr("NOT")) +
|
||||
"</li>";
|
||||
|
||||
if (rules.size() == 9) {
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ int main(int argc, char *argv[])
|
|||
const QByteArray configPath = "";
|
||||
#endif
|
||||
|
||||
if (!qEnvironmentVariableIsSet(("QT_LOGGING_CONF"))) {
|
||||
if (!qEnvironmentVariableIsSet("QT_LOGGING_CONF")) {
|
||||
// Set the QT_LOGGING_CONF environment variable
|
||||
qputenv("QT_LOGGING_CONF", configPath);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ bool CardInfoComparator::operator()(const CardInfoPtr &a, const CardInfoPtr &b)
|
|||
// Compare the current property
|
||||
if (valueA != valueB) {
|
||||
// If values differ, perform comparison
|
||||
return compareVariants(valueA, valueB) ? (m_order == Qt::AscendingOrder) : (m_order == Qt::DescendingOrder);
|
||||
return compareVariants(valueA, valueB) ? m_order == Qt::AscendingOrder : m_order == Qt::DescendingOrder;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -202,11 +202,11 @@ void CockatriceXml3Parser::loadCardsFromXml(QXmlStreamReader &xml)
|
|||
} else if (xmlName == "tablerow") {
|
||||
tableRow = xml.readElementText(QXmlStreamReader::IncludeChildElements).toInt();
|
||||
} else if (xmlName == "cipt") {
|
||||
cipt = (xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1");
|
||||
cipt = xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1";
|
||||
} else if (xmlName == "landscapeOrientation") {
|
||||
landscapeOrientation = (xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1");
|
||||
landscapeOrientation = xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1";
|
||||
} else if (xmlName == "upsidedown") {
|
||||
upsideDown = (xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1");
|
||||
upsideDown = xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1";
|
||||
// sets
|
||||
} else if (xmlName == "set") {
|
||||
// NOTE: attributes must be read before readElementText()
|
||||
|
|
|
|||
|
|
@ -177,11 +177,11 @@ void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml)
|
|||
} else if (xmlName == "tablerow") {
|
||||
tableRow = xml.readElementText(QXmlStreamReader::IncludeChildElements).toInt();
|
||||
} else if (xmlName == "cipt") {
|
||||
cipt = (xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1");
|
||||
cipt = xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1";
|
||||
} else if (xmlName == "landscapeOrientation") {
|
||||
landscapeOrientation = (xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1");
|
||||
landscapeOrientation = xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1";
|
||||
} else if (xmlName == "upsidedown") {
|
||||
upsideDown = (xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1");
|
||||
upsideDown = xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1";
|
||||
// sets
|
||||
} else if (xmlName == "set") {
|
||||
// NOTE: attributes but be read before readElementText()
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ bool AbstractDecklistCardNode::compareNumber(AbstractDecklistNode *other) const
|
|||
if (other2) {
|
||||
int n1 = getNumber();
|
||||
int n2 = other2->getNumber();
|
||||
return (n1 != n2) ? (n1 > n2) : compareName(other);
|
||||
return n1 != n2 ? n1 > n2 : compareName(other);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ bool AbstractDecklistCardNode::compareName(AbstractDecklistNode *other) const
|
|||
{
|
||||
auto *other2 = dynamic_cast<AbstractDecklistCardNode *>(other);
|
||||
if (other2) {
|
||||
return (getName() > other2->getName());
|
||||
return getName() > other2->getName();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,13 +50,13 @@ bool SideboardPlan::readElement(QXmlStreamReader *xml)
|
|||
m.set_start_zone(xml->readElementText().toStdString());
|
||||
else if (childName2 == "target_zone")
|
||||
m.set_target_zone(xml->readElementText().toStdString());
|
||||
} else if (xml->isEndElement() && (childName2 == "move_card_to_zone")) {
|
||||
} else if (xml->isEndElement() && childName2 == "move_card_to_zone") {
|
||||
moveList.append(m);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (xml->isEndElement() && (childName == "sideboard_plan"))
|
||||
} else if (xml->isEndElement() && childName == "sideboard_plan")
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -148,7 +148,7 @@ bool DeckList::readElement(QXmlStreamReader *xml)
|
|||
delete newSideboardPlan;
|
||||
}
|
||||
}
|
||||
} else if (xml->isEndElement() && (childName == "cockatrice_deck")) {
|
||||
} else if (xml->isEndElement() && childName == "cockatrice_deck") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -674,10 +674,10 @@ static QString computeDeckHash(const InnerDecklistNode *root)
|
|||
}
|
||||
cardList.sort();
|
||||
QByteArray deckHashArray = QCryptographicHash::hash(cardList.join(";").toUtf8(), QCryptographicHash::Sha1);
|
||||
quint64 number = (((quint64)(unsigned char)deckHashArray[0]) << 32) +
|
||||
(((quint64)(unsigned char)deckHashArray[1]) << 24) +
|
||||
(((quint64)(unsigned char)deckHashArray[2] << 16)) +
|
||||
(((quint64)(unsigned char)deckHashArray[3]) << 8) + (quint64)(unsigned char)deckHashArray[4];
|
||||
quint64 number = ((quint64)(unsigned char)deckHashArray[0] << 32) +
|
||||
((quint64)(unsigned char)deckHashArray[1] << 24) +
|
||||
((quint64)(unsigned char)deckHashArray[2] << 16) +
|
||||
((quint64)(unsigned char)deckHashArray[3] << 8) + (quint64)(unsigned char)deckHashArray[4];
|
||||
return QString::number(number, 32).rightJustified(8, '0');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ bool InnerDecklistNode::compareNumber(AbstractDecklistNode *other) const
|
|||
if (other2) {
|
||||
int n1 = recursiveCount(true);
|
||||
int n2 = other2->recursiveCount(true);
|
||||
return (n1 != n2) ? (n1 > n2) : compareName(other);
|
||||
return n1 != n2 ? n1 > n2 : compareName(other);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ bool InnerDecklistNode::compareName(AbstractDecklistNode *other) const
|
|||
{
|
||||
auto *other2 = dynamic_cast<InnerDecklistNode *>(other);
|
||||
if (other2) {
|
||||
return (getName() > other2->getName());
|
||||
return getName() > other2->getName();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ bool InnerDecklistNode::readElement(QXmlStreamReader *xml)
|
|||
xml->attributes().value("collectorNumber").toString(), xml->attributes().value("uuid").toString());
|
||||
newCard->readElement(xml);
|
||||
}
|
||||
} else if (xml->isEndElement() && (childName == "zone"))
|
||||
} else if (xml->isEndElement() && childName == "zone")
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -182,7 +182,7 @@ QVector<QPair<int, int>> InnerDecklistNode::sort(Qt::SortOrder order)
|
|||
|
||||
// Sort temporary list
|
||||
auto cmp = [order](const auto &a, const auto &b) {
|
||||
return (order == Qt::AscendingOrder) ? (b.second->compare(a.second)) : (a.second->compare(b.second));
|
||||
return order == Qt::AscendingOrder ? b.second->compare(a.second) : a.second->compare(b.second);
|
||||
};
|
||||
|
||||
std::sort(tempList.begin(), tempList.end(), cmp);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
template <class T> FilterTreeNode *FilterTreeBranch<T>::nodeAt(int i) const
|
||||
{
|
||||
return (childNodes.size() > i) ? childNodes.at(i) : nullptr;
|
||||
return childNodes.size() > i ? childNodes.at(i) : nullptr;
|
||||
}
|
||||
|
||||
template <class T> void FilterTreeBranch<T>::deleteAt(int i)
|
||||
|
|
@ -21,7 +21,7 @@ template <class T> int FilterTreeBranch<T>::childIndex(const FilterTreeNode *nod
|
|||
{
|
||||
auto *unconst = const_cast<FilterTreeNode *>(node);
|
||||
auto downcasted = dynamic_cast<T>(unconst);
|
||||
return (downcasted) ? childNodes.indexOf(downcasted) : -1;
|
||||
return downcasted ? childNodes.indexOf(downcasted) : -1;
|
||||
}
|
||||
|
||||
template <class T> FilterTreeBranch<T>::~FilterTreeBranch()
|
||||
|
|
@ -74,7 +74,7 @@ FilterTreeNode *LogicMap::parent() const
|
|||
int FilterItemList::termIndex(const QString &term) const
|
||||
{
|
||||
for (int i = 0; i < childNodes.count(); i++) {
|
||||
if ((childNodes.at(i))->term == term) {
|
||||
if (childNodes.at(i)->term == term) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
|
@ -365,7 +365,7 @@ bool FilterItem::relationCheck(int cardInfo) const
|
|||
bool result, conversion;
|
||||
|
||||
// if int conversion fails, there's probably an operator at the start
|
||||
result = (cardInfo == term.toInt(&conversion));
|
||||
result = cardInfo == term.toInt(&conversion);
|
||||
if (!conversion) {
|
||||
// leading whitespaces could cause indexing to fail
|
||||
QString trimmedTerm = term.trimmed();
|
||||
|
|
@ -373,20 +373,20 @@ bool FilterItem::relationCheck(int cardInfo) const
|
|||
if (trimmedTerm[1] == '=') {
|
||||
int termInt = trimmedTerm.mid(2).toInt();
|
||||
if (trimmedTerm.startsWith('<')) {
|
||||
result = (cardInfo <= termInt);
|
||||
result = cardInfo <= termInt;
|
||||
} else if (trimmedTerm.startsWith('>')) {
|
||||
result = (cardInfo >= termInt);
|
||||
result = cardInfo >= termInt;
|
||||
} else {
|
||||
result = (cardInfo == termInt);
|
||||
result = cardInfo == termInt;
|
||||
}
|
||||
} else {
|
||||
int termInt = trimmedTerm.mid(1).toInt();
|
||||
if (trimmedTerm.startsWith('<')) {
|
||||
result = (cardInfo < termInt);
|
||||
result = cardInfo < termInt;
|
||||
} else if (trimmedTerm.startsWith('>')) {
|
||||
result = (cardInfo > termInt);
|
||||
result = cardInfo > termInt;
|
||||
} else if (trimmedTerm.startsWith("=")) {
|
||||
result = (cardInfo == termInt);
|
||||
result = cardInfo == termInt;
|
||||
} else {
|
||||
// the int conversion hasn't failed due to an operator at the start
|
||||
result = false;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public:
|
|||
}
|
||||
[[nodiscard]] virtual int index() const
|
||||
{
|
||||
return (parent() != nullptr) ? parent()->childIndex(this) : -1;
|
||||
return parent() != nullptr ? parent()->childIndex(this) : -1;
|
||||
}
|
||||
[[nodiscard]] virtual const QString text() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex
|
|||
{
|
||||
CardInfoPtr info = static_cast<CardDatabaseModel *>(sourceModel())->getCard(sourceRow);
|
||||
|
||||
if (((isToken == ShowTrue) && !info->getIsToken()) || ((isToken == ShowFalse) && info->getIsToken()))
|
||||
if ((isToken == ShowTrue && !info->getIsToken()) || (isToken == ShowFalse && info->getIsToken()))
|
||||
return false;
|
||||
|
||||
if (filterString != nullptr) {
|
||||
|
|
|
|||
|
|
@ -23,8 +23,9 @@ int SetsModel::rowCount(const QModelIndex &parent) const
|
|||
|
||||
QVariant SetsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || (index.column() >= NUM_COLS) || (index.row() >= rowCount()))
|
||||
if (!index.isValid() || index.column() >= NUM_COLS || index.row() >= rowCount()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
CardSetPtr set = sets[index.row()];
|
||||
|
||||
|
|
@ -72,7 +73,7 @@ bool SetsModel::setData(const QModelIndex &index, const QVariant &value, int rol
|
|||
|
||||
QVariant SetsModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if ((role != Qt::DisplayRole) || (orientation != Qt::Horizontal))
|
||||
if (role != Qt::DisplayRole || orientation != Qt::Horizontal)
|
||||
return QVariant();
|
||||
switch (section) {
|
||||
case SortKeyCol:
|
||||
|
|
@ -289,9 +290,9 @@ bool SetsDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex &source
|
|||
const auto filter = filterRegExp();
|
||||
#endif
|
||||
|
||||
return (sourceModel()->data(typeIndex).toString().contains(filter) ||
|
||||
return sourceModel()->data(typeIndex).toString().contains(filter) ||
|
||||
sourceModel()->data(nameIndex).toString().contains(filter) ||
|
||||
sourceModel()->data(shortNameIndex).toString().contains(filter));
|
||||
sourceModel()->data(shortNameIndex).toString().contains(filter);
|
||||
}
|
||||
|
||||
bool SetsDisplayModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ void DeckListModel::emitBackgroundUpdates(const QModelIndex &parent)
|
|||
|
||||
QVariant DeckListModel::headerData(const int section, const Qt::Orientation orientation, const int role) const
|
||||
{
|
||||
if ((role != Qt::DisplayRole) || (orientation != Qt::Horizontal)) {
|
||||
if (role != Qt::DisplayRole || orientation != Qt::Horizontal) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ void DeckListModel::emitRecursiveUpdates(const QModelIndex &index)
|
|||
bool DeckListModel::setData(const QModelIndex &index, const QVariant &value, const int role)
|
||||
{
|
||||
auto *node = getNode<DecklistModelCardNode *>(index);
|
||||
if (!node || (role != Qt::EditRole)) {
|
||||
if (!node || role != Qt::EditRole) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -310,7 +310,7 @@ bool DeckListModel::removeRows(int row, int count, const QModelIndex &parent)
|
|||
}
|
||||
endRemoveRows();
|
||||
|
||||
if (node->empty() && (node != root)) {
|
||||
if (node->empty() && node != root) {
|
||||
removeRows(parent.row(), 1, parent.parent());
|
||||
} else {
|
||||
emitRecursiveUpdates(parent);
|
||||
|
|
|
|||
|
|
@ -380,10 +380,10 @@ void RemoteClient::readData()
|
|||
}
|
||||
} else {
|
||||
// end of hack
|
||||
messageLength = (((quint32)(unsigned char)inputBuffer[0]) << 24) +
|
||||
(((quint32)(unsigned char)inputBuffer[1]) << 16) +
|
||||
(((quint32)(unsigned char)inputBuffer[2]) << 8) +
|
||||
((quint32)(unsigned char)inputBuffer[3]);
|
||||
messageLength = ((quint32)(unsigned char)inputBuffer[0] << 24) +
|
||||
((quint32)(unsigned char)inputBuffer[1] << 16) +
|
||||
((quint32)(unsigned char)inputBuffer[2] << 8) +
|
||||
(quint32)(unsigned char)inputBuffer[3];
|
||||
inputBuffer.remove(0, 4);
|
||||
messageInProgress = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ void Server_AbstractParticipant::getProperties(ServerInfo_PlayerProperties &resu
|
|||
{
|
||||
result.set_player_id(playerId);
|
||||
if (withUserInfo) {
|
||||
copyUserInfo(*(result.mutable_user_info()), true);
|
||||
copyUserInfo(*result.mutable_user_info(), true);
|
||||
}
|
||||
result.set_spectator(spectator);
|
||||
result.set_judge(judge);
|
||||
|
|
@ -149,7 +149,7 @@ Response::ResponseCode Server_AbstractParticipant::cmdKickFromGame(const Command
|
|||
ResponseContainer & /*rc*/,
|
||||
GameEventStorage & /*ges*/)
|
||||
{
|
||||
if ((game->getHostId() != playerId) && !(userInfo->user_level() & ServerInfo_User::IsModerator)) {
|
||||
if (game->getHostId() != playerId && !(userInfo->user_level() & ServerInfo_User::IsModerator)) {
|
||||
return Response::RespFunctionNotAllowed;
|
||||
}
|
||||
|
||||
|
|
@ -232,7 +232,7 @@ Server_AbstractParticipant::cmdGameSay(const Command_GameSay &cmd, ResponseConta
|
|||
* (b) the spectator is a moderator/administrator
|
||||
* (c) the spectator is a judge
|
||||
*/
|
||||
bool isModOrJudge = (userInfo->user_level() & (ServerInfo_User::IsModerator | ServerInfo_User::IsJudge));
|
||||
bool isModOrJudge = userInfo->user_level() & (ServerInfo_User::IsModerator | ServerInfo_User::IsJudge);
|
||||
if (!isModOrJudge && !game->getSpectatorsCanTalk()) {
|
||||
return Response::RespFunctionNotAllowed;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,12 +209,12 @@ Response::ResponseCode Server_AbstractPlayer::moveCard(GameEventStorage &ges,
|
|||
bool isReversed)
|
||||
{
|
||||
// Disallow controller change to other zones than the table.
|
||||
if (((targetzone->getType() != ServerInfo_Zone::PublicZone) || !targetzone->hasCoords()) &&
|
||||
(startzone->getPlayer() != targetzone->getPlayer()) && !judge) {
|
||||
if ((targetzone->getType() != ServerInfo_Zone::PublicZone || !targetzone->hasCoords()) &&
|
||||
startzone->getPlayer() != targetzone->getPlayer() && !judge) {
|
||||
return Response::RespContextError;
|
||||
}
|
||||
|
||||
if (!targetzone->hasCoords() && (xCoord <= -1)) {
|
||||
if (!targetzone->hasCoords() && xCoord <= -1) {
|
||||
xCoord = targetzone->getCards().size();
|
||||
}
|
||||
|
||||
|
|
@ -284,7 +284,7 @@ Response::ResponseCode Server_AbstractPlayer::moveCard(GameEventStorage &ges,
|
|||
for (auto *player : game->getPlayers().values()) {
|
||||
QList<int> arrowsToDelete;
|
||||
for (Server_Arrow *arrow : player->getArrows()) {
|
||||
if ((arrow->getStartCard() == card) || (arrow->getTargetItem() == card))
|
||||
if (arrow->getStartCard() == card || arrow->getTargetItem() == card)
|
||||
arrowsToDelete.append(arrow->getId());
|
||||
}
|
||||
for (int j : arrowsToDelete) {
|
||||
|
|
@ -334,11 +334,11 @@ Response::ResponseCode Server_AbstractPlayer::moveCard(GameEventStorage &ges,
|
|||
targetzone->setCardsBeingLookedAt(targetLookedCards);
|
||||
}
|
||||
|
||||
bool targetHiddenToOthers = faceDown || (targetzone->getType() != ServerInfo_Zone::PublicZone);
|
||||
bool sourceHiddenToOthers = card->getFaceDown() || (startzone->getType() != ServerInfo_Zone::PublicZone);
|
||||
bool targetHiddenToOthers = faceDown || targetzone->getType() != ServerInfo_Zone::PublicZone;
|
||||
bool sourceHiddenToOthers = card->getFaceDown() || startzone->getType() != ServerInfo_Zone::PublicZone;
|
||||
|
||||
int oldCardId = card->getId();
|
||||
if ((faceDown && (startzone != targetzone)) || (targetzone->getPlayer() != startzone->getPlayer())) {
|
||||
if ((faceDown && startzone != targetzone) || targetzone->getPlayer() != startzone->getPlayer()) {
|
||||
card->setId(targetzone->getPlayer()->newCardId());
|
||||
}
|
||||
card->setFaceDown(faceDown);
|
||||
|
|
@ -378,19 +378,19 @@ Response::ResponseCode Server_AbstractPlayer::moveCard(GameEventStorage &ges,
|
|||
if (
|
||||
// cards from public zones have their id known, their previous position is already known, the event does
|
||||
// not accomodate for previous locations in zones with coordinates (which are always public)
|
||||
(startzone->getType() != ServerInfo_Zone::PublicZone) &&
|
||||
startzone->getType() != ServerInfo_Zone::PublicZone &&
|
||||
// other players are not allowed to be able to track which card is which in private zones like the hand
|
||||
(startzone->getType() != ServerInfo_Zone::PrivateZone)) {
|
||||
startzone->getType() != ServerInfo_Zone::PrivateZone) {
|
||||
eventOthers.set_position(position);
|
||||
}
|
||||
if (
|
||||
// other players are not allowed to be able to track which card is which in private zones like the hand
|
||||
(targetzone->getType() != ServerInfo_Zone::PrivateZone)) {
|
||||
targetzone->getType() != ServerInfo_Zone::PrivateZone) {
|
||||
eventOthers.set_x(newX);
|
||||
}
|
||||
|
||||
if ((startzone->getType() == ServerInfo_Zone::PublicZone) ||
|
||||
(targetzone->getType() == ServerInfo_Zone::PublicZone)) {
|
||||
if (startzone->getType() == ServerInfo_Zone::PublicZone ||
|
||||
targetzone->getType() == ServerInfo_Zone::PublicZone) {
|
||||
eventOthers.set_card_id(oldCardId);
|
||||
if (!(sourceHiddenToOthers && targetHiddenToOthers)) {
|
||||
QString publicCardName = card->getName();
|
||||
|
|
@ -628,7 +628,7 @@ Server_AbstractPlayer::cmdConcede(const Command_Concede & /*cmd*/, ResponseConta
|
|||
ges.setGameEventContext(Context_Concede());
|
||||
|
||||
game->stopGameIfFinished();
|
||||
if (game->getGameStarted() && (game->getActivePlayer() == playerId)) {
|
||||
if (game->getGameStarted() && game->getActivePlayer() == playerId) {
|
||||
game->nextTurn();
|
||||
}
|
||||
|
||||
|
|
@ -735,7 +735,7 @@ Server_AbstractPlayer::cmdMoveCard(const Command_MoveCard &cmd, ResponseContaine
|
|||
return Response::RespNameNotFound;
|
||||
}
|
||||
|
||||
if ((startPlayer != this) && (!startZone->getPlayersWithWritePermission().contains(playerId)) && !judge) {
|
||||
if (startPlayer != this && !startZone->getPlayersWithWritePermission().contains(playerId) && !judge) {
|
||||
return Response::RespContextError;
|
||||
}
|
||||
|
||||
|
|
@ -748,7 +748,7 @@ Server_AbstractPlayer::cmdMoveCard(const Command_MoveCard &cmd, ResponseContaine
|
|||
return Response::RespNameNotFound;
|
||||
}
|
||||
|
||||
if ((startPlayer != this) && (targetPlayer != this) && !judge) {
|
||||
if (startPlayer != this && targetPlayer != this && !judge) {
|
||||
return Response::RespContextError;
|
||||
}
|
||||
|
||||
|
|
@ -872,7 +872,7 @@ Server_AbstractPlayer::cmdAttachCard(const Command_AttachCard &cmd, ResponseCont
|
|||
QList<Server_Arrow *> toDelete;
|
||||
for (auto a : _arrows) {
|
||||
auto *tCard = qobject_cast<Server_Card *>(a->getTargetItem());
|
||||
if ((tCard == card) || (a->getStartCard() == card)) {
|
||||
if (tCard == card || a->getStartCard() == card) {
|
||||
toDelete.append(a);
|
||||
}
|
||||
}
|
||||
|
|
@ -1202,7 +1202,7 @@ Server_AbstractPlayer::cmdCreateArrow(const Command_CreateArrow &cmd, ResponseCo
|
|||
}
|
||||
|
||||
for (Server_Arrow *temp : arrows) {
|
||||
if ((temp->getStartCard() == startCard) && (temp->getTargetItem() == targetItem)) {
|
||||
if (temp->getStartCard() == startCard && temp->getTargetItem() == targetItem) {
|
||||
return Response::RespContextError;
|
||||
}
|
||||
}
|
||||
|
|
@ -1349,7 +1349,7 @@ Server_AbstractPlayer::cmdDumpZone(const Command_DumpZone &cmd, ResponseContaine
|
|||
if (!zone) {
|
||||
return Response::RespNameNotFound;
|
||||
}
|
||||
if (!((zone->getType() == ServerInfo_Zone::PublicZone) || (this == otherPlayer))) {
|
||||
if (!(zone->getType() == ServerInfo_Zone::PublicZone || this == otherPlayer)) {
|
||||
return Response::RespContextError;
|
||||
}
|
||||
|
||||
|
|
@ -1363,7 +1363,7 @@ Server_AbstractPlayer::cmdDumpZone(const Command_DumpZone &cmd, ResponseContaine
|
|||
zoneInfo->set_with_coords(zone->hasCoords());
|
||||
zoneInfo->set_card_count(numberCards < cards.size() ? cards.size() : numberCards);
|
||||
|
||||
for (int i = 0; (i < cards.size()) && (i < numberCards || numberCards == -1); ++i) {
|
||||
for (int i = 0; i < cards.size() && (i < numberCards || numberCards == -1); ++i) {
|
||||
const auto &findId = cmd.is_reversed() ? cards.size() - numberCards + i : i;
|
||||
Server_Card *card = cards[findId];
|
||||
QString displayedName = card->getFaceDown() ? QString() : card->getName();
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ void Server_CardZone::removeCardFromCoordMap(Server_Card *card, int oldX, int ol
|
|||
if (oldX < 0)
|
||||
return;
|
||||
|
||||
const int baseX = (oldX / 3) * 3;
|
||||
const int baseX = oldX / 3 * 3;
|
||||
QMap<int, Server_Card *> &coordMap = coordinateMap[oldY];
|
||||
|
||||
if (coordMap.contains(baseX) && coordMap.contains(baseX + 1) && coordMap.contains(baseX + 2))
|
||||
|
|
@ -117,7 +117,7 @@ void Server_CardZone::insertCardIntoCoordMap(Server_Card *card, int x, int y)
|
|||
freeSpaceMap[y] = nextFreeX;
|
||||
}
|
||||
} else if (!((x - 2) % 3)) {
|
||||
const int baseX = (x / 3) * 3;
|
||||
const int baseX = x / 3 * 3;
|
||||
freePilesMap[y].remove(coordinateMap[y].value(baseX)->getName(), baseX);
|
||||
}
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ Server_Card *Server_CardZone::getCard(int id, int *position, bool remove)
|
|||
}
|
||||
return nullptr;
|
||||
} else {
|
||||
if ((id >= cards.size()) || (id < 0))
|
||||
if (id >= cards.size() || id < 0)
|
||||
return nullptr;
|
||||
Server_Card *tmp = cards[id];
|
||||
if (position)
|
||||
|
|
@ -184,7 +184,7 @@ int Server_CardZone::getFreeGridColumn(int x, int y, const QString &cardName, bo
|
|||
const QMap<int, Server_Card *> &coordMap = coordinateMap.value(y);
|
||||
if (x == -1) {
|
||||
if (!dontStackSameName && freePilesMap[y].contains(cardName)) {
|
||||
x = (freePilesMap[y].value(cardName) / 3) * 3;
|
||||
x = freePilesMap[y].value(cardName) / 3 * 3;
|
||||
|
||||
if (coordMap.contains(x) && (coordMap[x]->getFaceDown() || !coordMap[x]->getAttachedCards().isEmpty())) {
|
||||
// don't pile up on: 1. facedown cards 2. cards with attached cards
|
||||
|
|
@ -197,7 +197,7 @@ int Server_CardZone::getFreeGridColumn(int x, int y, const QString &cardName, bo
|
|||
}
|
||||
} else if (x >= 0) {
|
||||
int resultX = 0;
|
||||
x = (x / 3) * 3;
|
||||
x = x / 3 * 3;
|
||||
if (!coordMap.contains(x))
|
||||
resultX = x;
|
||||
else if (!coordMap.value(x)->getAttachedCards().isEmpty()) {
|
||||
|
|
@ -226,7 +226,7 @@ bool Server_CardZone::isColumnStacked(int x, int y) const
|
|||
if (!has_coords)
|
||||
return false;
|
||||
|
||||
return coordinateMap[y].contains((x / 3) * 3 + 1);
|
||||
return coordinateMap[y].contains(x / 3 * 3 + 1);
|
||||
}
|
||||
|
||||
bool Server_CardZone::isColumnEmpty(int x, int y) const
|
||||
|
|
@ -234,7 +234,7 @@ bool Server_CardZone::isColumnEmpty(int x, int y) const
|
|||
if (!has_coords)
|
||||
return true;
|
||||
|
||||
return !coordinateMap[y].contains((x / 3) * 3);
|
||||
return !coordinateMap[y].contains(x / 3 * 3);
|
||||
}
|
||||
|
||||
void Server_CardZone::moveCardInRow(GameEventStorage &ges, Server_Card *card, int x, int y)
|
||||
|
|
@ -252,7 +252,7 @@ void Server_CardZone::fixFreeSpaces(GameEventStorage &ges)
|
|||
|
||||
QSet<QPair<int, int>> placesToLook;
|
||||
for (auto &card : cards)
|
||||
placesToLook.insert(QPair<int, int>((card->getX() / 3) * 3, card->getY()));
|
||||
placesToLook.insert(QPair<int, int>(card->getX() / 3 * 3, card->getY()));
|
||||
|
||||
QSetIterator<QPair<int, int>> placeIterator(placesToLook);
|
||||
while (placeIterator.hasNext()) {
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ void Server_Game::pingClockTimeout()
|
|||
ges.enqueueGameEvent(event, participant->getPlayerId());
|
||||
}
|
||||
|
||||
if ((participant->getPingTime() != -1) &&
|
||||
if (participant->getPingTime() != -1 &&
|
||||
(!participant->getSpectator() || participant->getPlayerId() == hostId)) {
|
||||
allPlayersInactive = false;
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ void Server_Game::pingClockTimeout()
|
|||
|
||||
const int maxTime = room->getServer()->getMaxGameInactivityTime();
|
||||
if (allPlayersInactive) {
|
||||
if (((maxTime > 0) && (++inactivityCounter >= maxTime)) || (playerCount < maxPlayers)) {
|
||||
if ((maxTime > 0 && ++inactivityCounter >= maxTime) || playerCount < maxPlayers) {
|
||||
deleteLater();
|
||||
}
|
||||
} else {
|
||||
|
|
@ -438,12 +438,12 @@ Response::ResponseCode Server_Game::checkJoin(ServerInfo_User *user,
|
|||
if (asJudge && !(user->user_level() & ServerInfo_User::IsJudge)) {
|
||||
return Response::RespUserLevelTooLow;
|
||||
}
|
||||
if (!(overrideRestrictions && (user->user_level() & ServerInfo_User::IsModerator))) {
|
||||
if ((_password != password) && !(spectator && !spectatorsNeedPassword))
|
||||
if (!(overrideRestrictions && user->user_level() & ServerInfo_User::IsModerator)) {
|
||||
if (_password != password && !(spectator && !spectatorsNeedPassword))
|
||||
return Response::RespWrongPassword;
|
||||
if (!(user->user_level() & ServerInfo_User::IsRegistered) && onlyRegistered)
|
||||
return Response::RespUserLevelTooLow;
|
||||
if (onlyBuddies && (user->name() != creatorInfo->name()))
|
||||
if (onlyBuddies && user->name() != creatorInfo->name())
|
||||
if (!databaseInterface->isInBuddyList(QString::fromStdString(creatorInfo->name()),
|
||||
QString::fromStdString(user->name())))
|
||||
return Response::RespOnlyBuddies;
|
||||
|
|
@ -455,7 +455,7 @@ Response::ResponseCode Server_Game::checkJoin(ServerInfo_User *user,
|
|||
return Response::RespSpectatorsNotAllowed;
|
||||
}
|
||||
}
|
||||
if (!spectator && (gameStarted || (getPlayerCount() >= getMaxPlayers())))
|
||||
if (!spectator && (gameStarted || getPlayerCount() >= getMaxPlayers()))
|
||||
return Response::RespGameFull;
|
||||
|
||||
return Response::RespOk;
|
||||
|
|
@ -519,7 +519,7 @@ void Server_Game::addPlayer(Server_AbstractUserInterface *userInterface,
|
|||
emit gameInfoChanged(gameInfo);
|
||||
}
|
||||
|
||||
if ((newParticipant->getUserInfo()->user_level() & ServerInfo_User::IsRegistered) && !spectator)
|
||||
if (newParticipant->getUserInfo()->user_level() & ServerInfo_User::IsRegistered && !spectator)
|
||||
room->getServer()->addPersistentPlayer(playerName, room->getId(), gameId, newParticipant->getPlayerId());
|
||||
|
||||
userInterface->playerAddedToGame(gameId, room->getId(), newParticipant->getPlayerId());
|
||||
|
|
@ -770,7 +770,7 @@ void Server_Game::sendGameEventContainer(GameEventContainer *cont,
|
|||
cont->set_game_id(gameId);
|
||||
for (auto *participant : participants.values()) {
|
||||
const bool playerPrivate =
|
||||
(participant->getPlayerId() == privatePlayerId) ||
|
||||
participant->getPlayerId() == privatePlayerId ||
|
||||
(participant->getSpectator() && (spectatorsSeeEverything || participant->getJudge()));
|
||||
if ((recipients.testFlag(GameEventStorageItem::SendToPrivate) && playerPrivate) ||
|
||||
(recipients.testFlag(GameEventStorageItem::SendToOthers) && !playerPrivate))
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public:
|
|||
}
|
||||
bool operator==(const PlayerReference &other)
|
||||
{
|
||||
return ((roomId == other.roomId) && (gameId == other.gameId) && (playerId == other.playerId));
|
||||
return roomId == other.roomId && gameId == other.gameId && playerId == other.playerId;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -371,7 +371,7 @@ void Server_ProtocolHandler::processCommandContainer(const CommandContainer &con
|
|||
else
|
||||
finalResponseCode = Response::RespInvalidCommand;
|
||||
|
||||
if ((finalResponseCode != Response::RespNothing))
|
||||
if (finalResponseCode != Response::RespNothing)
|
||||
sendResponseContainer(responseContainer, finalResponseCode);
|
||||
}
|
||||
|
||||
|
|
@ -386,10 +386,10 @@ void Server_ProtocolHandler::pingClockTimeout()
|
|||
if (interval > 0) {
|
||||
if (pingclockinterval > 0) {
|
||||
messageSizeOverTime.prepend(0);
|
||||
if (messageSizeOverTime.size() > (msgcountinterval / pingclockinterval))
|
||||
if (messageSizeOverTime.size() > msgcountinterval / pingclockinterval)
|
||||
messageSizeOverTime.removeLast();
|
||||
messageCountOverTime.prepend(0);
|
||||
if (messageCountOverTime.size() > (msgcountinterval / pingclockinterval))
|
||||
if (messageCountOverTime.size() > msgcountinterval / pingclockinterval)
|
||||
messageCountOverTime.removeLast();
|
||||
}
|
||||
}
|
||||
|
|
@ -398,7 +398,7 @@ void Server_ProtocolHandler::pingClockTimeout()
|
|||
if (interval > 0) {
|
||||
if (pingclockinterval > 0) {
|
||||
commandCountOverTime.prepend(0);
|
||||
if (commandCountOverTime.size() > (cmdcountinterval / pingclockinterval))
|
||||
if (commandCountOverTime.size() > cmdcountinterval / pingclockinterval)
|
||||
commandCountOverTime.removeLast();
|
||||
}
|
||||
}
|
||||
|
|
@ -409,16 +409,16 @@ void Server_ProtocolHandler::pingClockTimeout()
|
|||
// PrivLevel users, Moderators, and Admins are not subject to the server idle timeout policy
|
||||
const bool hasPrivLevel = userInfo && QString::fromStdString(userInfo->privlevel()).toLower() != "none";
|
||||
const bool isModOrAdmin =
|
||||
userInfo && (userInfo->user_level() & (ServerInfo_User::IsModerator | ServerInfo_User::IsAdmin));
|
||||
userInfo && userInfo->user_level() & (ServerInfo_User::IsModerator | ServerInfo_User::IsAdmin);
|
||||
if (!hasPrivLevel && !isModOrAdmin) {
|
||||
if ((server->getIdleClientTimeout() > 0) && (idleClientWarningSent)) {
|
||||
if (server->getIdleClientTimeout() > 0 && idleClientWarningSent) {
|
||||
if (timeRunning - lastActionReceived > server->getIdleClientTimeout()) {
|
||||
prepareDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
if (((timeRunning - lastActionReceived) >= qCeil(server->getIdleClientTimeout() * .9)) &&
|
||||
(!idleClientWarningSent) && (server->getIdleClientTimeout() > 0)) {
|
||||
if (timeRunning - lastActionReceived >= qCeil(server->getIdleClientTimeout() * .9) && !idleClientWarningSent &&
|
||||
server->getIdleClientTimeout() > 0) {
|
||||
Event_NotifyUser event;
|
||||
event.set_type(Event_NotifyUser::IDLEWARNING);
|
||||
SessionEvent *se = prepareSessionEvent(event);
|
||||
|
|
@ -689,7 +689,7 @@ Response::ResponseCode Server_ProtocolHandler::cmdJoinRoom(const Command_JoinRoo
|
|||
return Response::RespNameNotFound;
|
||||
|
||||
if (!(userInfo->user_level() & ServerInfo_User::IsModerator))
|
||||
if (!(room->userMayJoin(*userInfo)))
|
||||
if (!room->userMayJoin(*userInfo))
|
||||
return Response::RespUserLevelTooLow;
|
||||
|
||||
room->addClient(this);
|
||||
|
|
@ -837,7 +837,7 @@ Server_ProtocolHandler::cmdCreateGame(const Command_CreateGame &cmd, Server_Room
|
|||
}
|
||||
|
||||
// When server doesn't permit registered users to exist, do not honor only-reg setting
|
||||
bool onlyRegisteredUsers = cmd.only_registered() && (server->permitUnregisteredUsers());
|
||||
bool onlyRegisteredUsers = cmd.only_registered() && server->permitUnregisteredUsers();
|
||||
auto *game = new Server_Game(copyUserInfo(false), gameId, description, QString::fromStdString(cmd.password()),
|
||||
cmd.max_players(), gameTypes, cmd.only_buddies(), onlyRegisteredUsers,
|
||||
cmd.spectators_allowed(), cmd.spectators_need_password(), cmd.spectators_can_talk(),
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ QVector<int> RNG_Abstract::makeNumbersVector(int n, int min, int max)
|
|||
QVector<int> result(bins);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
int number = rand(min, max);
|
||||
if ((number < min) || (number > max))
|
||||
if (number < min || number > max)
|
||||
qDebug() << "rand(" << min << "," << max << ") returned " << number;
|
||||
else
|
||||
result[number - min]++;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ int levenshteinDistance(const QString &s1, const QString &s2)
|
|||
|
||||
for (int i = 1; i <= len1; i++) {
|
||||
for (int j = 1; j <= len2; j++) {
|
||||
int cost = (s1[i - 1] == s2[j - 1]) ? 0 : 1;
|
||||
int cost = s1[i - 1] == s2[j - 1] ? 0 : 1;
|
||||
dp[i][j] = std::min({dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + cost});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -237,10 +237,9 @@ void IslInterface::readClient()
|
|||
do {
|
||||
if (!messageInProgress) {
|
||||
if (inputBuffer.size() >= 4) {
|
||||
messageLength = (((quint32)(unsigned char)inputBuffer[0]) << 24) +
|
||||
(((quint32)(unsigned char)inputBuffer[1]) << 16) +
|
||||
(((quint32)(unsigned char)inputBuffer[2]) << 8) +
|
||||
((quint32)(unsigned char)inputBuffer[3]);
|
||||
messageLength = ((quint32)(unsigned char)inputBuffer[0] << 24) +
|
||||
((quint32)(unsigned char)inputBuffer[1] << 16) +
|
||||
((quint32)(unsigned char)inputBuffer[2] << 8) + (quint32)(unsigned char)inputBuffer[3];
|
||||
inputBuffer.remove(0, 4);
|
||||
messageInProgress = true;
|
||||
} else
|
||||
|
|
|
|||
|
|
@ -38,9 +38,10 @@
|
|||
#include <QUuid>
|
||||
#include <QtDebug>
|
||||
|
||||
static bool isASCII(const QString &string) {
|
||||
for(const QChar &chr : string){
|
||||
if(chr.unicode() > 0x7f)
|
||||
static bool isASCII(const QString &string)
|
||||
{
|
||||
for (const QChar &chr : string) {
|
||||
if (chr.unicode() > 0x7f)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -277,9 +278,9 @@ QByteArray qxt_fold_mime_header(const QString &key, const QString &value, const
|
|||
QByteArray QxtMailMessage::rfc2822() const
|
||||
{
|
||||
// Use quoted-printable if requested
|
||||
bool useQuotedPrintable = (extraHeader("Content-Transfer-Encoding").toLower() == "quoted-printable");
|
||||
bool useQuotedPrintable = extraHeader("Content-Transfer-Encoding").toLower() == "quoted-printable";
|
||||
// Use base64 if requested
|
||||
bool useBase64 = (extraHeader("Content-Transfer-Encoding").toLower() == "base64");
|
||||
bool useBase64 = extraHeader("Content-Transfer-Encoding").toLower() == "base64";
|
||||
// Check to see if plain text is ASCII-clean; assume it isn't if QP or base64 was requested
|
||||
bool bodyIsAscii = !useQuotedPrintable && !useBase64 && isASCII(body());
|
||||
|
||||
|
|
@ -465,8 +466,7 @@ QByteArray QxtMailMessage::rfc2822() const
|
|||
if (attach.count()) {
|
||||
for (const QString &filename : attach.keys()) {
|
||||
rv += "--" + qxt_d->boundary + "\r\n";
|
||||
rv +=
|
||||
qxt_fold_mime_header("Content-Disposition", QDir(filename).dirName(), "attachment; filename=");
|
||||
rv += qxt_fold_mime_header("Content-Disposition", QDir(filename).dirName(), "attachment; filename=");
|
||||
rv += attach[filename].mimeData();
|
||||
}
|
||||
rv += "--" + qxt_d->boundary + "--\r\n";
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ void QxtSmtpPrivate::socketRead()
|
|||
case HeloSent:
|
||||
case EhloSent:
|
||||
case EhloGreetReceived:
|
||||
parseEhlo(code, (line[3] != ' '), line.mid(4));
|
||||
parseEhlo(code, line[3] != ' ', line.mid(4));
|
||||
break;
|
||||
case StartTLSSent:
|
||||
if (code == "220") {
|
||||
|
|
@ -414,7 +414,7 @@ static QByteArray qxt_extract_address(const QString &address)
|
|||
inQuote = false;
|
||||
} else if (addrStart != -1) {
|
||||
if (ch == '>')
|
||||
return address.mid(addrStart, (i - addrStart)).toLatin1();
|
||||
return address.mid(addrStart, i - addrStart).toLatin1();
|
||||
} else if (ch == '(') {
|
||||
parenDepth++;
|
||||
} else if (ch == ')') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue