Merge pull request #13181 from hrydgard/blinking-room-issue-ANR2ME

Fix Blinking game room issue on NFS Most Wanted (extracted from #13132 by ANR2ME)
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2020-07-22 21:20:14 +02:00
commit 2e1a06b09a
3 files changed
+28 -35

No files matched your search

+25 -33
View File
@@ -603,7 +603,7 @@ SceNetAdhocMatchingMemberInternal * findP2P(SceNetAdhocMatchingContext * context
* @param context Matching Context Pointer
* @param peer Internal Peer Reference
*/
void deletePeer(SceNetAdhocMatchingContext * context, SceNetAdhocMatchingMemberInternal * peer)
void deletePeer(SceNetAdhocMatchingContext * context, SceNetAdhocMatchingMemberInternal *& peer)
{
// Valid Arguments
if (context != NULL && peer != NULL)
@@ -729,7 +729,8 @@ void sendGenericMessage(SceNetAdhocMatchingContext * context, int stack, SceNetE
peerlock.lock();
// Out of Memory Emergency Delete
deletePeer(context, findPeer(context, mac));
auto peer = findPeer(context, mac);
deletePeer(context, peer);
peerlock.unlock();
}
@@ -924,7 +925,7 @@ void handleTimeout(SceNetAdhocMatchingContext * context)
* Recursive Stack Cleaner
* @param node Current Thread Message Node
*/
void clearStackRecursive(ThreadMessage * node)
void clearStackRecursive(ThreadMessage *& node)
{
// Not End of List
if (node != NULL) clearStackRecursive(node->next);
@@ -1107,7 +1108,7 @@ void freeFriendsRecursive(SceNetAdhocctlPeerInfo * node, int32_t* count) {
if (count != NULL) (*count)++;
}
void timeoutFriendsRecursive(SceNetAdhocctlPeerInfo* node, int32_t* count) {
void timeoutFriendsRecursive(SceNetAdhocctlPeerInfo * node, int32_t* count) {
// End of List
if (node == NULL) return;
@@ -1389,41 +1390,30 @@ int friendFinder(){
// Multithreading Lock
peerlock.lock();
// Should only add non-existing group (or replace an existing group) to prevent Ford Street Racing from showing a strange game session list
SceNetAdhocctlScanInfo * group = findGroup(&packet->mac);
// Allocate Structure Data
SceNetAdhocctlScanInfo* group = (SceNetAdhocctlScanInfo*)malloc(sizeof(SceNetAdhocctlScanInfo));
// Allocated Structure Data
if (group != NULL) {
// Clear Memory, should this be done only when allocating new group?
memset(group, 0, sizeof(SceNetAdhocctlScanInfo));
// Link to existing Groups
group->next = newnetworks;
// Copy Group Name
group->group_name = packet->group;
// Set Group Host
group->bssid.mac_addr = packet->mac;
} else {
// Allocate Structure Data
SceNetAdhocctlScanInfo * group = (SceNetAdhocctlScanInfo *)malloc(sizeof(SceNetAdhocctlScanInfo));
// Allocated Structure Data
if (group != NULL) {
// Clear Memory, should this be done only when allocating new group?
memset(group, 0, sizeof(SceNetAdhocctlScanInfo));
// Set group parameters
// Since 0 is not a valid active channel we fake the channel for Automatic Channel (JPCSP use 11 as default). Ridge Racer 2 will ignore any groups with channel 0 or that doesn't matched with channel value returned from sceUtilityGetSystemParamInt (which mean sceUtilityGetSystemParamInt must not return channel 0 when connected to a network?)
group->channel = parameter.channel; //(parameter.channel == PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC) ? defaultWlanChannel : parameter.channel;
group->mode = ADHOCCTL_MODE_ADHOC; //adhocctlCurrentMode;
// Link to existing Groups
group->next = newnetworks;
// Copy Group Name
group->group_name = packet->group;
// Set Group Host
group->bssid.mac_addr = packet->mac;
// Set group parameters
// Since 0 is not a valid active channel we fake the channel for Automatic Channel (JPCSP use 11 as default). Ridge Racer 2 will ignore any groups with channel 0 or that doesn't matched with channel value returned from sceUtilityGetSystemParamInt (which mean sceUtilityGetSystemParamInt must not return channel 0 when connected to a network?)
group->channel = parameter.channel; //(parameter.channel == PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC) ? defaultWlanChannel : parameter.channel;
group->mode = ADHOCCTL_MODE_ADHOC; //adhocctlCurrentMode;
// Link into Group List
newnetworks = group;
}
// Link into Group List
newnetworks = group;
}
// Multithreading Unlock
@@ -1443,10 +1433,12 @@ int friendFinder(){
// Log Scan Completion
INFO_LOG(SCENET, "FriendFinder: Incoming Scan complete response...");
// Reset current networks to prevent leaving host to be listed again
// Reset current networks to prevent disbanded host to be listed again
peerlock.lock();
freeGroupsRecursive(networks);
networks = newnetworks;
if (networks != newnetworks) {
freeGroupsRecursive(networks);
networks = newnetworks;
}
newnetworks = NULL;
peerlock.unlock();
+2 -2
View File
@@ -964,7 +964,7 @@ void deleteFriendByIP(uint32_t ip);
*/
void freeFriendsRecursive(SceNetAdhocctlPeerInfo * node, int32_t* count);
void timeoutFriendsRecursive(SceNetAdhocctlPeerInfo* node, int32_t* count);
void timeoutFriendsRecursive(SceNetAdhocctlPeerInfo * node, int32_t* count);
/**
* Friend Finder Thread (Receives Peer Information)
@@ -1094,7 +1094,7 @@ s32_le countChildren(SceNetAdhocMatchingContext * context, const bool excludeTim
* @param context Matching Context Pointer
* @param peer Internal Peer Reference
*/
void deletePeer(SceNetAdhocMatchingContext * context, SceNetAdhocMatchingMemberInternal * peer);
void deletePeer(SceNetAdhocMatchingContext * context, SceNetAdhocMatchingMemberInternal *& peer);
/**
* Find Peer in Context by MAC
+1
View File
@@ -26,6 +26,7 @@
#include <string>
#include <algorithm>
#include <Core/System.h>
#include <Core/Host.h>
#include <Core/ELF/ParamSFO.h>