Skip to content

Commit 42e9eda

Browse files
authored
RPCN: Add delete trophies from rpcn button (#19306)
Allows user to delete their synced trophies
1 parent 5e40242 commit 42e9eda

6 files changed

Lines changed: 509 additions & 6 deletions

File tree

rpcs3/Emu/NP/rpcn_client.cpp

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ void fmt_class_string<rpcn::CommandType>::format(std::string& out, u64 arg)
163163
case rpcn::CommandType::SearchJoinRoomGUI: return "SearchJoinRoomGUI";
164164
case rpcn::CommandType::UnlockTrophy: return "UnlockTrophy";
165165
case rpcn::CommandType::SyncTrophies: return "SyncTrophies";
166+
case rpcn::CommandType::DeleteTrophies: return "DeleteTrophies";
166167
}
167168

168169
return unknown;
@@ -259,7 +260,7 @@ namespace rpcn
259260
rpcn_log.notice("online: %s, pr_com_id: %s, pr_title: %s, pr_status: %s, pr_comment: %s, pr_data: %s", online ? "true" : "false", pr_com_id.data, pr_title, pr_status, pr_comment, fmt::buf_to_hexstring(pr_data.data(), pr_data.size()));
260261
}
261262

262-
constexpr u32 RPCN_PROTOCOL_VERSION = 31;
263+
constexpr u32 RPCN_PROTOCOL_VERSION = 32;
263264
constexpr usz RPCN_HEADER_SIZE = 15;
264265

265266
const char* error_to_explanation(rpcn::ErrorType error)
@@ -676,7 +677,7 @@ namespace rpcn
676677
command == CommandType::SendMessage || command == CommandType::SendToken ||
677678
command == CommandType::SendResetToken || command == CommandType::ResetPassword ||
678679
command == CommandType::GetNetworkTime || command == CommandType::SetPresence || command == CommandType::Terminate ||
679-
command == CommandType::SyncTrophies)
680+
command == CommandType::SyncTrophies || command == CommandType::DeleteTrophies)
680681
{
681682
std::lock_guard lock(mutex_replies_sync);
682683
replies_sync.insert(std::make_pair(packet_id, std::make_pair(command, std::move(data))));
@@ -1482,6 +1483,37 @@ namespace rpcn
14821483
return error;
14831484
}
14841485

1486+
ErrorType rpcn_client::delete_trophies(std::string_view communication_id)
1487+
{
1488+
std::vector<u8> data;
1489+
std::copy(communication_id.begin(), communication_id.end(), std::back_inserter(data));
1490+
data.push_back(0);
1491+
1492+
std::vector<u8> packet_data;
1493+
1494+
if (!forge_send_reply(CommandType::DeleteTrophies, rpcn_request_counter.fetch_add(1), data, packet_data))
1495+
{
1496+
return ErrorType::Malformed;
1497+
}
1498+
1499+
vec_stream reply(packet_data);
1500+
const auto error = static_cast<ErrorType>(reply.get<u8>());
1501+
1502+
if (error == rpcn::ErrorType::NoError)
1503+
{
1504+
if (communication_id.empty())
1505+
{
1506+
rpcn_log.success("RPCN trophies were successfully deleted!");
1507+
}
1508+
else
1509+
{
1510+
rpcn_log.success("RPCN trophies for %s were successfully deleted!", communication_id);
1511+
}
1512+
}
1513+
1514+
return error;
1515+
}
1516+
14851517
std::optional<ErrorType> rpcn_client::add_friend(std::string_view friend_username)
14861518
{
14871519
std::vector<u8> data;

rpcs3/Emu/NP/rpcn_client.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ namespace rpcn
301301
ErrorType send_reset_token(std::string_view npid, std::string_view email);
302302
ErrorType reset_password(std::string_view npid, std::string_view token, std::string_view password);
303303
ErrorType delete_account();
304+
ErrorType delete_trophies(std::string_view communication_id = {});
304305
std::optional<ErrorType> add_friend(std::string_view friend_username);
305306
bool remove_friend(std::string_view friend_username);
306307

rpcs3/Emu/NP/rpcn_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ namespace rpcn
7171
GetRoomMemberDataExternalList,
7272
UnlockTrophy,
7373
SyncTrophies,
74+
DeleteTrophies,
7475
};
7576

7677
enum class NotificationType : u16

rpcs3/rpcs3qt/rpcn_settings_dialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ rpcn_account_edit_dialog::rpcn_account_edit_dialog(QWidget* parent)
751751

752752
QPushButton* btn_resendtoken = new QPushButton(tr("Resend Token"), this);
753753
QPushButton* btn_change_password = new QPushButton(tr("Change Password"), this);
754-
QPushButton* btn_delete_account = new QPushButton(tr("Delete Account"), this);
754+
QPushButton* btn_delete_account = new QPushButton(tr("Delete Account"), this);
755755
QPushButton* btn_save = new QPushButton(tr("Save"), this);
756756

757757
vbox_labels->addWidget(lbl_username);

0 commit comments

Comments
 (0)