add global chat toggle
This commit is contained in:
parent
d1918e50a9
commit
49071e6936
@ -58,6 +58,7 @@ class AOClient : public QObject {
|
|||||||
QString moderator_name = "";
|
QString moderator_name = "";
|
||||||
QString ooc_name = "";
|
QString ooc_name = "";
|
||||||
QString showname = "";
|
QString showname = "";
|
||||||
|
bool global_enabled = true;
|
||||||
|
|
||||||
QMap<QString, unsigned long long> ACLFlags {
|
QMap<QString, unsigned long long> ACLFlags {
|
||||||
{"NONE", 0ULL},
|
{"NONE", 0ULL},
|
||||||
@ -212,6 +213,7 @@ class AOClient : public QObject {
|
|||||||
void cmdSwitch(int argc, QStringList argv);
|
void cmdSwitch(int argc, QStringList argv);
|
||||||
void cmdRandomChar(int argc, QStringList argv);
|
void cmdRandomChar(int argc, QStringList argv);
|
||||||
void cmdG(int argc, QStringList argv);
|
void cmdG(int argc, QStringList argv);
|
||||||
|
void cmdToggleGlobal(int argc, QStringList argv);
|
||||||
|
|
||||||
// Command helper functions
|
// Command helper functions
|
||||||
QString getAreaTimer(int area_idx, QTimer* timer);
|
QString getAreaTimer(int area_idx, QTimer* timer);
|
||||||
@ -267,6 +269,7 @@ class AOClient : public QObject {
|
|||||||
{"areakick", {ACLFlags.value("CM"), 1, &AOClient::cmdAreaKick}},
|
{"areakick", {ACLFlags.value("CM"), 1, &AOClient::cmdAreaKick}},
|
||||||
{"randomchar", {ACLFlags.value("NONE"), 0, &AOClient::cmdRandomChar}},
|
{"randomchar", {ACLFlags.value("NONE"), 0, &AOClient::cmdRandomChar}},
|
||||||
{"switch", {ACLFlags.value("NONE"), 1, &AOClient::cmdSwitch}},
|
{"switch", {ACLFlags.value("NONE"), 1, &AOClient::cmdSwitch}},
|
||||||
|
{"toggleglobal", {ACLFlags.value("NONE"), 0, &AOClient::cmdToggleGlobal}},
|
||||||
};
|
};
|
||||||
|
|
||||||
QString partial_packet;
|
QString partial_packet;
|
||||||
|
@ -373,7 +373,10 @@ void AOClient::cmdG(int argc, QStringList argv)
|
|||||||
QString sender_name = ooc_name;
|
QString sender_name = ooc_name;
|
||||||
QString sender_area = server->area_names.value(current_area);
|
QString sender_area = server->area_names.value(current_area);
|
||||||
QString sender_message = argv.join(" ");
|
QString sender_message = argv.join(" ");
|
||||||
server->broadcast(AOPacket("CT", {"[" + sender_area + "]" + sender_name, sender_message}));
|
for (AOClient* client : server->clients) {
|
||||||
|
if (client->global_enabled)
|
||||||
|
client->sendPacket("CT", {"[G][" + sender_area + "]" + sender_name, sender_message});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -682,6 +685,13 @@ void AOClient::cmdRandomChar(int argc, QStringList argv)
|
|||||||
changeCharacter(char_id);
|
changeCharacter(char_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AOClient::cmdToggleGlobal(int argc, QStringList argv)
|
||||||
|
{
|
||||||
|
global_enabled = !global_enabled;
|
||||||
|
QString str_en = global_enabled ? "shown" : "hidden";
|
||||||
|
sendServerMessage("Global chat set to " + str_en);
|
||||||
|
}
|
||||||
|
|
||||||
QStringList AOClient::buildAreaList(int area_idx)
|
QStringList AOClient::buildAreaList(int area_idx)
|
||||||
{
|
{
|
||||||
QStringList entries;
|
QStringList entries;
|
||||||
|
@ -136,7 +136,11 @@ void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket pa
|
|||||||
|
|
||||||
void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
||||||
{
|
{
|
||||||
ooc_name = dezalgo(argv[0]);
|
ooc_name = dezalgo(argv[0]).replace(QRegExp("\\[|\\]|\\{|\\}|\\#|\\$|\\%|\\&"), ""); // no fucky wucky shit here
|
||||||
|
|
||||||
|
if (ooc_name == server->getServerName()) // impersonation prevention
|
||||||
|
return;
|
||||||
|
|
||||||
QString message = dezalgo(argv[1]);
|
QString message = dezalgo(argv[1]);
|
||||||
AOPacket final_packet("CT", {ooc_name, message, "0"});
|
AOPacket final_packet("CT", {ooc_name, message, "0"});
|
||||||
if(message.at(0) == '/') {
|
if(message.at(0) == '/') {
|
||||||
|
Loading…
Reference in New Issue
Block a user