From 116185c1dc7548b2c5ec093e2b9ce17c80a6eef0 Mon Sep 17 00:00:00 2001 From: RipleyTom Date: Fri, 2 Feb 2024 00:35:09 +0100 Subject: [PATCH] Review fixes --- rpcs3/Emu/NP/np_handler.cpp | 14 ++++---------- rpcs3/Emu/NP/np_handler.h | 2 +- rpcs3/rpcs3qt/rpcn_settings_dialog.cpp | 13 ++++++------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/rpcs3/Emu/NP/np_handler.cpp b/rpcs3/Emu/NP/np_handler.cpp index 6c21460410e5..94a9da6d23b9 100644 --- a/rpcs3/Emu/NP/np_handler.cpp +++ b/rpcs3/Emu/NP/np_handler.cpp @@ -1358,17 +1358,10 @@ namespace np } const std::string communication_id_str = std::string(basic_handler.context.data); - u32 count = 0; - - for (auto it = players_history.begin(); it != players_history.end(); it++) - { - if (it->second.communication_ids.contains(communication_id_str)) + return std::count_if(players_history.begin(), players_history.end(), [&](const auto& entry) { - count++; - } - } - - return count; + return entry.second.communication_ids.contains(communication_id_str); + }); } bool np_handler::get_player_history_entry(u32 options, u32 index, SceNpId* npid) @@ -1392,6 +1385,7 @@ namespace np { const std::string communication_id_str = std::string(basic_handler.context.data); + // Get the nth element that contains the current communication_id for (auto it = players_history.begin(); it != players_history.end(); it++) { if (it->second.communication_ids.contains(communication_id_str)) diff --git a/rpcs3/Emu/NP/np_handler.h b/rpcs3/Emu/NP/np_handler.h index 2c2075331f78..085dfa522e59 100644 --- a/rpcs3/Emu/NP/np_handler.h +++ b/rpcs3/Emu/NP/np_handler.h @@ -42,7 +42,7 @@ namespace np struct player_history { - u64 timestamp; + u64 timestamp{}; std::set communication_ids; std::string description; }; diff --git a/rpcs3/rpcs3qt/rpcn_settings_dialog.cpp b/rpcs3/rpcs3qt/rpcn_settings_dialog.cpp index cf42cb0c7863..6a0f88826f9d 100644 --- a/rpcs3/rpcs3qt/rpcn_settings_dialog.cpp +++ b/rpcs3/rpcs3qt/rpcn_settings_dialog.cpp @@ -863,7 +863,7 @@ namespace np { struct player_history { - u64 timestamp; + u64 timestamp{}; std::set communication_ids; std::string description; }; @@ -1068,13 +1068,12 @@ rpcn_friends_dialog::rpcn_friends_dialog(QWidget* parent) if (!m_rpcn->add_friend(str_sel_friend)) { QMessageBox::critical(this, tr("Error sending a friend request!"), tr("An error occurred while trying to send a friend request!"), QMessageBox::Ok); + return; } - else - { - QString qstr_friend = QString::fromStdString(str_sel_friend); - add_update_list(m_lst_requests, qstr_friend, m_orange_icon, QVariant(false)); - remove_list(m_lst_history, qstr_friend); - } + + QString qstr_friend = QString::fromStdString(str_sel_friend); + add_update_list(m_lst_requests, qstr_friend, m_orange_icon, QVariant(false)); + remove_list(m_lst_history, qstr_friend); }); context_menu->exec(m_lst_history->viewport()->mapToGlobal(pos));