|
|
|
//
|
|
|
|
// Created by koncord on 07.01.17.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <apps/browser/netutils/QueryClient.hpp>
|
|
|
|
#include "qdebug.h"
|
|
|
|
|
|
|
|
#include "ServerInfoDialog.hpp"
|
|
|
|
#include <algorithm>
|
[Browser] Rework browser for improved stability & clarity
(cherry picked from commits 5c79e7106f840ef217b9bf45ec5d3bd925825863, 57353cdffff3580566415039544fae15052e8d73, 15723adb9a0383d8ebb8b7e26849b2de70b9952d, 01a5196a92f27f0c09bd053daf4d779d0c113974, ed75563a94174ca38cb67beba9c0e35a810dfbd2, 3839a2dcfd8fbbc7598771ee604f9ff9eb08e044, 1fd16ba69c4893cfe7379ea6bb0f65e5ac59cd4b, 66283943c593a406592daf0b90491d42a2e80050, ba8613a179936631d6c5fa7ae6dedb8a5f3eb684, 5b8f4f3e92d662f36580b94184057b648be9f01d, 35b771b19e00a813350553f686c0971334bbc3b5, 043eb224e29ca7b41a738eb598e16131ccfedd1a, 05fac2f67d5281d72b48bdba0db14e6bd7974765)
6 years ago
|
|
|
#include <utility>
|
|
|
|
#include <QThread>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace RakNet;
|
|
|
|
|
[Browser] Rework browser for improved stability & clarity
(cherry picked from commits 5c79e7106f840ef217b9bf45ec5d3bd925825863, 57353cdffff3580566415039544fae15052e8d73, 15723adb9a0383d8ebb8b7e26849b2de70b9952d, 01a5196a92f27f0c09bd053daf4d779d0c113974, ed75563a94174ca38cb67beba9c0e35a810dfbd2, 3839a2dcfd8fbbc7598771ee604f9ff9eb08e044, 1fd16ba69c4893cfe7379ea6bb0f65e5ac59cd4b, 66283943c593a406592daf0b90491d42a2e80050, ba8613a179936631d6c5fa7ae6dedb8a5f3eb684, 5b8f4f3e92d662f36580b94184057b648be9f01d, 35b771b19e00a813350553f686c0971334bbc3b5, 043eb224e29ca7b41a738eb598e16131ccfedd1a, 05fac2f67d5281d72b48bdba0db14e6bd7974765)
6 years ago
|
|
|
ThrWorker::ThrWorker(ServerInfoDialog *dialog, QString addr, unsigned short port): addr(std::move(addr)), port(port), stopped(false)
|
|
|
|
{
|
|
|
|
this->dialog = dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ThrWorker::process()
|
|
|
|
{
|
|
|
|
stopped = false;
|
|
|
|
auto newSD = QueryClient::Get().Update(SystemAddress(addr.toUtf8(), port));
|
|
|
|
if (dialog != nullptr)
|
|
|
|
dialog->setData(newSD);
|
|
|
|
stopped = true;
|
|
|
|
emit finished();
|
|
|
|
}
|
|
|
|
|
|
|
|
ServerInfoDialog::ServerInfoDialog(const QString &addr, QWidget *parent): QDialog(parent)
|
|
|
|
{
|
|
|
|
setupUi(this);
|
[Browser] Rework browser for improved stability & clarity
(cherry picked from commits 5c79e7106f840ef217b9bf45ec5d3bd925825863, 57353cdffff3580566415039544fae15052e8d73, 15723adb9a0383d8ebb8b7e26849b2de70b9952d, 01a5196a92f27f0c09bd053daf4d779d0c113974, ed75563a94174ca38cb67beba9c0e35a810dfbd2, 3839a2dcfd8fbbc7598771ee604f9ff9eb08e044, 1fd16ba69c4893cfe7379ea6bb0f65e5ac59cd4b, 66283943c593a406592daf0b90491d42a2e80050, ba8613a179936631d6c5fa7ae6dedb8a5f3eb684, 5b8f4f3e92d662f36580b94184057b648be9f01d, 35b771b19e00a813350553f686c0971334bbc3b5, 043eb224e29ca7b41a738eb598e16131ccfedd1a, 05fac2f67d5281d72b48bdba0db14e6bd7974765)
6 years ago
|
|
|
refreshThread = new QThread;
|
|
|
|
|
|
|
|
QStringList list = addr.split(':');
|
|
|
|
worker = new ThrWorker(this, list[0].toLatin1(), list[1].toUShort());
|
|
|
|
worker->moveToThread(refreshThread);
|
|
|
|
connect(refreshThread, SIGNAL(started()), worker, SLOT(process()));
|
|
|
|
connect(worker, SIGNAL(finished()), refreshThread, SLOT(quit()));
|
|
|
|
connect(refreshThread, SIGNAL(finished()), this, SLOT(refresh()));
|
|
|
|
|
|
|
|
connect(btnRefresh, &QPushButton::clicked, [this]{
|
|
|
|
if (!refreshThread->isRunning())
|
|
|
|
refreshThread->start();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
ServerInfoDialog::~ServerInfoDialog()
|
|
|
|
{
|
[Browser] Rework browser for improved stability & clarity
(cherry picked from commits 5c79e7106f840ef217b9bf45ec5d3bd925825863, 57353cdffff3580566415039544fae15052e8d73, 15723adb9a0383d8ebb8b7e26849b2de70b9952d, 01a5196a92f27f0c09bd053daf4d779d0c113974, ed75563a94174ca38cb67beba9c0e35a810dfbd2, 3839a2dcfd8fbbc7598771ee604f9ff9eb08e044, 1fd16ba69c4893cfe7379ea6bb0f65e5ac59cd4b, 66283943c593a406592daf0b90491d42a2e80050, ba8613a179936631d6c5fa7ae6dedb8a5f3eb684, 5b8f4f3e92d662f36580b94184057b648be9f01d, 35b771b19e00a813350553f686c0971334bbc3b5, 043eb224e29ca7b41a738eb598e16131ccfedd1a, 05fac2f67d5281d72b48bdba0db14e6bd7974765)
6 years ago
|
|
|
worker->dialog = nullptr;
|
|
|
|
if (!refreshThread->isRunning())
|
|
|
|
refreshThread->terminate();
|
|
|
|
}
|
|
|
|
|
[Browser] Rework browser for improved stability & clarity
(cherry picked from commits 5c79e7106f840ef217b9bf45ec5d3bd925825863, 57353cdffff3580566415039544fae15052e8d73, 15723adb9a0383d8ebb8b7e26849b2de70b9952d, 01a5196a92f27f0c09bd053daf4d779d0c113974, ed75563a94174ca38cb67beba9c0e35a810dfbd2, 3839a2dcfd8fbbc7598771ee604f9ff9eb08e044, 1fd16ba69c4893cfe7379ea6bb0f65e5ac59cd4b, 66283943c593a406592daf0b90491d42a2e80050, ba8613a179936631d6c5fa7ae6dedb8a5f3eb684, 5b8f4f3e92d662f36580b94184057b648be9f01d, 35b771b19e00a813350553f686c0971334bbc3b5, 043eb224e29ca7b41a738eb598e16131ccfedd1a, 05fac2f67d5281d72b48bdba0db14e6bd7974765)
6 years ago
|
|
|
bool ServerInfoDialog::isUpdated()
|
|
|
|
{
|
|
|
|
return sd.first != UNASSIGNED_SYSTEM_ADDRESS;
|
|
|
|
}
|
|
|
|
|
[Browser] Rework browser for improved stability & clarity
(cherry picked from commits 5c79e7106f840ef217b9bf45ec5d3bd925825863, 57353cdffff3580566415039544fae15052e8d73, 15723adb9a0383d8ebb8b7e26849b2de70b9952d, 01a5196a92f27f0c09bd053daf4d779d0c113974, ed75563a94174ca38cb67beba9c0e35a810dfbd2, 3839a2dcfd8fbbc7598771ee604f9ff9eb08e044, 1fd16ba69c4893cfe7379ea6bb0f65e5ac59cd4b, 66283943c593a406592daf0b90491d42a2e80050, ba8613a179936631d6c5fa7ae6dedb8a5f3eb684, 5b8f4f3e92d662f36580b94184057b648be9f01d, 35b771b19e00a813350553f686c0971334bbc3b5, 043eb224e29ca7b41a738eb598e16131ccfedd1a, 05fac2f67d5281d72b48bdba0db14e6bd7974765)
6 years ago
|
|
|
void ServerInfoDialog::setData(std::pair<RakNet::SystemAddress, QueryData> &newSD)
|
|
|
|
{
|
[Browser] Rework browser for improved stability & clarity
(cherry picked from commits 5c79e7106f840ef217b9bf45ec5d3bd925825863, 57353cdffff3580566415039544fae15052e8d73, 15723adb9a0383d8ebb8b7e26849b2de70b9952d, 01a5196a92f27f0c09bd053daf4d779d0c113974, ed75563a94174ca38cb67beba9c0e35a810dfbd2, 3839a2dcfd8fbbc7598771ee604f9ff9eb08e044, 1fd16ba69c4893cfe7379ea6bb0f65e5ac59cd4b, 66283943c593a406592daf0b90491d42a2e80050, ba8613a179936631d6c5fa7ae6dedb8a5f3eb684, 5b8f4f3e92d662f36580b94184057b648be9f01d, 35b771b19e00a813350553f686c0971334bbc3b5, 043eb224e29ca7b41a738eb598e16131ccfedd1a, 05fac2f67d5281d72b48bdba0db14e6bd7974765)
6 years ago
|
|
|
sd = newSD;
|
|
|
|
}
|
|
|
|
|
[Browser] Rework browser for improved stability & clarity
(cherry picked from commits 5c79e7106f840ef217b9bf45ec5d3bd925825863, 57353cdffff3580566415039544fae15052e8d73, 15723adb9a0383d8ebb8b7e26849b2de70b9952d, 01a5196a92f27f0c09bd053daf4d779d0c113974, ed75563a94174ca38cb67beba9c0e35a810dfbd2, 3839a2dcfd8fbbc7598771ee604f9ff9eb08e044, 1fd16ba69c4893cfe7379ea6bb0f65e5ac59cd4b, 66283943c593a406592daf0b90491d42a2e80050, ba8613a179936631d6c5fa7ae6dedb8a5f3eb684, 5b8f4f3e92d662f36580b94184057b648be9f01d, 35b771b19e00a813350553f686c0971334bbc3b5, 043eb224e29ca7b41a738eb598e16131ccfedd1a, 05fac2f67d5281d72b48bdba0db14e6bd7974765)
6 years ago
|
|
|
void ServerInfoDialog::refresh()
|
|
|
|
{
|
|
|
|
if (sd.first != UNASSIGNED_SYSTEM_ADDRESS)
|
|
|
|
{
|
|
|
|
leAddr->setText(sd.first.ToString(true, ':'));
|
|
|
|
lblName->setText(sd.second.GetName());
|
|
|
|
int ping = PingRakNetServer(sd.first.ToString(false), sd.first.GetPort());
|
|
|
|
lblPing->setNum(ping);
|
|
|
|
btnConnect->setDisabled(ping == PING_UNREACHABLE);
|
|
|
|
|
|
|
|
listPlayers->clear();
|
[Browser] Rework browser for improved stability & clarity
(cherry picked from commits 5c79e7106f840ef217b9bf45ec5d3bd925825863, 57353cdffff3580566415039544fae15052e8d73, 15723adb9a0383d8ebb8b7e26849b2de70b9952d, 01a5196a92f27f0c09bd053daf4d779d0c113974, ed75563a94174ca38cb67beba9c0e35a810dfbd2, 3839a2dcfd8fbbc7598771ee604f9ff9eb08e044, 1fd16ba69c4893cfe7379ea6bb0f65e5ac59cd4b, 66283943c593a406592daf0b90491d42a2e80050, ba8613a179936631d6c5fa7ae6dedb8a5f3eb684, 5b8f4f3e92d662f36580b94184057b648be9f01d, 35b771b19e00a813350553f686c0971334bbc3b5, 043eb224e29ca7b41a738eb598e16131ccfedd1a, 05fac2f67d5281d72b48bdba0db14e6bd7974765)
6 years ago
|
|
|
for (const auto &player : sd.second.players)
|
|
|
|
listPlayers->addItem(QString::fromStdString(player));
|
|
|
|
|
|
|
|
listPlugins->clear();
|
[Browser] Rework browser for improved stability & clarity
(cherry picked from commits 5c79e7106f840ef217b9bf45ec5d3bd925825863, 57353cdffff3580566415039544fae15052e8d73, 15723adb9a0383d8ebb8b7e26849b2de70b9952d, 01a5196a92f27f0c09bd053daf4d779d0c113974, ed75563a94174ca38cb67beba9c0e35a810dfbd2, 3839a2dcfd8fbbc7598771ee604f9ff9eb08e044, 1fd16ba69c4893cfe7379ea6bb0f65e5ac59cd4b, 66283943c593a406592daf0b90491d42a2e80050, ba8613a179936631d6c5fa7ae6dedb8a5f3eb684, 5b8f4f3e92d662f36580b94184057b648be9f01d, 35b771b19e00a813350553f686c0971334bbc3b5, 043eb224e29ca7b41a738eb598e16131ccfedd1a, 05fac2f67d5281d72b48bdba0db14e6bd7974765)
6 years ago
|
|
|
for (const auto &plugin : sd.second.plugins)
|
|
|
|
listPlugins->addItem(QString::fromStdString(plugin.name));
|
|
|
|
|
|
|
|
listRules->clear();
|
|
|
|
const static vector<std::string> defaultRules {"gamemode", "maxPlayers", "name", "passw", "players", "version"};
|
[Browser] Rework browser for improved stability & clarity
(cherry picked from commits 5c79e7106f840ef217b9bf45ec5d3bd925825863, 57353cdffff3580566415039544fae15052e8d73, 15723adb9a0383d8ebb8b7e26849b2de70b9952d, 01a5196a92f27f0c09bd053daf4d779d0c113974, ed75563a94174ca38cb67beba9c0e35a810dfbd2, 3839a2dcfd8fbbc7598771ee604f9ff9eb08e044, 1fd16ba69c4893cfe7379ea6bb0f65e5ac59cd4b, 66283943c593a406592daf0b90491d42a2e80050, ba8613a179936631d6c5fa7ae6dedb8a5f3eb684, 5b8f4f3e92d662f36580b94184057b648be9f01d, 35b771b19e00a813350553f686c0971334bbc3b5, 043eb224e29ca7b41a738eb598e16131ccfedd1a, 05fac2f67d5281d72b48bdba0db14e6bd7974765)
6 years ago
|
|
|
for (auto &rule : sd.second.rules)
|
|
|
|
{
|
|
|
|
if (::find(defaultRules.begin(), defaultRules.end(), rule.first) != defaultRules.end())
|
|
|
|
continue;
|
|
|
|
QString ruleStr = QString::fromStdString(rule.first) + " : ";
|
|
|
|
if (rule.second.type == 's')
|
|
|
|
ruleStr += QString::fromStdString(rule.second.str);
|
|
|
|
else
|
|
|
|
ruleStr += QString::number(rule.second.val);
|
|
|
|
listRules->addItem(ruleStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
lblPlayers->setText(QString::number(sd.second.players.size()) + " / " + QString::number(sd.second.GetMaxPlayers()));
|
|
|
|
}
|
[Browser] Rework browser for improved stability & clarity
(cherry picked from commits 5c79e7106f840ef217b9bf45ec5d3bd925825863, 57353cdffff3580566415039544fae15052e8d73, 15723adb9a0383d8ebb8b7e26849b2de70b9952d, 01a5196a92f27f0c09bd053daf4d779d0c113974, ed75563a94174ca38cb67beba9c0e35a810dfbd2, 3839a2dcfd8fbbc7598771ee604f9ff9eb08e044, 1fd16ba69c4893cfe7379ea6bb0f65e5ac59cd4b, 66283943c593a406592daf0b90491d42a2e80050, ba8613a179936631d6c5fa7ae6dedb8a5f3eb684, 5b8f4f3e92d662f36580b94184057b648be9f01d, 35b771b19e00a813350553f686c0971334bbc3b5, 043eb224e29ca7b41a738eb598e16131ccfedd1a, 05fac2f67d5281d72b48bdba0db14e6bd7974765)
6 years ago
|
|
|
}
|
|
|
|
|
|
|
|
int ServerInfoDialog::exec()
|
|
|
|
{
|
|
|
|
if (!refreshThread->isRunning())
|
|
|
|
refreshThread->start();
|
|
|
|
return QDialog::exec();
|
|
|
|
}
|