diff --git a/core/include/area_data.h b/core/include/area_data.h index 87f10d7..b5102ba 100644 --- a/core/include/area_data.h +++ b/core/include/area_data.h @@ -329,6 +329,15 @@ class AreaData : public QObject */ int getJukeboxQueueSize() const; + /** + * @brief Returns whether /play is allowed without CM in this area + * + * @return See short description. + * + * @see #m_playcmd + */ + bool isPlayEnabled() const; + /** * @brief Locks the area, setting it to LOCKED. */ @@ -1183,6 +1192,11 @@ class AreaData : public QObject */ bool m_jukebox; + /** + * @brief Whether or not /play can be used without CM. + */ + bool m_playcmd; + /** * @brief Timer until the next IC message can be sent. */ diff --git a/core/src/aoclient.cpp b/core/src/aoclient.cpp index 8ac9e60..340405c 100644 --- a/core/src/aoclient.cpp +++ b/core/src/aoclient.cpp @@ -59,7 +59,7 @@ const QMap AOClient::COMMANDS{ {"area_unlock", {{ACLRole::CM}, 0, &AOClient::cmdUnLock}}, {"timer", {{ACLRole::CM}, 0, &AOClient::cmdTimer}}, {"area", {{ACLRole::NONE}, 1, &AOClient::cmdArea}}, - {"play", {{ACLRole::CM}, 1, &AOClient::cmdPlay}}, + {"play", {{ACLRole::NONE}, 1, &AOClient::cmdPlay}}, {"area_kick", {{ACLRole::CM}, 1, &AOClient::cmdAreaKick}}, {"randomchar", {{ACLRole::NONE}, 0, &AOClient::cmdRandomChar}}, {"switch", {{ACLRole::NONE}, 1, &AOClient::cmdSwitch}}, diff --git a/core/src/area_data.cpp b/core/src/area_data.cpp index 1145d75..03cb1ec 100644 --- a/core/src/area_data.cpp +++ b/core/src/area_data.cpp @@ -60,6 +60,7 @@ AreaData::AreaData(QString p_name, int p_index, MusicManager *p_music_manager = m_shownameAllowed = areas_ini->value("shownames_allowed", "true").toBool(); m_ignoreBgList = areas_ini->value("ignore_bglist", "false").toBool(); m_jukebox = areas_ini->value("jukebox_enabled", "false").toBool(); + m_playcmd = areas_ini->value("playcmd_enabled", "false").toBool(); m_can_send_wtce = areas_ini->value("wtce_enabled", "true").toBool(); m_can_use_shouts = areas_ini->value("shouts_enabled", "true").toBool(); areas_ini->endGroup(); @@ -166,6 +167,11 @@ int AreaData::getJukeboxQueueSize() const return m_jukebox_queue.size(); } +bool AreaData::isPlayEnabled() const +{ + return m_playcmd; +} + void AreaData::lock() { m_locked = LockStatus::LOCKED; diff --git a/core/src/commands/music.cpp b/core/src/commands/music.cpp index a3693b7..9ac56c2 100644 --- a/core/src/commands/music.cpp +++ b/core/src/commands/music.cpp @@ -34,6 +34,10 @@ void AOClient::cmdPlay(int argc, QStringList argv) return; } AreaData *l_area = server->getAreaById(m_current_area); + if (!l_area->owners().contains(m_id) && !l_area->isPlayEnabled()) { // Make sure we have permission to play music + sendServerMessage("Free music play is disabled in this area."); + return; + } QString l_song = argv.join(" "); if (m_showname.isEmpty()) { l_area->changeMusic(m_current_char, l_song);