Merge remote-tracking branch 'upstream/master' into Testimony-Loading/Saving

This commit is contained in:
Salanto 2021-04-18 22:34:56 +02:00
commit bddbafb87e
2 changed files with 69 additions and 8 deletions

View File

@ -251,6 +251,16 @@ class AOClient : public QObject {
*/ */
bool is_afk = false; bool is_afk = false;
/**
* @brief If true, the client will not recieve PM messages.
*/
bool pm_mute = false;
/**
* @brief If true, the client will recieve advertisements.
*/
bool advert_enabled = true;
/** /**
* @brief Timer for tracking user interaction. Automatically restarted whenever a user interacts (i.e. sends any packet besides CH) * @brief Timer for tracking user interaction. Automatically restarted whenever a user interacts (i.e. sends any packet besides CH)
*/ */
@ -1313,8 +1323,6 @@ class AOClient : public QObject {
* *
* @details No arguments. * @details No arguments.
* *
* Can silently "fail" if the character picked is already being used by another client.
*
* @iscommand * @iscommand
*/ */
void cmdRandomChar(int argc, QStringList argv); void cmdRandomChar(int argc, QStringList argv);
@ -1454,6 +1462,20 @@ class AOClient : public QObject {
*/ */
void cmdUnShake(int argc, QStringList argv); void cmdUnShake(int argc, QStringList argv);
/**
* @brief Toggles whether a client will recieve @ref cmdPM private messages or not.
*
* @details No arguments.
*/
void cmdMutePM(int argc, QStringList argv);
/**
* @brief Toggles whether a client will recieve @ref cmdNeed "advertisement" messages.
*
* @details No arguments.
*/
void cmdToggleAdverts(int argc, QStringList argv);
/** /**
* @brief Toggles whether this client is considered AFK. * @brief Toggles whether this client is considered AFK.
* *
@ -1897,6 +1919,8 @@ class AOClient : public QObject {
{"savetestimony", {ACLFlags.value("NONE"), 1, &AOClient::cmdSaveTestimony}}, {"savetestimony", {ACLFlags.value("NONE"), 1, &AOClient::cmdSaveTestimony}},
{"loadtestimony", {ACLFlags.value("CM"), 1, &AOClient::cmdLoadTestimony}}, {"loadtestimony", {ACLFlags.value("CM"), 1, &AOClient::cmdLoadTestimony}},
{"permitsaving", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdPermitSaving}}, {"permitsaving", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdPermitSaving}},
{"mutepm", {ACLFlags.value("NONE"), 0, &AOClient::cmdMutePM}},
{"toggleadverts", {ACLFlags.value("NONE"), 0, &AOClient::cmdToggleAdverts}},
{"oocmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocMute}}, {"oocmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocMute}},
{"ooc_mute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocMute}}, {"ooc_mute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocMute}},
{"oocunmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocUnMute}}, {"oocunmute", {ACLFlags.value("MUTE"), 1, &AOClient::cmdOocUnMute}},

View File

@ -77,23 +77,42 @@ void AOClient::cmdNeed(int argc, QStringList argv)
{ {
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(" ");
sendServerBroadcast({"=== Advert ===\n[" + sender_area + "] needs " + sender_message+ "."}); for (AOClient* client : server->clients) {
if (client->advert_enabled) {
client->sendServerMessage({"=== Advert ===\n[" + sender_area + "] needs " + sender_message+ "."});
}
}
} }
void AOClient::cmdSwitch(int argc, QStringList argv) void AOClient::cmdSwitch(int argc, QStringList argv)
{ {
int char_id = server->getCharID(argv.join(" ")); int selected_char_id = server->getCharID(argv.join(" "));
if (char_id == -1) { if (selected_char_id == -1) {
sendServerMessage("That does not look like a valid character."); sendServerMessage("That does not look like a valid character.");
return; return;
} }
changeCharacter(char_id); if (changeCharacter(selected_char_id)) {
char_id = selected_char_id;
}
else {
sendServerMessage("The character you picked is either taken or invalid.");
}
} }
void AOClient::cmdRandomChar(int argc, QStringList argv) void AOClient::cmdRandomChar(int argc, QStringList argv)
{ {
int char_id = genRand(0, server->characters.size() - 1); AreaData* area = server->areas[current_area];
changeCharacter(char_id); int selected_char_id;
bool taken = true;
while (taken) {
selected_char_id = genRand(0, server->characters.size() - 1);
if (!area->characters_taken.contains(selected_char_id)) {
taken = false;
}
}
if (changeCharacter(selected_char_id)) {
char_id = selected_char_id;
}
} }
void AOClient::cmdToggleGlobal(int argc, QStringList argv) void AOClient::cmdToggleGlobal(int argc, QStringList argv)
@ -116,6 +135,10 @@ void AOClient::cmdPM(int arc, QStringList argv)
sendServerMessage("No client with that ID found."); sendServerMessage("No client with that ID found.");
return; return;
} }
if (target_client->pm_mute) {
sendServerMessage("That user is not recieving PMs.");
return;
}
QString message = argv.join(" "); //...which means it will not end up as part of the message QString message = argv.join(" "); //...which means it will not end up as part of the message
target_client->sendServerMessage("Message from " + ooc_name + " (" + QString::number(id) + "): " + message); target_client->sendServerMessage("Message from " + ooc_name + " (" + QString::number(id) + "): " + message);
} }
@ -275,6 +298,20 @@ void AOClient::cmdUnShake(int argc, QStringList argv)
target->is_shaken = false; target->is_shaken = false;
} }
void AOClient::cmdMutePM(int argc, QStringList argv)
{
pm_mute = !pm_mute;
QString str_en = pm_mute ? "muted" : "unmuted";
sendServerMessage("PM's are now " + str_en);
}
void AOClient::cmdToggleAdverts(int argc, QStringList argv)
{
advert_enabled = !advert_enabled;
QString str_en = advert_enabled ? "on" : "off";
sendServerMessage("Advertisements turned " + str_en);
}
void AOClient::cmdAfk(int argc, QStringList argv) void AOClient::cmdAfk(int argc, QStringList argv)
{ {
is_afk = true; is_afk = true;