aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/aosfxplayer.cpp27
-rw-r--r--src/courtroom.cpp8
-rw-r--r--src/path_functions.cpp50
3 files changed, 31 insertions, 54 deletions
diff --git a/src/aosfxplayer.cpp b/src/aosfxplayer.cpp
index 1a0e2d2..13de04f 100644
--- a/src/aosfxplayer.cpp
+++ b/src/aosfxplayer.cpp
@@ -24,17 +24,17 @@ void AOSfxPlayer::loop_clear()
set_volume_internal(m_volume);
}
-void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout,
- int channel)
+void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout)
{
- if (channel == -1) {
- if (BASS_ChannelIsActive(m_stream_list[channel]) == BASS_ACTIVE_PLAYING)
- m_channel = (m_channel + 1) % m_channelmax;
- channel = m_channel;
+ for (int i = 0; i < m_channelmax; ++i) {
+ if (BASS_ChannelIsActive(m_stream_list[i]) == BASS_ACTIVE_PLAYING)
+ m_channel = (i + 1) % m_channelmax;
+ else {
+ m_channel = i;
+ break;
+ }
}
- BASS_ChannelStop(m_stream_list[channel]);
-
QString misc_path = "";
QString char_path = "";
QString theme_path = "";
@@ -45,7 +45,8 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout,
shout + "/" + p_sfx);
theme_path = ao_app->get_sfx_suffix(ao_app->get_theme_path(p_sfx));
if (!file_exists(theme_path))
- theme_path = ao_app->get_sfx_suffix(ao_app->get_default_theme_path(p_sfx));
+ theme_path =
+ ao_app->get_sfx_suffix(ao_app->get_default_theme_path(p_sfx));
}
if (p_char != "")
char_path =
@@ -57,17 +58,17 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout,
f_path = char_path;
else if (file_exists(misc_path))
f_path = misc_path;
- else if (shout != "" && file_exists(theme_path)) //only check here for shouts
+ else if (shout != "" && file_exists(theme_path)) // only check here for shouts
f_path = theme_path;
else
f_path = sound_path;
if (f_path.endsWith(".opus"))
- m_stream_list[channel] = BASS_OPUS_StreamCreateFile(
+ m_stream_list[m_channel] = BASS_OPUS_StreamCreateFile(
FALSE, f_path.utf16(), 0, 0,
BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE);
else
- m_stream_list[channel] = BASS_StreamCreateFile(
+ m_stream_list[m_channel] = BASS_StreamCreateFile(
FALSE, f_path.utf16(), 0, 0,
BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE);
@@ -81,7 +82,7 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout,
}
BASS_ChannelPlay(m_stream_list[m_channel], false);
- BASS_ChannelSetSync(m_stream_list[channel], BASS_SYNC_DEV_FAIL, 0,
+ BASS_ChannelSetSync(m_stream_list[m_channel], BASS_SYNC_DEV_FAIL, 0,
ao_app->BASSreset, 0);
}
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index baa6631..e39c3d9 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -1333,6 +1333,9 @@ void Courtroom::update_character(int p_cid)
ui_char_select_background->hide();
ui_ic_chat_message->setEnabled(m_cid != -1);
ui_ic_chat_message->setFocus();
+ // have to call these to make sure sfx and blips don't get accidentally muted forever when we change characters
+ sfx_player->set_volume(ui_sfx_slider->value());
+ blip_player->set_volume(ui_blip_slider->value());
}
void Courtroom::enter_courtroom()
@@ -1807,6 +1810,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
if (p_contents->size() < MS_MINIMUM)
return;
+ int prev_char_id = m_chatmessage[CHAR_ID].toInt();
for (int n_string = 0; n_string < MS_MAXIMUM; ++n_string) {
// Note that we have added stuff that vanilla clients and servers simply
// won't send. So now, we have to check if the thing we want even exists
@@ -1875,8 +1879,8 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
m_chatmessage[MESSAGE] = ""; // Turn it into true blankpost
}
- if (!m_chatmessage[MESSAGE].isEmpty() || ic_chatlog_history.isEmpty() ||
- ic_chatlog_history.last().get_message() != "") {
+ if (prev_char_id != f_char_id || !m_chatmessage[MESSAGE].isEmpty() ||
+ ic_chatlog_history.isEmpty() || ic_chatlog_history.last().get_message() != "") {
log_ic_text(f_charname, f_displayname, m_chatmessage[MESSAGE], "",
m_chatmessage[TEXT_COLOR].toInt());
append_ic_text(m_chatmessage[MESSAGE], f_displayname, "",
diff --git a/src/path_functions.cpp b/src/path_functions.cpp
index 10c8ae5..b1d7976 100644
--- a/src/path_functions.cpp
+++ b/src/path_functions.cpp
@@ -44,61 +44,37 @@ QString AOApplication::get_data_path() { return get_base_path() + "data/"; }
QString AOApplication::get_default_theme_path(QString p_file)
{
QString path = get_base_path() + "themes/default/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
return get_case_sensitive_path(path);
-#endif
}
QString AOApplication::get_custom_theme_path(QString p_theme, QString p_file)
{
QString path = get_base_path() + "themes/" + p_theme + "/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
return get_case_sensitive_path(path);
-#endif
}
QString AOApplication::get_theme_path(QString p_file)
{
QString path = get_base_path() + "themes/" + current_theme + "/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
return get_case_sensitive_path(path);
-#endif
}
QString AOApplication::get_character_path(QString p_char, QString p_file)
{
QString path = get_base_path() + "characters/" + p_char + "/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
return get_case_sensitive_path(path);
-#endif
}
QString AOApplication::get_sounds_path(QString p_file)
{
QString path = get_base_path() + "sounds/general/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
return get_case_sensitive_path(path);
-#endif
}
QString AOApplication::get_music_path(QString p_song)
{
QString path = get_base_path() + "sounds/music/" + p_song;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
return get_case_sensitive_path(path);
-#endif
}
QString AOApplication::get_background_path(QString p_file)
@@ -106,11 +82,7 @@ QString AOApplication::get_background_path(QString p_file)
QString path = get_base_path() + "background/" +
w_courtroom->get_current_background() + "/" + p_file;
if (courtroom_constructed) {
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
return get_case_sensitive_path(path);
-#endif
}
return get_default_background_path(p_file);
}
@@ -118,33 +90,30 @@ QString AOApplication::get_background_path(QString p_file)
QString AOApplication::get_default_background_path(QString p_file)
{
QString path = get_base_path() + "background/default/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
return get_case_sensitive_path(path);
-#endif
}
QString AOApplication::get_evidence_path(QString p_file)
{
QString path = get_base_path() + "evidence/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
return get_case_sensitive_path(path);
-#endif
}
QString AOApplication::get_case_sensitive_path(QString p_file)
{
+ QFileInfo file(p_file);
+ QString file_basename = file.fileName();
+
+ // no path traversal above base folder
+ if (!(file.absolutePath().startsWith(get_base_path())))
+ return get_base_path() + file_basename;
+
+ #ifdef CASE_SENSITIVE_FILESYSTEM
// first, check to see if it's actually there (also serves as base case for
// recursion)
if (exists(p_file))
return p_file;
- QFileInfo file(p_file);
-
- QString file_basename = file.fileName();
QString file_parent_dir = get_case_sensitive_path(file.absolutePath());
// second, does it exist in the new parent dir?
@@ -163,4 +132,7 @@ QString AOApplication::get_case_sensitive_path(QString p_file)
// if nothing is found, let the caller handle the missing file
return file_parent_dir + "/" + file_basename;
+#else
+ return p_file;
+#endif
}