mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-06 15:05:59 +00:00
rpcn: signaling handler improvements & upnp
Simplify signaling by making Matching2 a layer over normal signaling. Implements UPNP port forwarding Implement sceNpMatching2AbortRequest Fix reported bw in sceNpUtil Hack for Fat Princess binding udp on 3658 Reenable CB for sceNpBasicAddPlayersHistoryAsync Misc fixes
This commit is contained in:
parent
364c33060b
commit
6186ac0245
45 changed files with 1290 additions and 747 deletions
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include "Emu/NP/np_allocator.h"
|
||||
#include "Emu/NP/np_cache.h"
|
||||
#include "Emu/NP/np_helpers.h"
|
||||
|
||||
LOG_CHANNEL(np_cache);
|
||||
|
||||
namespace np
|
||||
{
|
||||
|
|
@ -80,20 +83,32 @@ namespace np
|
|||
rooms[sce_roomdata->roomId].update(sce_roomdata);
|
||||
}
|
||||
|
||||
void cache_manager::add_member(SceNpMatching2RoomId room_id, const SceNpMatching2RoomMemberDataInternal* sce_roommemberdata)
|
||||
bool cache_manager::add_member(SceNpMatching2RoomId room_id, const SceNpMatching2RoomMemberDataInternal* sce_roommemberdata)
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
ensure(rooms.contains(room_id), "cache_manager::add_member: Room not cached!");
|
||||
if (!rooms.contains(room_id))
|
||||
{
|
||||
np_cache.error("np_cache::add_member cache miss: room_id(%d)", room_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
rooms[room_id].members.insert_or_assign(sce_roommemberdata->memberId, member_cache(sce_roommemberdata));
|
||||
return true;
|
||||
}
|
||||
|
||||
void cache_manager::del_member(SceNpMatching2RoomId room_id, SceNpMatching2RoomMemberId member_id)
|
||||
bool cache_manager::del_member(SceNpMatching2RoomId room_id, SceNpMatching2RoomMemberId member_id)
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
ensure(rooms.contains(room_id), "cache_manager::del_member: Room not cached!");
|
||||
if (!rooms.contains(room_id))
|
||||
{
|
||||
np_cache.error("np_cache::del_member cache miss: room_id(%d)/member_id(%d)", room_id, member_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
rooms.erase(member_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
void cache_manager::update_password(SceNpMatching2RoomId room_id, const std::optional<SceNpMatching2SessionPassword>& password)
|
||||
|
|
@ -121,7 +136,7 @@ namespace np
|
|||
SceNpMatching2RoomJoinedSlotMask join_mask = 0;
|
||||
for (const auto& member : room.members)
|
||||
{
|
||||
join_mask |= (1 << (member.first - 1));
|
||||
join_mask |= (1 << ((member.first >> 4) - 1));
|
||||
}
|
||||
slots.joinedSlotMask = join_mask;
|
||||
slots.passwordSlotMask = room.mask_password;
|
||||
|
|
@ -307,14 +322,45 @@ namespace np
|
|||
return needed_data_size;
|
||||
}
|
||||
|
||||
SceNpId cache_manager::get_npid(u64 room_id, u16 member_id)
|
||||
std::pair<error_code, std::optional<SceNpId>> cache_manager::get_npid(u64 room_id, u16 member_id)
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
ensure(rooms.contains(room_id), "cache_manager::get_npid: Room not cached!");
|
||||
ensure(::at32(rooms, room_id).members.contains(member_id), "cache_manager::get_npid: Member not cached!");
|
||||
if (!rooms.contains(room_id))
|
||||
{
|
||||
np_cache.error("np_cache::get_npid cache miss room_id: room_id(%d)/member_id(%d)", room_id, member_id);
|
||||
return {SCE_NP_MATCHING2_ERROR_INVALID_ROOM_ID, std::nullopt};
|
||||
}
|
||||
|
||||
return ::at32(::at32(rooms, room_id).members, member_id).userInfo.npId;
|
||||
if (!::at32(rooms, room_id).members.contains(member_id))
|
||||
{
|
||||
np_cache.error("np_cache::get_npid cache miss member_id: room_id(%d)/member_id(%d)", room_id, member_id);
|
||||
return {SCE_NP_MATCHING2_ERROR_INVALID_MEMBER_ID, std::nullopt};
|
||||
}
|
||||
|
||||
return {CELL_OK, ::at32(::at32(rooms, room_id).members, member_id).userInfo.npId};
|
||||
}
|
||||
|
||||
std::optional<u16> cache_manager::get_memberid(u64 room_id, const SceNpId& npid)
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
if (!rooms.contains(room_id))
|
||||
{
|
||||
np_cache.error("np_cache::get_memberid cache miss room_id: room_id(%d)/npid(%s)", room_id, static_cast<const char*>(npid.handle.data));
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const auto& members = ::at32(rooms, room_id).members;
|
||||
|
||||
for (const auto& [id, member_cache] : members)
|
||||
{
|
||||
if (np::is_same_npid(member_cache.userInfo.npId, npid))
|
||||
return id;
|
||||
}
|
||||
|
||||
np_cache.error("np_cache::get_memberid cache miss member_id: room_id(%d)/npid(%s)", room_id, static_cast<const char*>(npid.handle.data));
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
} // namespace np
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue