From a2013aa32e6df18366096df80bd646131da84206 Mon Sep 17 00:00:00 2001 From: MangosArentLiterature <58055358+MangosArentLiterature@users.noreply.github.com> Date: Sat, 10 Apr 2021 00:43:08 -0500 Subject: [PATCH] Cleanup getBanInfo and cmdJudgeLog - Removes unneeded parentheses from AOClient::cmdJudgeLog() - Removes duplicate code in DBManager::getBanInfo() --- src/commands.cpp | 2 +- src/db_manager.cpp | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/commands.cpp b/src/commands.cpp index 38bdd2c..0dbf7d8 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1289,7 +1289,7 @@ void AOClient::cmdJudgeLog(int argc, QStringList argv) } QString message = area->judgelog.join("\n"); //Judgelog contains an IPID, so we shouldn't send that unless the caller has appropriate permissions - if (((checkAuth(ACLFlags.value("KICK"))) == 1) || (((checkAuth(ACLFlags.value("BAN"))) == 1))) { + if (checkAuth(ACLFlags.value("KICK")) == 1 || checkAuth(ACLFlags.value("BAN")) == 1) { sendServerMessage(message); } else { diff --git a/src/db_manager.cpp b/src/db_manager.cpp index 2aeb12e..861ec1a 100644 --- a/src/db_manager.cpp +++ b/src/db_manager.cpp @@ -332,26 +332,21 @@ QList DBManager::getBanInfo(QString lookup_type, QString id) QList invalid; if (lookup_type == "banid") { query.prepare("SELECT * FROM BANS WHERE ID = ?"); - query.addBindValue(id); - query.setForwardOnly(true); - query.exec(); } else if (lookup_type == "hdid") { query.prepare("SELECT * FROM BANS WHERE HDID = ?"); - query.addBindValue(id); - query.setForwardOnly(true); - query.exec(); } else if (lookup_type == "ipid") { query.prepare("SELECT * FROM BANS WHERE IPID = ?"); - query.addBindValue(id); - query.setForwardOnly(true); - query.exec(); } else { qCritical("Invalid ban lookup type!"); return invalid; } + query.addBindValue(id); + query.setForwardOnly(true); + query.exec(); + while (query.next()) { BanInfo ban; ban.ipid = query.value(0).toString();