@@ -3508,23 +3508,28 @@ void Courtroom::handle_ic_speaking()
35083508
35093509struct PauseInfo
35103510{
3511- int multiplier ;
3511+ int ms ;
35123512 int digit_count;
3513+ bool valid;
35133514};
35143515
3515- // returns multiplier and number of digits to skip
3516- static PauseInfo parse_pause_multiplier (const QString &text, int start_pos)
3516+ static PauseInfo parse_pause_duration (const QString &text, int start_pos)
35173517{
3518- // matches upto 999 (and 1000) and also prevents leading zeros
3519- static QRegularExpression pause_regex (" ^([1-9]\\ d{0,2}|1000) " );
3518+ static const int max_digits = QString::number ( 10000 ). length ();
3519+ static const QRegularExpression pause_regex (QString ( " ^([1-9]\\ d{0,%1}) " ). arg (max_digits - 1 ) );
35203520 QRegularExpressionMatch match = pause_regex.match (text.mid (start_pos));
3521- if (match.hasMatch ())
3521+ if (! match.hasMatch ())
35223522 {
3523- int value = match.captured (1 ).toInt ();
3524- int length = match.capturedLength (0 );
3525- return {value, length};
3523+ return {0 , 0 , false };
35263524 }
3527- return {1 , 0 }; // default: multiplier=1, no digits to skip
3525+ bool ok = false ;
3526+ int value = match.captured (1 ).toInt (&ok);
3527+ int length = match.capturedLength (0 );
3528+ if (!ok || value < 1 || value > 10000 )
3529+ {
3530+ return {0 , 0 , false };
3531+ }
3532+ return {value, length, true };
35283533}
35293534
35303535QString Courtroom::filter_ic_text (QString p_text, bool html, int target_pos, int default_color)
@@ -3744,11 +3749,13 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, int
37443749 if (f_character == " s" || f_character == " f" || f_character == " p" ) // screenshake/flash/pause
37453750 {
37463751 skip = true ;
3747- // also skip any following digits
3748- if (f_character == " p" )
3752+ if (f_character == " p" ) // also skip any following digits
37493753 {
3750- PauseInfo info = parse_pause_multiplier (p_text, check_pos + f_char_bytes);
3751- check_pos += info.digit_count ;
3754+ PauseInfo info = parse_pause_duration (p_text, check_pos + f_char_bytes);
3755+ if (info.valid )
3756+ {
3757+ check_pos += info.digit_count ;
3758+ }
37523759 }
37533760 }
37543761
@@ -4228,7 +4235,6 @@ void Courtroom::start_chat_ticking()
42284235
42294236 tick_pos = 0 ;
42304237 blip_ticker = 0 ;
4231- pause_multiplier = 1 ;
42324238 text_crawl = Options::getInstance ().textCrawlSpeed ();
42334239 blip_rate = Options::getInstance ().blipRate ();
42344240 blank_blip = Options::getInstance ().blankBlip ();
@@ -4448,9 +4454,14 @@ void Courtroom::chat_tick()
44484454 if (f_character == " p" )
44494455 {
44504456 formatting_char = true ;
4451- PauseInfo info = parse_pause_multiplier (f_message, tick_pos);
4452- pause_multiplier = info.multiplier ;
4453- tick_pos += info.digit_count ;
4457+ PauseInfo info = parse_pause_duration (f_message, tick_pos);
4458+ if (info.valid )
4459+ {
4460+ tick_pos += info.digit_count ;
4461+ real_tick_pos += f_char_length;
4462+ chat_tick_timer->start (info.ms );
4463+ return ;
4464+ }
44544465 }
44554466 next_character_is_not_special = false ;
44564467 }
@@ -4472,11 +4483,6 @@ void Courtroom::chat_tick()
44724483
44734484 if ((msg_delay <= 0 && tick_pos < f_message.size () - 1 ) || formatting_char)
44744485 {
4475- if (f_character == " p" )
4476- {
4477- chat_tick_timer->start (pause_base_ms * pause_multiplier);
4478- }
4479- else
44804486 {
44814487 chat_tick_timer->start (0 ); // Don't bother rendering anything out as we're
44824488 // doing the SPEED. (there's latency otherwise)
0 commit comments