Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
uses: jurplel/install-qt-action@v4
with:
arch: ${{ matrix.qt_arch }}
version: '6.9.0'
version: '6.9.3'

- name: Configure
if: "!startsWith(runner.os, 'Windows')"
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ endif()
# Generate version header from project version
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/version.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/version.h"
"${CMAKE_CURRENT_BINARY_DIR}/generated_version.h"
@ONLY
)

Expand Down Expand Up @@ -94,6 +94,8 @@ qt_add_executable(${PROJECT_NAME}
${RESOURCES}
)

target_compile_definitions(${PROJECT_NAME} PRIVATE SOURCEADMINTOOL_GENERATED_VERSION)

# Find third-party libraries
# On macOS, always use bundled static libs to avoid Homebrew dynamic lib crashes
if(APPLE)
Expand Down
18 changes: 16 additions & 2 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <QLabel>
#include <QStatusBar>
#include <QRegularExpression>
#include <memory>

extern Settings *settings;
extern QList<ServerInfo *> serverList;
Expand Down Expand Up @@ -63,6 +64,8 @@ MainWindow::MainWindow(QWidget *parent) :
m_updateChecker = new UpdateChecker(this);
Database::instance()->open();

infoQueryPool.setMaxThreadCount(8);

settings = new Settings(this);
settings->SetDefaultSettings();
settings->ReadSettings();
Expand Down Expand Up @@ -101,6 +104,7 @@ MainWindow::MainWindow(QWidget *parent) :

MainWindow::~MainWindow()
{
infoQueryPool.waitForDone();
Database::instance()->close();
delete settings;
serverList.clear();
Expand All @@ -110,6 +114,17 @@ MainWindow::~MainWindow()
delete commandIter;
}

void MainWindow::QueueInfoQuery(QHostAddress host, quint16 port, ServerTableIndexItem *item)
{
item->GetServerInfo()->queryState = QueryRunning;
infoQueryPool.start([this, host, port, item]() {
std::shared_ptr<InfoReply> reply(GetInfoReply(host, port));
QMetaObject::invokeMethod(this, [this, reply, item]() {
ServerInfoReady(reply.get(), item);
}, Qt::QueuedConnection);
});
}

AddServerError MainWindow::CheckServerList(QString server)
{
QStringList address = server.split(":");
Expand Down Expand Up @@ -192,8 +207,7 @@ ServerInfo *MainWindow::AddServerToList(QString server, AddServerError *pError)

if(isIP)
{
InfoQuery *infoQuery = new InfoQuery(this);
infoQuery->query(&info->host, info->port, id);
QueueInfoQuery(info->host, info->port, id);
}
else
{
Expand Down
5 changes: 4 additions & 1 deletion mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QDebug>
#include <QMainWindow>
#include <QThreadPool>
#include <QSplitter>
#include <QStringList>
#include <QHostAddress>
Expand Down Expand Up @@ -116,6 +117,7 @@ class MainWindow : public QMainWindow
explicit MainWindow(QWidget *parent = nullptr);
AddServerError CheckServerList(QString server);
ServerInfo *AddServerToList(QString server, AddServerError *error = nullptr);
void QueueInfoQuery(QHostAddress host, quint16 port, ServerTableIndexItem *item);
void UpdateSelectedItemInfo(bool removeFirst = true, bool updateRules = false);
void CreateTableItemOrUpdate(size_t row, size_t col, QTableWidget *table, ServerInfo *info);
ServerTableIndexItem *GetServerTableIndexItem(size_t row);
Expand All @@ -137,7 +139,7 @@ class MainWindow : public QMainWindow
bool eventFilter(QObject *object, QEvent *event);

public slots:
void ServerInfoReady(InfoReply *, ServerTableIndexItem *);
void ServerInfoReady(const InfoReply *, ServerTableIndexItem *);
void PlayerInfoReady(QList<PlayerInfo> *, ServerTableIndexItem *);
void RulesInfoReady(QList<RulesInfo> *, ServerTableIndexItem *);
void RconAuthReady(ServerInfo *info, QList<QueuedCommand>queuedcmds);
Expand Down Expand Up @@ -177,6 +179,7 @@ private slots:

private:
Ui::MainWindow *ui;
QThreadPool infoQueryPool;
QTimer *updateTimer;
void ConnectSlots();
void UpdateInfoTable(ServerInfo *info, bool current = true, QList<RulesInfo> *list = nullptr);
Expand Down
12 changes: 0 additions & 12 deletions query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,18 +501,6 @@ InfoReply::InfoReply(QByteArray response, qint64 ping)
}
}

