Merge pull request #21 from AttorneyOnline/in1tiate/commands-uwu
Fixes and improvements
This commit is contained in:
commit
325aeb5349
@ -28,7 +28,7 @@
|
|||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#if QT_VERSION > QT_VERSION_CHECK(5, 10, 0)
|
#if QT_VERSION > QT_VERSION_CHECK(5, 10, 0)
|
||||||
#include <QRandomGenerator>
|
#include <QRandomGenerator>
|
||||||
|
@ -68,10 +68,17 @@ void AOClient::clientDisconnected()
|
|||||||
false;
|
false;
|
||||||
server->updateCharsTaken(server->areas[current_area]);
|
server->updateCharsTaken(server->areas[current_area]);
|
||||||
}
|
}
|
||||||
|
bool update_locks;
|
||||||
for (AreaData* area : server->areas) {
|
for (AreaData* area : server->areas) {
|
||||||
area->owners.removeAll(id);
|
area->owners.removeAll(id);
|
||||||
area->invited.removeAll(id);
|
area->invited.removeAll(id);
|
||||||
|
if (area->owners.isEmpty() && area->locked != AreaData::FREE) {
|
||||||
|
area->locked = AreaData::FREE;
|
||||||
|
update_locks = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (update_locks)
|
||||||
|
arup(ARUPType::LOCKED, true);
|
||||||
arup(ARUPType::CM, true);
|
arup(ARUPType::CM, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,20 +182,20 @@ void AOClient::changeCharacter(int char_id)
|
|||||||
sendPacket("PV", {QString::number(id), "CID", QString::number(char_id)});
|
sendPacket("PV", {QString::number(id), "CID", QString::number(char_id)});
|
||||||
fullArup();
|
fullArup();
|
||||||
if (server->timer->isActive()) {
|
if (server->timer->isActive()) {
|
||||||
sendPacket("TI", {QString::number(0), QString::number(2)});
|
sendPacket("TI", {"0", "2"});
|
||||||
sendPacket("TI", {QString::number(0), QString::number(0), QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(server->timer->remainingTime())))});
|
sendPacket("TI", {"0", "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(server->timer->remainingTime())))});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sendPacket("TI", {QString::number(0), QString::number(3)});
|
sendPacket("TI", {"0", "3"});
|
||||||
}
|
}
|
||||||
for (QTimer* timer : area->timers) {
|
for (QTimer* timer : area->timers) {
|
||||||
int timer_id = area->timers.indexOf(timer) + 1;
|
int timer_id = area->timers.indexOf(timer) + 1;
|
||||||
if (timer->isActive()) {
|
if (timer->isActive()) {
|
||||||
sendPacket("TI", {QString::number(timer_id), QString::number(2)});
|
sendPacket("TI", {QString::number(timer_id), "2"});
|
||||||
sendPacket("TI", {QString::number(timer_id), QString::number(0), QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(timer->remainingTime())))});
|
sendPacket("TI", {QString::number(timer_id), "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(timer->remainingTime())))});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sendPacket("TI", {QString::number(timer_id), QString::number(3)});
|
sendPacket("TI", {QString::number(timer_id), "3"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -505,8 +505,13 @@ void AOClient::cmdUnCM(int argc, QStringList argv)
|
|||||||
area->invited.removeAll(id);
|
area->invited.removeAll(id);
|
||||||
sendServerMessage("You are no longer CM in this area.");
|
sendServerMessage("You are no longer CM in this area.");
|
||||||
arup(ARUPType::CM, true);
|
arup(ARUPType::CM, true);
|
||||||
if (area->owners.isEmpty())
|
if (area->owners.isEmpty()) {
|
||||||
area->invited.clear();
|
area->invited.clear();
|
||||||
|
if (area->locked != AreaData::FREE) {
|
||||||
|
area->locked = AreaData::FREE;
|
||||||
|
arup(ARUPType::LOCKED, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClient::cmdInvite(int argc, QStringList argv)
|
void AOClient::cmdInvite(int argc, QStringList argv)
|
||||||
@ -657,28 +662,28 @@ void AOClient::cmdTimer(int argc, QStringList argv)
|
|||||||
requested_timer->setInterval(QTime(0,0).msecsTo(requested_time));
|
requested_timer->setInterval(QTime(0,0).msecsTo(requested_time));
|
||||||
requested_timer->start();
|
requested_timer->start();
|
||||||
sendServerMessage("Set timer " + QString::number(timer_id) + " to " + argv[1] + ".");
|
sendServerMessage("Set timer " + QString::number(timer_id) + " to " + argv[1] + ".");
|
||||||
sendPacket("TI", {QString::number(timer_id), QString::number(2)});
|
sendPacket("TI", {QString::number(timer_id), "2"}); // Show the timer
|
||||||
sendPacket("TI", {QString::number(timer_id), QString::number(0), QString::number(QTime(0,0).msecsTo(requested_time))});
|
sendPacket("TI", {QString::number(timer_id), "0", QString::number(QTime(0,0).msecsTo(requested_time))});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (argv[1] == "start") {
|
if (argv[1] == "start") {
|
||||||
requested_timer->start();
|
requested_timer->start();
|
||||||
sendServerMessage("Started timer " + QString::number(timer_id) + ".");
|
sendServerMessage("Started timer " + QString::number(timer_id) + ".");
|
||||||
sendPacket("TI", {QString::number(timer_id), QString::number(2)});
|
sendPacket("TI", {QString::number(timer_id), "2"}); // Show the timer
|
||||||
sendPacket("TI", {QString::number(timer_id), QString::number(0), QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(requested_timer->remainingTime())))});
|
sendPacket("TI", {QString::number(timer_id), "0", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(requested_timer->remainingTime())))});
|
||||||
}
|
}
|
||||||
else if (argv[1] == "pause" || argv[1] == "stop") {
|
else if (argv[1] == "pause" || argv[1] == "stop") {
|
||||||
requested_timer->setInterval(requested_timer->remainingTime());
|
requested_timer->setInterval(requested_timer->remainingTime());
|
||||||
requested_timer->stop();
|
requested_timer->stop();
|
||||||
sendServerMessage("Stopped timer " + QString::number(timer_id) + ".");
|
sendServerMessage("Stopped timer " + QString::number(timer_id) + ".");
|
||||||
sendPacket("TI", {QString::number(timer_id), QString::number(1), QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(requested_timer->interval())))});
|
sendPacket("TI", {QString::number(timer_id), "1", QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(requested_timer->interval())))});
|
||||||
}
|
}
|
||||||
else if (argv[1] == "hide" || argv[1] == "unset") {
|
else if (argv[1] == "hide" || argv[1] == "unset") {
|
||||||
requested_timer->setInterval(0);
|
requested_timer->setInterval(0);
|
||||||
requested_timer->stop();
|
requested_timer->stop();
|
||||||
sendServerMessage("Hid timer " + QString::number(timer_id) + ".");
|
sendServerMessage("Hid timer " + QString::number(timer_id) + ".");
|
||||||
sendPacket("TI", {QString::number(timer_id), QString::number(3)});
|
sendPacket("TI", {QString::number(timer_id), "3"}); // Hide the timer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -869,7 +874,7 @@ QStringList AOClient::buildAreaList(int area_idx)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
entries.append("[" + QString::number(area->player_count) + " users][" + area->status + "]");
|
entries.append("[" + QString::number(area->player_count) + " users][" + QVariant::fromValue(area->status).toString().replace("_", "-") + "]");
|
||||||
for (AOClient* client : server->clients) {
|
for (AOClient* client : server->clients) {
|
||||||
if (client->current_area == area_idx && client->joined) {
|
if (client->current_area == area_idx && client->joined) {
|
||||||
QString char_entry = "[" + QString::number(client->id) + "] " + client->current_char;
|
QString char_entry = "[" + QString::number(client->id) + "] " + client->current_char;
|
||||||
|
@ -36,7 +36,7 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
QCoreApplication::setApplicationName("akashi");
|
QCoreApplication::setApplicationName("akashi");
|
||||||
QCoreApplication::setApplicationVersion("0.0.1");
|
QCoreApplication::setApplicationVersion("1.0.0-alpha");
|
||||||
std::atexit(cleanup);
|
std::atexit(cleanup);
|
||||||
|
|
||||||
ConfigManager config_manager;
|
ConfigManager config_manager;
|
||||||
|
@ -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(".");
|
QRegularExpression rx("\\b(\\d+)\\.(\\d+)\\.(\\d+)\\b"); // matches X.X.X (e.g. 2.9.0, 2.4.10, etc.)
|
||||||
bool ok;
|
QRegularExpressionMatch match = rx.match(version.string);
|
||||||
int release_version = version_raw[0].toInt(&ok);
|
if (match.hasMatch()) {
|
||||||
if (ok && version_raw.size() >= 1)
|
version.release = match.captured(1).toInt();
|
||||||
version.release = release_version;
|
version.major = match.captured(2).toInt();
|
||||||
if (ok && version_raw.size() >= 2) {
|
version.minor = match.captured(3).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