mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-11-16 19:14:29 +01:00
signaling-fix: always answer the offer (#5337)
* always answer the offer so it can finish handshake * fixed peer connection * misc
This commit is contained in:
1 parent
2c1961a270
commit
811bfcd7d1
3 files changed
+38
-3
No files matched your search
@@ -324,6 +324,20 @@ s32 PS4_SYSV_ABI sceNpSignalingActivateConnection(OrbisNpSignalingContextId ctxI
|
||||
s32 PS4_SYSV_ABI sceNpSignalingActivateConnectionA(
|
||||
OrbisNpSignalingContextId ctxId, const OrbisNpSignalingAccountPlatformPair* peerAddr,
|
||||
OrbisNpSignalingConnectionId* outConnId) {
|
||||
OrbisNpId peer_npid{};
|
||||
if (peerAddr && peerAddr->accountId != 0 && peerAddr->platformType != 0 && outConnId &&
|
||||
SignalingHandler::FindMatching2MemberNpId(peerAddr->accountId, &peer_npid)) {
|
||||
s32 rc = SignalingHandler::ActivateSig1(ctxId, peer_npid, peer_npid.handle, outConnId);
|
||||
if (rc == ORBIS_NP_SIGNALING_ERROR_OWN_NP_ID) {
|
||||
rc = ORBIS_NP_SIGNALING_ERROR_OWN_PEER_ADDRESS;
|
||||
}
|
||||
LOG_INFO(Lib_NpSignaling,
|
||||
"ctxId={} accountId={:#x} platform={} peer='{}' rc={:#x} connId={}", ctxId,
|
||||
peerAddr->accountId, peerAddr->platformType, OnlineIdToString(peer_npid.handle),
|
||||
rc, rc == ORBIS_OK ? *outConnId : 0);
|
||||
return rc;
|
||||
}
|
||||
|
||||
SignalingMutexGuard lock;
|
||||
if (!NpHandler::GetInstance().GetSignalingState().initialized) {
|
||||
return ORBIS_NP_SIGNALING_ERROR_NOT_INITIALIZED;
|
||||
|
||||
@@ -892,10 +892,10 @@ void HandleHandshakePacket(u32 from_addr, u16 from_port,
|
||||
transport.peer_activated = true;
|
||||
if (transport.state != NpSignaling::ConnState::Established) {
|
||||
SetTransportStateLocked(transport, NpSignaling::ConnState::SendingAccept);
|
||||
reply = MakeHandshakeLocked(transport, NpSignaling::HandshakeKind::Accept);
|
||||
send_reply = true;
|
||||
reply_transport = transport_id;
|
||||
}
|
||||
reply = MakeHandshakeLocked(transport, NpSignaling::HandshakeKind::Accept);
|
||||
send_reply = true;
|
||||
reply_transport = transport_id;
|
||||
} else if (transport_id == 0) {
|
||||
return;
|
||||
} else if (kind == NpSignaling::HandshakeKind::Accept) {
|
||||
@@ -1358,6 +1358,26 @@ void ReleaseContextRef() {
|
||||
}
|
||||
}
|
||||
|
||||
bool FindMatching2MemberNpId(OrbisNpAccountId account_id, OrbisNpId* out_npid) {
|
||||
for (u32 id = 1; id <= NpMatching2::ContextManager::kMaxContexts; ++id) {
|
||||
auto ctx = NpHandler::GetInstance().GetMatching2ContextManager().Get(
|
||||
static_cast<NpMatching2::OrbisNpMatching2ContextId>(id));
|
||||
if (!ctx) {
|
||||
continue;
|
||||
}
|
||||
auto cache = NpHandler::GetInstance().LockMatching2Cache(ctx->ctx_id);
|
||||
for (const auto& [room_id, room] : cache->rooms) {
|
||||
for (const auto& [member_id, member] : room.members) {
|
||||
if (member.account_id == account_id && member.np_id.handle.data[0] != '\0') {
|
||||
*out_npid = member.np_id;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
s32 ActivateSig1(NpSignaling::OrbisNpSignalingContextId ctx_id, const OrbisNpId& peer_npid,
|
||||
const OrbisNpOnlineId& peer_online_id,
|
||||
NpSignaling::OrbisNpSignalingConnectionId* out_conn_id) {
|
||||
|
||||
@@ -22,6 +22,7 @@ void ReleaseContextRef();
|
||||
s32 ActivateSig1(NpSignaling::OrbisNpSignalingContextId ctx_id, const OrbisNpId& peer_npid,
|
||||
const OrbisNpOnlineId& peer_online_id,
|
||||
NpSignaling::OrbisNpSignalingConnectionId* out_conn_id);
|
||||
bool FindMatching2MemberNpId(OrbisNpAccountId account_id, OrbisNpId* out_npid);
|
||||
void DeactivateSig1(NpSignaling::OrbisNpSignalingConnectionId conn_id);
|
||||
void TerminateSig1(NpSignaling::OrbisNpSignalingConnectionId conn_id);
|
||||
|
||||
|
||||
Reference in new issue
Block a user