aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoriamgoofball <iamgoofball@gmail.com>2019-01-19 21:01:19 -0800
committeriamgoofball <iamgoofball@gmail.com>2019-01-19 21:01:19 -0800
commit10436992148e2342e6bd563d1acfb684f225aa30 (patch)
tree466e25514efc1b53bf22b3c6ed3d6ab58f391fd9 /src
parentc44832a707f655191e4337e3b3fc567ff02636eb (diff)
Suffix-independent Music, Mod Music List, looping bugfixes, easter eggs, etc.
Diffstat (limited to 'src')
-rw-r--r--src/aomusicplayer.cpp14
-rw-r--r--src/courtroom.cpp23
-rw-r--r--src/packet_distribution.cpp40
-rw-r--r--src/path_functions.cpp23
4 files changed, 67 insertions, 33 deletions
diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp
index a52603c7..2a35f0bb 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 da1b090f..a097444f 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 f8adb122..9ea28395 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 c51cfde3..92ff765b 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
}