diff --git a/aoapplication.h b/aoapplication.h index dc8071e..ecb33fb 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -69,8 +69,7 @@ public: bool improved_loading_enabled = false; bool desk_mod_enabled = false; bool evidence_enabled = false; - bool shownames_enabled = false; - bool charpairs_enabled = false; + bool cccc_ic_support_enabled = false; bool arup_enabled = false; bool modcall_reason_enabled = false; diff --git a/courtroom.cpp b/courtroom.cpp index 347e889..0a9baef 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -208,6 +208,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_pre_non_interrupt = new QCheckBox(this); ui_pre_non_interrupt->setText("No Intrpt"); + ui_pre_non_interrupt->hide(); ui_custom_objection = new AOButton(this, ao_app); ui_realization = new AOButton(this, ao_app); @@ -470,7 +471,7 @@ void Courtroom::set_widgets() ui_pair_offset_spinbox->hide(); set_size_and_pos(ui_pair_button, "pair_button"); ui_pair_button->set_image("pair_button.png"); - if (ao_app->charpairs_enabled) + if (ao_app->cccc_ic_support_enabled) { ui_pair_button->setEnabled(true); ui_pair_button->show(); @@ -583,7 +584,6 @@ void Courtroom::set_widgets() ui_pre->setText("Pre"); set_size_and_pos(ui_pre_non_interrupt, "pre_no_interrupt"); - ui_pre_non_interrupt->setText("No Intrpt"); set_size_and_pos(ui_flip, "flip"); @@ -864,6 +864,11 @@ void Courtroom::enter_courtroom(int p_cid) else ui_flip->hide(); + if (ao_app->cccc_ic_support_enabled) + ui_pre_non_interrupt->show(); + else + ui_pre_non_interrupt->hide(); + list_music(); list_areas(); @@ -879,7 +884,7 @@ void Courtroom::enter_courtroom(int p_cid) //ui_server_chatlog->setHtml(ui_server_chatlog->toHtml()); ui_char_select_background->hide(); - if (ao_app->shownames_enabled) + if (ao_app->cccc_ic_support_enabled) { ui_ic_chat_name->setPlaceholderText(ao_app->get_showname(f_char)); ui_ic_chat_name->setEnabled(true); @@ -1159,39 +1164,41 @@ void Courtroom::on_chat_return_pressed() packet_contents.append(f_text_color); - if (!ui_ic_chat_name->text().isEmpty()) + // If the server we're on supports CCCC stuff, we should use it! + if (ao_app->cccc_ic_support_enabled) { - packet_contents.append(ui_ic_chat_name->text()); - } - - // If there is someone this user would like to appear with. - // And said someone is not ourselves! - if (other_charid > -1 && other_charid != m_cid) - { - // First, we'll add a filler in case we haven't set an IC showname. - if (ui_ic_chat_name->text().isEmpty()) + // If there is a showname entered, use that -- else, just send an empty packet-part. + if (!ui_ic_chat_name->text().isEmpty()) + { + packet_contents.append(ui_ic_chat_name->text()); + } + else { packet_contents.append(""); } - packet_contents.append(QString::number(other_charid)); - packet_contents.append(QString::number(offset_with_pair)); - } - - if (ui_pre_non_interrupt->isChecked()) - { - if (ui_ic_chat_name->text().isEmpty()) + // Similarly, we send over whom we're paired with, unless we have chosen ourselves. + // Or a charid of -1 or lower, through some means. + if (other_charid > -1 && other_charid != m_cid) { - packet_contents.append(""); + packet_contents.append(QString::number(other_charid)); + packet_contents.append(QString::number(offset_with_pair)); } - - if (!(other_charid > -1 && other_charid != m_cid)) + else { packet_contents.append("-1"); packet_contents.append("0"); } - packet_contents.append("1"); + // Finally, we send over if we want our pres to not interrupt. + if (ui_pre_non_interrupt->isChecked()) + { + packet_contents.append("1"); + } + else + { + packet_contents.append("0"); + } } ao_app->send_server_packet(new AOPacket("MS", packet_contents)); @@ -1205,23 +1212,22 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) if (p_contents->size() < 15) return; - //qDebug() << "A message was got. Its contents:"; for (int n_string = 0 ; n_string < chatmessage_size ; ++n_string) { //m_chatmessage[n_string] = p_contents->at(n_string); // Note that we have added stuff that vanilla clients and servers simply won't send. // So now, we have to check if the thing we want even exists amongst the packet's content. + // We also have to check if the server even supports CCCC's IC features, or if it's just japing us. // Also, don't forget! A size 15 message will have indices from 0 to 14. - if (n_string < p_contents->size()) + if (n_string < p_contents->size() && + (n_string < 15 || ao_app->cccc_ic_support_enabled)) { m_chatmessage[n_string] = p_contents->at(n_string); - //qDebug() << "- " << n_string << ": " << p_contents->at(n_string); } else { m_chatmessage[n_string] = ""; - //qDebug() << "- " << n_string << ": Nothing?"; } } @@ -2771,8 +2777,7 @@ void Courtroom::on_ooc_return_pressed() else if (ooc_message.startsWith("/enable_blocks")) { append_server_chatmessage("CLIENT", "You have forcefully enabled features that the server may not support. You may not be able to talk IC, or worse, because of this.", "1"); - ao_app->shownames_enabled = true; - ao_app->charpairs_enabled = true; + ao_app->cccc_ic_support_enabled = true; ao_app->arup_enabled = true; ao_app->modcall_reason_enabled = true; on_reload_theme_clicked(); diff --git a/packet_distribution.cpp b/packet_distribution.cpp index 8d23fe5..a0d3cca 100644 --- a/packet_distribution.cpp +++ b/packet_distribution.cpp @@ -147,8 +147,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) improved_loading_enabled = false; desk_mod_enabled = false; evidence_enabled = false; - shownames_enabled = false; - charpairs_enabled = false; + cccc_ic_support_enabled = false; arup_enabled = false; modcall_reason_enabled = false; @@ -201,10 +200,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet) desk_mod_enabled = true; if (f_packet.contains("evidence",Qt::CaseInsensitive)) evidence_enabled = true; - if (f_packet.contains("cc_customshownames",Qt::CaseInsensitive)) - shownames_enabled = true; - if (f_packet.contains("characterpairs",Qt::CaseInsensitive)) - charpairs_enabled = true; + if (f_packet.contains("cccc_ic_support",Qt::CaseInsensitive)) + cccc_ic_support_enabled = true; if (f_packet.contains("arup",Qt::CaseInsensitive)) arup_enabled = true; if (f_packet.contains("modcall_reason",Qt::CaseInsensitive)) diff --git a/server/aoprotocol.py b/server/aoprotocol.py index 1c6146e..18f688b 100644 --- a/server/aoprotocol.py +++ b/server/aoprotocol.py @@ -213,7 +213,7 @@ class AOProtocol(asyncio.Protocol): self.client.is_ao2 = True - self.client.send_command('FL', 'yellowtext', 'customobjections', 'flipping', 'fastloading', 'noencryption', 'deskmod', 'evidence', 'modcall_reason', 'cc_customshownames', 'characterpairs', 'arup') + self.client.send_command('FL', 'yellowtext', 'customobjections', 'flipping', 'fastloading', 'noencryption', 'deskmod', 'evidence', 'modcall_reason', 'cccc_ic_support', 'arup') def net_cmd_ch(self, _): """ Periodically checks the connection. @@ -348,7 +348,7 @@ class AOProtocol(asyncio.Protocol): showname = "" charid_pair = -1 offset_pair = 0 - nonint_pre = '' + nonint_pre = 0 elif self.validate_net_cmd(args, self.ArgType.STR, self.ArgType.STR_OR_EMPTY, self.ArgType.STR, self.ArgType.STR, self.ArgType.STR, self.ArgType.STR, self.ArgType.STR, self.ArgType.INT, @@ -358,7 +358,7 @@ class AOProtocol(asyncio.Protocol): msg_type, pre, folder, anim, text, pos, sfx, anim_type, cid, sfx_delay, button, evidence, flip, ding, color, showname = args charid_pair = -1 offset_pair = 0 - nonint_pre = '' + nonint_pre = 0 if len(showname) > 0 and not self.client.area.showname_changes_allowed: self.client.send_host_message("Showname changes are forbidden in this area!") return @@ -369,7 +369,7 @@ class AOProtocol(asyncio.Protocol): self.ArgType.INT, self.ArgType.INT, self.ArgType.INT, self.ArgType.STR_OR_EMPTY, self.ArgType.INT, self.ArgType.INT): # 1.3.5 validation monstrosity. msg_type, pre, folder, anim, text, pos, sfx, anim_type, cid, sfx_delay, button, evidence, flip, ding, color, showname, charid_pair, offset_pair = args - nonint_pre = '' + nonint_pre = 0 if len(showname) > 0 and not self.client.area.showname_changes_allowed: self.client.send_host_message("Showname changes are forbidden in this area!") return @@ -442,7 +442,7 @@ class AOProtocol(asyncio.Protocol): if len(showname) > 15: self.client.send_host_message("Your IC showname is way too long!") return - if nonint_pre != '': + if nonint_pre == 1: if button in (1, 2, 3, 4, 23): if anim_type == 1 or anim_type == 2: anim_type = 0