mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Don't launch the friend finder thread if the adhoc network init fails.
Adds a flag for network success but doesn't check it anywhere yet..
This commit is contained in:
parent
58238bc7ed
commit
101fe5c481
3 changed files with 18 additions and 25 deletions
|
@ -1406,14 +1406,6 @@ int getPTPSocketCount(void) {
|
||||||
|
|
||||||
int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){
|
int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){
|
||||||
int iResult = 0;
|
int iResult = 0;
|
||||||
/*#ifdef _MSC_VER
|
|
||||||
WSADATA data;
|
|
||||||
iResult = WSAStartup(MAKEWORD(2,2),&data); // Might be better to call WSAStartup/WSACleanup from sceNetInit/sceNetTerm isn't? since it's the first/last network function being used, even better to put it in __NetInit/__NetShutdown as it's only called once
|
|
||||||
if(iResult != NOERROR){
|
|
||||||
ERROR_LOG(SCENET, "WSA failed");
|
|
||||||
return iResult;
|
|
||||||
}
|
|
||||||
#endif*/
|
|
||||||
metasocket = (int)INVALID_SOCKET;
|
metasocket = (int)INVALID_SOCKET;
|
||||||
metasocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
metasocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
if (metasocket == INVALID_SOCKET){
|
if (metasocket == INVALID_SOCKET){
|
||||||
|
|
|
@ -55,7 +55,7 @@ void __NetInit() {
|
||||||
//net::Init();
|
//net::Init();
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
WSADATA data;
|
WSADATA data;
|
||||||
int iResult = WSAStartup(MAKEWORD(2, 2), &data); // Might be better to call WSAStartup/WSACleanup from sceNetInit/sceNetTerm isn't? since it's the first/last network function being used, even better to put it in __NetInit/__NetShutdown as it's only called once
|
int iResult = WSAStartup(MAKEWORD(2, 2), &data);
|
||||||
if (iResult != NOERROR){
|
if (iResult != NOERROR){
|
||||||
ERROR_LOG(SCENET, "WSA Failed");
|
ERROR_LOG(SCENET, "WSA Failed");
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ void __NetShutdown() {
|
||||||
__ResetInitNetLib();
|
__ResetInitNetLib();
|
||||||
//net::Shutdown();
|
//net::Shutdown();
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
WSACleanup(); // Might be better to call WSAStartup/WSACleanup from sceNetInit/sceNetTerm isn't? since it's the first/last network function being used, even better to put it in __NetInit/__NetShutdown as it's only called once
|
WSACleanup();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,11 @@
|
||||||
#include "Core/HLE/proAdhocServer.h"
|
#include "Core/HLE/proAdhocServer.h"
|
||||||
|
|
||||||
// shared in sceNetAdhoc.h since it need to be used from sceNet.cpp also
|
// shared in sceNetAdhoc.h since it need to be used from sceNet.cpp also
|
||||||
|
// TODO: Make accessor functions instead, and throw all this state in a struct.
|
||||||
bool netAdhocInited;
|
bool netAdhocInited;
|
||||||
bool netAdhocctlInited;
|
bool netAdhocctlInited;
|
||||||
|
bool networkInited;
|
||||||
|
|
||||||
static bool netAdhocMatchingInited;
|
static bool netAdhocMatchingInited;
|
||||||
int netAdhocMatchingStarted = 0;
|
int netAdhocMatchingStarted = 0;
|
||||||
|
|
||||||
|
@ -225,25 +228,23 @@ u32 sceNetAdhocInit() {
|
||||||
|
|
||||||
static u32 sceNetAdhocctlInit(int stackSize, int prio, u32 productAddr) {
|
static u32 sceNetAdhocctlInit(int stackSize, int prio, u32 productAddr) {
|
||||||
INFO_LOG(SCENET, "sceNetAdhocctlInit(%i, %i, %08x) at %08x", stackSize, prio, productAddr, currentMIPS->pc);
|
INFO_LOG(SCENET, "sceNetAdhocctlInit(%i, %i, %08x) at %08x", stackSize, prio, productAddr, currentMIPS->pc);
|
||||||
/*if (!g_Config.bEnableWlan) {
|
|
||||||
// Pretend success but don't actually start the friendfinder thread and stuff.
|
|
||||||
// Dunno if this is the way to go...
|
|
||||||
netAdhocctlInited = true;
|
|
||||||
return 0; //Faking success to prevent GTA:VCS stuck in Host/Join screen
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (netAdhocctlInited) return ERROR_NET_ADHOCCTL_ALREADY_INITIALIZED;
|
if (netAdhocctlInited)
|
||||||
|
return ERROR_NET_ADHOCCTL_ALREADY_INITIALIZED;
|
||||||
if(g_Config.bEnableWlan)
|
|
||||||
{
|
|
||||||
if (initNetwork((SceNetAdhocctlAdhocId *)Memory::GetPointer(productAddr)) != 0) WARN_LOG(SCENET, "sceNetAdhocctlInit: Faking success");
|
|
||||||
|
|
||||||
|
if(g_Config.bEnableWlan) {
|
||||||
|
if (initNetwork((SceNetAdhocctlAdhocId *)Memory::GetPointer(productAddr)) == 0) {
|
||||||
if (!friendFinderRunning) {
|
if (!friendFinderRunning) {
|
||||||
friendFinderRunning = true;
|
friendFinderRunning = true;
|
||||||
friendFinderThread = std::thread(friendFinder);
|
friendFinderThread = std::thread(friendFinder);
|
||||||
}
|
}
|
||||||
|
networkInited = true;
|
||||||
|
} else {
|
||||||
|
WARN_LOG(SCENET, "sceNetAdhocctlInit: Failed to init the network but faking success");
|
||||||
|
networkInited = false; // TODO: What needs to check this? Pretty much everything? Maybe we should just set netAdhocctlInited to false..
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
netAdhocctlInited = true; //needed for cleanup during AdhocctlTerm even when it failed to connect to Adhoc Server (since it's being faked as success)
|
netAdhocctlInited = true; //needed for cleanup during AdhocctlTerm even when it failed to connect to Adhoc Server (since it's being faked as success)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue