vastly improve client version string validation
This commit is contained in:
parent
953426fea1
commit
7157d5410e
@ -55,28 +55,14 @@ void AOClient::pktSoftwareId(AreaData* area, int argc, QStringList argv, AOPacke
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Extremely cursed client version string validation
|
|
||||||
// Ideally version strings should be X.X.X but it can be literally anything
|
|
||||||
// so we have to be super careful
|
|
||||||
version.string = argv[1];
|
version.string = argv[1];
|
||||||
QStringList version_raw = version.string.split(".");
|
QRegExp rx("\\b(\\d+)\\.(\\d+)\\.(\\d+)\\b"); // matches X.X.X (e.g. 2.9.0, 2.4.10, etc.)
|
||||||
bool ok;
|
if (rx.indexIn(version.string) != -1) {
|
||||||
int release_version = version_raw[0].toInt(&ok);
|
QStringList version_raw = rx.capturedTexts();
|
||||||
if (ok && version_raw.size() >= 1)
|
version.release = version_raw[0].toInt();
|
||||||
version.release = release_version;
|
version.major = version_raw[1].toInt();
|
||||||
if (ok && version_raw.size() >= 2) {
|
version.minor = version_raw[2].toInt();
|
||||||
int major_version = version_raw[1].toInt(&ok);
|
|
||||||
if (ok)
|
|
||||||
version.major = major_version;
|
|
||||||
}
|
}
|
||||||
if (ok && version_raw.size() >= 3) {
|
|
||||||
int minor_version = version_raw[2].toInt(&ok);
|
|
||||||
if (ok)
|
|
||||||
version.minor = minor_version;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sendPacket("PN", {QString::number(server->player_count), max_players});
|
sendPacket("PN", {QString::number(server->player_count), max_players});
|
||||||
sendPacket("FL", feature_list);
|
sendPacket("FL", feature_list);
|
||||||
|
Loading…
Reference in New Issue
Block a user