Skip to content

Commit ddff99b

Browse files
committed
Dropped Qt5, ...
Resolve #360, resolve #361 * Dropped Qt5 * Now targets Qt6.5 * Dropped backward compatibility/feature list
1 parent 040f5a3 commit ddff99b

18 files changed

+157
-168
lines changed

core.pro

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ INCLUDEPATH += src
3131

3232
SOURCES += \
3333
src/acl_roles_handler.cpp \
34+
src/akashidefs.cpp \
3435
src/aoclient.cpp \
3536
src/network/aopacket.cpp \
3637
src/network/network_socket.cpp \

src/acl_roles_handler.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ void ACLRolesHandler::clearRoles()
176176
bool ACLRolesHandler::loadFile(QString f_file_name)
177177
{
178178
QSettings l_settings(f_file_name, QSettings::IniFormat);
179-
l_settings.setIniCodec("UTF-8");
180179
if (!checkPermissionsIni(&l_settings)) {
181180
return false;
182181
}
@@ -218,7 +217,6 @@ bool ACLRolesHandler::loadFile(QString f_file_name)
218217
bool ACLRolesHandler::saveFile(QString f_file_name)
219218
{
220219
QSettings l_settings(f_file_name, QSettings::IniFormat);
221-
l_settings.setIniCodec("UTF-8");
222220
if (!checkPermissionsIni(&l_settings)) {
223221
return false;
224222
}

src/akashidefs.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "akashidefs.h"
2+
3+
namespace akashi {
4+
QString get_protocol_version_string()
5+
{
6+
return QString::number(PROTOCOL_MAJOR_VERSION) + "." + QString::number(PROTOCOL_MINOR_VERSION) + "." + QString::number(PROTOCOL_PATCH_VERSION);
7+
}
8+
}

src/akashidefs.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define AKASHIDEFS_H
33

44
#include <QString>
5-
#include <qnamespace.h>
65

76
namespace akashi {
87
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
@@ -12,6 +11,11 @@ using SplitBehavior = Qt::SplitBehaviorFlags;
1211
#endif
1312
const SplitBehavior KeepEmptyParts = SplitBehavior::KeepEmptyParts;
1413
const SplitBehavior SkipEmptyParts = SplitBehavior::SkipEmptyParts;
15-
}
1614

15+
QString get_protocol_version_string();
16+
17+
const int PROTOCOL_MAJOR_VERSION = 1;
18+
const int PROTOCOL_MINOR_VERSION = 0;
19+
const int PROTOCOL_PATCH_VERSION = 0;
20+
}
1721
#endif // AKASHIDEFS_H

src/aoclient.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,9 @@ class AOClient : public QObject
240240
*/
241241
struct ClientVersion
242242
{
243-
QString string; //!< The name of the client software, for example, `AO2`.
244-
int release = -1; //!< The 'release' part of the version number. In Attorney Online's case, this is fixed at `2`.
245-
int major = -1; //!< The 'major' part of the version number. In Attorney Online's case, this increases when a new feature is introduced (generally).
246-
int minor = -1; //!< The 'minor' part of the version number. In Attorney Online's case, this increases for bugfix releases (generally).
243+
int major = -1;
244+
int minor = -1;
245+
int patch = -1;
247246
};
248247

249248
/**

src/area_data.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ AreaData::AreaData(QString p_name, int p_index, MusicManager *p_music_manager =
4545
name_split.removeFirst();
4646
m_name = name_split.join(":");
4747
QSettings *areas_ini = ConfigManager::areaData();
48-
areas_ini->setIniCodec("UTF-8");
4948
areas_ini->beginGroup(p_name);
5049
m_background = areas_ini->value("background", "gs4").toString();
5150
m_isProtected = areas_ini->value("protected_area", "false").toBool();
@@ -262,12 +261,7 @@ QList<AreaData::Evidence> AreaData::evidence() const
262261

263262
void AreaData::swapEvidence(int f_eviId1, int f_eviId2)
264263
{
265-
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
266-
// swapItemsAt does not exist in Qt older than 5.13
267-
m_evidence.swap(f_eviId1, f_eviId2);
268-
#else
269264
m_evidence.swapItemsAt(f_eviId1, f_eviId2);
270-
#endif
271265
}
272266

273267
void AreaData::appendEvidence(const AreaData::Evidence &f_evi_r)

src/command_extension.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ CommandExtension CommandExtensionCollection::getExtension(QString f_command_name
112112
bool CommandExtensionCollection::loadFile(QString f_filename)
113113
{
114114
QSettings l_settings(f_filename, QSettings::IniFormat);
115-
l_settings.setIniCodec("UTF-8");
116115
if (l_settings.status() != QSettings::NoError) {
117116
qWarning() << "[Command Extension Collection]"
118117
<< "error: failed to load file" << f_filename << "; aborting";

src/commands/casing.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ void AOClient::cmdSaveTestimony(int argc, QStringList argv)
240240
}
241241

242242
QTextStream l_out(&l_file);
243-
l_out.setCodec("UTF-8");
244243
if (l_file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
245244
for (int i = 0; i <= l_area->testimony().size() - 1; i++) {
246245
l_out << l_area->testimony().at(i).join("#") << "\n";
@@ -280,7 +279,6 @@ void AOClient::cmdLoadTestimony(int argc, QStringList argv)
280279
clearTestimony();
281280
int l_testimony_lines = 0;
282281
QTextStream l_in(&l_file);
283-
l_in.setCodec("UTF-8");
284282
while (!l_in.atEnd()) {
285283
if (l_testimony_lines <= ConfigManager::maxStatements()) {
286284
QString line = l_in.readLine();

src/commands/command_helper.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,7 @@ QStringList AOClient::buildAreaList(int area_idx)
7474

7575
int AOClient::genRand(int min, int max)
7676
{
77-
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
78-
qsrand(QDateTime::currentMSecsSinceEpoch());
79-
quint32 random_number = (qrand() % (max - min + 1)) + min;
80-
return random_number;
81-
82-
#else
8377
return QRandomGenerator::system()->bounded(min, max + 1);
84-
#endif
8578
}
8679

8780
void AOClient::diceThrower(int sides, int dice, bool p_roll, int roll_modifier)

src/config_manager.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ bool ConfigManager::verifyServerConfig()
5454

5555
// Verify areas
5656
QSettings l_areas_ini("config/areas.ini", QSettings::IniFormat);
57-
l_areas_ini.setIniCodec("UTF-8");
5857
if (l_areas_ini.childGroups().length() < 1) {
5958
qCritical() << "areas.ini is invalid!";
6059
return false;

src/data_types.h

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define DATA_TYPES_H
2020

2121
#include <QDebug>
22+
#include <QVariant>
2223

2324
/**
2425
* @brief A class for handling several custom data types.

src/packet/packet_casea.cpp

+2-9
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,13 @@ void PacketCasea::handlePacket(AreaData *area, AOClient &client) const
4444
QString l_message = "=== Case Announcement ===\r\n" + (client.name() == "" ? client.character() : client.name()) + " needs " + l_needed_roles.join(", ") + " for " + (l_case_title == "" ? "a case" : l_case_title) + "!";
4545

4646
QList<AOClient *> l_clients_to_alert;
47-
// here lies morton, RIP
48-
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
4947
QSet<bool> l_needs_set(l_needs_list.begin(), l_needs_list.end());
50-
#else
51-
QSet<bool> l_needs_set = l_needs_list.toSet();
52-
#endif
48+
5349
const QVector<AOClient *> l_clients = client.getServer()->getClients();
5450
for (AOClient *l_client : l_clients) {
55-
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
5651
QSet<bool> l_matches(l_client->m_casing_preferences.begin(), l_client->m_casing_preferences.end());
5752
l_matches.intersect(l_needs_set);
58-
#else
59-
QSet<bool> l_matches = l_client->m_casing_preferences.toSet().intersect(l_needs_set);
60-
#endif
53+
6154
if (!l_matches.isEmpty() && !l_clients_to_alert.contains(l_client))
6255
l_clients_to_alert.append(l_client);
6356
}

src/packet/packet_ct.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#include "packet/packet_ct.h"
2+
23
#include "akashidefs.h"
34
#include "config_manager.h"
45
#include "packet/packet_factory.h"
56
#include "server.h"
67

78
#include <QDebug>
9+
#include <QRegularExpression>
810

911
PacketCT::PacketCT(QStringList &contents) :
1012
AOPacket(contents)
@@ -27,8 +29,8 @@ void PacketCT::handlePacket(AreaData *area, AOClient &client) const
2729
return;
2830
}
2931

30-
client.setName(client.dezalgo(m_content[0]).replace(QRegExp("\\[|\\]|\\{|\\}|\\#|\\$|\\%|\\&"), "")); // no fucky wucky shit here
31-
if (client.name().isEmpty() || client.name() == ConfigManager::serverName()) // impersonation & empty name protection
32+
client.setName(client.dezalgo(m_content[0]).replace(QRegularExpression("\\[|\\]|\\{|\\}|\\#|\\$|\\%|\\&"), "")); // no fucky wucky shit here
33+
if (client.name().isEmpty() || client.name() == ConfigManager::serverName()) // impersonation & empty name protection
3234
return;
3335

3436
if (client.name().length() > 30) {

src/packet/packet_hi.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "packet/packet_hi.h"
2-
#include "akashiutils.h"
2+
3+
#include "config_manager.h"
34
#include "db_manager.h"
45
#include "server.h"
56

@@ -47,5 +48,10 @@ void PacketHI::handlePacket(AreaData *area, AOClient &client) const
4748
return;
4849
}
4950

50-
client.sendPacket("ID", {QString::number(client.clientId()), "akashi", QCoreApplication::applicationVersion()});
51+
client.sendPacket("PN", {QString::number(client.getServer()->getPlayerCount()), QString::number(ConfigManager::maxPlayers()), ConfigManager::serverDescription()});
52+
53+
if (ConfigManager::assetUrl().isValid()) {
54+
QByteArray l_asset_url = ConfigManager::assetUrl().toEncoded(QUrl::EncodeSpaces);
55+
client.sendPacket("ASS", {l_asset_url});
56+
}
5157
}

src/packet/packet_id.cpp

+12-37
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "packet/packet_id.h"
2-
#include "config_manager.h"
2+
3+
#include "akashidefs.h"
34
#include "server.h"
45

56
#include <QDebug>
@@ -13,7 +14,7 @@ PacketInfo PacketID::getPacketInfo() const
1314
{
1415
PacketInfo info{
1516
.acl_permission = ACLRole::Permission::NONE,
16-
.min_args = 2,
17+
.min_args = 3,
1718
.header = "ID"};
1819
return info;
1920
}
@@ -22,50 +23,24 @@ void PacketID::handlePacket(AreaData *area, AOClient &client) const
2223
{
2324
Q_UNUSED(area)
2425

25-
if (client.m_version.major == 2) {
26+
if (client.m_version.major == akashi::PROTOCOL_MAJOR_VERSION) {
2627
// No double sending of the ID packet!
2728
client.sendPacket("BD", {"A protocol error has been encountered. Packet : ID"});
2829
client.m_socket->close();
2930
return;
3031
}
3132

32-
// Full feature list as of AO 2.8.5
33-
// The only ones that are critical to ensuring the server works are
34-
// "noencryption" and "fastloading"
35-
QStringList l_feature_list = {
36-
"noencryption", "yellowtext", "prezoom",
37-
"flipping", "customobjections", "fastloading",
38-
"deskmod", "evidence", "cccc_ic_support",
39-
"arup", "casing_alerts", "modcall_reason",
40-
"looping_sfx", "additive", "effects",
41-
"y_offset", "expanded_desk_mods", "auth_packet", "custom_blips"};
42-
43-
client.m_version.string = m_content[1];
44-
QRegularExpression rx("\\b(\\d+)\\.(\\d+)\\.(\\d+)\\b"); // matches X.X.X (e.g. 2.9.0, 2.4.10, etc.)
45-
QRegularExpressionMatch l_match = rx.match(client.m_version.string);
46-
if (l_match.hasMatch()) {
47-
client.m_version.release = l_match.captured(1).toInt();
48-
client.m_version.major = l_match.captured(2).toInt();
49-
client.m_version.minor = l_match.captured(3).toInt();
50-
}
51-
if (m_content[0] == "webAO") {
52-
client.m_version.release = 2;
53-
client.m_version.major = 10;
54-
client.m_version.minor = 0;
33+
AOClient::ClientVersion version;
34+
if (m_content[0] == akashi::get_protocol_version_string()) {
35+
version.major = akashi::PROTOCOL_MAJOR_VERSION;
36+
version.minor = akashi::PROTOCOL_MINOR_VERSION;
37+
version.patch = akashi::PROTOCOL_PATCH_VERSION;
5538
}
56-
57-
if (client.m_version.release != 2) {
58-
// No valid ID packet resolution.
59-
client.sendPacket("BD", {"A protocol error has been encountered. Packet : ID\nMajor version not recognised."});
39+
else {
40+
client.sendPacket("BD", {"A protocol error has been encountered. Packet : ID\nProtocol version not supported."});
6041
client.m_socket->close();
6142
return;
6243
}
6344

64-
client.sendPacket("PN", {QString::number(client.getServer()->getPlayerCount()), QString::number(ConfigManager::maxPlayers()), ConfigManager::serverDescription()});
65-
client.sendPacket("FL", l_feature_list);
66-
67-
if (ConfigManager::assetUrl().isValid()) {
68-
QByteArray l_asset_url = ConfigManager::assetUrl().toEncoded(QUrl::EncodeSpaces);
69-
client.sendPacket("ASS", {l_asset_url});
70-
}
45+
client.sendPacket("ID", {QString::number(client.clientId()), "akashi", QCoreApplication::applicationVersion()});
7146
}

0 commit comments

Comments
 (0)