added 360 support and fixed vita again again

This commit is contained in:
552eden
2026-08-13 00:04:53 +03:00
parent 92891de261
commit 1005e64629
17 changed files with 591 additions and 208 deletions
@@ -88,6 +88,25 @@ bool NetworkSocketLayer::Initialize()
}
#if defined _WINDOWS64 || defined _XBOX
#if defined _XBOX
// XNet has to be up before Winsock, and it has to be up insecure.
static bool s_xnetStarted = false;
if (!s_xnetStarted)
{
XNetStartupParams xnsp;
memset(&xnsp, 0, sizeof(xnsp));
xnsp.cfgSizeOfStruct = sizeof(XNetStartupParams);
xnsp.cfgFlags = XNET_STARTUP_BYPASS_SECURITY;
int xnetResult = XNetStartup(&xnsp);
if (xnetResult != 0)
{
app.DebugPrintf("XNetStartup failed: %d\n", xnetResult);
return false;
}
s_xnetStarted = true;
}
#endif
WSADATA wsaData;
int result = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (result != 0)
@@ -486,31 +505,43 @@ bool NetworkSocketLayer::JoinGame(const char *ip, int port)
s_hostConnectionSocket = INVALID_SOCKET;
}
XNDNS *pDns = NULL;
int iResult = XNetDnsLookup(ip, NULL, &pDns);
if (iResult != 0 || pDns == NULL)
{
app.DebugPrintf("XNetDnsLookup failed for %s - %d\n", ip, iResult);
return false;
}
while (pDns->iStatus == WSAEINPROGRESS)
{
Sleep(10);
}
if (pDns->iStatus != 0 || pDns->cina == 0)
{
app.DebugPrintf("pDns->iStatus failed for %s - %d\n", ip, iResult);
XNetDnsRelease(pDns);
return false;
}
int iResult;
struct sockaddr_in addr = {};
addr.sin_family = AF_INET;
addr.sin_port = htons((WORD)port);
addr.sin_addr = pDns->aina[0];
XNetDnsRelease(pDns);
// The discovery broadcast always hands an ip and a LAN has no reason to run a DNS server, so only fall back to XNetDnsLookup for actual host names.
unsigned long literalAddr = inet_addr(ip);
if (literalAddr != INADDR_NONE)
{
addr.sin_addr.s_addr = literalAddr;
}
else
{
XNDNS *pDns = NULL;
iResult = XNetDnsLookup(ip, NULL, &pDns);
if (iResult != 0 || pDns == NULL)
{
app.DebugPrintf("XNetDnsLookup failed for %s - %d\n", ip, iResult);
return false;
}
while (pDns->iStatus == WSAEINPROGRESS)
{
Sleep(10);
}
if (pDns->iStatus != 0 || pDns->cina == 0)
{
app.DebugPrintf("pDns->iStatus failed for %s - %d\n", ip, pDns->iStatus);
XNetDnsRelease(pDns);
return false;
}
addr.sin_addr = pDns->aina[0];
XNetDnsRelease(pDns);
}
bool connected = false;
BYTE assignedSmallId = 0;
@@ -1224,7 +1255,7 @@ void NetworkSocketLayer::StopAdvertising()
{
s_advertising = false;
#if defined _WINDOWS64
#if defined _WINDOWS64 || defined _XBOX
if (s_advertiseSock != INVALID_SOCKET)
{
closesocket(s_advertiseSock);
@@ -1507,7 +1538,7 @@ int NetworkSocketLayer::DiscoveryThreadProc(LPVOID param)
(struct sockaddr *)&senderAddr, &senderLen);
#endif
#ifdef _WINDOWS64
#if defined _WINDOWS64 || defined _XBOX
if (recvLen == SOCKET_ERROR)
{
continue;