Merge branch 'master' into messaging-commands

This commit is contained in:
MangosArentLiterature 2021-04-17 22:34:31 -05:00
commit bcaf9a1f29
6 changed files with 88 additions and 25 deletions

View File

@ -219,6 +219,7 @@ class AOClient : public QObject {
{"ANNOUNCE", 1ULL << 8 },
{"MODCHAT", 1ULL << 9 },
{"MUTE", 1ULL << 10},
{"UNCM", 1ULL << 11},
{"SUPER", ~0ULL },
};
@ -1462,6 +1463,15 @@ class AOClient : public QObject {
*/
void cmdToggleAdverts(int argc, QStringList argv);
/**
* @brief Toggles whether this client is considered AFK.
*
* @details No arguments.
*
* @iscommand
*/
void cmdAfk(int argc, QStringList argv);
///@}
/**
@ -1611,16 +1621,6 @@ class AOClient : public QObject {
*/
void cmdCurrentMusic(int argc, QStringList argv);
/**
* @brief Toggles whether this client is considered AFK.
*
* @details No arguments.
*
* @iscommand
*/
void cmdAfk(int argc, QStringList argv);
///@}
/**
@ -1876,6 +1876,18 @@ class AOClient : public QObject {
{"afk", {ACLFlags.value("NONE"), 0, &AOClient::cmdAfk}},
{"mutepm", {ACLFlags.value("NONE"), 0, &AOClient::cmdMutePM}},
{"toggleadverts", {ACLFlags.value("NONE"), 0, &AOClient::cmdToggleAdverts}},
{"oocmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocMute}},
{"ooc_mute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocMute}},
{"oocunmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocUnMute}},
{"ooc_unmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocUnMute}},
{"blockwtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockWtce}},
{"block_wtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockWtce}},
{"unblockwtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockWtce}},
{"unblock_wtce", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockWtce}},
{"blockdj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockDj}},
{"block_dj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdBlockDj}},
{"unblockdj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockDj}},
{"unblock_dj", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnBlockDj}},
};
/**
@ -1934,6 +1946,13 @@ class AOClient : public QObject {
* @param action String containing the info that is being recorded.
*/
void updateJudgeLog(AreaData* area, AOClient* client, QString action);
/**
* @brief A helper function for decoding AO encoding from a QString.
*
* @param incoming_message QString to be decoded.
*/
QString decodeMessage(QString incoming_message);
};
#endif // AOCLIENT_H

View File

@ -61,9 +61,36 @@ void AOClient::cmdCM(int argc, QStringList argv)
void AOClient::cmdUnCM(int argc, QStringList argv)
{
AreaData* area = server->areas[current_area];
int removed = area->owners.removeAll(id);
area->invited.removeAll(id);
sendServerMessage("You are no longer CM in this area.");
int uid;
if (area->owners.isEmpty()) {
sendServerMessage("There are no CMs in this area.");
return;
}
else if (argc == 0) {
uid = id;
sendServerMessage("You are no longer CM in this area.");
}
else if (checkAuth(ACLFlags.value("UNCM")) && argc == 1) {
bool conv_ok = false;
uid = argv[0].toInt(&conv_ok);
if (!conv_ok) {
sendServerMessage("Invalid user ID.");
return;
}
if (!area->owners.contains(uid)) {
sendServerMessage("That user is not CMed.");
return;
}
AOClient* target = server->getClientByID(uid);
target->sendServerMessage("You have been unCMed by a moderator.");
}
else {
sendServerMessage("Invalid command.");
return;
}
area->owners.removeAll(uid);
area->invited.removeAll(uid);
arup(ARUPType::CM, true);
if (area->owners.isEmpty()) {
area->invited.clear();
@ -283,9 +310,3 @@ void AOClient::cmdJudgeLog(int argc, QStringList argv)
sendServerMessage(filteredmessage);
}
}
void AOClient::cmdAfk(int argc, QStringList argv)
{
is_afk = true;
sendServerMessage("You are now AFK.");
}

View File

@ -296,3 +296,9 @@ void AOClient::cmdToggleAdverts(int argc, QStringList argv)
QString str_en = advert_enabled ? "on" : "off";
sendServerMessage("Advertisements turned " + str_en);
}
void AOClient::cmdAfk(int argc, QStringList argv)
{
is_afk = true;
sendServerMessage("You are now AFK.");
}

View File

@ -22,6 +22,10 @@
void AOClient::cmdPlay(int argc, QStringList argv)
{
if (is_dj_blocked) {
sendServerMessage("You are blocked from changing the music.");
return;
}
AreaData* area = server->areas[current_area];
QString song = argv.join(" ");
area->current_music = song;

View File

@ -62,7 +62,10 @@ int main(int argc, char* argv[])
}
server = new Server(settings.port, settings.ws_port);
QObject::connect(server, &Server::reloadRequest, advertiser, &Advertiser::reloadRequested);
if (advertiser != nullptr) {
QObject::connect(server, &Server::reloadRequest, advertiser, &Advertiser::reloadRequested);
}
server->start();
}
} else {

View File

@ -210,10 +210,6 @@ void AOClient::pktPing(AreaData* area, int argc, QStringList argv, AOPacket pack
void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPacket packet)
{
if (is_dj_blocked) {
sendServerMessage("You are blocked from changing the music.");
return;
}
// Due to historical reasons, this
// packet has two functions:
// Change area, and set music.
@ -225,6 +221,10 @@ void AOClient::pktChangeMusic(AreaData* area, int argc, QStringList argv, AOPack
for (QString song : server->music_list) {
if (song == argument || song == "~stop.mp3") { // ~stop.mp3 is a dummy track used by 2.9+
// We have a song here
if (is_dj_blocked) {
sendServerMessage("You are blocked from changing the music.");
return;
}
QString effects;
if (argc >= 4)
effects = argv[3];
@ -724,8 +724,9 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
area->statement = area->statement - 1;
args = playTestimony();
}
QString decoded_message = decodeMessage(args[4]); //Get rid of that pesky encoding first.
QRegularExpression jump("(?<arrow>>)(?<int>[0,1,2,3,4,5,6,7,8,9]+)");
QRegularExpressionMatch match = jump.match(args[4]);
QRegularExpressionMatch match = jump.match(decoded_message);
if (match.hasMatch()) {
pos = "wit";
area->statement = match.captured("int").toInt();
@ -773,3 +774,12 @@ void AOClient::updateJudgeLog(AreaData* area, AOClient* client, QString action)
}
else area->judgelog.append(logmessage);
}
QString AOClient::decodeMessage(QString incoming_message)
{
QString decoded_message = incoming_message.replace("<num>", "#")
.replace("<percent>", "%")
.replace("<dollar>", "$")
.replace("<and>", "&");
return decoded_message;
}