From e36d79f7499ca4484585fad7738df4764f3fd0aa Mon Sep 17 00:00:00 2001 From: Rosemary Witchaven <32779090+in1tiate@users.noreply.github.com> Date: Fri, 29 Jul 2022 11:23:36 -0500 Subject: [PATCH] Fix or suppress compiler warnings (Qt 5.15 w/MinGW) (#818) * Major cleanup of screenshake code * Add pre-5.10 support for screenshake math * more compat, uglier too * add surprise tool * we don't need inline functions * only run qsrand on old versions * Squash compiler warnings * >= not > please * only run qsrand on old versions * Squash compiler warnings * >= not > please Co-authored-by: stonedDiscord Co-authored-by: Salanto <62221668+Salanto@users.noreply.github.com> --- include/courtroom.h | 2 +- src/courtroom.cpp | 12 +++++++++++- src/demoserver.cpp | 4 ++++ src/discord_rich_presence.cpp | 3 +++ src/networkmanager.cpp | 5 ++++- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index 88e6037..479b105 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -52,7 +52,7 @@ #include #include #include -#if QT_VERSION > QT_VERSION_CHECK(5, 10, 0) +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) #include //added in Qt 5.10 #endif #include diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 7a65391..f14cc20 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -8,8 +8,9 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ~Qt::WindowMaximizeButtonHint); ao_app->initBASS(); - +#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) // Needed for pre-5.10 RNG stuff qsrand(static_cast(QDateTime::currentMSecsSinceEpoch() / 1000)); +#endif keepalive_timer = new QTimer(this); keepalive_timer->start(45000); @@ -4142,6 +4143,11 @@ void Courtroom::mod_called(QString p_ip) void Courtroom::case_called(QString msg, bool def, bool pro, bool jud, bool jur, bool steno) { + Q_UNUSED(def); + Q_UNUSED(pro); + Q_UNUSED(jud); + Q_UNUSED(jur); + Q_UNUSED(steno); if (ui_casing->isChecked()) { ui_server_chatlog->append(msg); modcall_player->play(ao_app->get_court_sfx("case_call")); @@ -4946,7 +4952,11 @@ void Courtroom::music_random() } if (clist.length() == 0) return; +#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) on_music_list_double_clicked(clist.at(qrand() % clist.length()), 1); +#else + on_music_list_double_clicked(clist.at(QRandomGenerator::global()->bounded(0, clist.length())), 1); +#endif } void Courtroom::music_list_expand_all() { ui_music_list->expandAll(); } diff --git a/src/demoserver.cpp b/src/demoserver.cpp index c4f8c15..0aefc0c 100644 --- a/src/demoserver.cpp +++ b/src/demoserver.cpp @@ -95,7 +95,11 @@ void DemoServer::recv_data() } QStringList packet_list = +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) in_data.split("%", QString::SplitBehavior(QString::SkipEmptyParts)); +#else + in_data.split("%", Qt::SkipEmptyParts); +#endif for (const QString &packet : packet_list) { AOPacket ao_packet(packet); diff --git a/src/discord_rich_presence.cpp b/src/discord_rich_presence.cpp index cd3a475..81e5a86 100644 --- a/src/discord_rich_presence.cpp +++ b/src/discord_rich_presence.cpp @@ -106,11 +106,14 @@ void Discord::state_lobby() {} void Discord::state_server(std::string name, std::string server_id) { + Q_UNUSED(name); + Q_UNUSED(server_id); qDebug() << "Discord RPC: Setting server state"; } void Discord::state_character(std::string name) { + Q_UNUSED(name); qDebug() << "Discord RPC: Setting character state"; } diff --git a/src/networkmanager.cpp b/src/networkmanager.cpp index 7e039d2..27b3e01 100644 --- a/src/networkmanager.cpp +++ b/src/networkmanager.cpp @@ -240,8 +240,11 @@ void NetworkManager::handle_server_packet(const QString& p_data) partial_packet = false; } } - +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) const QStringList packet_list = in_data.split("%", QString::SkipEmptyParts); +#else + const QStringList packet_list = in_data.split("%", Qt::SkipEmptyParts); +#endif for (const QString &packet : packet_list) { AOPacket *f_packet = new AOPacket(packet);