added 360 support and fixed vita again again

This commit is contained in:
552eden committed 2026-08-13 00:04:53 +03:00
1 parent 92891de261
commit 1005e64629
17 files changed
+591 -208

No files matched your search

@@ -1,4 +1,5 @@
#include "stdafx.h"
#include "..\LivePrivileges.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\AABB.h"
#include "..\..\..\Minecraft.World\Vec3.h"
@@ -794,7 +795,7 @@ int CGameNetworkManager::JoinFromInvite_SignInReturned(void *pParam,bool bContin
if(ProfileManager.IsSignedIn(index) )
{
++joiningUsers;
if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true;
if( !Live_AllowedToPlayMultiplayer(index) ) noPrivileges = true;
localUsersMask |= GetLocalPlayerMask( index );
}
}
@@ -1743,7 +1744,7 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO *
if(index==userIndex || pMinecraft->localplayers[index]!=NULL )
{
++joiningUsers;
if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true;
if( !Live_AllowedToPlayMultiplayer(index) ) noPrivileges = true;
localUsersMask |= GetLocalPlayerMask( index );
}
}
@@ -1757,7 +1758,7 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO *
#if defined(__PS3__) || defined(__PSVITA__)
ProfileManager.GetChatAndContentRestrictions(userIndex,false,&noUGC,&bContentRestricted,NULL);
#else
ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed);
Live_AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed);
if(!pccAllowed && !pccFriendsAllowed) noUGC = true;
#endif
@@ -1898,7 +1899,7 @@ void CGameNetworkManager::HandleInviteWhenInMenus( int userIndex, const INVITE_I
if(!app.IsLocalMultiplayerAvailable())
#endif
{
bool noPrivileges=!ProfileManager.AllowedToPlayMultiplayer(userIndex);
bool noPrivileges=!Live_AllowedToPlayMultiplayer(userIndex);
if(noPrivileges)
{
@@ -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;
@@ -379,6 +379,17 @@ void CPlatformNetworkManagerStub::HostGame(int localUsersMask, bool bOnlineGame,
if (!NetworkSocketLayer::IsActive())
NetworkSocketLayer::HostGame(port);
//Fall back to the local name.
if (IQNet::m_player[0].m_gamertag[0] == 0)
{
Minecraft *pMinecraft = Minecraft::GetInstance();
if (pMinecraft != NULL && pMinecraft->user != NULL)
{
wcsncpy(IQNet::m_player[0].m_gamertag, pMinecraft->user->name.c_str(), 31);
IQNet::m_player[0].m_gamertag[31] = L'\0';
}
}
const wchar_t *hostName = IQNet::m_player[0].m_gamertag;
unsigned int settings = app.GetGameHostOption(eGameHostOption_All);
NetworkSocketLayer::StartAdvertising(port, hostName, settings, 0, 0, MINECRAFT_NET_VERSION);
@@ -731,19 +742,47 @@ void CPlatformNetworkManagerStub::SearchForGames()
}
}
for (size_t i = 0; i < friendsSessions[0].size(); i++)
delete friendsSessions[0][i];
friendsSessions[0].clear();
std::vector<FriendSessionInfo *> updatedSessions;
for (size_t i = 0; i < lanSessions.size(); i++)
{
FriendSessionInfo *info = new FriendSessionInfo();
size_t nameLen = wcslen(lanSessions[i].hostName);
info->displayLabel = new wchar_t[nameLen + 1];
wcsncpy(info->displayLabel, lanSessions[i].hostName, nameLen);
info->displayLabel[nameLen] = L'\0';
info->displayLabelLength = (unsigned char)nameLen;
info->displayLabelViewableStartIndex = 0;
#if defined(__ORBIS__) || defined(__PSVITA__)
SceNetInAddr ip_addr = {};
sceNetInetPton(SCE_NET_AF_INET, lanSessions[i].hostIP, &ip_addr);
SessionID sessionId = (ULONGLONG)((uint64_t)ip_addr.s_addr | ((uint64_t)lanSessions[i].hostPort << 32));
#else
SessionID sessionId = (ULONGLONG)((unsigned __int64)inet_addr(lanSessions[i].hostIP) | ((unsigned __int64)lanSessions[i].hostPort << 32));
#endif
FriendSessionInfo *info = NULL;
for (size_t j = 0; j < friendsSessions[0].size(); j++)
{
if (friendsSessions[0][j] != NULL && friendsSessions[0][j]->sessionId == sessionId)
{
info = friendsSessions[0][j];
friendsSessions[0][j] = NULL;
break;
}
}
if (info == NULL)
info = new FriendSessionInfo();
info->sessionId = sessionId;
// Only reallocate the label when the name actually changed, so it stays put as well
if (info->displayLabel == NULL || wcscmp(info->displayLabel, lanSessions[i].hostName) != 0)
{
size_t nameLen = wcslen(lanSessions[i].hostName);
wchar_t *newLabel = new wchar_t[nameLen + 1];
wcsncpy(newLabel, lanSessions[i].hostName, nameLen);
newLabel[nameLen] = L'\0';
delete [] info->displayLabel;
info->displayLabel = newLabel;
info->displayLabelLength = (unsigned char)nameLen;
info->displayLabelViewableStartIndex = 0;
}
info->data.netVersion = lanSessions[i].netVersion;
info->data.m_uiGameHostSettings = lanSessions[i].gameHostSettings;
@@ -770,16 +809,14 @@ void CPlatformNetworkManagerStub::SearchForGames()
}
}
#if defined(__ORBIS__) || defined(__PSVITA__)
SceNetInAddr ip_addr = {};
sceNetInetPton(SCE_NET_AF_INET, lanSessions[i].hostIP, &ip_addr);
info->sessionId = (ULONGLONG)((uint64_t)ip_addr.s_addr | ((uint64_t)lanSessions[i].hostPort << 32));
#else
info->sessionId = (ULONGLONG)((unsigned __int64)inet_addr(lanSessions[i].hostIP) | ((unsigned __int64)lanSessions[i].hostPort << 32));
#endif
friendsSessions[0].push_back(info);
updatedSessions.push_back(info);
}
for (size_t j = 0; j < friendsSessions[0].size(); j++)
delete friendsSessions[0][j];
friendsSessions[0] = updatedSessions;
m_searchResultsCount[0] = (int)friendsSessions[0].size();
if (m_SessionsUpdatedCallback != NULL)
@@ -820,6 +857,7 @@ bool CPlatformNetworkManagerStub::GetGameSessionInfo(int iPad, SessionID session
return true;
}
}
return false;
}
void CPlatformNetworkManagerStub::SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam )