[Fix-Warnings] Remove redundant parentheses

This commit is contained in:
Brübach, Lukas 2025-11-29 09:23:11 +01:00
parent 858361e6d3
commit 8ddbdf31f9
75 changed files with 269 additions and 269 deletions

View file

@ -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;
}

View file

@ -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;
}

View file

@ -209,12 +209,12 @@ Response::ResponseCode Server_AbstractPlayer::moveCard(GameEventStorage &ges,
bool isReversed)
{
// Disallow controller change to other zones than the table.
if (((targetzone->getType() != ServerInfo_Zone::PublicZone) || !targetzone->hasCoords()) &&
(startzone->getPlayer() != targetzone->getPlayer()) && !judge) {
if ((targetzone->getType() != ServerInfo_Zone::PublicZone || !targetzone->hasCoords()) &&
startzone->getPlayer() != targetzone->getPlayer() && !judge) {
return Response::RespContextError;
}
if (!targetzone->hasCoords() && (xCoord <= -1)) {
if (!targetzone->hasCoords() && xCoord <= -1) {
xCoord = targetzone->getCards().size();
}
@ -284,7 +284,7 @@ Response::ResponseCode Server_AbstractPlayer::moveCard(GameEventStorage &ges,
for (auto *player : game->getPlayers().values()) {
QList<int> arrowsToDelete;
for (Server_Arrow *arrow : player->getArrows()) {
if ((arrow->getStartCard() == card) || (arrow->getTargetItem() == card))
if (arrow->getStartCard() == card || arrow->getTargetItem() == card)
arrowsToDelete.append(arrow->getId());
}
for (int j : arrowsToDelete) {
@ -334,11 +334,11 @@ Response::ResponseCode Server_AbstractPlayer::moveCard(GameEventStorage &ges,
targetzone->setCardsBeingLookedAt(targetLookedCards);
}
bool targetHiddenToOthers = faceDown || (targetzone->getType() != ServerInfo_Zone::PublicZone);
bool sourceHiddenToOthers = card->getFaceDown() || (startzone->getType() != ServerInfo_Zone::PublicZone);
bool targetHiddenToOthers = faceDown || targetzone->getType() != ServerInfo_Zone::PublicZone;
bool sourceHiddenToOthers = card->getFaceDown() || startzone->getType() != ServerInfo_Zone::PublicZone;
int oldCardId = card->getId();
if ((faceDown && (startzone != targetzone)) || (targetzone->getPlayer() != startzone->getPlayer())) {
if ((faceDown && startzone != targetzone) || targetzone->getPlayer() != startzone->getPlayer()) {
card->setId(targetzone->getPlayer()->newCardId());
}
card->setFaceDown(faceDown);
@ -378,19 +378,19 @@ Response::ResponseCode Server_AbstractPlayer::moveCard(GameEventStorage &ges,
if (
// cards from public zones have their id known, their previous position is already known, the event does
// not accomodate for previous locations in zones with coordinates (which are always public)
(startzone->getType() != ServerInfo_Zone::PublicZone) &&
startzone->getType() != ServerInfo_Zone::PublicZone &&
// other players are not allowed to be able to track which card is which in private zones like the hand
(startzone->getType() != ServerInfo_Zone::PrivateZone)) {
startzone->getType() != ServerInfo_Zone::PrivateZone) {
eventOthers.set_position(position);
}
if (
// other players are not allowed to be able to track which card is which in private zones like the hand
(targetzone->getType() != ServerInfo_Zone::PrivateZone)) {
targetzone->getType() != ServerInfo_Zone::PrivateZone) {
eventOthers.set_x(newX);
}
if ((startzone->getType() == ServerInfo_Zone::PublicZone) ||
(targetzone->getType() == ServerInfo_Zone::PublicZone)) {
if (startzone->getType() == ServerInfo_Zone::PublicZone ||
targetzone->getType() == ServerInfo_Zone::PublicZone) {
eventOthers.set_card_id(oldCardId);
if (!(sourceHiddenToOthers && targetHiddenToOthers)) {
QString publicCardName = card->getName();
@ -628,7 +628,7 @@ Server_AbstractPlayer::cmdConcede(const Command_Concede & /*cmd*/, ResponseConta
ges.setGameEventContext(Context_Concede());
game->stopGameIfFinished();
if (game->getGameStarted() && (game->getActivePlayer() == playerId)) {
if (game->getGameStarted() && game->getActivePlayer() == playerId) {
game->nextTurn();
}
@ -735,7 +735,7 @@ Server_AbstractPlayer::cmdMoveCard(const Command_MoveCard &cmd, ResponseContaine
return Response::RespNameNotFound;
}
if ((startPlayer != this) && (!startZone->getPlayersWithWritePermission().contains(playerId)) && !judge) {
if (startPlayer != this && !startZone->getPlayersWithWritePermission().contains(playerId) && !judge) {
return Response::RespContextError;
}
@ -748,7 +748,7 @@ Server_AbstractPlayer::cmdMoveCard(const Command_MoveCard &cmd, ResponseContaine
return Response::RespNameNotFound;
}
if ((startPlayer != this) && (targetPlayer != this) && !judge) {
if (startPlayer != this && targetPlayer != this && !judge) {
return Response::RespContextError;
}
@ -872,7 +872,7 @@ Server_AbstractPlayer::cmdAttachCard(const Command_AttachCard &cmd, ResponseCont
QList<Server_Arrow *> toDelete;
for (auto a : _arrows) {
auto *tCard = qobject_cast<Server_Card *>(a->getTargetItem());
if ((tCard == card) || (a->getStartCard() == card)) {
if (tCard == card || a->getStartCard() == card) {
toDelete.append(a);
}
}
@ -1202,7 +1202,7 @@ Server_AbstractPlayer::cmdCreateArrow(const Command_CreateArrow &cmd, ResponseCo
}
for (Server_Arrow *temp : arrows) {
if ((temp->getStartCard() == startCard) && (temp->getTargetItem() == targetItem)) {
if (temp->getStartCard() == startCard && temp->getTargetItem() == targetItem) {
return Response::RespContextError;
}
}
@ -1349,7 +1349,7 @@ Server_AbstractPlayer::cmdDumpZone(const Command_DumpZone &cmd, ResponseContaine
if (!zone) {
return Response::RespNameNotFound;
}
if (!((zone->getType() == ServerInfo_Zone::PublicZone) || (this == otherPlayer))) {
if (!(zone->getType() == ServerInfo_Zone::PublicZone || this == otherPlayer)) {
return Response::RespContextError;
}
@ -1363,7 +1363,7 @@ Server_AbstractPlayer::cmdDumpZone(const Command_DumpZone &cmd, ResponseContaine
zoneInfo->set_with_coords(zone->hasCoords());
zoneInfo->set_card_count(numberCards < cards.size() ? cards.size() : numberCards);
for (int i = 0; (i < cards.size()) && (i < numberCards || numberCards == -1); ++i) {
for (int i = 0; i < cards.size() && (i < numberCards || numberCards == -1); ++i) {
const auto &findId = cmd.is_reversed() ? cards.size() - numberCards + i : i;
Server_Card *card = cards[findId];
QString displayedName = card->getFaceDown() ? QString() : card->getName();

View file

@ -77,7 +77,7 @@ void Server_CardZone::removeCardFromCoordMap(Server_Card *card, int oldX, int ol
if (oldX < 0)
return;
const int baseX = (oldX / 3) * 3;
const int baseX = oldX / 3 * 3;
QMap<int, Server_Card *> &coordMap = coordinateMap[oldY];
if (coordMap.contains(baseX) && coordMap.contains(baseX + 1) && coordMap.contains(baseX + 2))
@ -117,7 +117,7 @@ void Server_CardZone::insertCardIntoCoordMap(Server_Card *card, int x, int y)
freeSpaceMap[y] = nextFreeX;
}
} else if (!((x - 2) % 3)) {
const int baseX = (x / 3) * 3;
const int baseX = x / 3 * 3;
freePilesMap[y].remove(coordinateMap[y].value(baseX)->getName(), baseX);
}
}
@ -161,7 +161,7 @@ Server_Card *Server_CardZone::getCard(int id, int *position, bool remove)
}
return nullptr;
} else {
if ((id >= cards.size()) || (id < 0))
if (id >= cards.size() || id < 0)
return nullptr;
Server_Card *tmp = cards[id];
if (position)
@ -184,7 +184,7 @@ int Server_CardZone::getFreeGridColumn(int x, int y, const QString &cardName, bo
const QMap<int, Server_Card *> &coordMap = coordinateMap.value(y);
if (x == -1) {
if (!dontStackSameName && freePilesMap[y].contains(cardName)) {
x = (freePilesMap[y].value(cardName) / 3) * 3;
x = freePilesMap[y].value(cardName) / 3 * 3;
if (coordMap.contains(x) && (coordMap[x]->getFaceDown() || !coordMap[x]->getAttachedCards().isEmpty())) {
// don't pile up on: 1. facedown cards 2. cards with attached cards
@ -197,7 +197,7 @@ int Server_CardZone::getFreeGridColumn(int x, int y, const QString &cardName, bo
}
} else if (x >= 0) {
int resultX = 0;
x = (x / 3) * 3;
x = x / 3 * 3;
if (!coordMap.contains(x))
resultX = x;
else if (!coordMap.value(x)->getAttachedCards().isEmpty()) {
@ -226,7 +226,7 @@ bool Server_CardZone::isColumnStacked(int x, int y) const
if (!has_coords)
return false;
return coordinateMap[y].contains((x / 3) * 3 + 1);
return coordinateMap[y].contains(x / 3 * 3 + 1);
}
bool Server_CardZone::isColumnEmpty(int x, int y) const
@ -234,7 +234,7 @@ bool Server_CardZone::isColumnEmpty(int x, int y) const
if (!has_coords)
return true;
return !coordinateMap[y].contains((x / 3) * 3);
return !coordinateMap[y].contains(x / 3 * 3);
}
void Server_CardZone::moveCardInRow(GameEventStorage &ges, Server_Card *card, int x, int y)
@ -252,7 +252,7 @@ void Server_CardZone::fixFreeSpaces(GameEventStorage &ges)
QSet<QPair<int, int>> placesToLook;
for (auto &card : cards)
placesToLook.insert(QPair<int, int>((card->getX() / 3) * 3, card->getY()));
placesToLook.insert(QPair<int, int>(card->getX() / 3 * 3, card->getY()));
QSetIterator<QPair<int, int>> placeIterator(placesToLook);
while (placeIterator.hasNext()) {

View file

@ -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))

View file

@ -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;
}
};

View file

@ -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(),