InfoQuery::InfoQuery(MainWindow *main)
{
Worker *worker = new Worker;
worker->moveToThread(&workerThread);
connect(&workerThread, &QThread::finished, worker, &Worker::deleteLater);
connect(&workerThread, &QThread::finished, this, &InfoQuery::deleteLater);
connect(this, &InfoQuery::query, worker, &Worker::getServerInfo);
connect(worker, &Worker::serverInfoReady, main, &MainWindow::ServerInfoReady);

workerThread.start();
}

InfoReply *GetInfoReply(QHostAddress host, quint16 port)
{
QByteArray query;
Expand Down
15 changes: 0 additions & 15 deletions query.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,6 @@ class RulesInfo
QString value;
};

class InfoQuery : public QObject
{
Q_OBJECT
QThread workerThread;
public:
InfoQuery(MainWindow *main);
~InfoQuery() {
workerThread.quit();
workerThread.wait();
}
signals:
void query(QHostAddress *, quint16, ServerTableIndexItem *item);
};

class PlayerQuery : public QObject
{
Q_OBJECT
Expand Down Expand Up @@ -127,4 +113,3 @@ QList<RulesInfo> *GetRulesReply(QHostAddress, quint16, bool goldsrcSplits = fals
QString SecondsToDisplayTime(float time);
QString GetStringFromStream(QDataStream &stream);
#endif // INFOQUERY

12 changes: 2 additions & 10 deletions query_slots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ void MainWindow::TimedUpdate()
if(info->queryState == QueryResolveFailed || info->queryState == QueryResolving || info->queryState == QueryRunning)
continue;

InfoQuery *infoQuery = new InfoQuery(this);

info->cleanHashTable();

infoQuery->query(&info->host, info->port, id);
QueueInfoQuery(info->host, info->port, id);
}
if(run % 60 == 0)
{
Expand Down Expand Up @@ -426,7 +423,7 @@ void MainWindow::UpdateInfoTable(ServerInfo *info, bool current, QList<RulesInfo
}

//QUERY INFO READY
void MainWindow::ServerInfoReady(InfoReply *reply, ServerTableIndexItem *indexCell)
void MainWindow::ServerInfoReady(const InfoReply *reply, ServerTableIndexItem *indexCell)
{
QTableWidget *browserTable = this->ui->browserTable;

Expand All @@ -444,8 +441,6 @@ void MainWindow::ServerInfoReady(InfoReply *reply, ServerTableIndexItem *indexCe

if(row == -1)
{
if(reply)
delete reply;
return;
}

Expand Down Expand Up @@ -564,7 +559,6 @@ void MainWindow::ServerInfoReady(InfoReply *reply, ServerTableIndexItem *indexCe
this->CreateTableItemOrUpdate(row, kBrowserColMap, browserTable, info);
this->CreateTableItemOrUpdate(row, kBrowserColPlayerCount, browserTable, info);

delete reply;
}
else
{
Expand All @@ -576,8 +570,6 @@ void MainWindow::ServerInfoReady(InfoReply *reply, ServerTableIndexItem *indexCe
connect(pingCheck, &PingCheck::finished, this, &MainWindow::HostReachabilityReady);
pingCheck->check(info->hostPort, indexCell);

if(reply)
delete reply;
}
this->UpdateInfoTable(info, (row == this->ui->browserTable->currentRow()));
this->ApplyBrowserFilter();
Expand Down
3 changes: 1 addition & 2 deletions serverinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ void HostQueryResult::HostInfoResolved(QHostInfo hostInfo)

this->info->GetCountryFlag();

InfoQuery *infoQuery = new InfoQuery(this->mainWindow);
infoQuery->query(& this->info->host, this->info->port, this->id);
this->mainWindow->QueueInfoQuery(this->info->host, this->info->port, this->id);
this->deleteLater();
return;
}
Expand Down
8 changes: 5 additions & 3 deletions updatechecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,13 @@ void UpdateChecker::onReplyFinished(QNetworkReply *reply)

// For same version (dev builds), compare commit hashes
bool isDifferentCommit = false;
if(!isNewer && !targetCommit.isEmpty())
if(!isNewer && remoteVersion == APP_VERSION_STRING &&
QRegularExpression("^[0-9a-fA-F]{40}$").match(targetCommit).hasMatch())
{
QString localCommit = APP_COMMIT_HASH_FULL;
// target_commitish is the full SHA; compare with our full hash
if(localCommit != "unknown" && targetCommit != localCommit)
// Only compare commits when the build has a real full Git SHA.
if(QRegularExpression("^[0-9a-fA-F]{40}$").match(localCommit).hasMatch() &&
targetCommit.compare(localCommit, Qt::CaseInsensitive) != 0)
isDifferentCommit = true;
}

Expand Down
10 changes: 7 additions & 3 deletions version.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#ifndef VERSION_H
#define VERSION_H

#define APP_VERSION_STRING "1.0.0"
#ifdef SOURCEADMINTOOL_GENERATED_VERSION
#include <generated_version.h>
#else
#define APP_VERSION_STRING "1.1.1"
#define APP_VERSION_MAJOR 1
#define APP_VERSION_MINOR 0
#define APP_VERSION_PATCH 0
#define APP_VERSION_MINOR 1
#define APP_VERSION_PATCH 1
#define APP_COMMIT_HASH "dev"
#define APP_COMMIT_HASH_FULL "dev"
#endif

#endif // VERSION_H
6 changes: 3 additions & 3 deletions version.h.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef VERSION_H
#define VERSION_H
#ifndef GENERATED_VERSION_H
#define GENERATED_VERSION_H

#define APP_VERSION_STRING "@PROJECT_VERSION@"
#define APP_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
Expand All @@ -8,4 +8,4 @@
#define APP_COMMIT_HASH "@GIT_COMMIT_HASH@"
#define APP_COMMIT_HASH_FULL "@GIT_COMMIT_HASH_FULL@"

#endif // VERSION_H
#endif // GENERATED_VERSION_H
7 changes: 0 additions & 7 deletions worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
#include "serverinfo.h"
#include <QString>

void Worker::getServerInfo(QHostAddress *host, quint16 port, ServerTableIndexItem *item)
{
InfoReply *reply = GetInfoReply(*host, port);
emit serverInfoReady(reply, item);
this->currentThread()->quit();
}

void Worker::getPlayerInfo(QHostAddress *host, quint16 port, ServerTableIndexItem *item)
{
bool goldsrcSplits = item->GetServerInfo()->goldsrc;
Expand Down
2 changes: 0 additions & 2 deletions worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ class Worker : public QThread
Q_OBJECT

public slots:
void getServerInfo(QHostAddress *host, quint16 port, ServerTableIndexItem *item);
void getPlayerInfo(QHostAddress *host, quint16 port, ServerTableIndexItem *item);
void getRulesInfo(QHostAddress *host, quint16 port, ServerTableIndexItem *item);
void setupUPnP(LogHandler *);

signals:
void serverInfoReady(InfoReply *reply, ServerTableIndexItem *item);
void playerInfoReady(QList<PlayerInfo> *, ServerTableIndexItem *item);
void rulesInfoReady(QList<RulesInfo> *, ServerTableIndexItem *item);
void UPnPReady();
Expand Down
Loading