@@ -3510,10 +3510,9 @@ struct PauseInfo
35103510{
35113511 int ms;
35123512 int digit_count;
3513- bool valid;
35143513};
35153514
3516- static PauseInfo parse_pause_duration (const QString &text, int start_pos)
3515+ static std::optional< PauseInfo> parse_pause_duration (const QString &text, int start_pos)
35173516{
35183517 int pos = start_pos;
35193518 while (pos < text.length () && text[pos].isDigit ())
@@ -3523,12 +3522,12 @@ static PauseInfo parse_pause_duration(const QString &text, int start_pos)
35233522
35243523 if (pos == start_pos)
35253524 {
3526- return {1000 , 0 , true };
3525+ return PauseInfo {1000 , 0 };
35273526 }
35283527
35293528 bool ok;
35303529 int value = qMin (10000 , text.mid (start_pos, pos - start_pos).toInt (&ok));
3531- return ok ? PauseInfo{ value, pos - start_pos, true } : PauseInfo{ 0 , 0 , false } ;
3530+ return ok ? std::optional< PauseInfo>{PauseInfo{ value, pos - start_pos}} : std:: nullopt ;
35323531}
35333532
35343533QString Courtroom::filter_ic_text (QString p_text, bool html, int target_pos, int default_color)
@@ -3750,10 +3749,9 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, int
37503749 skip = true ;
37513750 if (f_character == " p" ) // also skip any following digits
37523751 {
3753- PauseInfo info = parse_pause_duration (p_text, check_pos + f_char_bytes);
3754- if (info.valid )
3752+ if (auto info = parse_pause_duration (p_text, check_pos + f_char_bytes))
37553753 {
3756- check_pos += info. digit_count ;
3754+ check_pos += info-> digit_count ;
37573755 }
37583756 }
37593757 }
@@ -4453,12 +4451,11 @@ void Courtroom::chat_tick()
44534451 if (f_character == " p" )
44544452 {
44554453 formatting_char = true ;
4456- PauseInfo info = parse_pause_duration (f_message, tick_pos);
4457- if (info.valid )
4454+ if (auto info = parse_pause_duration (f_message, tick_pos))
44584455 {
4459- tick_pos += info. digit_count ;
4456+ tick_pos += info-> digit_count ;
44604457 real_tick_pos += f_char_length;
4461- chat_tick_timer->start (info. ms );
4458+ chat_tick_timer->start (info-> ms );
44624459 return ;
44634460 }
44644461 }
0 commit comments