Don't allow ForcedFirstConnect hack when using PtpConnect within PtpOpen to prevent returning result from blocking PtpConnect instead of result of PtpOpen.

This commit is contained in:
ANR2ME committed 2021-01-25 18:40:20 +07:00
1 parent 136c861d17
commit 3d813aec73
1 file changed
+4 -4
+4 -4
View File
@@ -109,7 +109,7 @@ int PollAdhocSocket(SceNetAdhocPollSd* sds, int count, int timeout, int nonblock
int FlushPtpSocket(int socketId);
int NetAdhocGameMode_DeleteMaster();
int NetAdhocctl_ExitGameMode();
int NetAdhoc_PtpConnect(int id, int timeout, int flag);
int NetAdhoc_PtpConnect(int id, int timeout, int flag, bool allowForcedConnect = true);
static int sceNetAdhocPdpSend(int id, const char* mac, u32 port, void* data, int len, int timeout, int flag);
static int sceNetAdhocPdpRecv(int id, void* addr, void* port, void* buf, void* dataLength, u32 timeout, int flag);
@@ -3201,7 +3201,7 @@ static int sceNetAdhocPtpOpen(const char *srcmac, int sport, const char *dstmac,
changeBlockingMode(tcpsocket, 1);
// Initiate PtpConnect (ie. The Warrior seems to try to PtpSend right after PtpOpen without trying to PtpConnect first)
NetAdhoc_PtpConnect(i + 1, rexmt_int, 1);
NetAdhoc_PtpConnect(i + 1, rexmt_int, 1, false);
// Return PTP Socket Pointer
return hleLogDebug(SCENET, i + 1, "success");
@@ -3450,7 +3450,7 @@ static int sceNetAdhocPtpAccept(int id, u32 peerMacAddrPtr, u32 peerPortPtr, int
return hleLogSuccessVerboseI(SCENET, ERROR_NET_ADHOC_NOT_INITIALIZED, "not initialized");
}
int NetAdhoc_PtpConnect(int id, int timeout, int flag) {
int NetAdhoc_PtpConnect(int id, int timeout, int flag, bool allowForcedConnect) {
// Library is initialized
if (netAdhocInited)
{
@@ -3523,7 +3523,7 @@ int NetAdhoc_PtpConnect(int id, int timeout, int flag) {
socket->lastAttempt = CoreTiming::GetGlobalTimeUsScaled();
// Blocking Mode
// Workaround: Forcing first attempt to be blocking to prevent issue related to lobby or high latency networks. (can be useful for GvG Next Plus, Dissidia 012, and Fate Unlimited Codes)
if (!flag || (g_Config.bForcedFirstConnect && socket->attemptCount == 1)) {
if (!flag || (allowForcedConnect && g_Config.bForcedFirstConnect && socket->attemptCount == 1)) {
// Simulate blocking behaviour with non-blocking socket
u64 threadSocketId = ((u64)__KernelGetCurThread()) << 32 | ptpsocket.id;
return WaitBlockingAdhocSocket(threadSocketId, PTP_CONNECT, id, nullptr, nullptr, (flag) ? std::max((int)socket->retry_interval, timeout) : timeout, nullptr, nullptr, "ptp connect");