Attempt a theoretically safer method of tracking last displayed message

This commit is contained in:
Crystalwarrior 2021-01-18 17:56:21 +03:00
parent 96fcb75c4c
commit ea94644cf5
2 changed files with 2 additions and 10 deletions

View File

@ -349,7 +349,6 @@ private:
QVector<QString> arup_locks; QVector<QString> arup_locks;
QVector<chatlogpiece> ic_chatlog_history; QVector<chatlogpiece> ic_chatlog_history;
int ic_chatlog_current = -1;
QQueue<QStringList> chatmessage_queue; QQueue<QStringList> chatmessage_queue;

View File

@ -2139,7 +2139,6 @@ void Courtroom::display_log_chatmessage(QString f_message, int f_char_id, QStrin
break; break;
} }
append_ic_text(shout_message, f_displayname, tr("shouts")); append_ic_text(shout_message, f_displayname, tr("shouts"));
ic_chatlog_current += 1;
} }
// Obtain evidence ID we're trying to work with // Obtain evidence ID we're trying to work with
@ -2150,16 +2149,14 @@ void Courtroom::display_log_chatmessage(QString f_message, int f_char_id, QStrin
QString f_evi_name = local_evidence_list.at(f_evi_id - 1).name; QString f_evi_name = local_evidence_list.at(f_evi_id - 1).name;
// Append the message to the IC chatlogs in client // Append the message to the IC chatlogs in client
append_ic_text(f_evi_name, f_displayname, tr("has presented evidence")); append_ic_text(f_evi_name, f_displayname, tr("has presented evidence"));
ic_chatlog_current += 1;
} }
} }
int current = ic_chatlog_history.size() - chatmessage_queue.size() - 1;
// If the chat message isn't a blankpost, or the chatlog history is empty, or its last message isn't a blankpost // If the chat message isn't a blankpost, or the chatlog history is empty, or its last message isn't a blankpost
if (!f_message.isEmpty() || ic_chatlog_current == -1 || ic_chatlog_history[ic_chatlog_current].get_showname() != f_showname) { if (!f_message.isEmpty() || current <= -1 || ic_chatlog_history[current].get_showname() != f_showname) {
// Append the message to the IC chatlogs in client // Append the message to the IC chatlogs in client
append_ic_text(f_message, f_displayname, "", append_ic_text(f_message, f_displayname, "",
f_color); f_color);
ic_chatlog_current += 1;
} }
} }
@ -3679,12 +3676,10 @@ void Courtroom::handle_song(QStringList *p_contents)
if (f_song == "~stop.mp3") { if (f_song == "~stop.mp3") {
log_ic_text(str_char, str_show, "", tr("has stopped the music")); log_ic_text(str_char, str_show, "", tr("has stopped the music"));
append_ic_text("", str_show, tr("has stopped the music")); append_ic_text("", str_show, tr("has stopped the music"));
ic_chatlog_current += 1;
} }
else { else {
log_ic_text(str_char, str_show, f_song, tr("has played a song")); log_ic_text(str_char, str_show, f_song, tr("has played a song"));
append_ic_text(f_song_clear, str_show, tr("has played a song")); append_ic_text(f_song_clear, str_show, tr("has played a song"));
ic_chatlog_current += 1;
} }
music_player->play(f_song, channel, looping, effect_flags); music_player->play(f_song, channel, looping, effect_flags);
if (f_song == "~stop.mp3") if (f_song == "~stop.mp3")
@ -5246,14 +5241,12 @@ void Courtroom::on_showname_enable_clicked()
void Courtroom::regenerate_ic_chatlog() void Courtroom::regenerate_ic_chatlog()
{ {
ui_ic_chatlog->clear(); ui_ic_chatlog->clear();
ic_chatlog_current = -1;
foreach (chatlogpiece item, ic_chatlog_history) { foreach (chatlogpiece item, ic_chatlog_history) {
append_ic_text(item.get_message(), append_ic_text(item.get_message(),
ui_showname_enable->isChecked() ? item.get_showname() ui_showname_enable->isChecked() ? item.get_showname()
: item.get_name(), : item.get_name(),
item.get_action(), item.get_chat_color(), item.get_action(), item.get_chat_color(),
item.get_datetime().toLocalTime()); item.get_datetime().toLocalTime());
ic_chatlog_current += 1;
} }
} }