Suffix-independent Music, Mod Music List, looping bugfixes, easter eggs, etc.

This commit is contained in:
iamgoofball 2019-01-19 21:01:19 -08:00
parent c44832a707
commit 1043699214
7 changed files with 71 additions and 40 deletions

Binary file not shown.

View File

@ -21,6 +21,7 @@ public:
void kill_loop();
QString get_path();
bool enable_looping = true;
private:
QWidget *m_parent;

View File

@ -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)

View File

@ -29,6 +29,8 @@ void AOMusicPlayer::play(QString p_song)
BASS_ChannelSetDevice(m_stream, BASS_GetDevice());
BASS_ChannelPlay(m_stream, false);
music_loop_timer->stop();
if(enable_looping)
{
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)
@ -36,6 +38,8 @@ void AOMusicPlayer::play(QString p_song)
qDebug() << "Will loop in " << time << " seconds.";
music_loop_timer->start(time*1000);
}
}
}

View File

@ -2760,10 +2760,23 @@ void Courtroom::handle_song(QStringList *p_contents)
QString str_show = char_list.at(n_char).name;
if (p_contents->length() > 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";

View File

@ -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)

View File

@ -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 path;
return get_base_path() + "sounds/music/" + p_song + ".opus";
#else
return get_case_sensitive_path(path);
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 get_base_path() + "sounds/music/" + p_song + ".wav";
#else
return get_case_sensitive_path(get_base_path() + "sounds/music/" + p_song + ".wav");
#endif
}