Skip to content
Merged
8 changes: 4 additions & 4 deletions src/animationlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ void CharacterAnimationLayer::loadCharacterEmote(QString character, QString file

QVector<VPath> path_list;
QVector<QString> prefixed_emote_list;
for (const QString &prefix : qAsConst(prefixes))
for (const QString &prefix : std::as_const(prefixes))
{
path_list << ao_app->get_character_path(character, prefix + m_emote);
prefixed_emote_list << prefix + m_emote;
Expand Down Expand Up @@ -479,13 +479,13 @@ void CharacterAnimationLayer::setFrameEffects(QStringList data)
const EffectType effect_type = EFFECT_TYPE_LIST.at(i);

QStringList emotes = data.at(i).split("^");
for (const QString &emote : qAsConst(emotes))
for (const QString &emote : std::as_const(emotes))
{
QStringList emote_effects = emote.split("|");

const QString emote_name = emote_effects.takeFirst();

for (const QString &raw_effect : qAsConst(emote_effects))
for (const QString &raw_effect : std::as_const(emote_effects))
{
QStringList frame_data = raw_effect.split("=");

Expand Down Expand Up @@ -553,7 +553,7 @@ void CharacterAnimationLayer::notifyFrameEffect(int frameNumber)
auto it = m_effects.constFind(frameNumber);
if (it != m_effects.constEnd())
{
for (const FrameEffect &effect : qAsConst(*it))
for (const FrameEffect &effect : std::as_const(*it))
{
if (effect.emote_name == m_resolved_emote)
{
Expand Down
2 changes: 1 addition & 1 deletion src/animationloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ AnimationFrame AnimationLoader::frame(int frameNumber)
m_task_signal.wait(&m_task_lock);
}

AnimationFrame frame = qAsConst(m_frames)[frameNumber];
AnimationFrame frame = std::as_const(m_frames)[frameNumber];
m_task_lock.unlock();

return frame;
Expand Down
2 changes: 1 addition & 1 deletion src/aoapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class VPath : QString
inline VPath operator+(const VPath &str) const { return VPath(this->toQString() + str.toQString()); }
};

inline size_t qHash(const VPath &key, uint seed = qGlobalQHashSeed())
inline size_t qHash(const VPath &key, uint seed = QHashSeed::globalSeed())
{
return qHash(key.toQString(), seed);
}
Expand Down
2 changes: 1 addition & 1 deletion src/aopacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ QString AOPacket::toString(bool ensureEncoded)
QString message = m_header;
if (!m_content.isEmpty())
{
for (QString item : qAsConst(m_content))
for (QString item : std::as_const(m_content))
{
if (ensureEncoded)
{
Expand Down
2 changes: 1 addition & 1 deletion src/aotextboxwidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void AOChatboxLabel::paintEvent(QPaintEvent *event)

if (alignment() & Qt::AlignLeft)
{
x = rect.left() + l_indent - std::min(metrics.leftBearing(text()[0]), 0);
x = rect.left() + l_indent - std::min(metrics.leftBearing(text().at(0)), 0);
}
else if (alignment() & Qt::AlignRight)
{
Expand Down
4 changes: 2 additions & 2 deletions src/aoutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void AOUtils::migrateEffects(QSettings &p_effects_ini)
// realization_scaling - This would not be appended to the key_list as it matches scaling property.
// realization_alt - This would be appened as it contains an underscore, but not a property.
// hearts - This would be appended as it does not contain a property
const QRegularExpression l_regex(QStringLiteral("(\\w+)_(%1)$").arg(l_property_list.join("|")));
static QRegularExpression l_regex(QStringLiteral("(\\w+)_(%1)$").arg(l_property_list.join("|")));
for (auto i = l_effect_map.begin(); i != l_effect_map.end(); i++)
{
if (l_regex.match(i.key()).hasMatch())
Expand All @@ -57,7 +57,7 @@ void AOUtils::migrateEffects(QSettings &p_effects_ini)
}

int i = 0;
for (const QString &i_effect_key : qAsConst(l_key_list))
for (const QString &i_effect_key : std::as_const(l_key_list))
{
p_effects_ini.beginGroup(QString::number(i++));
p_effects_ini.setValue("name", i_effect_key);
Expand Down
4 changes: 2 additions & 2 deletions src/charselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void Courtroom::set_char_select_page()
ui_char_select_left->hide();
ui_char_select_right->hide();

for (AOCharButton *i_button : qAsConst(ui_char_button_list))
for (AOCharButton *i_button : std::as_const(ui_char_button_list))
{
i_button->hide();
i_button->move(0, 0);
Expand Down Expand Up @@ -352,7 +352,7 @@ void Courtroom::filter_character_list()
for (int i = 0; i < char_list.size(); i++)
{
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)[0];
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.
Expand Down
40 changes: 21 additions & 19 deletions src/courtroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ void Courtroom::set_mute_list()

QStringList sorted_mute_list;

for (const CharacterSlot &i_char : qAsConst(char_list))
for (const CharacterSlot &i_char : std::as_const(char_list))
{
sorted_mute_list.append(i_char.name);
}
Expand All @@ -723,7 +723,7 @@ void Courtroom::set_pair_list()
{
QStringList sorted_pair_list;

for (const CharacterSlot &i_char : qAsConst(char_list))
for (const CharacterSlot &i_char : std::as_const(char_list))
{
sorted_pair_list.append(i_char.name);
}
Expand Down Expand Up @@ -1408,7 +1408,7 @@ void Courtroom::set_background(QString p_background, bool display)

// Populate the dropdown list with all pos that exist on this bg
QStringList pos_list = {};
for (const QString &key : default_pos.keys())
for (const QString &key : std::as_const(default_pos))
{
if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path(default_pos[key]))) || // if we have 2.8-style positions, e.g. def.png, wit.webp, hld.apng
file_exists(ao_app->get_image_suffix(ao_app->get_background_path(key))))
Expand Down Expand Up @@ -3120,7 +3120,7 @@ void Courtroom::do_transition(QString p_desk_mod, QString oldPosId, QString newP

void Courtroom::post_transition_cleanup()
{
for (kal::CharacterAnimationLayer *layer : qAsConst(ui_vp_char_list))
for (kal::CharacterAnimationLayer *layer : std::as_const(ui_vp_char_list))
{
bool is_visible = layer->isVisible();
layer->stopPlayback();
Expand Down Expand Up @@ -3404,7 +3404,7 @@ void Courtroom::handle_callwords()
// No more file IO on every message.
QStringList call_words = Options::getInstance().callwords();
// Loop through each word in the call words list
for (const QString &word : qAsConst(call_words))
for (const QString &word : std::as_const(call_words))
{
// If our message contains that specific call word
if (f_message.contains(word, Qt::CaseInsensitive))
Expand Down Expand Up @@ -3765,7 +3765,8 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, int
// white-space: pre; stylesheet tag, but for whataver reason it doesn't work
// no matter where I try it. If somoene else can get that piece of HTML
// memery to work, please do.
p_text_escaped.replace(QRegularExpression("^\\s|(?<=\\s)\\s"), "&nbsp;");
static QRegularExpression whitespace("^\\s|(?<=\\s)\\s");
p_text_escaped.replace(whitespace, "&nbsp;");
if (!align.isEmpty())
{
p_text_escaped.append("</div>");
Expand Down Expand Up @@ -5115,9 +5116,10 @@ void Courtroom::on_ooc_return_pressed()
casefile.setValue("doc", "");
casefile.setValue("status", command[2]);
casefile.sync();
static QRegularExpression owner_regexp("<owner = ...>...");
for (int i = 0; i < local_evidence_list.size(); i++)
{
QString clean_evidence_dsc = local_evidence_list[i].description.replace(QRegularExpression("<owner = ...>..."), "");
QString clean_evidence_dsc = local_evidence_list[i].description.replace(owner_regexp, "");
clean_evidence_dsc = clean_evidence_dsc.replace(clean_evidence_dsc.lastIndexOf(">"), 1, "");
casefile.beginGroup(QString::number(i));
casefile.sync();
Expand Down Expand Up @@ -5428,7 +5430,7 @@ void Courtroom::set_sfx_dropdown()
sound_list += ao_app->get_list_file(VPath("soundlist.ini"));

QStringList display_sounds;
for (const QString &sound : qAsConst(sound_list))
for (const QString &sound : std::as_const(sound_list))
{
QStringList unpacked = sound.split("=");
QString display = unpacked[0].trimmed();
Expand Down Expand Up @@ -5730,7 +5732,7 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index)
// Redo the character list.
QStringList sorted_pair_list;

for (const CharacterSlot &i_char : qAsConst(char_list))
for (const CharacterSlot &i_char : std::as_const(char_list))
{
sorted_pair_list.append(i_char.name);
}
Expand Down Expand Up @@ -5798,19 +5800,19 @@ void Courtroom::on_music_list_context_menu_requested(const QPoint &pos)
}

menu->addAction(new QAction(tr("Fade Out Previous"), this));
menu->actions().back()->setCheckable(true);
menu->actions().back()->setChecked(music_flags & FADE_OUT);
connect(menu->actions().back(), &QAction::toggled, this, &Courtroom::music_fade_out);
menu->actions().constLast()->setCheckable(true);
menu->actions().constLast()->setChecked(music_flags & FADE_OUT);
connect(menu->actions().constLast(), &QAction::toggled, this, &Courtroom::music_fade_out);

menu->addAction(new QAction(tr("Fade In"), this));
menu->actions().back()->setCheckable(true);
menu->actions().back()->setChecked(music_flags & FADE_IN);
connect(menu->actions().back(), &QAction::toggled, this, &Courtroom::music_fade_in);
menu->actions().constLast()->setCheckable(true);
menu->actions().constLast()->setChecked(music_flags & FADE_IN);
connect(menu->actions().constLast(), &QAction::toggled, this, &Courtroom::music_fade_in);

menu->addAction(new QAction(tr("Synchronize"), this));
menu->actions().back()->setCheckable(true);
menu->actions().back()->setChecked(music_flags & SYNC_POS);
connect(menu->actions().back(), &QAction::toggled, this, &Courtroom::music_synchronize);
menu->actions().constLast()->setCheckable(true);
menu->actions().constLast()->setChecked(music_flags & SYNC_POS);
connect(menu->actions().constLast(), &QAction::toggled, this, &Courtroom::music_synchronize);

menu->addSeparator();
menu->addAction(QString("Open base music folder"), this, [=] {
Expand Down Expand Up @@ -5930,7 +5932,7 @@ void Courtroom::music_stop(bool no_effects)
if (!music_list.contains(fake_song))
{
// Loop through our music list
for (const QString &song : qAsConst(music_list))
for (const QString &song : std::as_const(music_list))
{
// Pick first song that does not contain a file extension
if (!song.contains('.'))
Expand Down
3 changes: 2 additions & 1 deletion src/demoserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ void DemoServer::load_demo(QString filename)
out.setCodec("UTF-8");
#endif
out << p_demo_data.dequeue();
for (const QString &line : qAsConst(p_demo_data))
for (const QString &line : std::as_const(p_demo_data))
{
out << "\n" << line;
}
Expand Down Expand Up @@ -442,6 +442,7 @@ void DemoServer::playback()
}
// Take the first arg as the command
QString command = f_contents.takeFirst();
Q_UNUSED(command); // this seems load-bearing. TODO: this should not be load-bearing
int duration = 0;
if (!f_contents.isEmpty())
{
Expand Down
3 changes: 1 addition & 2 deletions src/emotes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void Courtroom::set_emote_page()
ui_emote_left->hide();
ui_emote_right->hide();

for (AOEmoteButton *i_button : qAsConst(ui_emote_list))
for (AOEmoteButton *i_button : std::as_const(ui_emote_list))
{
i_button->hide();
}
Expand Down Expand Up @@ -265,7 +265,6 @@ void Courtroom::show_emote_menu(const QPoint &pos)
emote_preview->updateViewportGeometry();
update_emote_preview();
}));
QString prefix;
QString f_pre = ao_app->get_pre_emote(current_char, emote_num);
if (!f_pre.isEmpty() && f_pre != "-")
{
Expand Down
6 changes: 3 additions & 3 deletions src/evidence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ void Courtroom::set_evidence_page()
ui_evidence_left->hide();
ui_evidence_right->hide();

for (AOEvidenceButton *i_button : qAsConst(ui_evidence_list))
for (AOEvidenceButton *i_button : std::as_const(ui_evidence_list))
{
i_button->hide();
}
Expand Down Expand Up @@ -481,7 +481,7 @@ void Courtroom::on_evidence_clicked(int p_id)
}

ui_evidence_name->setText(local_evidence_list.at(f_real_id).name);
for (AOEvidenceButton *i_button : qAsConst(ui_evidence_list))
for (AOEvidenceButton *i_button : std::as_const(ui_evidence_list))
{
i_button->setSelected(false);
}
Expand All @@ -508,7 +508,7 @@ void Courtroom::on_evidence_double_clicked(int p_id)
}
}

for (AOEvidenceButton *i_button : qAsConst(ui_evidence_list))
for (AOEvidenceButton *i_button : std::as_const(ui_evidence_list))
{
i_button->setSelected(false);
}
Expand Down
9 changes: 6 additions & 3 deletions src/lobby.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ void Lobby::list_servers()
ui_serverlist_search->setText("");

int i = 0;
for (const ServerInfo &i_server : qAsConst(ao_app->get_server_list()))
for (const ServerInfo &i_server : std::as_const(ao_app->get_server_list()))
{
QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_serverlist_tree);
treeItem->setData(0, Qt::DisplayRole, i);
Expand Down Expand Up @@ -563,11 +563,13 @@ void Lobby::check_for_updates()
QVersionNumber current_version = QVersionNumber::fromString(ao_app->get_version_string());
QVersionNumber master_version = QVersionNumber::fromString(version);

static QRegularExpression regexp_links("\\b(https?://\\S+\\.\\S+)\\b");

if (current_version < master_version)
{
ui_game_version_lbl->setText(tr("Version: %1 [OUTDATED]").arg(current_version.toString()));
setWindowTitle(tr("[Your client is outdated]"));
const QString download_url = QString("https://github.com/AttorneyOnline/AO2-Client/releases/latest").replace(QRegularExpression("\\b(https?://\\S+\\.\\S+)\\b"), "<a href='\\1'>\\1</a>");
const QString download_url = QString("https://github.com/AttorneyOnline/AO2-Client/releases/latest").replace(regexp_links, "<a href='\\1'>\\1</a>");
const QString message = QString("Your client is outdated!<br>Your Version: %1<br>Current Version: %2<br>Download the latest version at<br>%3").arg(current_version.toString(), master_version.toString(), download_url);
QMessageBox::warning(this, "Your client is outdated!", message);
}
Expand All @@ -583,7 +585,8 @@ void Lobby::set_player_count(int players_online, int max_players)
void Lobby::set_server_description(const QString &server_description)
{
ui_server_description_text->clear();
QString result = server_description.toHtmlEscaped().replace("\n", "<br>").replace(QRegularExpression("\\b(https?://\\S+\\.\\S+)\\b"), "<a href='\\1'>\\1</a>");
static QRegularExpression regexp_links("\\b(https?://\\S+\\.\\S+)\\b");
QString result = server_description.toHtmlEscaped().replace("\n", "<br>").replace(regexp_links, "<a href='\\1'>\\1</a>");
ui_server_description_text->insertHtml(result);
}

Expand Down
2 changes: 1 addition & 1 deletion src/network/serverinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

QString ServerInfo::toString() const
{
return QString("%1 (%2:%3)").arg(name.isEmpty() ? QStringLiteral("Unnamed Server") : name).arg(address).arg(port);
return QString("%1 (%2:%3)").arg((name.isEmpty() ? QStringLiteral("Unnamed Server") : name), address, QString::number(port));
}
6 changes: 3 additions & 3 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ QVector<ServerInfo> Options::favorites()
auto grouplist = favorite.childGroups();
{ // remove all negative and non-numbers
auto filtered_grouplist = grouplist;
for (const QString &group : qAsConst(grouplist))
for (const QString &group : std::as_const(grouplist))
{
bool ok = false;
const int l_num = group.toInt(&ok);
Expand All @@ -674,7 +674,7 @@ QVector<ServerInfo> Options::favorites()
grouplist = std::move(filtered_grouplist);
}

for (const QString &group : qAsConst(grouplist))
for (const QString &group : std::as_const(grouplist))
{
ServerInfo f_server;
favorite.beginGroup(group);
Expand Down Expand Up @@ -763,7 +763,7 @@ QString Options::getUIAsset(QString f_asset_name)
l_paths.prepend(":/base/themes/" + theme() + "/" + subTheme() + "/" + f_asset_name);
}

for (const QString &l_path : qAsConst(l_paths))
for (const QString &l_path : std::as_const(l_paths))
{
if (QFile::exists(l_path))
{
Expand Down
9 changes: 5 additions & 4 deletions src/packet_distribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void AOApplication::server_packet_received(AOPacket packet)
client_id = content.at(0).toInt();
m_serverdata.set_server_software(content.at(1));

net_manager->server_connected(true);
emit net_manager->server_connected(true);

QStringList f_contents = {"AO2", get_version_string()};
send_server_packet(AOPacket("ID", f_contents));
Expand Down Expand Up @@ -160,10 +160,12 @@ void AOApplication::server_packet_received(AOPacket packet)

// Remove any characters not accepted in folder names for the server_name
// here

QString server_name_stripped = server_name;
static QRegularExpression illegal_filename_chars("[\\\\/:*?\"<>|\']");
if (Options::getInstance().logToDemoFileEnabled() && server_name != "Demo playback")
{
this->log_filename = QDateTime::currentDateTime().toUTC().toString("'logs/" + server_name_stripped.remove(QRegularExpression("[\\\\/:*?\"<>|\']")) + "/'yyyy-MM-dd hh-mm-ss t'.log'");
this->log_filename = QDateTime::currentDateTime().toUTC().toString("'logs/" + server_name_stripped.remove(illegal_filename_chars) + "/'yyyy-MM-dd hh-mm-ss t'.log'");
this->write_to_file("Joined server " + server_name_stripped + " hosted on address " + server_address + " on " + QDateTime::currentDateTime().toUTC().toString(), log_filename, true);
}
else
Expand Down Expand Up @@ -426,7 +428,7 @@ void AOApplication::server_packet_received(AOPacket packet)
{
QVector<EvidenceItem> f_evi_list;

for (QString f_string : packet.content())
for (const QString &f_string : packet.content())
{
QStringList sub_contents = f_string.split("&");
if (sub_contents.size() < 3)
Expand Down Expand Up @@ -714,7 +716,6 @@ void AOApplication::server_packet_received(AOPacket packet)

void AOApplication::send_server_packet(AOPacket p_packet)
{
QString f_packet = p_packet.toString();
#ifdef DEBUG_NETWORK
qDebug() << "S:" << p_packet.to_string();
#endif
Expand Down
Loading
Loading