mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-20 22:05:12 +00:00
NP: Implement sceNpBasicGetFriendListEntry
This commit is contained in:
parent
d41e405420
commit
c194804fec
12 changed files with 104 additions and 34 deletions
|
|
@ -1,8 +1,8 @@
|
|||
#include "stdafx.h"
|
||||
#include <bit>
|
||||
|
||||
#include "np_allocator.h"
|
||||
#include "np_cache.h"
|
||||
#include "Emu/NP/np_allocator.h"
|
||||
#include "Emu/NP/np_cache.h"
|
||||
|
||||
namespace np
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
#include "np_dnshook.h"
|
||||
#include "Emu/NP/np_dnshook.h"
|
||||
|
||||
#include "Emu/system_config.h"
|
||||
#include "Utilities/StrUtil.h"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "stdafx.h"
|
||||
#include "Emu/system_config.h"
|
||||
#include "np_handler.h"
|
||||
#include "Emu/NP/np_handler.h"
|
||||
#include "Emu/Cell/PPUModule.h"
|
||||
#include "Emu/Cell/Modules/sceNp.h"
|
||||
#include "Emu/Cell/Modules/sceNp2.h"
|
||||
|
|
@ -8,10 +8,11 @@
|
|||
#include "Utilities/StrUtil.h"
|
||||
#include "Emu/Cell/Modules/cellSysutil.h"
|
||||
#include "Emu/IdManager.h"
|
||||
#include "np_structs_extra.h"
|
||||
#include "Emu/NP/np_structs_extra.h"
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/NP/rpcn_config.h"
|
||||
#include "Emu/NP/np_contexts.h"
|
||||
#include "Emu/NP/np_helpers.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
|
|
@ -603,6 +604,21 @@ namespace np
|
|||
return rpcn->get_num_blocks();
|
||||
}
|
||||
|
||||
std::pair<error_code, std::optional<SceNpId>> np_handler::get_friend_by_index(u32 index)
|
||||
{
|
||||
auto str_friend = rpcn->get_friend_by_index(index);
|
||||
|
||||
if (!str_friend)
|
||||
{
|
||||
return {SCE_NP_ERROR_ID_NOT_FOUND, {}};
|
||||
}
|
||||
|
||||
SceNpId npid_friend;
|
||||
string_to_npid(str_friend.value(), &npid_friend);
|
||||
|
||||
return {CELL_OK, npid_friend};
|
||||
}
|
||||
|
||||
std::pair<error_code, std::optional<SceNpMatching2SessionPassword>> np_handler::local_get_room_password(SceNpMatching2RoomId room_id)
|
||||
{
|
||||
return np_cache.get_password(room_id);
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@
|
|||
#include "Emu/Cell/Modules/sceNp2.h"
|
||||
|
||||
#include "Emu/NP/rpcn_client.h"
|
||||
#include "generated/np2_structs_generated.h"
|
||||
#include "signaling_handler.h"
|
||||
#include "np_allocator.h"
|
||||
#include "np_cache.h"
|
||||
#include "np_event_data.h"
|
||||
#include "Emu/NP/generated/np2_structs_generated.h"
|
||||
#include "Emu/NP/signaling_handler.h"
|
||||
#include "Emu/NP/np_allocator.h"
|
||||
#include "Emu/NP/np_cache.h"
|
||||
#include "Emu/NP/np_event_data.h"
|
||||
|
||||
namespace np
|
||||
{
|
||||
|
|
@ -24,15 +24,6 @@ namespace np
|
|||
std::vector<u8> data;
|
||||
};
|
||||
|
||||
// Helper functions
|
||||
std::string ip_to_string(u32 addr);
|
||||
std::string ether_to_string(std::array<u8, 6>& ether);
|
||||
|
||||
void string_to_npid(const std::string& str, SceNpId* npid);
|
||||
void string_to_online_name(const std::string& str, SceNpOnlineName* online_name);
|
||||
void string_to_avatar_url(const std::string& str, SceNpAvatarUrl* avatar_url);
|
||||
void string_to_communication_id(const std::string& str, SceNpCommunicationId* comm_id);
|
||||
|
||||
class np_handler
|
||||
{
|
||||
public:
|
||||
|
|
@ -125,6 +116,7 @@ namespace np
|
|||
// Friend stuff
|
||||
u32 get_num_friends();
|
||||
u32 get_num_blocks();
|
||||
std::pair<error_code, std::optional<SceNpId>> get_friend_by_index(u32 index);
|
||||
|
||||
// Misc stuff
|
||||
void req_ticket(u32 version, const SceNpId* npid, const char* service_id, const u8* cookie, u32 cookie_size, const char* entitlement_id, u32 consumed_count);
|
||||
|
|
|
|||
14
rpcs3/Emu/NP/np_helpers.h
Normal file
14
rpcs3/Emu/NP/np_helpers.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include "util/types.hpp"
|
||||
#include "Emu/Cell/Modules/sceNp.h"
|
||||
#include "Emu/Cell/Modules/sceNp2.h"
|
||||
|
||||
namespace np
|
||||
{
|
||||
std::string ip_to_string(u32 addr);
|
||||
std::string ether_to_string(std::array<u8, 6>& ether);
|
||||
|
||||
void string_to_npid(const std::string& str, SceNpId* npid);
|
||||
void string_to_online_name(const std::string& str, SceNpOnlineName* online_name);
|
||||
void string_to_avatar_url(const std::string& str, SceNpAvatarUrl* avatar_url);
|
||||
void string_to_communication_id(const std::string& str, SceNpCommunicationId* comm_id);
|
||||
}
|
||||
|
|
@ -2,8 +2,9 @@
|
|||
#include "Emu/Cell/PPUModule.h"
|
||||
#include "Emu/Cell/Modules/cellSysutil.h"
|
||||
#include "Emu/IdManager.h"
|
||||
#include "np_handler.h"
|
||||
#include "np_structs_extra.h"
|
||||
#include "Emu/NP/np_handler.h"
|
||||
#include "Emu/NP/np_helpers.h"
|
||||
#include "Emu/NP/np_structs_extra.h"
|
||||
|
||||
LOG_CHANNEL(rpcn_log, "rpcn");
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "Emu/IdManager.h"
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/NP/rpcn_config.h"
|
||||
#include "Emu/NP/np_helpers.h"
|
||||
|
||||
#include "util/asm.hpp"
|
||||
|
||||
|
|
@ -774,10 +775,14 @@ namespace rpcn
|
|||
}
|
||||
};
|
||||
|
||||
get_usernames_and_status(reply, friend_infos.friends);
|
||||
get_usernames(reply, friend_infos.requests_sent);
|
||||
get_usernames(reply, friend_infos.requests_received);
|
||||
get_usernames(reply, friend_infos.blocked);
|
||||
{
|
||||
std::lock_guard lock(mutex_friends);
|
||||
|
||||
get_usernames_and_status(reply, friend_infos.friends);
|
||||
get_usernames(reply, friend_infos.requests_sent);
|
||||
get_usernames(reply, friend_infos.requests_received);
|
||||
get_usernames(reply, friend_infos.blocked);
|
||||
}
|
||||
|
||||
if (is_error(error))
|
||||
{
|
||||
|
|
@ -1736,6 +1741,7 @@ namespace rpcn
|
|||
void rpcn_client::get_friends_and_register_cb(friend_data& friend_infos, friend_cb_func cb_func, void* cb_param)
|
||||
{
|
||||
std::lock_guard lock(mutex_friends);
|
||||
|
||||
friend_infos = this->friend_infos;
|
||||
friend_cbs.insert(std::make_pair(cb_func, cb_param));
|
||||
}
|
||||
|
|
@ -1743,6 +1749,7 @@ namespace rpcn
|
|||
void rpcn_client::remove_friend_cb(friend_cb_func cb_func, void* cb_param)
|
||||
{
|
||||
std::lock_guard lock(mutex_friends);
|
||||
|
||||
for (const auto& friend_cb : friend_cbs)
|
||||
{
|
||||
if (friend_cb.first == cb_func && friend_cb.second == cb_param)
|
||||
|
|
@ -1933,6 +1940,7 @@ namespace rpcn
|
|||
void rpcn_client::remove_message_cb(message_cb_func cb_func, void* cb_param)
|
||||
{
|
||||
std::lock_guard lock(mutex_messages);
|
||||
|
||||
for (const auto& message_cb : message_cbs)
|
||||
{
|
||||
if (message_cb.cb_func == cb_func && message_cb.cb_param == cb_param)
|
||||
|
|
@ -1946,17 +1954,40 @@ namespace rpcn
|
|||
void rpcn_client::discard_active_message(u64 id)
|
||||
{
|
||||
std::lock_guard lock(mutex_messages);
|
||||
|
||||
active_messages.erase(id);
|
||||
}
|
||||
|
||||
u32 rpcn_client::get_num_friends() const
|
||||
u32 rpcn_client::get_num_friends()
|
||||
{
|
||||
std::lock_guard lock(mutex_friends);
|
||||
|
||||
return friend_infos.friends.size();
|
||||
}
|
||||
|
||||
u32 rpcn_client::get_num_blocks() const
|
||||
u32 rpcn_client::get_num_blocks()
|
||||
{
|
||||
std::lock_guard lock(mutex_friends);
|
||||
|
||||
return friend_infos.blocked.size();
|
||||
}
|
||||
|
||||
std::optional<std::string> rpcn_client::get_friend_by_index(u32 index)
|
||||
{
|
||||
std::lock_guard lock(mutex_friends);
|
||||
|
||||
if (index >= friend_infos.friends.size())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
auto it = friend_infos.friends.begin();
|
||||
for (usz i = 0; i < index; i++)
|
||||
{
|
||||
it++;
|
||||
}
|
||||
|
||||
return it->first;
|
||||
}
|
||||
|
||||
} // namespace rpcn
|
||||
|
|
|
|||
|
|
@ -293,8 +293,9 @@ namespace rpcn
|
|||
bool add_friend(const std::string& friend_username);
|
||||
bool remove_friend(const std::string& friend_username);
|
||||
|
||||
u32 get_num_friends() const;
|
||||
u32 get_num_blocks() const;
|
||||
u32 get_num_friends();
|
||||
u32 get_num_blocks();
|
||||
std::optional<std::string> get_friend_by_index(u32 index);
|
||||
|
||||
std::vector<std::pair<u16, std::vector<u8>>> get_notifications();
|
||||
std::unordered_map<u32, std::pair<u16, std::vector<u8>>> get_replies();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue