diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index eb2dea3fc9..fcdd00dc5c 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -1406,14 +1406,6 @@ int getPTPSocketCount(void) { int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){ 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 = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (metasocket == INVALID_SOCKET){ diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index 530bea25f2..c30310e179 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -55,7 +55,7 @@ void __NetInit() { //net::Init(); #ifdef _MSC_VER 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){ ERROR_LOG(SCENET, "WSA Failed"); } @@ -67,7 +67,7 @@ void __NetShutdown() { __ResetInitNetLib(); //net::Shutdown(); #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 } diff --git a/Core/HLE/sceNetAdhoc.cpp b/Core/HLE/sceNetAdhoc.cpp index 73334dde31..02387cc6cd 100644 --- a/Core/HLE/sceNetAdhoc.cpp +++ b/Core/HLE/sceNetAdhoc.cpp @@ -38,8 +38,11 @@ #include "Core/HLE/proAdhocServer.h" // 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 netAdhocctlInited; +bool networkInited; + static bool netAdhocMatchingInited; int netAdhocMatchingStarted = 0; @@ -225,25 +228,23 @@ u32 sceNetAdhocInit() { static u32 sceNetAdhocctlInit(int stackSize, int prio, u32 productAddr) { 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 (!friendFinderRunning) { - friendFinderRunning = true; - friendFinderThread = std::thread(friendFinder); + if(g_Config.bEnableWlan) { + if (initNetwork((SceNetAdhocctlAdhocId *)Memory::GetPointer(productAddr)) == 0) { + if (!friendFinderRunning) { + friendFinderRunning = true; + 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) return 0; }