More example implementation.
This commit is contained in:
parent
d943981ef1
commit
578aee2251
@ -80,7 +80,8 @@ class Server : public QObject {
|
|||||||
*/
|
*/
|
||||||
enum class TARGET_TYPE {
|
enum class TARGET_TYPE {
|
||||||
AUTHENTICATED,
|
AUTHENTICATED,
|
||||||
MODCHAT
|
MODCHAT,
|
||||||
|
ADVERT
|
||||||
};
|
};
|
||||||
Q_ENUM(TARGET_TYPE)
|
Q_ENUM(TARGET_TYPE)
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ void AOClient::cmdG(int argc, QStringList argv)
|
|||||||
QString l_sender_name = m_ooc_name;
|
QString l_sender_name = m_ooc_name;
|
||||||
QString l_sender_area = server->m_area_names.value(m_current_area);
|
QString l_sender_area = server->m_area_names.value(m_current_area);
|
||||||
QString l_sender_message = argv.join(" ");
|
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_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});
|
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);
|
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_area = server->m_area_names.value(m_current_area);
|
||||||
QString l_sender_message = argv.join(" ");
|
QString l_sender_message = argv.join(" ");
|
||||||
for (AOClient* l_client : qAsConst(server->m_clients)) {
|
server->broadcast(AOPacket("CT",{"=== Advert ===\n[" + l_sender_area + "] needs " + l_sender_message+ "."}),Server::TARGET_TYPE::ADVERT);
|
||||||
if (l_client->m_advert_enabled) {
|
|
||||||
l_client->sendServerMessage({"=== Advert ===\n[" + l_sender_area + "] needs " + l_sender_message+ "."});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClient::cmdSwitch(int argc, QStringList argv)
|
void AOClient::cmdSwitch(int argc, QStringList argv)
|
||||||
|
@ -217,16 +217,21 @@ void Server::broadcast(AOPacket packet)
|
|||||||
|
|
||||||
void Server::broadcast(AOPacket packet, TARGET_TYPE target)
|
void Server::broadcast(AOPacket packet, TARGET_TYPE target)
|
||||||
{
|
{
|
||||||
switch (target) {
|
for (AOClient* l_client : qAsConst(m_clients)) {
|
||||||
case TARGET_TYPE::MODCHAT:
|
switch (target) {
|
||||||
for (AOClient* l_client : qAsConst(m_clients)) {
|
case TARGET_TYPE::MODCHAT:
|
||||||
if (l_client->checkAuth(l_client->ACLFlags.value("MODCHAT"))) {
|
if (l_client->checkAuth(l_client->ACLFlags.value("MODCHAT"))) {
|
||||||
l_client->sendPacket(packet);
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user