From 84da730bcef71aeb0d0944261a44dc289949a74d Mon Sep 17 00:00:00 2001 From: Cerapter Date: Fri, 10 Aug 2018 00:09:41 +0200 Subject: [PATCH] Music changing now shows your custom showname, if set. --- courtroom.cpp | 15 ++++++++++++++- server/aoprotocol.py | 11 ++++++++--- server/area_manager.py | 12 ++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/courtroom.cpp b/courtroom.cpp index 040c5b4..1b24bd3 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -2155,6 +2155,12 @@ void Courtroom::handle_song(QStringList *p_contents) { QString str_char = char_list.at(n_char).name; + if (p_contents->length() > 2) + { + if (ui_showname_enable->isChecked()) + str_char = p_contents->at(2); + } + if (!mute_map.value(n_char)) { append_ic_songchange(f_song_clear, str_char); @@ -2401,7 +2407,14 @@ void Courtroom::on_music_list_double_clicked(QModelIndex p_model) //QString p_song = ui_music_list->item(p_model.row())->text(); QString p_song = music_list.at(p_model.row()); - ao_app->send_server_packet(new AOPacket("MC#" + p_song + "#" + QString::number(m_cid) + "#%"), false); + if (!ui_ic_chat_name->text().isEmpty()) + { + ao_app->send_server_packet(new AOPacket("MC#" + p_song + "#" + QString::number(m_cid) + "#" + ui_ic_chat_name->text() + "#%"), false); + } + else + { + ao_app->send_server_packet(new AOPacket("MC#" + p_song + "#" + QString::number(m_cid) + "#%"), false); + } } void Courtroom::on_hold_it_clicked() diff --git a/server/aoprotocol.py b/server/aoprotocol.py index 9b8822b..d26afc9 100644 --- a/server/aoprotocol.py +++ b/server/aoprotocol.py @@ -478,7 +478,7 @@ class AOProtocol(asyncio.Protocol): if not self.client.is_dj: self.client.send_host_message('You were blockdj\'d by a moderator.') return - if not self.validate_net_cmd(args, self.ArgType.STR, self.ArgType.INT): + if not self.validate_net_cmd(args, self.ArgType.STR, self.ArgType.INT) and not self.validate_net_cmd(args, self.ArgType.STR, self.ArgType.INT, self.ArgType.STR): return if args[1] != self.client.char_id: return @@ -487,8 +487,13 @@ class AOProtocol(asyncio.Protocol): return try: name, length = self.server.get_song_data(args[0]) - self.client.area.play_music(name, self.client.char_id, length) - self.client.area.add_music_playing(self.client, name) + if len(args) > 2: + showname = args[2] + self.client.area.play_music_shownamed(name, self.client.char_id, showname, length) + self.client.area.add_music_playing_shownamed(self.client, showname, name) + else: + self.client.area.play_music(name, self.client.char_id, length) + self.client.area.add_music_playing(self.client, name) logger.log_server('[{}][{}]Changed music to {}.' .format(self.client.area.id, self.client.get_char_name(), name), self.client) except ServerError: diff --git a/server/area_manager.py b/server/area_manager.py index 3ed543d..99b4efd 100644 --- a/server/area_manager.py +++ b/server/area_manager.py @@ -116,6 +116,14 @@ class AreaManager: if length > 0: self.music_looper = asyncio.get_event_loop().call_later(length, lambda: self.play_music(name, -1, length)) + + def play_music_shownamed(self, name, cid, showname, length=-1): + self.send_command('MC', name, cid, showname) + if self.music_looper: + self.music_looper.cancel() + if length > 0: + self.music_looper = asyncio.get_event_loop().call_later(length, + lambda: self.play_music(name, -1, length)) def can_send_message(self, client): @@ -159,6 +167,10 @@ class AreaManager: self.current_music_player = client.get_char_name() self.current_music = name + def add_music_playing_shownamed(self, client, showname, name): + self.current_music_player = showname + " (" + client.get_char_name() + ")" + self.current_music = name + def get_evidence_list(self, client): client.evi_list, evi_list = self.evi_list.create_evi_list(client) return evi_list