mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-11 12:54:10 -07:00
[Fix-Warnings] Local variable can be made const
This commit is contained in:
parent
8abd04dab1
commit
f2d3e81331
214 changed files with 1375 additions and 1355 deletions
|
|
@ -68,7 +68,7 @@ IslInterface::~IslInterface()
|
|||
server->roomsLock.lockForRead();
|
||||
QMapIterator<int, Server_Room *> roomIterator(server->getRooms());
|
||||
while (roomIterator.hasNext()) {
|
||||
Server_Room *room = roomIterator.next().value();
|
||||
const Server_Room *room = roomIterator.next().value();
|
||||
room->usersLock.lockForRead();
|
||||
QMapIterator<QString, ServerInfo_User_Container> roomUsers(room->getExternalUsers());
|
||||
while (roomUsers.hasNext()) {
|
||||
|
|
@ -113,7 +113,7 @@ void IslInterface::initServer()
|
|||
socket->startServerEncryption();
|
||||
if (!socket->waitForEncrypted(5000)) {
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||
QList<QSslError> sslErrors(socket->sslHandshakeErrors());
|
||||
const QList<QSslError> sslErrors(socket->sslHandshakeErrors());
|
||||
#else
|
||||
QList<QSslError> sslErrors(socket->sslErrors());
|
||||
#endif
|
||||
|
|
@ -146,7 +146,7 @@ void IslInterface::initServer()
|
|||
server->roomsLock.lockForRead();
|
||||
QMapIterator<int, Server_Room *> roomIterator(server->getRooms());
|
||||
while (roomIterator.hasNext()) {
|
||||
Server_Room *room = roomIterator.next().value();
|
||||
const Server_Room *room = roomIterator.next().value();
|
||||
room->usersLock.lockForRead();
|
||||
room->gamesLock.lockForRead();
|
||||
room->getInfo(*event.add_room_list(), true, true, false);
|
||||
|
|
@ -194,7 +194,7 @@ void IslInterface::initClient()
|
|||
}
|
||||
if (!socket->waitForEncrypted(5000)) {
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||
QList<QSslError> sslErrors(socket->sslHandshakeErrors());
|
||||
const QList<QSslError> sslErrors(socket->sslHandshakeErrors());
|
||||
#else
|
||||
QList<QSslError> sslErrors(socket->sslErrors());
|
||||
#endif
|
||||
|
|
@ -230,7 +230,7 @@ void IslInterface::flushOutputBuffer()
|
|||
|
||||
void IslInterface::readClient()
|
||||
{
|
||||
QByteArray data = socket->readAll();
|
||||
const QByteArray data = socket->readAll();
|
||||
server->incRxBytes(data.size());
|
||||
inputBuffer.append(data);
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ void IslInterface::transmitMessage(const IslMessage &item)
|
|||
{
|
||||
QByteArray buf;
|
||||
#if GOOGLE_PROTOBUF_VERSION > 3001000
|
||||
unsigned int size = static_cast<unsigned int>(item.ByteSizeLong());
|
||||
const unsigned int size = static_cast<unsigned int>(item.ByteSizeLong());
|
||||
#else
|
||||
unsigned int size = static_cast<unsigned int>(item.ByteSize());
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ void testRNG()
|
|||
std::cerr << std::endl;
|
||||
}
|
||||
std::cerr << std::endl << "Chi^2 =";
|
||||
for (double j : chisq)
|
||||
for (const double j : chisq)
|
||||
std::cerr << "\t" << QString::number(j, 'f', 3).toStdString();
|
||||
std::cerr << std::endl << "k =";
|
||||
for (int j = 0; j < chisq.size(); ++j)
|
||||
|
|
@ -89,10 +89,10 @@ void testHash()
|
|||
{
|
||||
const int n = 5000;
|
||||
std::cerr << "Benchmarking password hash function (n =" << n << ")..." << std::endl;
|
||||
QDateTime startTime = QDateTime::currentDateTime();
|
||||
const QDateTime startTime = QDateTime::currentDateTime();
|
||||
for (int i = 0; i < n; ++i)
|
||||
PasswordHasher::computeHash("aaaaaa", "aaaaaaaaaaaaaaaa");
|
||||
QDateTime endTime = QDateTime::currentDateTime();
|
||||
const QDateTime endTime = QDateTime::currentDateTime();
|
||||
std::cerr << startTime.secsTo(endTime) << "secs" << std::endl;
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ void myMessageOutput2(QtMsgType /*type*/, const QMessageLogContext &, const QStr
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
const QCoreApplication app(argc, argv);
|
||||
QCoreApplication::setOrganizationName("Cockatrice");
|
||||
QCoreApplication::setApplicationName("Servatrice");
|
||||
QCoreApplication::setApplicationVersion(VERSION_STRING);
|
||||
|
|
@ -118,23 +118,23 @@ int main(int argc, char *argv[])
|
|||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
|
||||
QCommandLineOption testRandomOpt("test-random", "Test PRNG (chi^2)");
|
||||
const QCommandLineOption testRandomOpt("test-random", "Test PRNG (chi^2)");
|
||||
parser.addOption(testRandomOpt);
|
||||
|
||||
QCommandLineOption testHashFunctionOpt("test-hash", "Test password hash function");
|
||||
const QCommandLineOption testHashFunctionOpt("test-hash", "Test password hash function");
|
||||
parser.addOption(testHashFunctionOpt);
|
||||
|
||||
QCommandLineOption logToConsoleOpt("log-to-console", "Write server logs to console");
|
||||
const QCommandLineOption logToConsoleOpt("log-to-console", "Write server logs to console");
|
||||
parser.addOption(logToConsoleOpt);
|
||||
|
||||
QCommandLineOption configPathOpt("config", "Read server configuration from <file>", "file", "");
|
||||
const QCommandLineOption configPathOpt("config", "Read server configuration from <file>", "file", "");
|
||||
parser.addOption(configPathOpt);
|
||||
|
||||
parser.process(app);
|
||||
|
||||
bool testRandom = parser.isSet(testRandomOpt);
|
||||
bool testHashFunction = parser.isSet(testHashFunctionOpt);
|
||||
bool logToConsole = parser.isSet(logToConsoleOpt);
|
||||
const bool testRandom = parser.isSet(testRandomOpt);
|
||||
const bool testHashFunction = parser.isSet(testHashFunctionOpt);
|
||||
const bool logToConsole = parser.isSet(logToConsoleOpt);
|
||||
QString configPath = parser.value(configPathOpt);
|
||||
|
||||
qRegisterMetaType<QList<int>>("QList<int>");
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ ServerLogger::~ServerLogger()
|
|||
void ServerLogger::startLog(const QString &logFileName)
|
||||
{
|
||||
if (!logFileName.isEmpty()) {
|
||||
QFileInfo fi(logFileName);
|
||||
QDir fileDir(fi.path());
|
||||
const QFileInfo fi(logFileName);
|
||||
const QDir fileDir(fi.path());
|
||||
if (!fileDir.exists() && !fileDir.mkpath(fileDir.absolutePath())) {
|
||||
std::cerr << "ERROR: logfile folder doesn't exist and i can't create it." << std::endl;
|
||||
logFile = 0;
|
||||
|
|
@ -55,8 +55,8 @@ void ServerLogger::logMessage(const QString &message, void *caller)
|
|||
callerString = QString::number((qulonglong)caller, 16) + " ";
|
||||
|
||||
// filter out all log entries based on values in configuration file
|
||||
bool shouldWeWriteLog = settingsCache->value("server/writelog", 1).toBool();
|
||||
QString logFilters = settingsCache->value("server/logfilters").toString();
|
||||
const bool shouldWeWriteLog = settingsCache->value("server/writelog", 1).toBool();
|
||||
const QString logFilters = settingsCache->value("server/logfilters").toString();
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
QStringList listlogFilters = logFilters.split(",", Qt::SkipEmptyParts);
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ SmtpClient::~SmtpClient()
|
|||
|
||||
bool SmtpClient::enqueueActivationTokenMail(const QString &nickname, const QString &recipient, const QString &token)
|
||||
{
|
||||
QString email = settingsCache->value("smtp/email", "").toString();
|
||||
QString name = settingsCache->value("smtp/name", "").toString();
|
||||
QString subject = settingsCache->value("smtp/subject", "").toString();
|
||||
const QString email = settingsCache->value("smtp/email", "").toString();
|
||||
const QString name = settingsCache->value("smtp/name", "").toString();
|
||||
const QString subject = settingsCache->value("smtp/subject", "").toString();
|
||||
QString body = settingsCache->value("smtp/body", "").toString();
|
||||
|
||||
if (email.isEmpty()) {
|
||||
|
|
@ -74,16 +74,16 @@ bool SmtpClient::enqueueActivationTokenMail(const QString &nickname, const QStri
|
|||
message.setSubject(subject);
|
||||
message.setBody(body.replace("%username", nickname).replace("%token", token));
|
||||
|
||||
int id = smtp->send(message);
|
||||
const int id = smtp->send(message);
|
||||
qDebug() << "[MAIL] Enqueued mail to" << recipient << "as" << id;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SmtpClient::enqueueForgotPasswordTokenMail(const QString &nickname, const QString &recipient, const QString &token)
|
||||
{
|
||||
QString email = settingsCache->value("smtp/email", "").toString();
|
||||
QString name = settingsCache->value("smtp/name", "").toString();
|
||||
QString subject = settingsCache->value("forgotpassword/subject", "").toString();
|
||||
const QString email = settingsCache->value("smtp/email", "").toString();
|
||||
const QString name = settingsCache->value("smtp/name", "").toString();
|
||||
const QString subject = settingsCache->value("forgotpassword/subject", "").toString();
|
||||
QString body = settingsCache->value("forgotpassword/body", "").toString();
|
||||
|
||||
if (email.isEmpty()) {
|
||||
|
|
@ -117,7 +117,7 @@ bool SmtpClient::enqueueForgotPasswordTokenMail(const QString &nickname, const Q
|
|||
message.setSubject(subject);
|
||||
message.setBody(body.replace("%username", nickname).replace("%token", token));
|
||||
|
||||
int id = smtp->send(message);
|
||||
const int id = smtp->send(message);
|
||||
qDebug() << "[MAIL] Enqueued mail to" << recipient << "as" << id;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -131,12 +131,12 @@ void SmtpClient::sendAllEmails()
|
|||
if (smtp->pendingMessages() == 0)
|
||||
return;
|
||||
|
||||
QString connectionType = settingsCache->value("smtp/connection", "tcp").toString();
|
||||
QString host = settingsCache->value("smtp/host", "localhost").toString();
|
||||
int port = settingsCache->value("smtp/port", 25).toInt();
|
||||
QByteArray username = settingsCache->value("smtp/username", "").toByteArray();
|
||||
QByteArray password = settingsCache->value("smtp/password", "").toByteArray();
|
||||
bool acceptAllCerts = settingsCache->value("smtp/acceptallcerts", false).toBool();
|
||||
const QString connectionType = settingsCache->value("smtp/connection", "tcp").toString();
|
||||
const QString host = settingsCache->value("smtp/host", "localhost").toString();
|
||||
const int port = settingsCache->value("smtp/port", 25).toInt();
|
||||
const QByteArray username = settingsCache->value("smtp/username", "").toByteArray();
|
||||
const QByteArray password = settingsCache->value("smtp/password", "").toByteArray();
|
||||
const bool acceptAllCerts = settingsCache->value("smtp/acceptallcerts", false).toBool();
|
||||
|
||||
smtp->setUsername(username);
|
||||
smtp->setPassword(password);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue