From 3b8bc386d316b6e177c814920f21f5ab5d798ee6 Mon Sep 17 00:00:00 2001 From: Osmium Sorcerer Date: Sun, 22 Mar 2026 17:30:03 +0000 Subject: Support passworded characters in character list This obscure feature has been present for years, from sending passwords to the server to showing `char_passworded` image over character icons. Servers could already exploit clients sending `PW` with a password every time they select a character to implement passworded characters. The clients had no way of knowing which ones were passworded, however, and couldn't filter them despite "Passworded" checkbox being here all along. The approach used by this commit is a hack. During loading, server sends SC which is a list of characters, each one having name, description, and evidence. In practice, only names were used. Descriptions were stored in memory but unused, and evidence was ignored altogether. By adding a magic value "P" in this "character evidence" field, server can mark passworded characters without breaking Vanilla compatibility. --- src/charselect.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/charselect.cpp') diff --git a/src/charselect.cpp b/src/charselect.cpp index 040bfd0..2443393 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -62,8 +62,8 @@ void Courtroom::construct_char_select() connect(ui_spectator, &AOButton::clicked, this, &Courtroom::on_spectator_clicked); connect(ui_char_search, &QLineEdit::textEdited, this, &Courtroom::on_char_search_changed); - connect(ui_char_passworded, &QCheckBox::stateChanged, this, &Courtroom::on_char_passworded_clicked); - connect(ui_char_taken, &QCheckBox::stateChanged, this, &Courtroom::on_char_taken_clicked); + connect(ui_char_passworded, &QCheckBox::checkStateChanged, this, &Courtroom::on_char_passworded_clicked); + connect(ui_char_taken, &QCheckBox::checkStateChanged, this, &Courtroom::on_char_taken_clicked); } void Courtroom::set_char_select() @@ -300,6 +300,7 @@ void Courtroom::character_loading_finished() char_button->setContextMenuPolicy(Qt::CustomContextMenu); char_button->hide(); char_button->setCharacter(character.name); + char_button->setPassworded(character.passworded); char_button->setTaken(character.taken); char_button->setToolTip(character.name); ui_char_button_list.append(char_button); @@ -354,10 +355,11 @@ void Courtroom::filter_character_list() AOCharButton *current_char = ui_char_button_list.at(i); QTreeWidgetItem *current_char_list_item = ui_char_list->findItems(QString::number(i), Qt::MatchExactly | Qt::MatchRecursive, 1).at(0); - // It seems passwording characters is unimplemented yet? - // Until then, this will stay here, I suppose. - // if (ui_char_passworded->isChecked() && character_is_passworded??) - // continue; + if (!ui_char_passworded->isChecked() && char_list.at(i).passworded) + { + current_char_list_item->setHidden(true); + continue; + } if (!ui_char_taken->isChecked() && char_list.at(i).taken) { @@ -375,6 +377,7 @@ void Courtroom::filter_character_list() // for the buttons that actually appear. // You'd also update the passwordedness and etc. here later. current_char_list_item->setHidden(false); + current_char->setPassworded(char_list.at(i).passworded); current_char->setTaken(char_list.at(i).taken); current_char_list_item->setText(0, char_list.at(i).name); // reset disabled -- cgit