From 8ddbdf31f9ff8da8b8286b59ad5e9486bcce296e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Br=C3=BCbach=2C=20Lukas?= Date: Sat, 29 Nov 2025 09:23:11 +0100 Subject: [PATCH] [Fix-Warnings] Remove redundant parentheses --- .../network/update/client/release_channel.cpp | 4 +- .../client/settings/card_counter_settings.cpp | 8 ++-- .../src/game/board/abstract_card_item.cpp | 4 +- .../src/game/board/abstract_counter.cpp | 2 +- cockatrice/src/game/board/arrow_item.cpp | 8 ++-- cockatrice/src/game/board/card_drag_item.cpp | 4 +- cockatrice/src/game/board/card_item.cpp | 16 ++++---- cockatrice/src/game/deckview/deck_view.cpp | 2 +- cockatrice/src/game/game_event_handler.cpp | 2 +- cockatrice/src/game/game_scene.cpp | 6 +-- .../src/game/log/message_log_widget.cpp | 2 +- cockatrice/src/game/phases_toolbar.cpp | 2 +- cockatrice/src/game/player/player_actions.cpp | 4 +- .../src/game/player/player_event_handler.cpp | 6 +-- .../src/game/player/player_list_widget.cpp | 7 ++-- cockatrice/src/game/zones/hand_zone.cpp | 12 +++--- .../src/game/zones/logic/card_zone_logic.cpp | 33 ++++++++-------- cockatrice/src/game/zones/pile_zone.cpp | 3 +- cockatrice/src/game/zones/stack_zone.cpp | 2 +- cockatrice/src/game/zones/table_zone.cpp | 16 ++++---- cockatrice/src/game/zones/table_zone.h | 4 +- cockatrice/src/game/zones/view_zone.cpp | 10 ++--- .../src/game/zones/view_zone_widget.cpp | 4 +- .../board/abstract_graphics_item.cpp | 10 +++-- .../src/interface/deck_loader/deck_loader.cpp | 6 +-- .../src/interface/layouts/flow_layout.cpp | 8 ++-- .../src/interface/layouts/overlap_layout.cpp | 18 ++++----- .../src/interface/pixel_map_generator.cpp | 4 +- .../additional_info/color_identity_widget.cpp | 2 +- .../additional_info/mana_cost_widget.cpp | 2 +- .../deck_editor/deck_list_style_proxy.cpp | 2 +- .../interface/widgets/dialogs/dlg_connect.cpp | 2 +- .../widgets/dialogs/dlg_manage_sets.cpp | 2 +- .../widgets/general/display/banner_widget.cpp | 2 +- .../widgets/general/display/bar_widget.cpp | 4 +- .../display/dynamic_font_size_label.cpp | 4 +- .../general/display/percent_bar_widget.cpp | 4 +- .../printing_selector_card_overlay_widget.cpp | 2 +- .../widgets/replay/replay_manager.cpp | 2 +- .../widgets/replay/replay_timeline_widget.cpp | 2 +- .../widgets/server/chat_view/chat_view.cpp | 20 +++++----- .../interface/widgets/server/games_model.cpp | 4 +- .../widgets/server/user/user_context_menu.cpp | 16 ++++---- .../widgets/server/user/user_list_widget.cpp | 6 +-- .../tabs/api/edhrec/tab_edhrec_main.cpp | 4 +- .../interface/widgets/tabs/tab_message.cpp | 6 +-- .../interface/widgets/tabs/tab_supervisor.cpp | 4 +- .../widgets/utility/line_edit_completer.cpp | 2 +- .../widgets/utility/sequence_edit.cpp | 2 +- .../visual_deck_editor_widget.cpp | 2 +- cockatrice/src/interface/window_main.cpp | 11 +++--- cockatrice/src/main.cpp | 2 +- .../card/card_info_comparator.cpp | 2 +- .../card/database/parser/cockatrice_xml_3.cpp | 6 +-- .../card/database/parser/cockatrice_xml_4.cpp | 6 +-- .../abstract_deck_list_card_node.cpp | 4 +- .../libcockatrice/deck_list/deck_list.cpp | 14 +++---- .../deck_list/inner_deck_list_node.cpp | 8 ++-- .../libcockatrice/filters/filter_tree.cpp | 20 +++++----- .../libcockatrice/filters/filter_tree.h | 2 +- .../database/card_database_display_model.cpp | 2 +- .../database/card_set/card_sets_model.cpp | 11 +++--- .../models/deck_list/deck_list_model.cpp | 6 +-- .../network/client/remote/remote_client.cpp | 8 ++-- .../game/server_abstract_participant.cpp | 6 +-- .../remote/game/server_abstract_player.cpp | 38 +++++++++---------- .../server/remote/game/server_cardzone.cpp | 16 ++++---- .../server/remote/game/server_game.cpp | 16 ++++---- .../server/remote/server_player_reference.h | 2 +- .../server/remote/server_protocolhandler.cpp | 20 +++++----- .../libcockatrice/rng/rng_abstract.cpp | 2 +- .../libcockatrice/utility/levenshtein.cpp | 2 +- servatrice/src/isl_interface.cpp | 7 ++-- servatrice/src/smtp/qxtmailmessage.cpp | 20 +++++----- servatrice/src/smtp/qxtsmtp.cpp | 4 +- 75 files changed, 269 insertions(+), 269 deletions(-) diff --git a/cockatrice/src/client/network/update/client/release_channel.cpp b/cockatrice/src/client/network/update/client/release_channel.cpp index 9edfe7caf..7cf40287f 100644 --- a/cockatrice/src/client/network/update/client/release_channel.cpp +++ b/cockatrice/src/client/network/update/client/release_channel.cpp @@ -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{}; diff --git a/cockatrice/src/client/settings/card_counter_settings.cpp b/cockatrice/src/client/settings/card_counter_settings.cpp index 71ce4cfc6..70d7f8b69 100644 --- a/cockatrice/src/client/settings/card_counter_settings.cpp +++ b/cockatrice/src/client/settings/card_counter_settings.cpp @@ -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; } diff --git a/cockatrice/src/game/board/abstract_card_item.cpp b/cockatrice/src/game/board/abstract_card_item.cpp index d5538011d..dcd12aa62 100644 --- a/cockatrice/src/game/board/abstract_card_item.cpp +++ b/cockatrice/src/game/board/abstract_card_item.cpp @@ -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(); diff --git a/cockatrice/src/game/board/abstract_counter.cpp b/cockatrice/src/game/board/abstract_counter.cpp index 985c78ad2..2e5f1b1c0 100644 --- a/cockatrice/src/game/board/abstract_counter.cpp +++ b/cockatrice/src/game/board/abstract_counter.cpp @@ -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(); diff --git a/cockatrice/src/game/board/arrow_item.cpp b/cockatrice/src/game/board/arrow_item.cpp index d5d0ebfe0..c98d0cc6f 100644 --- a/cockatrice/src/game/board/arrow_item.cpp +++ b/cockatrice/src/game/board/arrow_item.cpp @@ -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(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(startItem); auto targetCard = qgraphicsitem_cast(targetItem); if (startCard && targetCard) { diff --git a/cockatrice/src/game/board/card_drag_item.cpp b/cockatrice/src/game/board/card_drag_item.cpp index 9eadadeda..6be33773e 100644 --- a/cockatrice/src/game/board/card_drag_item.cpp +++ b/cockatrice/src/game/board/card_drag_item.cpp @@ -110,7 +110,7 @@ void CardDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) QList dragItemList; CardZoneLogic *startZone = static_cast(item)->getZone(); - if (currentZone && !(static_cast(item)->getAttachedTo() && (startZone == currentZone->getLogic()))) { + if (currentZone && !(static_cast(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(childDrags[i]); if (!occupied && - !(static_cast(c->item)->getAttachedTo() && (startZone == currentZone->getLogic())) && + !(static_cast(c->item)->getAttachedTo() && startZone == currentZone->getLogic()) && !c->occupied) { dragItemList.append(c); } diff --git a/cockatrice/src/game/board/card_item.cpp b/cockatrice/src/game/board/card_item.cpp index e786b5329..30ebd1f5c 100644 --- a/cockatrice/src/game/board/card_item.cpp +++ b/cockatrice/src/game/board/card_item.cpp @@ -358,7 +358,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) int childIndex = 0; for (const auto &item : scene()->selectedItems()) { CardItem *card = static_cast(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); diff --git a/cockatrice/src/game/deckview/deck_view.cpp b/cockatrice/src/game/deckview/deck_view.cpp index 64e9abc46..839c88a60 100644 --- a/cockatrice/src/game/deckview/deck_view.cpp +++ b/cockatrice/src/game/deckview/deck_view.cpp @@ -289,7 +289,7 @@ void DeckViewCardContainer::rearrangeItems(const QList> &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; } diff --git a/cockatrice/src/game/game_event_handler.cpp b/cockatrice/src/game/game_event_handler.cpp index 1cb47f368..c3a4df80e 100644 --- a/cockatrice/src/game/game_event_handler.cpp +++ b/cockatrice/src/game/game_event_handler.cpp @@ -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; diff --git a/cockatrice/src/game/game_scene.cpp b/cockatrice/src/game/game_scene.cpp index 2175f4aa2..ff3bb5740 100644 --- a/cockatrice/src/game/game_scene.cpp +++ b/cockatrice/src/game/game_scene.cpp @@ -235,7 +235,7 @@ QSizeF GameScene::computeSceneSizeAndPlayerLayout(const QList &players playersByColumn.append(QList()); 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; } diff --git a/cockatrice/src/game/log/message_log_widget.cpp b/cockatrice/src/game/log/message_log_widget.cpp index d4af5d00d..f2bdfdb92 100644 --- a/cockatrice/src/game/log/message_log_widget.cpp +++ b/cockatrice/src/game/log/message_log_widget.cpp @@ -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())) diff --git a/cockatrice/src/game/phases_toolbar.cpp b/cockatrice/src/game/phases_toolbar.cpp index 5106e40de..9c43e7c55 100644 --- a/cockatrice/src/game/phases_toolbar.cpp +++ b/cockatrice/src/game/phases_toolbar.cpp @@ -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; diff --git a/cockatrice/src/game/player/player_actions.cpp b/cockatrice/src/game/player/player_actions.cpp index e6efaf854..e751b130b 100644 --- a/cockatrice/src/game/player/player_actions.cpp +++ b/cockatrice/src/game/player/player_actions.cpp @@ -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; diff --git a/cockatrice/src/game/player/player_event_handler.cpp b/cockatrice/src/game/player/player_event_handler.cpp index 972229489..61a0d3515 100644 --- a/cockatrice/src/game/player/player_event_handler.cpp +++ b/cockatrice/src/game/player/player_event_handler.cpp @@ -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 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) { diff --git a/cockatrice/src/game/player/player_list_widget.cpp b/cockatrice/src/game/player/player_list_widget.cpp index 7cf7c34a6..fb1e77094 100644 --- a/cockatrice/src/game/player/player_list_widget.cpp +++ b/cockatrice/src/game/player/player_list_widget.cpp @@ -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(event); if (mouseEvent->button() == Qt::RightButton) { #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) @@ -135,8 +135,9 @@ void PlayerListWidget::updatePlayerProperties(const ServerInfo_PlayerProperties if (prop.has_ready_start()) 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)); + player->setIcon(2, gameStarted ? (prop.conceded() ? concededIcon : QIcon()) + : prop.ready_start() ? readyIcon + : notReadyIcon); } if (prop.has_user_info()) { player->setData(3, Qt::UserRole, prop.user_info().user_level()); diff --git a/cockatrice/src/game/zones/hand_zone.cpp b/cockatrice/src/game/zones/hand_zone.cpp index 860881f38..5ff227215 100644 --- a/cockatrice/src/game/zones/hand_zone.cpp +++ b/cockatrice/src/game/zones/hand_zone.cpp @@ -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); diff --git a/cockatrice/src/game/zones/logic/card_zone_logic.cpp b/cockatrice/src/game/zones/logic/card_zone_logic.cpp index a5dc64b50..32c218b9b 100644 --- a/cockatrice/src/game/zones/logic/card_zone_logic.cpp +++ b/cockatrice/src/game/zones/logic/card_zone_logic.cpp @@ -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(); } \ No newline at end of file diff --git a/cockatrice/src/game/zones/pile_zone.cpp b/cockatrice/src/game/zones/pile_zone.cpp index cafb29038..0b4ad8a11 100644 --- a/cockatrice/src/game/zones/pile_zone.cpp +++ b/cockatrice/src/game/zones/pile_zone.cpp @@ -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); diff --git a/cockatrice/src/game/zones/stack_zone.cpp b/cockatrice/src/game/zones/stack_zone.cpp index 0c0501705..766e12518 100644 --- a/cockatrice/src/game/zones/stack_zone.cpp +++ b/cockatrice/src/game/zones/stack_zone.cpp @@ -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); diff --git a/cockatrice/src/game/zones/table_zone.cpp b/cockatrice/src/game/zones/table_zone.cpp index 55aaeaa39..400f49e2c 100644 --- a/cockatrice/src/game/zones/table_zone.cpp +++ b/cockatrice/src/game/zones/table_zone.cpp @@ -50,10 +50,10 @@ QRectF TableZone::boundingRect() const bool TableZone::isInverted() const { - return ((getLogic()->getPlayer()->getGraphicsItem()->getMirrored() && - !SettingsCache::instance().getInvertVerticalCoordinate()) || + 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)) diff --git a/cockatrice/src/game/zones/table_zone.h b/cockatrice/src/game/zones/table_zone.h index 3b353e76c..c409c2ea7 100644 --- a/cockatrice/src/game/zones/table_zone.h +++ b/cockatrice/src/game/zones/table_zone.h @@ -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; } }; diff --git a/cockatrice/src/game/zones/view_zone.cpp b/cockatrice/src/game/zones/view_zone.cpp index d5eea9dfe..490a02bf9 100644 --- a/cockatrice/src/game/zones/view_zone.cpp +++ b/cockatrice/src/game/zones/view_zone.cpp @@ -88,7 +88,7 @@ void ZoneViewZone::initializeCards(const QList &cardLis getLogic()->getPlayer()->getPlayerActions()->sendGameCommand(pend); } else { const CardList &c = qobject_cast(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); } diff --git a/cockatrice/src/game/zones/view_zone_widget.cpp b/cockatrice/src/game/zones/view_zone_widget.cpp index e2f242883..8d1c748e8 100644 --- a/cockatrice/src/game/zones/view_zone_widget.cpp +++ b/cockatrice/src/game/zones/view_zone_widget.cpp @@ -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); diff --git a/cockatrice/src/game_graphics/board/abstract_graphics_item.cpp b/cockatrice/src/game_graphics/board/abstract_graphics_item.cpp index 8ced8d5bc..dacb529ff 100644 --- a/cockatrice/src/game_graphics/board/abstract_graphics_item.cpp +++ b/cockatrice/src/game_graphics/board/abstract_graphics_item.cpp @@ -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); } diff --git a/cockatrice/src/interface/deck_loader/deck_loader.cpp b/cockatrice/src/interface/deck_loader/deck_loader.cpp index 372aa0aa8..167cdd862 100644 --- a/cockatrice/src/interface/deck_loader/deck_loader.cpp +++ b/cockatrice/src/interface/deck_loader/deck_loader.cpp @@ -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(node->at(i))); } } diff --git a/cockatrice/src/interface/layouts/flow_layout.cpp b/cockatrice/src/interface/layouts/flow_layout.cpp index f7ebbfb79..3a0394511 100644 --- a/cockatrice/src/interface/layouts/flow_layout.cpp +++ b/cockatrice/src/interface/layouts/flow_layout.cpp @@ -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); } /** diff --git a/cockatrice/src/interface/layouts/overlap_layout.cpp b/cockatrice/src/interface/layouts/overlap_layout.cpp index 9bf5e8468..65cae02f3 100644 --- a/cockatrice/src/interface/layouts/overlap_layout.cpp +++ b/cockatrice/src/interface/layouts/overlap_layout.cpp @@ -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 diff --git a/cockatrice/src/interface/pixel_map_generator.cpp b/cockatrice/src/interface/pixel_map_generator.cpp index 382fff317..755060c9d 100644 --- a/cockatrice/src/interface/pixel_map_generator.cpp +++ b/cockatrice/src/interface/pixel_map_generator.cpp @@ -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); diff --git a/cockatrice/src/interface/widgets/cards/additional_info/color_identity_widget.cpp b/cockatrice/src/interface/widgets/cards/additional_info/color_identity_widget.cpp index 20f4b29df..5411d6f80 100644 --- a/cockatrice/src/interface/widgets/cards/additional_info/color_identity_widget.cpp +++ b/cockatrice/src/interface/widgets/cards/additional_info/color_identity_widget.cpp @@ -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) { diff --git a/cockatrice/src/interface/widgets/cards/additional_info/mana_cost_widget.cpp b/cockatrice/src/interface/widgets/cards/additional_info/mana_cost_widget.cpp index e5d1127aa..569e21821 100644 --- a/cockatrice/src/interface/widgets/cards/additional_info/mana_cost_widget.cpp +++ b/cockatrice/src/interface/widgets/cards/additional_info/mana_cost_widget.cpp @@ -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) { diff --git a/cockatrice/src/interface/widgets/deck_editor/deck_list_style_proxy.cpp b/cockatrice/src/interface/widgets/deck_editor/deck_list_style_proxy.cpp index 9c2265dfd..8faf464ab 100644 --- a/cockatrice/src/interface/widgets/deck_editor/deck_list_style_proxy.cpp +++ b/cockatrice/src/interface/widgets/deck_editor/deck_list_style_proxy.cpp @@ -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(); diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_connect.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_connect.cpp index ed32b356c..1ae85412e 100644 --- a/cockatrice/src/interface/widgets/dialogs/dlg_connect.cpp +++ b/cockatrice/src/interface/widgets/dialogs/dlg_connect.cpp @@ -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)); diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_manage_sets.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_manage_sets.cpp index 2d3bc08a4..a58d04d6d 100644 --- a/cockatrice/src/interface/widgets/dialogs/dlg_manage_sets.cpp +++ b/cockatrice/src/interface/widgets/dialogs/dlg_manage_sets.cpp @@ -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 rows) diff --git a/cockatrice/src/interface/widgets/general/display/banner_widget.cpp b/cockatrice/src/interface/widgets/general/display/banner_widget.cpp index f03869a4d..4491fe712 100644 --- a/cockatrice/src/interface/widgets/general/display/banner_widget.cpp +++ b/cockatrice/src/interface/widgets/general/display/banner_widget.cpp @@ -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; diff --git a/cockatrice/src/interface/widgets/general/display/bar_widget.cpp b/cockatrice/src/interface/widgets/general/display/bar_widget.cpp index 2194b6b03..0e71452a5 100644 --- a/cockatrice/src/interface/widgets/general/display/bar_widget.cpp +++ b/cockatrice/src/interface/widgets/general/display/bar_widget.cpp @@ -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)); diff --git a/cockatrice/src/interface/widgets/general/display/dynamic_font_size_label.cpp b/cockatrice/src/interface/widgets/general/display/dynamic_font_size_label.cpp index ed4db1fd3..982cb2e7c 100644 --- a/cockatrice/src/interface/widgets/general/display/dynamic_font_size_label.cpp +++ b/cockatrice/src/interface/widgets/general/display/dynamic_font_size_label.cpp @@ -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; diff --git a/cockatrice/src/interface/widgets/general/display/percent_bar_widget.cpp b/cockatrice/src/interface/widgets/general/display/percent_bar_widget.cpp index 3726dd061..a83d9f5e3 100644 --- a/cockatrice/src/interface/widgets/general/display/percent_bar_widget.cpp +++ b/cockatrice/src/interface/widgets/general/display/percent_bar_widget.cpp @@ -22,7 +22,7 @@ void PercentBarWidget::paintEvent(QPaintEvent *event) const double halfWidth = rect.width() / 2.0; - const int barLength = static_cast((qAbs(valueToDisplay) / 100.0) * halfWidth); + const int barLength = static_cast(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((percent / 100.0) * halfWidth); + int x = midX + static_cast(percent / 100.0 * halfWidth); painter.drawLine(x, height - tickHeight, x, height); } } diff --git a/cockatrice/src/interface/widgets/printing_selector/printing_selector_card_overlay_widget.cpp b/cockatrice/src/interface/widgets/printing_selector/printing_selector_card_overlay_widget.cpp index 5f3a44b30..63df95bee 100644 --- a/cockatrice/src/interface/widgets/printing_selector/printing_selector_card_overlay_widget.cpp +++ b/cockatrice/src/interface/widgets/printing_selector/printing_selector_card_overlay_widget.cpp @@ -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); diff --git a/cockatrice/src/interface/widgets/replay/replay_manager.cpp b/cockatrice/src/interface/widgets/replay/replay_manager.cpp index fac3576f2..e559f0315 100644 --- a/cockatrice/src/interface/widgets/replay/replay_manager.cpp +++ b/cockatrice/src/interface/widgets/replay/replay_manager.cpp @@ -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; diff --git a/cockatrice/src/interface/widgets/replay/replay_timeline_widget.cpp b/cockatrice/src/interface/widgets/replay/replay_timeline_widget.cpp index fb5936cae..fff11f9d3 100644 --- a/cockatrice/src/interface/widgets/replay/replay_timeline_widget.cpp +++ b/cockatrice/src/interface/widgets/replay/replay_timeline_widget.cpp @@ -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 diff --git a/cockatrice/src/interface/widgets/server/chat_view/chat_view.cpp b/cockatrice/src/interface/widgets/server/chat_view/chat_view.cpp index c97d32d44..189b1b3cc 100644 --- a/cockatrice/src/interface/widgets/server/chat_view/chat_view.cpp +++ b/cockatrice/src/interface/widgets/server/chat_view/chat_view.cpp @@ -103,9 +103,8 @@ void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold, { bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum(); - QString htmlText = - "" + - QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + ""; + QString htmlText = "" + QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + ""; if (optionalIsBold) htmlText = "" + htmlText + ""; @@ -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 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); diff --git a/cockatrice/src/interface/widgets/server/games_model.cpp b/cockatrice/src/interface/widgets/server/games_model.cpp index dfb41fd29..2b5ade3ab 100644 --- a/cockatrice/src/interface/widgets/server/games_model.cpp +++ b/cockatrice/src/interface/widgets/server/games_model.cpp @@ -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: diff --git a/cockatrice/src/interface/widgets/server/user/user_context_menu.cpp b/cockatrice/src/interface/widgets/server/user/user_context_menu.cpp index cb7d2eca9..1a016948a 100644 --- a/cockatrice/src/interface/widgets/server/user/user_context_menu.cpp +++ b/cockatrice/src/interface/widgets/server/user/user_context_menu.cpp @@ -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(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(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); } } diff --git a/cockatrice/src/interface/widgets/server/user/user_list_widget.cpp b/cockatrice/src/interface/widgets/server/user/user_list_widget.cpp index b6d65c5fa..1271b7cc0 100644 --- a/cockatrice/src/interface/widgets/server/user/user_list_widget.cpp +++ b/cockatrice/src/interface/widgets/server/user/user_list_widget.cpp @@ -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(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())); } diff --git a/cockatrice/src/interface/widgets/tabs/api/edhrec/tab_edhrec_main.cpp b/cockatrice/src/interface/widgets/tabs/api/edhrec/tab_edhrec_main.cpp index 0dcd5d0ae..834ac26ff 100644 --- a/cockatrice/src/interface/widgets/tabs/api/edhrec/tab_edhrec_main.cpp +++ b/cockatrice/src/interface/widgets/tabs/api/edhrec/tab_edhrec_main.cpp @@ -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); } diff --git a/cockatrice/src/interface/widgets/tabs/tab_message.cpp b/cockatrice/src/interface/widgets/tabs/tab_message.cpp index bd0457990..0dfd09e63 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_message.cpp +++ b/cockatrice/src/interface/widgets/tabs/tab_message.cpp @@ -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 || - (event.sender_name() == otherUserInfo->name() && - tabSupervisor->currentIndex() != tabSupervisor->indexOf(this))); + return QApplication::activeWindow() == 0 || QApplication::focusWidget() == 0 || + (event.sender_name() == otherUserInfo->name() && + tabSupervisor->currentIndex() != tabSupervisor->indexOf(this)); } void TabMessage::showSystemPopup(const Event_UserMessage &event) diff --git a/cockatrice/src/interface/widgets/tabs/tab_supervisor.cpp b/cockatrice/src/interface/widgets/tabs/tab_supervisor.cpp index 902b1f589..0c8aed63f 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_supervisor.cpp +++ b/cockatrice/src/interface/widgets/tabs/tab_supervisor.cpp @@ -454,7 +454,7 @@ void TabSupervisor::startLocal(const QList &_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] { diff --git a/cockatrice/src/interface/widgets/utility/line_edit_completer.cpp b/cockatrice/src/interface/widgets/utility/line_edit_completer.cpp index 7820ad91b..959b15680 100644 --- a/cockatrice/src/interface/widgets/utility/line_edit_completer.cpp +++ b/cockatrice/src/interface/widgets/utility/line_edit_completer.cpp @@ -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); diff --git a/cockatrice/src/interface/widgets/utility/sequence_edit.cpp b/cockatrice/src/interface/widgets/utility/sequence_edit.cpp index 7e14d4335..981150a86 100644 --- a/cockatrice/src/interface/widgets/utility/sequence_edit.cpp +++ b/cockatrice/src/interface/widgets/utility/sequence_edit.cpp @@ -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; } diff --git a/cockatrice/src/interface/widgets/visual_deck_editor/visual_deck_editor_widget.cpp b/cockatrice/src/interface/widgets/visual_deck_editor/visual_deck_editor_widget.cpp index c1e5ead3a..970562ddf 100644 --- a/cockatrice/src/interface/widgets/visual_deck_editor/visual_deck_editor_widget.cpp +++ b/cockatrice/src/interface/widgets/visual_deck_editor/visual_deck_editor_widget.cpp @@ -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) { diff --git a/cockatrice/src/interface/window_main.cpp b/cockatrice/src/interface/window_main.cpp index 622c04a08..b18df1a45 100644 --- a/cockatrice/src/interface/window_main.cpp +++ b/cockatrice/src/interface/window_main.cpp @@ -480,18 +480,17 @@ QString MainWindow::extractInvalidUsernameMessage(QString &in) out += tr("Your username must respect these rules:") + "
    "; out += "
  • " + tr("is %1 - %2 characters long").arg(rules.at(0)).arg(rules.at(1)) + "
  • "; - out += "
  • " + tr("can %1 contain lowercase characters").arg((rules.at(2).toInt() > 0) ? "" : tr("NOT")) + - "
  • "; - out += "
  • " + tr("can %1 contain uppercase characters").arg((rules.at(3).toInt() > 0) ? "" : tr("NOT")) + - "
  • "; out += - "
  • " + tr("can %1 contain numeric characters").arg((rules.at(4).toInt() > 0) ? "" : tr("NOT")) + "
  • "; + "
  • " + tr("can %1 contain lowercase characters").arg(rules.at(2).toInt() > 0 ? "" : tr("NOT")) + "
  • "; + out += + "
  • " + tr("can %1 contain uppercase characters").arg(rules.at(3).toInt() > 0 ? "" : tr("NOT")) + "
  • "; + out += "
  • " + tr("can %1 contain numeric characters").arg(rules.at(4).toInt() > 0 ? "" : tr("NOT")) + "
  • "; if (rules.at(6).size() > 0) out += "
  • " + tr("can contain the following punctuation: %1").arg(rules.at(6).toHtmlEscaped()) + "
  • "; out += "
  • " + - 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")) + "
  • "; if (rules.size() == 9) { diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index f20dab6fb..debc29e27 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -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); } diff --git a/libcockatrice_card/libcockatrice/card/card_info_comparator.cpp b/libcockatrice_card/libcockatrice/card/card_info_comparator.cpp index 821cc8675..95985e9cf 100644 --- a/libcockatrice_card/libcockatrice/card/card_info_comparator.cpp +++ b/libcockatrice_card/libcockatrice/card/card_info_comparator.cpp @@ -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; } } diff --git a/libcockatrice_card/libcockatrice/card/database/parser/cockatrice_xml_3.cpp b/libcockatrice_card/libcockatrice/card/database/parser/cockatrice_xml_3.cpp index 35e2f3d83..2a268a907 100644 --- a/libcockatrice_card/libcockatrice/card/database/parser/cockatrice_xml_3.cpp +++ b/libcockatrice_card/libcockatrice/card/database/parser/cockatrice_xml_3.cpp @@ -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() diff --git a/libcockatrice_card/libcockatrice/card/database/parser/cockatrice_xml_4.cpp b/libcockatrice_card/libcockatrice/card/database/parser/cockatrice_xml_4.cpp index ab4c8002d..fd4ab5fb0 100644 --- a/libcockatrice_card/libcockatrice/card/database/parser/cockatrice_xml_4.cpp +++ b/libcockatrice_card/libcockatrice/card/database/parser/cockatrice_xml_4.cpp @@ -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() diff --git a/libcockatrice_deck_list/libcockatrice/deck_list/abstract_deck_list_card_node.cpp b/libcockatrice_deck_list/libcockatrice/deck_list/abstract_deck_list_card_node.cpp index b8a497c20..4d29b821f 100644 --- a/libcockatrice_deck_list/libcockatrice/deck_list/abstract_deck_list_card_node.cpp +++ b/libcockatrice_deck_list/libcockatrice/deck_list/abstract_deck_list_card_node.cpp @@ -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(other); if (other2) { - return (getName() > other2->getName()); + return getName() > other2->getName(); } else { return true; } diff --git a/libcockatrice_deck_list/libcockatrice/deck_list/deck_list.cpp b/libcockatrice_deck_list/libcockatrice/deck_list/deck_list.cpp index e26e55e08..eb2d24afd 100644 --- a/libcockatrice_deck_list/libcockatrice/deck_list/deck_list.cpp +++ b/libcockatrice_deck_list/libcockatrice/deck_list/deck_list.cpp @@ -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'); } diff --git a/libcockatrice_deck_list/libcockatrice/deck_list/inner_deck_list_node.cpp b/libcockatrice_deck_list/libcockatrice/deck_list/inner_deck_list_node.cpp index eca58963a..c5eef6371 100644 --- a/libcockatrice_deck_list/libcockatrice/deck_list/inner_deck_list_node.cpp +++ b/libcockatrice_deck_list/libcockatrice/deck_list/inner_deck_list_node.cpp @@ -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(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> 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); diff --git a/libcockatrice_filters/libcockatrice/filters/filter_tree.cpp b/libcockatrice_filters/libcockatrice/filters/filter_tree.cpp index 89b772b8e..3919bbf7f 100644 --- a/libcockatrice_filters/libcockatrice/filters/filter_tree.cpp +++ b/libcockatrice_filters/libcockatrice/filters/filter_tree.cpp @@ -6,7 +6,7 @@ template FilterTreeNode *FilterTreeBranch::nodeAt(int i) const { - return (childNodes.size() > i) ? childNodes.at(i) : nullptr; + return childNodes.size() > i ? childNodes.at(i) : nullptr; } template void FilterTreeBranch::deleteAt(int i) @@ -21,7 +21,7 @@ template int FilterTreeBranch::childIndex(const FilterTreeNode *nod { auto *unconst = const_cast(node); auto downcasted = dynamic_cast(unconst); - return (downcasted) ? childNodes.indexOf(downcasted) : -1; + return downcasted ? childNodes.indexOf(downcasted) : -1; } template FilterTreeBranch::~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; diff --git a/libcockatrice_filters/libcockatrice/filters/filter_tree.h b/libcockatrice_filters/libcockatrice/filters/filter_tree.h index 7e0f211ef..196d9c6fb 100644 --- a/libcockatrice_filters/libcockatrice/filters/filter_tree.h +++ b/libcockatrice_filters/libcockatrice/filters/filter_tree.h @@ -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 { diff --git a/libcockatrice_models/libcockatrice/models/database/card_database_display_model.cpp b/libcockatrice_models/libcockatrice/models/database/card_database_display_model.cpp index 5ce63a939..c57251b6c 100644 --- a/libcockatrice_models/libcockatrice/models/database/card_database_display_model.cpp +++ b/libcockatrice_models/libcockatrice/models/database/card_database_display_model.cpp @@ -155,7 +155,7 @@ bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex { CardInfoPtr info = static_cast(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) { diff --git a/libcockatrice_models/libcockatrice/models/database/card_set/card_sets_model.cpp b/libcockatrice_models/libcockatrice/models/database/card_set/card_sets_model.cpp index 2af815246..c1824c029 100644 --- a/libcockatrice_models/libcockatrice/models/database/card_set/card_sets_model.cpp +++ b/libcockatrice_models/libcockatrice/models/database/card_set/card_sets_model.cpp @@ -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) || - sourceModel()->data(nameIndex).toString().contains(filter) || - sourceModel()->data(shortNameIndex).toString().contains(filter)); + return sourceModel()->data(typeIndex).toString().contains(filter) || + sourceModel()->data(nameIndex).toString().contains(filter) || + sourceModel()->data(shortNameIndex).toString().contains(filter); } bool SetsDisplayModel::lessThan(const QModelIndex &left, const QModelIndex &right) const diff --git a/libcockatrice_models/libcockatrice/models/deck_list/deck_list_model.cpp b/libcockatrice_models/libcockatrice/models/deck_list/deck_list_model.cpp index e3e2de58d..2efd554c3 100644 --- a/libcockatrice_models/libcockatrice/models/deck_list/deck_list_model.cpp +++ b/libcockatrice_models/libcockatrice/models/deck_list/deck_list_model.cpp @@ -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(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); diff --git a/libcockatrice_network/libcockatrice/network/client/remote/remote_client.cpp b/libcockatrice_network/libcockatrice/network/client/remote/remote_client.cpp index c0167a875..7f244e908 100644 --- a/libcockatrice_network/libcockatrice/network/client/remote/remote_client.cpp +++ b/libcockatrice_network/libcockatrice/network/client/remote/remote_client.cpp @@ -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; } diff --git a/libcockatrice_network/libcockatrice/network/server/remote/game/server_abstract_participant.cpp b/libcockatrice_network/libcockatrice/network/server/remote/game/server_abstract_participant.cpp index c6a29b275..9d3085cab 100644 --- a/libcockatrice_network/libcockatrice/network/server/remote/game/server_abstract_participant.cpp +++ b/libcockatrice_network/libcockatrice/network/server/remote/game/server_abstract_participant.cpp @@ -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; } diff --git a/libcockatrice_network/libcockatrice/network/server/remote/game/server_abstract_player.cpp b/libcockatrice_network/libcockatrice/network/server/remote/game/server_abstract_player.cpp index aaf7f1332..474b39ab6 100644 --- a/libcockatrice_network/libcockatrice/network/server/remote/game/server_abstract_player.cpp +++ b/libcockatrice_network/libcockatrice/network/server/remote/game/server_abstract_player.cpp @@ -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 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 toDelete; for (auto a : _arrows) { auto *tCard = qobject_cast(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(); diff --git a/libcockatrice_network/libcockatrice/network/server/remote/game/server_cardzone.cpp b/libcockatrice_network/libcockatrice/network/server/remote/game/server_cardzone.cpp index 68dcadd35..6704e24d7 100644 --- a/libcockatrice_network/libcockatrice/network/server/remote/game/server_cardzone.cpp +++ b/libcockatrice_network/libcockatrice/network/server/remote/game/server_cardzone.cpp @@ -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 &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 &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> placesToLook; for (auto &card : cards) - placesToLook.insert(QPair((card->getX() / 3) * 3, card->getY())); + placesToLook.insert(QPair(card->getX() / 3 * 3, card->getY())); QSetIterator> placeIterator(placesToLook); while (placeIterator.hasNext()) { diff --git a/libcockatrice_network/libcockatrice/network/server/remote/game/server_game.cpp b/libcockatrice_network/libcockatrice/network/server/remote/game/server_game.cpp index b0dc7fc5b..19b653a57 100644 --- a/libcockatrice_network/libcockatrice/network/server/remote/game/server_game.cpp +++ b/libcockatrice_network/libcockatrice/network/server/remote/game/server_game.cpp @@ -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)) diff --git a/libcockatrice_network/libcockatrice/network/server/remote/server_player_reference.h b/libcockatrice_network/libcockatrice/network/server/remote/server_player_reference.h index 07b2d3d2b..4b27c7fae 100644 --- a/libcockatrice_network/libcockatrice/network/server/remote/server_player_reference.h +++ b/libcockatrice_network/libcockatrice/network/server/remote/server_player_reference.h @@ -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; } }; diff --git a/libcockatrice_network/libcockatrice/network/server/remote/server_protocolhandler.cpp b/libcockatrice_network/libcockatrice/network/server/remote/server_protocolhandler.cpp index bfd8d113c..772c2c047 100644 --- a/libcockatrice_network/libcockatrice/network/server/remote/server_protocolhandler.cpp +++ b/libcockatrice_network/libcockatrice/network/server/remote/server_protocolhandler.cpp @@ -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(), diff --git a/libcockatrice_rng/libcockatrice/rng/rng_abstract.cpp b/libcockatrice_rng/libcockatrice/rng/rng_abstract.cpp index 63072b988..57aeb9bb3 100644 --- a/libcockatrice_rng/libcockatrice/rng/rng_abstract.cpp +++ b/libcockatrice_rng/libcockatrice/rng/rng_abstract.cpp @@ -8,7 +8,7 @@ QVector RNG_Abstract::makeNumbersVector(int n, int min, int max) QVector 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]++; diff --git a/libcockatrice_utility/libcockatrice/utility/levenshtein.cpp b/libcockatrice_utility/libcockatrice/utility/levenshtein.cpp index cfb972f91..4863a5115 100644 --- a/libcockatrice_utility/libcockatrice/utility/levenshtein.cpp +++ b/libcockatrice_utility/libcockatrice/utility/levenshtein.cpp @@ -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}); } } diff --git a/servatrice/src/isl_interface.cpp b/servatrice/src/isl_interface.cpp index 2269ff314..7b414e5f1 100644 --- a/servatrice/src/isl_interface.cpp +++ b/servatrice/src/isl_interface.cpp @@ -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 diff --git a/servatrice/src/smtp/qxtmailmessage.cpp b/servatrice/src/smtp/qxtmailmessage.cpp index ca003d875..f121fa01f 100644 --- a/servatrice/src/smtp/qxtmailmessage.cpp +++ b/servatrice/src/smtp/qxtmailmessage.cpp @@ -38,12 +38,13 @@ #include #include -static bool isASCII(const QString &string) { - for(const QChar &chr : string){ - if(chr.unicode() > 0x7f) - return false; - } - return true; +static bool isASCII(const QString &string) +{ + for (const QChar &chr : string) { + if (chr.unicode() > 0x7f) + return false; + } + return true; } struct QxtMailMessagePrivate : public QSharedData @@ -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"; diff --git a/servatrice/src/smtp/qxtsmtp.cpp b/servatrice/src/smtp/qxtsmtp.cpp index 951492d7a..86fb025cf 100644 --- a/servatrice/src/smtp/qxtsmtp.cpp +++ b/servatrice/src/smtp/qxtsmtp.cpp @@ -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 == ')') {