diff --git a/.ci/release_template.md b/.ci/release_template.md index 17cd83e93..3c8c9d9df 100644 --- a/.ci/release_template.md +++ b/.ci/release_template.md @@ -44,7 +44,7 @@ If you'd like to help contribute to Cockatrice in any way, check out our [README > ⚠️ **With this release, we no longer provide a ready-to-install binary for:** > --DEPRECATED-OS-HERE-- --> - + - Run the internal software updater: Help → Check for Client Updates Don't forget to update your card database right after! (Help → Check for Card Updates...) diff --git a/cockatrice/src/player.cpp b/cockatrice/src/player.cpp index fe193bc50..6f3d1acd2 100644 --- a/cockatrice/src/player.cpp +++ b/cockatrice/src/player.cpp @@ -2615,15 +2615,6 @@ void Player::clearArrows() void Player::rearrangeCounters() { qreal marginTop = 80; - - // Determine total height of bounding rectangles - qreal totalHeight = 0; - for (const auto &counter : counters) { - if (counter->getShownInCounterArea()) { - totalHeight += counter->boundingRect().height(); - } - } - const qreal padding = 5; qreal ySize = boundingRect().y() + marginTop; diff --git a/common/passwordhasher.cpp b/common/passwordhasher.cpp index 83085d6f5..bc5f072e8 100644 --- a/common/passwordhasher.cpp +++ b/common/passwordhasher.cpp @@ -4,11 +4,6 @@ #include -void PasswordHasher::initialize() -{ - // dummy -} - QString PasswordHasher::computeHash(const QString &password, const QString &salt) { QCryptographicHash::Algorithm algo = QCryptographicHash::Sha512; @@ -41,4 +36,4 @@ QString PasswordHasher::generateRandomSalt(const int len) QString PasswordHasher::generateActivationToken() { return QCryptographicHash::hash(generateRandomSalt().toUtf8(), QCryptographicHash::Md5).toBase64().left(16); -} \ No newline at end of file +} diff --git a/common/passwordhasher.h b/common/passwordhasher.h index 075579754..811ecef15 100644 --- a/common/passwordhasher.h +++ b/common/passwordhasher.h @@ -6,7 +6,6 @@ class PasswordHasher { public: - static void initialize(); static QString computeHash(const QString &password, const QString &salt); static QString generateRandomSalt(const int len = 16); static QString generateActivationToken(); diff --git a/common/server_protocolhandler.cpp b/common/server_protocolhandler.cpp index a560d84e4..1ca934aca 100644 --- a/common/server_protocolhandler.cpp +++ b/common/server_protocolhandler.cpp @@ -50,9 +50,9 @@ void Server_ProtocolHandler::prepareDestroy() return; deleted = true; - QMapIterator roomIterator(rooms); - while (roomIterator.hasNext()) - roomIterator.next().value()->removeClient(this); + for (auto *room : rooms.values()) { + room->removeClient(this); + } QMap> tempGames(getGames()); @@ -61,27 +61,27 @@ void Server_ProtocolHandler::prepareDestroy() while (gameIterator.hasNext()) { gameIterator.next(); - Server_Room *r = server->getRooms().value(gameIterator.value().first); - if (!r) + Server_Room *room = server->getRooms().value(gameIterator.value().first); + if (!room) continue; - r->gamesLock.lockForRead(); - Server_Game *g = r->getGames().value(gameIterator.key()); - if (!g) { - r->gamesLock.unlock(); + room->gamesLock.lockForRead(); + Server_Game *game = room->getGames().value(gameIterator.key()); + if (!game) { + room->gamesLock.unlock(); continue; } - g->gameMutex.lock(); - Server_Player *p = g->getPlayers().value(gameIterator.value().second); + game->gameMutex.lock(); + Server_Player *p = game->getPlayers().value(gameIterator.value().second); if (!p) { - g->gameMutex.unlock(); - r->gamesLock.unlock(); + game->gameMutex.unlock(); + room->gamesLock.unlock(); continue; } p->disconnectClient(); - g->gameMutex.unlock(); - r->gamesLock.unlock(); + game->gameMutex.unlock(); + room->gamesLock.unlock(); } server->roomsLock.unlock(); @@ -671,24 +671,24 @@ Response::ResponseCode Server_ProtocolHandler::cmdJoinRoom(const Command_JoinRoo return Response::RespContextError; QReadLocker serverLocker(&server->roomsLock); - Server_Room *r = server->getRooms().value(cmd.room_id(), 0); - if (!r) + Server_Room *room = server->getRooms().value(cmd.room_id(), 0); + if (!room) return Response::RespNameNotFound; if (!(userInfo->user_level() & ServerInfo_User::IsModerator)) - if (!(r->userMayJoin(*userInfo))) + if (!(room->userMayJoin(*userInfo))) return Response::RespUserLevelTooLow; - r->addClient(this); - rooms.insert(r->getId(), r); + room->addClient(this); + rooms.insert(room->getId(), room); Event_RoomSay joinMessageEvent; - joinMessageEvent.set_message(r->getJoinMessage().toStdString()); + joinMessageEvent.set_message(room->getJoinMessage().toStdString()); joinMessageEvent.set_message_type(Event_RoomSay::Welcome); - rc.enqueuePostResponseItem(ServerMessage::ROOM_EVENT, r->prepareRoomEvent(joinMessageEvent)); + rc.enqueuePostResponseItem(ServerMessage::ROOM_EVENT, room->prepareRoomEvent(joinMessageEvent)); - QReadLocker chatHistoryLocker(&r->historyLock); - QList chatHistory = r->getChatHistory(); + QReadLocker chatHistoryLocker(&room->historyLock); + QList chatHistory = room->getChatHistory(); ServerInfo_ChatMessage chatMessage; for (int i = 0; i < chatHistory.size(); ++i) { chatMessage = chatHistory.at(i); @@ -697,11 +697,11 @@ Response::ResponseCode Server_ProtocolHandler::cmdJoinRoom(const Command_JoinRoo roomChatHistory.set_message_type(Event_RoomSay::ChatHistory); roomChatHistory.set_time_of( QDateTime::fromString(QString::fromStdString(chatMessage.time())).toMSecsSinceEpoch()); - rc.enqueuePostResponseItem(ServerMessage::ROOM_EVENT, r->prepareRoomEvent(roomChatHistory)); + rc.enqueuePostResponseItem(ServerMessage::ROOM_EVENT, room->prepareRoomEvent(roomChatHistory)); } Response_JoinRoom *re = new Response_JoinRoom; - r->getInfo(*re->mutable_room_info(), true); + room->getInfo(*re->mutable_room_info(), true); rc.setResponseExtension(re); return Response::RespOk; diff --git a/servatrice/src/main.cpp b/servatrice/src/main.cpp index 357a91705..de34755a2 100644 --- a/servatrice/src/main.cpp +++ b/servatrice/src/main.cpp @@ -171,8 +171,6 @@ int main(int argc, char *argv[]) std::cerr << "Servatrice " << VERSION_STRING << " starting." << std::endl; std::cerr << "-------------------------" << std::endl; - PasswordHasher::initialize(); - if (testRandom) { testRNG(); } diff --git a/servatrice/src/servatrice.cpp b/servatrice/src/servatrice.cpp index 26c3eab39..8a25cf3ef 100644 --- a/servatrice/src/servatrice.cpp +++ b/servatrice/src/servatrice.cpp @@ -206,8 +206,9 @@ Servatrice::~Servatrice() // clients live in other threads, we need to lock them clientsLock.lockForRead(); - for (auto client : clients) + for (auto *client : clients) { QMetaObject::invokeMethod(client, "prepareDestroy", Qt::QueuedConnection); + } clientsLock.unlock(); // client destruction is asynchronous, wait for all clients to be gone diff --git a/servatrice/src/serversocketinterface.cpp b/servatrice/src/serversocketinterface.cpp index 47fbe8fbf..bdfe6d999 100644 --- a/servatrice/src/serversocketinterface.cpp +++ b/servatrice/src/serversocketinterface.cpp @@ -893,8 +893,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdWarnUser(const Command_ delete se; } - QListIterator modIterator(moderatorList); - foreach (QString moderator, moderatorList) { + for (QString &moderator : moderatorList) { QString notificationMessage = sendingModerator + " has sent a warning with the following information"; notificationMessage.append("\n Username: " + userName); notificationMessage.append("\n Reason: " + warningReason); @@ -987,8 +986,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdBanFromServer(const Com } } - QListIterator modIterator(moderatorList); - foreach (QString moderator, moderatorList) { + for (QString &moderator : moderatorList) { QString notificationMessage = QString::fromStdString(userInfo->name()).simplified() + " has placed a ban with the following information"; if (!userName.isEmpty())