From 5248cc718f2dc2fd3b47d20d71a211069b78999e Mon Sep 17 00:00:00 2001 From: Salanto Date: Wed, 5 May 2021 00:11:37 +0200 Subject: [PATCH 1/3] Add asset packet + AO NetEncode --- include/server.h | 4 ++++ src/aoclient.cpp | 4 ++++ src/packets.cpp | 3 +++ src/server.cpp | 3 +++ 4 files changed, 14 insertions(+) diff --git a/include/server.h b/include/server.h index 3e610d2..c76417b 100644 --- a/include/server.h +++ b/include/server.h @@ -317,6 +317,10 @@ class Server : public QObject { * @brief The minimum time between IC messages, in milliseconds. */ int message_floodguard; + /** + * @brief URL send to the client during handshake to set the remote repository URL. + */ + QUrl asset_url; public slots: /** diff --git a/src/aoclient.cpp b/src/aoclient.cpp index 39fc6cd..ba544d2 100644 --- a/src/aoclient.cpp +++ b/src/aoclient.cpp @@ -265,6 +265,10 @@ void AOClient::sendPacket(AOPacket packet) #ifdef NET_DEBUG qDebug() << "Sent packet:" << packet.header << ":" << packet.contents; #endif + packet.contents.replaceInStrings("#", "") + .replaceInStrings("%", "") + .replaceInStrings("$", "") + .replaceInStrings("&", ""); socket->write(packet.toUtf8()); socket->flush(); } diff --git a/src/packets.cpp b/src/packets.cpp index ba52d85..13931af 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -63,6 +63,9 @@ void AOClient::pktSoftwareId(AreaData* area, int argc, QStringList argv, AOPacke sendPacket("PN", {QString::number(server->player_count), server->max_players}); sendPacket("FL", feature_list); + + QByteArray asset_url = server->asset_url.toEncoded(QUrl::EncodeSpaces); + sendPacket("ASS", {asset_url}); } void AOClient::pktBeginLoad(AreaData* area, int argc, QStringList argv, AOPacket packet) diff --git a/src/server.cpp b/src/server.cpp index 21bf840..2afdbe6 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -295,6 +295,9 @@ void Server::loadServerConfig() message_floodguard = config.value("message_floodguard", "250").toInt(&message_floodguard_conversion_success); if (!message_floodguard_conversion_success) message_floodguard = 30; + asset_url = config.value("asset_url","").toString().toUtf8(); + if (!asset_url.isValid()) + asset_url = NULL; config.endGroup(); //Load dice values From ea741f07a68611ae48846e78b25d1e59e8216b78 Mon Sep 17 00:00:00 2001 From: Salanto Date: Wed, 5 May 2021 00:13:19 +0200 Subject: [PATCH 2/3] Update sample config.ini --- bin/config_sample/config.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/config_sample/config.ini b/bin/config_sample/config.ini index 4f80324..dcbff37 100644 --- a/bin/config_sample/config.ini +++ b/bin/config_sample/config.ini @@ -20,6 +20,7 @@ maximum_statements=10 multiclient_limit=15 maximum_characters=256 message_floodguard=250 +asset_url=Your WebAO asset url here. [Dice] max_value=100 From 9b27774fd3cdd10e2ed5756083df3d589e67729e Mon Sep 17 00:00:00 2001 From: Salanto Date: Wed, 5 May 2021 14:33:57 +0200 Subject: [PATCH 3/3] Update packets.cpp Shouldn't send it if its garbage data --- src/packets.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/packets.cpp b/src/packets.cpp index 13931af..a77fe75 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -64,8 +64,10 @@ void AOClient::pktSoftwareId(AreaData* area, int argc, QStringList argv, AOPacke sendPacket("PN", {QString::number(server->player_count), server->max_players}); sendPacket("FL", feature_list); + if (server->asset_url.isValid()) { QByteArray asset_url = server->asset_url.toEncoded(QUrl::EncodeSpaces); sendPacket("ASS", {asset_url}); + } } void AOClient::pktBeginLoad(AreaData* area, int argc, QStringList argv, AOPacket packet)