Add the ability to ignore the BG list per area

- Adds the "ignore_bglist" option to areas, which toggles whether the BG list is enforced or ignored in an area.
- Adds a moderator permission "IGNORE_BGLIST" to give moderators the permission to toggle this setting.
- Adds a moderator command `/ignorebglist` to toggle this for an area.
This commit is contained in:
MangosArentLiterature 2021-06-08 09:12:04 -05:00
parent 4c32cf86cc
commit dc497a55f6
4 changed files with 51 additions and 1 deletions

View File

@ -230,6 +230,7 @@ class AOClient : public QObject {
{"SAVETEST", 1ULL << 12}, {"SAVETEST", 1ULL << 12},
{"FORCE_CHARSELECT",1ULL << 13}, {"FORCE_CHARSELECT",1ULL << 13},
{"BYPASS_LOCKS", 1ULL << 14}, {"BYPASS_LOCKS", 1ULL << 14},
{"IGNORE_BGLIST", 1ULL << 15},
{"SUPER", ~0ULL } {"SUPER", ~0ULL }
}; };
@ -963,6 +964,15 @@ class AOClient : public QObject {
*/ */
void cmdJudgeLog(int argc, QStringList argv); void cmdJudgeLog(int argc, QStringList argv);
/**
* @brief Toggles whether the BG list is ignored in an area.
*
* @details No arguments.
*
* @iscommand
*/
void cmdIgnoreBgList(int argc, QStringList argv);
///@} ///@}
/** /**
@ -2055,6 +2065,8 @@ class AOClient : public QObject {
{"updateban", {ACLFlags.value("BAN"), 3, &AOClient::cmdUpdateBan}}, {"updateban", {ACLFlags.value("BAN"), 3, &AOClient::cmdUpdateBan}},
{"update_ban", {ACLFlags.value("BAN"), 3, &AOClient::cmdUpdateBan}}, {"update_ban", {ACLFlags.value("BAN"), 3, &AOClient::cmdUpdateBan}},
{"changepass", {ACLFlags.value("NONE"), 1, &AOClient::cmdChangePassword}}, {"changepass", {ACLFlags.value("NONE"), 1, &AOClient::cmdChangePassword}},
{"ignorebglist", {ACLFlags.value("IGNORE_BGLIST"),0, &AOClient::cmdIgnoreBgList}},
{"ignore_bglist", {ACLFlags.value("IGNORE_BGLIST"),0, &AOClient::cmdIgnoreBgList}}
}; };
/** /**

View File

@ -797,9 +797,23 @@ class AreaData : public QObject {
* @brief Returns a copy of the underlying logger's buffer. * @brief Returns a copy of the underlying logger's buffer.
* *
* @return See short description. * @return See short description.
*
* @see #m_ignoreBgList
*/ */
QQueue<QString> buffer() const; QQueue<QString> buffer() const;
/**
* @brief Returns whether the BG list is ignored in this araa.
*
* @return See short description.
*/
bool ignoreBgList();
/**
* @brief Toggles whether the BG list is ignored in this area.
*/
void toggleIgnoreBgList();
private: private:
/** /**
* @brief The list of timers available in the area. * @brief The list of timers available in the area.
@ -983,6 +997,11 @@ private:
* @brief Whether or not music is allowed in this area. If false, only CMs can change the music. * @brief Whether or not music is allowed in this area. If false, only CMs can change the music.
*/ */
bool m_toggleMusic; bool m_toggleMusic;
/**
* @brief Whether or not to ignore the server defined background list. If true, any background can be set in an area.
*/
bool m_ignoreBgList;
}; };
#endif // AREA_DATA_H #endif // AREA_DATA_H

View File

@ -47,6 +47,7 @@ AreaData::AreaData(QString p_name, int p_index) :
m_forceImmediate = areas_ini.value("force_immediate", "false").toBool(); m_forceImmediate = areas_ini.value("force_immediate", "false").toBool();
m_toggleMusic = areas_ini.value("toggle_music", "true").toBool(); m_toggleMusic = areas_ini.value("toggle_music", "true").toBool();
m_shownameAllowed = areas_ini.value("shownames_allowed", "true").toBool(); m_shownameAllowed = areas_ini.value("shownames_allowed", "true").toBool();
m_ignoreBgList = areas_ini.value("ignore_bglist", "false").toBool();
areas_ini.endGroup(); areas_ini.endGroup();
QSettings config_ini("config/config.ini", QSettings::IniFormat); QSettings config_ini("config/config.ini", QSettings::IniFormat);
config_ini.setIniCodec("UTF-8"); config_ini.setIniCodec("UTF-8");
@ -534,3 +535,13 @@ QString AreaData::background() const
{ {
return m_background; return m_background;
} }
bool AreaData::ignoreBgList()
{
return m_ignoreBgList;
}
void AreaData::toggleIgnoreBgList()
{
m_ignoreBgList = !m_ignoreBgList;
}

View File

@ -239,7 +239,7 @@ void AOClient::cmdSetBackground(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
if (authenticated || !area->bgLocked()) { if (authenticated || !area->bgLocked()) {
if (server->backgrounds.contains(argv[0])) { if (server->backgrounds.contains(argv[0]) || area->ignoreBgList() == true) {
area->background() = argv[0]; area->background() = argv[0];
server->broadcast(AOPacket("BN", {argv[0]}), current_area); server->broadcast(AOPacket("BN", {argv[0]}), current_area);
sendServerMessageArea(current_char + " changed the background to " + argv[0]); sendServerMessageArea(current_char + " changed the background to " + argv[0]);
@ -305,3 +305,11 @@ void AOClient::cmdJudgeLog(int argc, QStringList argv)
sendServerMessage(filteredmessage); sendServerMessage(filteredmessage);
} }
} }
void AOClient::cmdIgnoreBgList(int argc, QStringList argv)
{
AreaData* area = server->areas[current_area];
area->toggleIgnoreBgList();
QString state = area->ignoreBgList() ? "ignored." : "enforced.";
sendServerMessage("BG list in this area is now " + state);
}