diff options
| author | sD <stoned@derpymail.org> | 2020-03-15 13:12:52 +0100 |
|---|---|---|
| committer | sD <stoned@derpymail.org> | 2020-03-15 13:12:52 +0100 |
| commit | beb469cd8051be445dcc9d7c7b7f10d23cede5c4 (patch) | |
| tree | bba5a3d9c95f6ef70e720c41fd5a5a0dbc7de412 /src/packet_distribution.cpp | |
| parent | b668bb227652f0b19f0d0b7251c2afa2f36473c5 (diff) | |
| parent | 4b0110d96cb3ad383d8ca517faa3c5235bed21df (diff) | |
Merge branch 'master' into pr/104
Diffstat (limited to 'src/packet_distribution.cpp')
| -rw-r--r-- | src/packet_distribution.cpp | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 5538c15e..c3812788 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -151,6 +151,16 @@ void AOApplication::ms_packet_received(AOPacket *p_packet) delete p_packet; } +bool AOApplication::is_music_track(QString trackname) +{ + return (trackname.startsWith("==") || + trackname.endsWith(".wav") || + trackname.endsWith(".mp3") || + trackname.endsWith(".mp4") || + trackname.endsWith(".ogg") || + trackname.endsWith(".opus")); +} + void AOApplication::server_packet_received(AOPacket *p_packet) { p_packet->net_decode(); @@ -411,7 +421,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) if (!courtroom_constructed) goto end; - bool musics_time = false; + bool musiclist_start = false; int areas = 0; for (int n_element = 0 ; n_element < f_contents.size() ; n_element += 2) @@ -428,19 +438,15 @@ void AOApplication::server_packet_received(AOPacket *p_packet) w_lobby->set_loading_text(tr("Loading music:\n%1/%2").arg(QString::number(loaded_music)).arg(QString::number(music_list_size))); - if (musics_time) + if (musiclist_start) { w_courtroom->append_music(f_music); } else { - if (f_music.endsWith(".wav") || - f_music.endsWith(".mp3") || - f_music.endsWith(".mp4") || - f_music.endsWith(".ogg") || - f_music.endsWith(".opus")) + if (is_music_track(f_music)) { - musics_time = true; + musiclist_start = true; areas--; //w_courtroom->fix_last_area(); w_courtroom->append_music(f_music); @@ -514,22 +520,17 @@ void AOApplication::server_packet_received(AOPacket *p_packet) if (!courtroom_constructed) goto end; - bool musics_time = false; + bool musiclist_start = false; area_count = 0; for (int n_element = 0 ; n_element < f_contents.size() ; ++n_element) { - if (!musics_time && (f_contents.at(n_element).startsWith("==") || - 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 (!musiclist_start && is_music_track(f_contents.at(n_element))) { - musics_time = true; + musiclist_start = true; continue; } - AOPacketLoadMusicThreading *music_load = new AOPacketLoadMusicThreading(this, f_contents.at(n_element), musics_time); + AOPacketLoadMusicThreading *music_load = new AOPacketLoadMusicThreading(this, f_contents.at(n_element), musiclist_start); QThreadPool::globalInstance()->start(music_load); ++loaded_music; int total_loading_size = char_list_size * 2 + evidence_list_size + music_list_size; @@ -606,11 +607,11 @@ void AOApplication::server_packet_received(AOPacket *p_packet) { 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(); + 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") { |
