Skip to content

Commit

Permalink
Allow areas to set whether or not /play requires CM (#347)
Browse files Browse the repository at this point in the history
* Allow areas to set whether or not /play requires cm

* make error message clearer (thank you 8)
  • Loading branch information
in1tiate authored Mar 23, 2024
1 parent 74820da commit 3e5776c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
14 changes: 14 additions & 0 deletions core/include/area_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion core/src/aoclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const QMap<QString, AOClient::CommandInfo> 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}},
Expand Down
6 changes: 6 additions & 0 deletions core/src/area_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions core/src/commands/music.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3e5776c

Please sign in to comment.