diff --git a/core/include/server.h b/core/include/server.h index 8b4d43f..a6c7e96 100644 --- a/core/include/server.h +++ b/core/include/server.h @@ -80,7 +80,8 @@ class Server : public QObject { */ enum class TARGET_TYPE { AUTHENTICATED, - MODCHAT + MODCHAT, + ADVERT }; Q_ENUM(TARGET_TYPE) diff --git a/core/src/commands/messaging.cpp b/core/src/commands/messaging.cpp index 556889a..040b6cd 100644 --- a/core/src/commands/messaging.cpp +++ b/core/src/commands/messaging.cpp @@ -71,6 +71,7 @@ void AOClient::cmdG(int argc, QStringList argv) QString l_sender_name = m_ooc_name; QString l_sender_area = server->m_area_names.value(m_current_area); QString l_sender_message = argv.join(" "); + //Slightly better readability AOPacket l_packet = AOPacket("CT", {"[G][" + m_ipid + "][" + l_sender_area + "]" + l_sender_name, l_sender_message}); AOPacket l_other_packet = AOPacket("CT", {"[G][" + l_sender_area + "]" + l_sender_name, l_sender_message}); server->broadcast(l_packet, l_other_packet, Server::TARGET_TYPE::AUTHENTICATED); @@ -83,11 +84,7 @@ void AOClient::cmdNeed(int argc, QStringList argv) QString l_sender_area = server->m_area_names.value(m_current_area); QString l_sender_message = argv.join(" "); - for (AOClient* l_client : qAsConst(server->m_clients)) { - if (l_client->m_advert_enabled) { - l_client->sendServerMessage({"=== Advert ===\n[" + l_sender_area + "] needs " + l_sender_message+ "."}); - } - } + server->broadcast(AOPacket("CT",{"=== Advert ===\n[" + l_sender_area + "] needs " + l_sender_message+ "."}),Server::TARGET_TYPE::ADVERT); } void AOClient::cmdSwitch(int argc, QStringList argv) diff --git a/core/src/server.cpp b/core/src/server.cpp index ce5816b..da0c521 100644 --- a/core/src/server.cpp +++ b/core/src/server.cpp @@ -217,16 +217,21 @@ void Server::broadcast(AOPacket packet) void Server::broadcast(AOPacket packet, TARGET_TYPE target) { - switch (target) { - case TARGET_TYPE::MODCHAT: - for (AOClient* l_client : qAsConst(m_clients)) { + for (AOClient* l_client : qAsConst(m_clients)) { + switch (target) { + case TARGET_TYPE::MODCHAT: if (l_client->checkAuth(l_client->ACLFlags.value("MODCHAT"))) { l_client->sendPacket(packet); } + break; + case TARGET_TYPE::ADVERT: + if (l_client->m_advert_enabled) { + l_client->sendPacket(packet); + } + break; + default: + break; } - default: - //Unimplemented, so not handled. - break; } }