aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroldmud0 <oldmud0@users.noreply.github.com>2020-11-10 14:07:45 -0600
committerGitHub <noreply@github.com>2020-11-10 14:07:45 -0600
commit4eb45ef2b08095b9ecd81b62de1761ed5dac8b84 (patch)
treef37f30a92bf883ea0e87cc5192d004626a1d23c1
parentfe3b16829fc51e04e284436788db57e96bdded24 (diff)
parentc392bb3415ca8a01dbfc5129527af25ae6de9c08 (diff)
Merge pull request #305 from Crystalwarrior/bugfix/blip-accuracy
More accurate/consistent blip rate functionality + punctuation slowdown fixes
-rw-r--r--include/aoblipplayer.h3
-rw-r--r--include/courtroom.h4
-rw-r--r--src/aoblipplayer.cpp4
-rw-r--r--src/courtroom.cpp35
4 files changed, 31 insertions, 15 deletions
diff --git a/include/aoblipplayer.h b/include/aoblipplayer.h
index 4d3b5f14..a11e29db 100644
--- a/include/aoblipplayer.h
+++ b/include/aoblipplayer.h
@@ -22,12 +22,9 @@ public:
int m_cycle = 0;
private:
- const int max_blip_ms = 60;
-
QWidget *m_parent;
AOApplication *ao_app;
qreal m_volume;
- QElapsedTimer delay;
void set_volume_internal(qreal p_volume);
diff --git a/include/courtroom.h b/include/courtroom.h
index df13c696..f05b15ac 100644
--- a/include/courtroom.h
+++ b/include/courtroom.h
@@ -275,7 +275,7 @@ private:
bool message_is_centered = false;
int current_display_speed = 3;
- int message_display_speed[7] = {0, 10, 25, 40, 50, 70, 90};
+ int message_display_speed[7] = {5, 10, 25, 40, 50, 70, 90};
// The character ID of the character this user wants to appear alongside with.
int other_charid = -1;
@@ -314,7 +314,7 @@ private:
int real_tick_pos = 0;
// used to determine how often blips sound
int blip_ticker = 0;
- int blip_rate = 1;
+ int blip_rate = 2;
int rainbow_counter = 0;
bool rainbow_appended = false;
bool blank_blip = false;
diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp
index 5b4d625c..6607d463 100644
--- a/src/aoblipplayer.cpp
+++ b/src/aoblipplayer.cpp
@@ -26,10 +26,6 @@ void AOBlipPlayer::set_blips(QString p_sfx)
void AOBlipPlayer::blip_tick()
{
- if (delay.isValid() && delay.elapsed() < max_blip_ms)
- return;
-
- delay.start();
int f_cycle = m_cycle++;
if (m_cycle == 5)
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index 96e2a533..ec4e47b4 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -2990,17 +2990,40 @@ void Courtroom::chat_tick()
ui_vp_message->ensureCursorVisible();
- // Blip player and real tick pos ticker
- if (!formatting_char && (f_character != ' ' || blank_blip)) {
- if (blip_ticker % blip_rate == 0) {
+ // We blip every "blip rate" letters.
+ // Here's an example with blank_blip being false and blip_rate being 2:
+ // I am you
+ // ! ! ! !
+ // where ! is the blip sound
+ int b_rate = blip_rate;
+ // Earrape prevention without using timers, this method is more consistent.
+ if (msg_delay != 0 && msg_delay <= 25) {
+ // The default blip speed is 40ms, and if current msg_delay is 25ms,
+ // the formula will result in the blip rate of:
+ // 40/25 = 1.6 = 2
+ // And if it's faster than that:
+ // 40/10 = 4
+ b_rate = qMax(b_rate, qRound(static_cast<float>(message_display_speed[3])/msg_delay));
+ }
+ if (blip_ticker % b_rate == 0) {
+ // ignoring white space unless blank_blip is enabled.
+ if (!formatting_char && (f_character != ' ' || blank_blip)) {
blip_player->blip_tick();
+ ++blip_ticker;
}
+ }
+ else
+ {
+ // Don't fully ignore whitespace still, keep ticking until
+ // we reached the need to play a blip sound - we also just
+ // need to wait for a letter to play it on.
++blip_ticker;
}
- // Punctuation delayer
- if (punctuation_chars.contains(f_character)) {
- msg_delay *= punctuation_modifier;
+ // Punctuation delayer, only kicks in on speed ticks less than }}
+ if (current_display_speed > 1 && punctuation_chars.contains(f_character)) {
+ // Making the user have to wait any longer than 150ms per letter is downright unreasonable
+ msg_delay = qMin(150, msg_delay * punctuation_modifier);
}
// If this color is talking