Skip to content

Commit dd8eee7

Browse files
Crystalwarrioroldmud0stonedDiscord
authored
Pending ghost messages (#736)
This feature allows text to be posted to the IC log as a "ghost" before it has been displayed in-game. When desync chat is enabled, it's common for the player to wait a little while before their messages are displayed. Ghosts only apply to the active player's messages, not all queued messages. They are also pinned at the end of the IC log until they are displayed. Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com> Co-authored-by: stonedDiscord <Tukz@gmx.de>
1 parent 4124a43 commit dd8eee7

6 files changed

Lines changed: 149 additions & 65 deletions

File tree

include/aoapplication.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ class AOApplication : public QApplication {
107107

108108
///////////////loading info///////////////////
109109

110-
// player number, it's hardly used but might be needed for some old servers
111-
int s_pv = 0;
110+
// client ID. Not useful, to be removed eventually
111+
int client_id = 0;
112112

113113
QString server_software = "";
114114

include/courtroom.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,11 @@ class Courtroom : public QMainWindow {
245245
enum LogMode {
246246
IO_ONLY,
247247
DISPLAY_ONLY,
248-
DISPLAY_AND_IO
248+
DISPLAY_AND_IO,
249+
QUEUED,
249250
};
250251
// Log the message contents and information such as evidence presenting etc. into the log file, the IC log, or both.
251-
void log_chatmessage(QString f_message, int f_char_id, QString f_showname = "", QString f_char = "", QString f_objection_mod = "", int f_evi_id = 0, int f_color = 0, LogMode f_log_mode=IO_ONLY);
252+
void log_chatmessage(QString f_message, int f_char_id, QString f_showname = "", QString f_char = "", QString f_objection_mod = "", int f_evi_id = 0, int f_color = 0, LogMode f_log_mode=IO_ONLY, bool sender = false);
252253

253254
// Log the message contents and information such as evidence presenting etc. into the IC logs
254255
void handle_callwords();
@@ -292,7 +293,12 @@ class Courtroom : public QMainWindow {
292293
// selected
293294
// or the user isn't already scrolled to the top
294295
void append_ic_text(QString p_text, QString p_name = "", QString action = "",
295-
int color = 0, bool selfname = false, QDateTime timestamp = QDateTime::currentDateTime());
296+
int color = 0, bool selfname = false, QDateTime timestamp = QDateTime::currentDateTime(),
297+
bool ghost = false);
298+
299+
// clear sent messages that appear on the IC log but haven't been delivered
300+
// yet to other players
301+
void pop_ic_ghost();
296302

297303
// prints who played the song to IC chat and plays said song(if found on local
298304
// filesystem) takes in a list where the first element is the song name and
@@ -485,6 +491,9 @@ class Courtroom : public QMainWindow {
485491
// amount by which we multiply the delay when we parse punctuation chars
486492
const int punctuation_modifier = 3;
487493

494+
// amount of ghost blocks
495+
int ghost_blocks = 0;
496+
488497
// Minumum and maximum number of parameters in the MS packet
489498
static const int MS_MINIMUM = 15;
490499
static const int MS_MAXIMUM = 30;

include/datatypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ enum CHAT_MESSAGE {
110110
FRAME_REALIZATION,
111111
FRAME_SFX,
112112
ADDITIVE,
113-
EFFECTS
113+
EFFECTS,
114114
};
115115

116116
enum EMOTE_MOD {

src/charselect.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ void Courtroom::char_clicked(int n_char)
180180
ao_app->send_server_packet(
181181
new AOPacket("PW", {ui_char_password->text()}));
182182
ao_app->send_server_packet(
183-
new AOPacket("CC", {QString::number(ao_app->s_pv), QString::number(n_char), get_hdid()}));
183+
new AOPacket("CC", {QString::number(ao_app->client_id),
184+
QString::number(n_char), get_hdid()}));
184185
}
185186
if (n_char == m_cid || n_char == -1) {
186187
update_character(n_char);

0 commit comments

Comments
 (0)