diff --git a/base/sounds/music/failed_login.opus b/base/sounds/music/failed_login.opus new file mode 100644 index 0000000..33532ee Binary files /dev/null and b/base/sounds/music/failed_login.opus differ diff --git a/include/aomusicplayer.h b/include/aomusicplayer.h index 54f3b5f..24ea0c5 100644 --- a/include/aomusicplayer.h +++ b/include/aomusicplayer.h @@ -21,6 +21,7 @@ public: void kill_loop(); QString get_path(); + bool enable_looping = true; private: QWidget *m_parent; diff --git a/include/courtroom.h b/include/courtroom.h index 7d2a551..c76e4a1 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -68,14 +68,10 @@ public: void append_evidence(evi_type p_evi){evidence_list.append(p_evi);} void append_music(QString f_music){music_list.append(f_music);} void append_area(QString f_area){area_list.append(f_area);} - void fix_last_area() + void handle_failed_login(); + void reset_music_list() { - if (area_list.size() > 0) - { - QString malplaced = area_list.last(); - area_list.removeLast(); - append_music(malplaced); - } + music_list.clear(); } void arup_append(int players, QString status, QString cm, QString locked) diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp index a52603c..2a35f0b 100644 --- a/src/aomusicplayer.cpp +++ b/src/aomusicplayer.cpp @@ -29,14 +29,18 @@ void AOMusicPlayer::play(QString p_song) BASS_ChannelSetDevice(m_stream, BASS_GetDevice()); BASS_ChannelPlay(m_stream, false); music_loop_timer->stop(); - QWORD len=BASS_ChannelGetLength(m_stream, BASS_POS_BYTE); // the length in bytes - double time=BASS_ChannelBytes2Seconds(m_stream, len); // the length in seconds - if(time > 0) + if(enable_looping) { - qDebug() << "Will loop in " << time << " seconds."; - music_loop_timer->start(time*1000); + QWORD len=BASS_ChannelGetLength(m_stream, BASS_POS_BYTE); // the length in bytes + double time=BASS_ChannelBytes2Seconds(m_stream, len); // the length in seconds + if(time > 0) + { + qDebug() << "Will loop in " << time << " seconds."; + music_loop_timer->start(time*1000); + } } + } void AOMusicPlayer::set_volume(int p_value) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index da1b090..a097444 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2761,9 +2761,22 @@ void Courtroom::handle_song(QStringList *p_contents) if (p_contents->length() > 2) { - str_show = p_contents->at(2); + if(p_contents->at(2) != "") + { + str_show = p_contents->at(2); + } + } + if (p_contents->length() > 3) + { + if(p_contents->at(3) != "-1") + { + music_player->enable_looping = false; + } + else + { + music_player->enable_looping = true; + } } - if (!mute_map.value(n_char)) { chatlogpiece* temp = new chatlogpiece(str_char, str_show, f_song, true); @@ -2780,6 +2793,12 @@ void Courtroom::handle_song(QStringList *p_contents) } } +void Courtroom::handle_failed_login() +{ + music_player->enable_looping = false; + music_player->play("failed_login"); +} + void Courtroom::handle_wtce(QString p_wtce, int variant) { QString sfx_file = "courtroom_sounds.ini"; diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index f8adb12..9ea2839 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -106,13 +106,6 @@ void AOApplication::ms_packet_received(AOPacket *p_packet) destruct_courtroom(); destruct_lobby(); } - else if (header == "DOOM") - { - call_notice("You have been exiled from AO." - "Have a nice day."); - destruct_courtroom(); - destruct_lobby(); - } end: @@ -398,16 +391,9 @@ void AOApplication::server_packet_received(AOPacket *p_packet) } else { - if (f_music.endsWith(".wav") || - f_music.endsWith(".mp3") || - f_music.endsWith(".mp4") || - f_music.endsWith(".ogg") || - f_music.endsWith(".opus")) + if (f_contents.at(n_element) == "===MUSIC START===.mp3") { musics_time = true; - areas--; - w_courtroom->fix_last_area(); - w_courtroom->append_music(f_music); } else { @@ -493,16 +479,9 @@ void AOApplication::server_packet_received(AOPacket *p_packet) } else { - if (f_contents.at(n_element).endsWith(".wav") || - f_contents.at(n_element).endsWith(".mp3") || - f_contents.at(n_element).endsWith(".mp4") || - f_contents.at(n_element).endsWith(".ogg") || - f_contents.at(n_element).endsWith(".opus")) + if (f_contents.at(n_element) == "===MUSIC START===.mp3") { musics_time = true; - w_courtroom->fix_last_area(); - w_courtroom->append_music(f_contents.at(n_element)); - areas--; } else { @@ -538,6 +517,16 @@ void AOApplication::server_packet_received(AOPacket *p_packet) destruct_lobby(); } + else if (header == "REFMUSIC") + { + if (courtroom_constructed) + w_courtroom->reset_music_list(); + for (int n_element = 0 ; n_element < f_contents.size() ; ++n_element) + { + w_courtroom->append_music(f_contents.at(n_element)); + } + w_courtroom->list_music(); + } else if (header == "BN") { if (f_contents.size() < 1) @@ -618,6 +607,11 @@ void AOApplication::server_packet_received(AOPacket *p_packet) } } } + else if (header == "FAILEDLOGIN") + { + if (courtroom_constructed) + w_courtroom->handle_failed_login(); + } else if (header == "IL") { if (courtroom_constructed && f_contents.size() > 0) diff --git a/src/path_functions.cpp b/src/path_functions.cpp index c51cfde..92ff765 100644 --- a/src/path_functions.cpp +++ b/src/path_functions.cpp @@ -94,11 +94,28 @@ QString AOApplication::get_sounds_path(QString p_file) QString AOApplication::get_music_path(QString p_song) { - QString path = get_base_path() + "sounds/music/" + p_song; + QString mp3_check = get_base_path() + "sounds/music/" + p_song + ".mp3"; + QString opus_check = get_base_path() + "sounds/music/" + p_song + ".opus"; + if (file_exists(opus_check)) + { + #ifndef CASE_SENSITIVE_FILESYSTEM + return get_base_path() + "sounds/music/" + p_song + ".opus"; + #else + return get_case_sensitive_path(get_base_path() + "sounds/music/" + p_song + ".opus"); + #endif + } + else if (file_exists(mp3_check)) + { + #ifndef CASE_SENSITIVE_FILESYSTEM + return get_base_path() + "sounds/music/" + p_song + ".mp3"; + #else + return get_case_sensitive_path(get_base_path() + "sounds/music/" + p_song + ".mp3"); + #endif + } #ifndef CASE_SENSITIVE_FILESYSTEM - return path; + return get_base_path() + "sounds/music/" + p_song + ".wav"; #else - return get_case_sensitive_path(path); + return get_case_sensitive_path(get_base_path() + "sounds/music/" + p_song + ".wav"); #endif }