From c2fd3796a97ee8d87544ec26df7d6797acfebd80 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 11 Sep 2019 00:49:30 +0300 Subject: [PATCH 1/2] Add clear_music and clear_areas Comment out the index as it can be potentially confusing alongside "true" area numbers Add "FM" to Packet Received that would reload the areas and music list TODO: Test this with arup systems --- include/courtroom.h | 2 ++ src/courtroom.cpp | 6 +++--- src/packet_distribution.cpp | 42 +++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index f0b6996..baefbfa 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -64,6 +64,8 @@ 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 clear_music(){music_list.clear();} + void clear_areas(){area_list.clear();} void fix_last_area() { diff --git a/src/courtroom.cpp b/src/courtroom.cpp index a171416..c6a8749 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1000,9 +1000,9 @@ void Courtroom::list_areas() for (int n_area = 0 ; n_area < area_list.size() ; ++n_area) { QString i_area = ""; - i_area.append("["); - i_area.append(QString::number(n_area)); - i_area.append("] "); +// i_area.append("["); +// i_area.append(QString::number(n_area)); +// i_area.append("] "); i_area.append(area_list.at(n_area)); diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 40015fd..cfd6d8c 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -525,6 +525,48 @@ void AOApplication::server_packet_received(AOPacket *p_packet) send_server_packet(new AOPacket("RD#%")); } + else if (header == "FM") + { + if (!courtroom_constructed) + goto end; + + w_courtroom->clear_music(); + w_courtroom->clear_areas(); + + bool musics_time = false; + int areas = 0; + + for (int n_element = 0 ; n_element < f_contents.size() ; ++n_element) + { + if (musics_time) + { + w_courtroom->append_music(f_contents.at(n_element)); + } + 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")) + { + musics_time = true; + w_courtroom->fix_last_area(); + w_courtroom->append_music(f_contents.at(n_element)); + areas--; +// qDebug() << "wtf!!" << f_contents.at(n_element); + } + else + { + w_courtroom->append_area(f_contents.at(n_element)); + areas++; + } + } + } + + w_courtroom->list_music(); + w_courtroom->list_areas(); + } else if (header == "DONE") { if (!courtroom_constructed) From dd2daf55f3d987fddb47a5afd269eaf00a674b8d Mon Sep 17 00:00:00 2001 From: sD Date: Sun, 15 Mar 2020 13:20:33 +0100 Subject: [PATCH 2/2] it's basically the same packet minus requesting the next list --- include/courtroom.h | 1 - src/packet_distribution.cpp | 51 +++++-------------------------------- 2 files changed, 6 insertions(+), 46 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index ec0fa5c..74374c9 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -79,7 +79,6 @@ public: void append_area(QString f_area){area_list.append(f_area);} void clear_music(){music_list.clear();} void clear_areas(){area_list.clear();} - void fix_last_area() void handle_failed_login(); QString threading_sfx = ""; QString threading_shake = ""; diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index c381278..b14cd57 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -515,11 +515,14 @@ void AOApplication::server_packet_received(AOPacket *p_packet) send_server_packet(new AOPacket("RM#%")); } - else if (header == "SM") + else if (header == "SM" || header == "FM") { if (!courtroom_constructed) goto end; + w_courtroom->clear_music(); + w_courtroom->clear_areas(); + bool musiclist_start = false; area_count = 0; @@ -543,50 +546,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet) } } QThreadPool::globalInstance()->waitForDone(); - - send_server_packet(new AOPacket("RD#%")); - } - else if (header == "FM") - { - if (!courtroom_constructed) - goto end; - - w_courtroom->clear_music(); - w_courtroom->clear_areas(); - - bool musics_time = false; - int areas = 0; - - for (int n_element = 0 ; n_element < f_contents.size() ; ++n_element) - { - if (musics_time) - { - w_courtroom->append_music(f_contents.at(n_element)); - } - 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")) - { - musics_time = true; - w_courtroom->fix_last_area(); - w_courtroom->append_music(f_contents.at(n_element)); - areas--; -// qDebug() << "wtf!!" << f_contents.at(n_element); - } - else - { - w_courtroom->append_area(f_contents.at(n_element)); - areas++; - } - } - } - - w_courtroom->list_music(); - w_courtroom->list_areas(); + if (header == "SM") + send_server_packet(new AOPacket("RD#%")); } else if (header == "DONE") {