forked from cafeberry/cafeberry
psvita networking (Experimental)
This commit is contained in:
@@ -6885,12 +6885,12 @@ HRESULT CMinecraftApp::RegisterDLCData(WCHAR *pType, WCHAR *pBannerName, int iGe
|
||||
// ignore the names if we don't recognize them
|
||||
if(pBannerName!=L"")
|
||||
{
|
||||
wcsncpy_s( pDLCData->wchBanner, pBannerName, MAX_BANNERNAME_SIZE);
|
||||
wcsncpy_s( pDLCData->wchBanner, MAX_BANNERNAME_SIZE, pBannerName, MAX_BANNERNAME_SIZE);
|
||||
}
|
||||
|
||||
if(pDataFile[0]!=0)
|
||||
{
|
||||
wcsncpy_s( pDLCData->wchDataFile, pDataFile, MAX_BANNERNAME_SIZE);
|
||||
wcsncpy_s( pDLCData->wchDataFile, MAX_BANNERNAME_SIZE, pDataFile, MAX_BANNERNAME_SIZE);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1847,7 +1847,7 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO *
|
||||
// joinData->pInviteInfo = pInviteInfo;
|
||||
|
||||
// tell the app to process this
|
||||
#ifdef __PSVITA__
|
||||
#if !defined(DISABLE_PSN) && defined(__PSVITA__)
|
||||
if(((CPlatformNetworkManagerSony*)s_pPlatformNetworkManager)->checkValidInviteData(pInviteInfo))
|
||||
#endif
|
||||
{
|
||||
@@ -2090,7 +2090,7 @@ void CGameNetworkManager::FakeLocalPlayerJoined()
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __PSVITA__
|
||||
#if !defined(DISABLE_PSN) && defined(__PSVITA__)
|
||||
bool CGameNetworkManager::usingAdhocMode()
|
||||
{
|
||||
return ((CPlatformNetworkManagerSony*)s_pPlatformNetworkManager)->usingAdhocMode();
|
||||
@@ -2105,5 +2105,17 @@ void CGameNetworkManager::startAdhocMatching()
|
||||
{
|
||||
((CPlatformNetworkManagerSony*)s_pPlatformNetworkManager)->startAdhocMatching();
|
||||
}
|
||||
#else
|
||||
bool CGameNetworkManager::usingAdhocMode()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void CGameNetworkManager::setAdhocMode(bool bAdhoc)
|
||||
{
|
||||
}
|
||||
|
||||
void CGameNetworkManager::startAdhocMatching()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4,26 +4,23 @@
|
||||
#include "..\..\Common\Network\PlatformNetworkManager.h"
|
||||
#include "..\..\..\Minecraft.World\Socket.h"
|
||||
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
SOCKET NetworkSocketLayer::s_listenSocket = INVALID_SOCKET;
|
||||
SOCKET NetworkSocketLayer::s_hostConnectionSocket = INVALID_SOCKET;
|
||||
SOCKET NetworkSocketLayer::s_advertiseSock = INVALID_SOCKET;
|
||||
SOCKET NetworkSocketLayer::s_discoverySock = INVALID_SOCKET;
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
SOCKET NetworkSocketLayer::s_listenSocket = -1;
|
||||
SOCKET NetworkSocketLayer::s_hostConnectionSocket = -1;
|
||||
SOCKET NetworkSocketLayer::s_advertiseSock = -1;
|
||||
SOCKET NetworkSocketLayer::s_discoverySock = -1;
|
||||
|
||||
#if defined __PS3__
|
||||
int closesocket(int s) { return socketclose(s); };
|
||||
#if defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
void WSACleanup() {};
|
||||
#endif
|
||||
|
||||
#ifdef __PS3__
|
||||
void terminate_networking() { cellNetCtlTerm(); sys_net_finalize_network(); };
|
||||
#elif defined __ORBIS__
|
||||
int closesocket(int s) { return sceNetSocketClose(s); };
|
||||
int socketclose(int s) { return sceNetSocketClose(s); };
|
||||
#else
|
||||
void terminate_networking() {};
|
||||
#endif
|
||||
void WSACleanup() {};
|
||||
|
||||
#if defined __PSVITA__
|
||||
int socket(int family, int type, int protocol) { return sceNetSocket(NULL, family, type, protocol); };
|
||||
#endif
|
||||
|
||||
C4JThread* NetworkSocketLayer::s_acceptThread = NULL;
|
||||
@@ -89,6 +86,19 @@ bool NetworkSocketLayer::Initialize()
|
||||
sys_net_finalize_network();
|
||||
return false;
|
||||
}
|
||||
#elif defined __PSVITA__
|
||||
SceNetInitParam param;
|
||||
static char memory[16 * 1024];
|
||||
|
||||
param.memory = memory;
|
||||
param.size = sizeof(memory);
|
||||
param.flags = 0;
|
||||
|
||||
int result = sceNetInit(¶m);
|
||||
if (result < 0) {
|
||||
app.DebugPrintf("sceNetInit failed: %d\n", result);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
InitializeCriticalSection(&s_sendLock);
|
||||
@@ -125,7 +135,7 @@ void NetworkSocketLayer::Shutdown()
|
||||
closesocket(s_hostConnectionSocket);
|
||||
s_hostConnectionSocket = INVALID_SOCKET;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (s_listenSocket >= 0)
|
||||
{
|
||||
socketclose(s_listenSocket);
|
||||
@@ -146,7 +156,7 @@ void NetworkSocketLayer::Shutdown()
|
||||
s_connections[i].active = false;
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
if (s_connections[i].tcpSocket != INVALID_SOCKET)
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (s_connections[i].tcpSocket >= 0)
|
||||
#endif
|
||||
{
|
||||
@@ -238,8 +248,12 @@ bool NetworkSocketLayer::HostGame(int port)
|
||||
app.DebugPrintf("socket() failed: %d\n", WSAGetLastError());
|
||||
return false;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
#ifdef __PSVITA__
|
||||
SceNetSockaddrIn addr = {};
|
||||
#else
|
||||
struct sockaddr_in addr = {};
|
||||
#endif
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
addr.sin_port = htons((uint16_t)port);
|
||||
@@ -292,8 +306,12 @@ bool NetworkSocketLayer::HostGame(int port)
|
||||
s_listenSocket = INVALID_SOCKET;
|
||||
return false;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
#ifdef __PSVITA__
|
||||
iResult = ::bind(s_listenSocket, (const sockaddr*)&addr, sizeof(addr));
|
||||
#else
|
||||
iResult = ::bind(s_listenSocket, (struct sockaddr*)&addr, sizeof(addr));
|
||||
#endif
|
||||
if (iResult < 0)
|
||||
{
|
||||
app.DebugPrintf("bind() failed: %d\n", iResult);
|
||||
@@ -546,14 +564,18 @@ bool NetworkSocketLayer::JoinGame(const char *ip, int port)
|
||||
connected = true;
|
||||
break;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (s_hostConnectionSocket != -1)
|
||||
{
|
||||
socketclose(s_hostConnectionSocket);
|
||||
s_hostConnectionSocket = -1;
|
||||
}
|
||||
|
||||
#ifdef __PSVITA__
|
||||
SceNetSockaddrIn addr = {};
|
||||
#else
|
||||
struct sockaddr_in addr = {};
|
||||
#endif
|
||||
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons((uint16_t)port);
|
||||
@@ -590,40 +612,47 @@ bool NetworkSocketLayer::JoinGame(const char *ip, int port)
|
||||
setsockopt(s_hostConnectionSocket, IPPROTO_TCP, TCP_NODELAY, (const char *)&noDelay, sizeof(noDelay));
|
||||
|
||||
int nonBlocking = 1;
|
||||
#ifdef __PS3__
|
||||
setsockopt(s_hostConnectionSocket, SOL_SOCKET, SO_NBIO, &nonBlocking, sizeof(nonBlocking));
|
||||
#elif defined(__ORBIS__)
|
||||
setsockopt(s_hostConnectionSocket, SOL_SOCKET, SCE_NET_SO_NBIO, &nonBlocking, sizeof(nonBlocking));
|
||||
#endif
|
||||
|
||||
#ifdef __PSVITA__
|
||||
iResult = connect(s_hostConnectionSocket, (const SceNetSockaddr*)&addr, sizeof(addr));
|
||||
#else
|
||||
iResult = connect(s_hostConnectionSocket, (struct sockaddr*)&addr, sizeof(addr));
|
||||
#endif
|
||||
if (iResult < 0)
|
||||
{
|
||||
#if defined(__PS3__)
|
||||
int err = sys_net_errno;
|
||||
if (err == SYS_NET_EINPROGRESS)
|
||||
{
|
||||
#elif defined(__ORBIS__)
|
||||
int err = sce_net_errno;
|
||||
if (err == SCE_NET_EINPROGRESS)
|
||||
{
|
||||
#endif
|
||||
#ifndef __PSVITA__
|
||||
fd_set writeFds, exceptFds;
|
||||
FD_ZERO(&writeFds);
|
||||
FD_ZERO(&exceptFds);
|
||||
FD_SET(s_hostConnectionSocket, &writeFds);
|
||||
FD_SET(s_hostConnectionSocket, &exceptFds);
|
||||
|
||||
struct timeval tv;
|
||||
tv.tv_sec = connectTimeoutMs / 1000;
|
||||
tv.tv_usec = (connectTimeoutMs % 1000) * 1000;
|
||||
|
||||
#if defined(__PS3__)
|
||||
int selectResult = socketselect(s_hostConnectionSocket + 1, NULL, &writeFds, &exceptFds, &tv);
|
||||
#elif defined(__ORBIS__)
|
||||
int selectResult = select(s_hostConnectionSocket + 1, NULL, &writeFds, &exceptFds, &tv);
|
||||
#else
|
||||
SceNetId eid = sceNetEpollCreate(NULL, 0);
|
||||
SceNetEpollEvent ev = {};
|
||||
ev.events = SCE_NET_EPOLLOUT;
|
||||
ev.data.fd = s_hostConnectionSocket;
|
||||
sceNetEpollControl(eid, SCE_NET_EPOLL_CTL_ADD, s_hostConnectionSocket, &ev);
|
||||
int timeoutUsec = connectTimeoutMs * 1000;
|
||||
SceNetEpollEvent outEvents[1];
|
||||
int selectResult = sceNetEpollWait(eid, outEvents, 1, timeoutUsec);
|
||||
sceNetEpollControl(eid, SCE_NET_EPOLL_CTL_DEL, s_hostConnectionSocket, NULL);
|
||||
sceNetEpollDestroy(eid);
|
||||
#endif
|
||||
|
||||
#ifndef __PSVITA__
|
||||
int selectResult = socketselect(s_hostConnectionSocket + 1, NULL, &writeFds, &exceptFds, &tv);
|
||||
if (selectResult <= 0 || FD_ISSET(s_hostConnectionSocket, &exceptFds))
|
||||
#else
|
||||
if (selectResult <= 0 || (selectResult > 0) &&
|
||||
(outEvents[0].events & (SCE_NET_EPOLLERR | SCE_NET_EPOLLHUP)))
|
||||
#endif
|
||||
{
|
||||
app.DebugPrintf("connect() to %s:%d timed out or failed (attempt %d/%d)\n", ip, port, attempt + 1, maxAttempts);
|
||||
closesocket(s_hostConnectionSocket);
|
||||
@@ -654,7 +683,7 @@ bool NetworkSocketLayer::JoinGame(const char *ip, int port)
|
||||
int blocking = 0;
|
||||
#ifdef __PS3__
|
||||
setsockopt(s_hostConnectionSocket, SOL_SOCKET, SO_NBIO, &blocking, sizeof(blocking));
|
||||
#elif defined(__ORBIS__)
|
||||
#elif defined(__ORBIS__) || defined __PSVITA__
|
||||
setsockopt(s_hostConnectionSocket, SOL_SOCKET, SCE_NET_SO_NBIO, &blocking, sizeof(blocking));
|
||||
#endif
|
||||
|
||||
@@ -708,7 +737,7 @@ bool NetworkSocketLayer::SendOnSocket(SOCKET sock, const void *data, int dataSiz
|
||||
{
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
if (sock == INVALID_SOCKET || dataSize <= 0) return false;
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (sock < 0 || dataSize <= 0) return false;
|
||||
#endif
|
||||
|
||||
@@ -727,7 +756,7 @@ bool NetworkSocketLayer::SendOnSocket(SOCKET sock, const void *data, int dataSiz
|
||||
int sent = send(sock, (const char *)header + totalSent, toSend - totalSent, 0);
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
if (sent == SOCKET_ERROR || sent == 0)
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (sent < 0 || sent == 0)
|
||||
#endif
|
||||
{
|
||||
@@ -744,7 +773,7 @@ bool NetworkSocketLayer::SendOnSocket(SOCKET sock, const void *data, int dataSiz
|
||||
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
if (sent == SOCKET_ERROR || sent == 0)
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (sent < 0 || sent == 0)
|
||||
#endif
|
||||
{
|
||||
@@ -767,7 +796,7 @@ bool NetworkSocketLayer::SendToSmallId(BYTE targetSmallId, const void *data, int
|
||||
SOCKET sock = GetSocketForSmallId(targetSmallId);
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
if (sock == INVALID_SOCKET) return false;
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (sock < 0) return false;
|
||||
#endif
|
||||
return SendOnSocket(sock, data, dataSize);
|
||||
@@ -793,7 +822,7 @@ SOCKET NetworkSocketLayer::GetSocketForSmallId(BYTE smallId)
|
||||
LeaveCriticalSection(&s_connectionsLock);
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
return INVALID_SOCKET;
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
@@ -835,7 +864,11 @@ int NetworkSocketLayer::AcceptThreadProc(LPVOID param)
|
||||
{
|
||||
while (s_active)
|
||||
{
|
||||
#ifdef __PSVITA__
|
||||
SOCKET clientSocket = accept(s_listenSocket, (SceNetSockaddr *)NULL, NULL);
|
||||
#else
|
||||
SOCKET clientSocket = accept(s_listenSocket, NULL, NULL);
|
||||
#endif
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
if (clientSocket == INVALID_SOCKET)
|
||||
{
|
||||
@@ -843,7 +876,7 @@ int NetworkSocketLayer::AcceptThreadProc(LPVOID param)
|
||||
app.DebugPrintf("accept() failed: %d\n", WSAGetLastError());
|
||||
break;
|
||||
}
|
||||
#elif __PS3__ || defined __ORBIS__
|
||||
#elif __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (clientSocket < 0)
|
||||
{
|
||||
if (s_active)
|
||||
@@ -1050,7 +1083,7 @@ int NetworkSocketLayer::ClientRecvThreadProc(LPVOID param)
|
||||
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
while (s_active && s_hostConnectionSocket != INVALID_SOCKET)
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
while (s_active && s_hostConnectionSocket >= 0)
|
||||
#endif
|
||||
{
|
||||
@@ -1115,7 +1148,7 @@ bool NetworkSocketLayer::StartAdvertising(int gamePort, const wchar_t *hostName,
|
||||
app.DebugPrintf("Win64 LAN: Failed to create advertise socket: %d\n", WSAGetLastError());
|
||||
return false;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (s_advertiseSock < 0)
|
||||
{
|
||||
app.DebugPrintf("PS3 LAN: Failed to create advertise socket: %d\n", s_advertiseSock);
|
||||
@@ -1143,7 +1176,7 @@ void NetworkSocketLayer::StopAdvertising()
|
||||
closesocket(s_advertiseSock);
|
||||
s_advertiseSock = INVALID_SOCKET;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (s_advertiseSock >= 0)
|
||||
{
|
||||
closesocket(s_advertiseSock);
|
||||
@@ -1187,7 +1220,11 @@ void NetworkSocketLayer::UpdateAdvertiseJoinable(bool joinable)
|
||||
|
||||
int NetworkSocketLayer::AdvertiseThreadProc(LPVOID param)
|
||||
{
|
||||
#ifdef __PSVITA__
|
||||
SceNetSockaddrIn broadcastAddr;
|
||||
#else
|
||||
struct sockaddr_in broadcastAddr;
|
||||
#endif
|
||||
memset(&broadcastAddr, 0, sizeof(broadcastAddr));
|
||||
broadcastAddr.sin_family = AF_INET;
|
||||
broadcastAddr.sin_port = htons(NETWORK_LAN_DISCOVERY_PORT);
|
||||
@@ -1205,15 +1242,20 @@ int NetworkSocketLayer::AdvertiseThreadProc(LPVOID param)
|
||||
data.gameHostSettings = htonl(data.gameHostSettings);
|
||||
data.texturePackParentId = htonl(data.texturePackParentId);
|
||||
|
||||
#ifdef __PSVITA__
|
||||
int sent = sendto(s_advertiseSock, (const char *)&data, sizeof(data), 0,
|
||||
(const sockaddr *)&broadcastAddr, sizeof(broadcastAddr));
|
||||
#else
|
||||
int sent = sendto(s_advertiseSock, (const char *)&data, sizeof(data), 0,
|
||||
(struct sockaddr *)&broadcastAddr, sizeof(broadcastAddr));
|
||||
#endif
|
||||
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
if (sent == SOCKET_ERROR && s_advertising)
|
||||
{
|
||||
app.DebugPrintf("Win64 LAN: Broadcast sendto failed: %d\n", WSAGetLastError());
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (sent < 0 && s_advertising)
|
||||
{
|
||||
app.DebugPrintf("PS3 LAN: Broadcast sendto failed: %d\n", sent);
|
||||
@@ -1238,7 +1280,7 @@ bool NetworkSocketLayer::StartDiscovery()
|
||||
app.DebugPrintf("Win64 LAN: Failed to create discovery socket: %d\n", WSAGetLastError());
|
||||
return false;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
app.DebugPrintf("Discovery socket: %d\n", s_discoverySock);
|
||||
if (s_discoverySock < 0)
|
||||
{
|
||||
@@ -1250,8 +1292,12 @@ bool NetworkSocketLayer::StartDiscovery()
|
||||
|
||||
BOOL reuseAddr = TRUE;
|
||||
setsockopt(s_discoverySock, SOL_SOCKET, SO_REUSEADDR, (const char *)&reuseAddr, sizeof(reuseAddr));
|
||||
|
||||
|
||||
#ifdef __PSVITA__
|
||||
SceNetSockaddrIn bindAddr;
|
||||
#else
|
||||
struct sockaddr_in bindAddr;
|
||||
#endif
|
||||
memset(&bindAddr, 0, sizeof(bindAddr));
|
||||
bindAddr.sin_family = AF_INET;
|
||||
bindAddr.sin_port = htons(NETWORK_LAN_DISCOVERY_PORT);
|
||||
@@ -1265,14 +1311,15 @@ bool NetworkSocketLayer::StartDiscovery()
|
||||
s_discoverySock = INVALID_SOCKET;
|
||||
return false;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
#ifdef __PSVITA__
|
||||
if (::bind(s_discoverySock, (const sockaddr *)&bindAddr, sizeof(bindAddr)) < 0)
|
||||
{
|
||||
#else
|
||||
if (::bind(s_discoverySock, (struct sockaddr *)&bindAddr, sizeof(bindAddr)) < 0)
|
||||
{
|
||||
#if defined(__PS3__)
|
||||
app.DebugPrintf("PS3 LAN: Discovery bind failed: %d\n", sys_net_errno);
|
||||
#elif defined(__ORBIS__)
|
||||
app.DebugPrintf("PS3 LAN: Discovery bind failed: %d\n", sce_net_errno);
|
||||
#endif
|
||||
app.DebugPrintf("PS3 LAN: Discovery bind failed: %d\n", sys_net_errno);
|
||||
socketclose(s_discoverySock);
|
||||
s_discoverySock = -1;
|
||||
return false;
|
||||
@@ -1299,7 +1346,7 @@ void NetworkSocketLayer::StopDiscovery()
|
||||
closesocket(s_discoverySock);
|
||||
s_discoverySock = INVALID_SOCKET;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (s_discoverySock >= 0)
|
||||
{
|
||||
socketclose(s_discoverySock);
|
||||
@@ -1337,22 +1384,31 @@ int NetworkSocketLayer::DiscoveryThreadProc(LPVOID param)
|
||||
|
||||
while (s_discovering)
|
||||
{
|
||||
#ifdef __PSVITA__
|
||||
SceNetSockaddrIn senderAddr;
|
||||
#else
|
||||
struct sockaddr_in senderAddr;
|
||||
#endif
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
int senderLen = sizeof(senderAddr);
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
socklen_t senderLen = sizeof(senderAddr);
|
||||
#endif
|
||||
|
||||
#ifdef __PSVITA__
|
||||
int recvLen = recvfrom(s_discoverySock, recvBuf, sizeof(recvBuf), 0,
|
||||
(sockaddr *)&senderAddr, &senderLen);
|
||||
#else
|
||||
int recvLen = recvfrom(s_discoverySock, recvBuf, sizeof(recvBuf), 0,
|
||||
(struct sockaddr *)&senderAddr, &senderLen);
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (recvLen == SOCKET_ERROR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (recvLen < 0)
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <stdint.h>
|
||||
#include <winsockx.h>
|
||||
#include <xtl.h>
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -16,6 +16,8 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/select.h>
|
||||
#elif defined __PSVITA__
|
||||
#include <net.h>
|
||||
#endif
|
||||
|
||||
#ifdef __PS3__
|
||||
@@ -37,8 +39,63 @@
|
||||
#define NETWORK_LAN_DISCOVERY_PORT 25566
|
||||
#define NETWORK_LAN_BROADCAST_MAGIC 0x4D434C4E
|
||||
|
||||
#if defined __PS3__ || defined __ORBIS__
|
||||
#ifdef __PS3__
|
||||
typedef int SOCKET;
|
||||
#define INVALID_SOCKET -1
|
||||
#define closesocket socketclose
|
||||
#define
|
||||
#elif defined(__ORBIS__)
|
||||
typedef int SOCKET;
|
||||
#define INVALID_SOCKET -1
|
||||
#define SO_NBIO SCE_NET_SO_NBIO
|
||||
#define sys_net_errno sce_net_errno
|
||||
#define SYS_NET_EINPROGRESS SCE_NET_EINPROGRESS
|
||||
#define socketselect select
|
||||
#define closesocket sceNetSocketClose
|
||||
#define socketclose sceNetSocketClose
|
||||
#elif defined(__PSVITA__)
|
||||
typedef SceNetId SOCKET;
|
||||
typedef SceNetSockaddr sockaddr;
|
||||
typedef SceNetSocklen_t socklen_t;
|
||||
|
||||
#define getsockopt sceNetGetsockopt
|
||||
#define setsockopt sceNetSetsockopt
|
||||
#define recv sceNetRecv
|
||||
#define send sceNetSend
|
||||
#define bind sceNetBind
|
||||
#define sendto sceNetSendto
|
||||
#define recvfrom sceNetRecvfrom
|
||||
#define listen sceNetListen
|
||||
#define connect sceNetConnect
|
||||
#define accept sceNetAccept
|
||||
#define closesocket sceNetSocketClose
|
||||
#define socketclose sceNetSocketClose
|
||||
#define inet_ntop sceNetInetNtop
|
||||
|
||||
#define SOL_SOCKET SCE_NET_SOL_SOCKET
|
||||
#define AF_INET SCE_NET_AF_INET
|
||||
#define SOCK_STREAM SCE_NET_SOCK_STREAM
|
||||
#define sys_net_errno sce_net_errno
|
||||
#define SYS_NET_EINPROGRESS SCE_NET_EINPROGRESS
|
||||
|
||||
#define htonl sceNetHtonl
|
||||
#define htons sceNetHtons
|
||||
#define ntohl sceNetNtohl
|
||||
#define ntohs sceNetNtohs
|
||||
|
||||
#define SO_BROADCAST SCE_NET_SO_BROADCAST
|
||||
#define SO_ERROR SCE_NET_SO_ERROR
|
||||
#define SO_RCVTIMEO SCE_NET_SO_RCVTIMEO
|
||||
#define SO_REUSEADDR SCE_NET_SO_REUSEADDR
|
||||
#define SO_NBIO SCE_NET_SO_NBIO
|
||||
#define SOCK_DGRAM SCE_NET_SOCK_DGRAM
|
||||
|
||||
#define INADDR_ANY SCE_NET_INADDR_ANY
|
||||
#define IPPROTO_TCP SCE_NET_IPPROTO_TCP
|
||||
#define IPPROTO_UDP SCE_NET_IPPROTO_UDP
|
||||
#define TCP_NODELAY SCE_NET_TCP_NODELAY
|
||||
#define INADDR_BROADCAST SCE_NET_INADDR_BROADCAST
|
||||
|
||||
#define INVALID_SOCKET -1
|
||||
#endif
|
||||
|
||||
|
||||
@@ -768,7 +768,7 @@ void CPlatformNetworkManagerStub::SearchForGames()
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __ORBIS__
|
||||
#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));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__))
|
||||
#include "..\..\Common\Network\Sony\SQRNetworkManager.h"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -80,7 +80,6 @@ public:
|
||||
bool inviteOnly;
|
||||
};
|
||||
|
||||
|
||||
// Externally exposed state. All internal states are mapped to one of these broader states.
|
||||
typedef enum
|
||||
{
|
||||
@@ -324,4 +323,4 @@ public:
|
||||
virtual void HandleAddLocalPlayerFailed(int idx) = 0;
|
||||
virtual void HandleDisconnect(bool bLostRoomOnly,bool bPSNSignOut=false) = 0;
|
||||
virtual void HandleInviteReceived( int userIndex, const SQRNetworkManager::PresenceSyncInfo *pInviteInfo) = 0;
|
||||
};
|
||||
};
|
||||
@@ -124,7 +124,7 @@ class SQRNetworkPlayer
|
||||
int GetTotalSendQueueMessages();
|
||||
|
||||
|
||||
#ifdef __PSVITA__
|
||||
#if !defined(DISABLE_PSN) && defined(__PSVITA__)
|
||||
void SendInternal_VitaAdhoc(const void *data, unsigned int dataSize, EAdhocDataTag tag = e_dataTag_Normal);
|
||||
void SendMoreInternal_VitaAdhoc();
|
||||
#endif
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "..\..\..\Minecraft.World\LevelType.h"
|
||||
#include "..\..\DLCTexturePack.h"
|
||||
|
||||
#ifdef __PSVITA__
|
||||
#if !defined(DISABLE_PSN) && defined(__PSVITA__)
|
||||
#include "PSVita\Network\SQRNetworkManager_AdHoc_Vita.h"
|
||||
#endif
|
||||
|
||||
@@ -1044,7 +1044,7 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, DWORD
|
||||
#endif
|
||||
|
||||
bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pClass->m_MoreOptionsParams.bOnlineGame;
|
||||
#ifdef __PSVITA__
|
||||
#if !defined DISABLE_PSN && defined __PSVITA__
|
||||
if(CGameNetworkManager::usingAdhocMode())
|
||||
{
|
||||
if(SQRNetworkManager_AdHoc_Vita::GetAdhocStatus())// && pClass->m_MoreOptionsParams.bOnlineGame)
|
||||
|
||||
@@ -201,7 +201,7 @@ void UIScene_DLCMainMenu::tick()
|
||||
{
|
||||
UIScene::tick();
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__))
|
||||
if((m_bCategoriesShown==false) && (app.GetCommerceCategoriesRetrieved()))
|
||||
{
|
||||
// disable the timer display on this menu
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "Common\Network\Sony\SonyHttp.h"
|
||||
#endif
|
||||
|
||||
#ifdef __PSVITA__
|
||||
#if !defined(DISABLE_PSN) && defined(__PSVITA__)
|
||||
#include "PSVita\Network\SonyCommerce_Vita.h"
|
||||
#endif
|
||||
|
||||
@@ -335,7 +335,7 @@ void UIScene_DLCOffersMenu::tick()
|
||||
{
|
||||
UIScene::tick();
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__))
|
||||
|
||||
if(m_bAddAllDLCButtons)
|
||||
{
|
||||
@@ -506,7 +506,7 @@ void UIScene_DLCOffersMenu::tick()
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef __PSVITA__
|
||||
#if !defined(DISABLE_PSN) && defined(__PSVITA__)
|
||||
// MGH - fixes bug 5768 on Vita - should be extended properly to work for other platforms
|
||||
if((SonyCommerce_Vita::getPurchasabilityUpdated()) && app.GetCommerceProductListRetrieved()&& app.GetCommerceProductListInfoRetrieved() && m_iTotalDLC > 0)
|
||||
{
|
||||
|
||||
@@ -532,7 +532,7 @@ int UIScene_InGameInfoMenu::ViewInvites_SignInReturned(void *pParam,bool bContin
|
||||
#elif defined(__PS3__)
|
||||
int ret = sceNpBasicRecvMessageCustom(SCE_NP_BASIC_MESSAGE_MAIN_TYPE_INVITE, SCE_NP_BASIC_RECV_MESSAGE_OPTIONS_INCLUDE_BOOTABLE, SYS_MEMORY_CONTAINER_ID_INVALID);
|
||||
app.DebugPrintf("sceNpBasicRecvMessageCustom return %d ( %08x )\n", ret, ret);
|
||||
#else // __PSVITA__
|
||||
#elif !defined(DISABLE_PSN) // __PSVITA__
|
||||
SQRNetworkManager_Vita::RecvInviteGUI();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass)
|
||||
#ifndef DISABLE_PSN
|
||||
isSignedInLive = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad());
|
||||
#endif
|
||||
#ifdef __PSVITA__
|
||||
#if !defined DISABLE_PSN && defined __PSVITA__
|
||||
if(CGameNetworkManager::usingAdhocMode() && SQRNetworkManager_AdHoc_Vita::GetAdhocStatus())
|
||||
isSignedInLive = true;
|
||||
#endif
|
||||
|
||||
@@ -1550,7 +1550,7 @@ void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, DWORD dwLocal
|
||||
}
|
||||
|
||||
bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pClass->m_MoreOptionsParams.bOnlineGame;
|
||||
#ifdef __PSVITA__
|
||||
#if !defined DISABLE_PSN && defined __PSVITA__
|
||||
if(CGameNetworkManager::usingAdhocMode())
|
||||
{
|
||||
if(SQRNetworkManager_AdHoc_Vita::GetAdhocStatus())// && pClass->m_MoreOptionsParams.bOnlineGame)
|
||||
|
||||
@@ -181,7 +181,7 @@ UIScene_LoadOrJoinMenu::UIScene_LoadOrJoinMenu(int iPad, void *initData, UILayer
|
||||
|
||||
Initialise();
|
||||
|
||||
#ifdef __PSVITA__
|
||||
#if !defined DISABLE_PSN && defined __PSVITA__
|
||||
if(CGameNetworkManager::usingAdhocMode() && SQRNetworkManager_AdHoc_Vita::GetAdhocStatus())
|
||||
{
|
||||
g_NetworkManager.startAdhocMatching(); // create the client matching context and clear out the friends list
|
||||
@@ -1552,7 +1552,7 @@ void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef __PSVITA__
|
||||
#if !defined DISABLE_PSN && defined __PSVITA__
|
||||
if(CGameNetworkManager::usingAdhocMode() && !SQRNetworkManager_AdHoc_Vita::GetAdhocStatus())
|
||||
{
|
||||
// not connected to adhoc anymore, must have connected back to PSN to buy texture pack so sign in again
|
||||
@@ -2225,6 +2225,9 @@ int UIScene_LoadOrJoinMenu::MustSignInTexturePack(void *pParam,int iPad,C4JStora
|
||||
{
|
||||
UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)pParam;
|
||||
|
||||
#ifdef DISABLE_PSN
|
||||
UIScene_LoadOrJoinMenu::MustSignInReturnedTexturePack(pClass, true, iPad);
|
||||
#else
|
||||
if(result==C4JStorage::EMessage_ResultAccept)
|
||||
{
|
||||
SQRNetworkManager_Vita::AttemptPSNSignIn(&UIScene_LoadOrJoinMenu::MustSignInReturnedTexturePack, pClass);
|
||||
@@ -2234,6 +2237,7 @@ int UIScene_LoadOrJoinMenu::MustSignInTexturePack(void *pParam,int iPad,C4JStora
|
||||
pClass->m_bIgnoreInput = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -740,7 +740,7 @@ int UIScene_MainMenu::CreateLoad_SignInReturned(void *pParam, bool bContinue, in
|
||||
if(ProfileManager.IsFullVersion())
|
||||
{
|
||||
bool bSignedInLive = ProfileManager.IsSignedInLive(iPad);
|
||||
#ifdef __PSVITA__
|
||||
#if !defined DISABLE_PSN && defined __PSVITA__
|
||||
if(CGameNetworkManager::usingAdhocMode())
|
||||
{
|
||||
if(SQRNetworkManager_AdHoc_Vita::GetAdhocStatus())
|
||||
@@ -1327,7 +1327,7 @@ void UIScene_MainMenu::RunPlayGame(int iPad)
|
||||
{
|
||||
// are we offline?
|
||||
bool bSignedInLive = ProfileManager.IsSignedInLive(iPad);
|
||||
#ifdef __PSVITA__
|
||||
#if !defined DISABLE_PSN && defined __PSVITA__
|
||||
if(app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_PSVita_NetworkModeAdhoc) == true)
|
||||
{
|
||||
CGameNetworkManager::setAdhocMode(true);
|
||||
|
||||
@@ -1703,12 +1703,16 @@ int UIScene_SkinSelectMenu::MustSignInReturned(void *pParam,int iPad,C4JStorage:
|
||||
{
|
||||
if(result==C4JStorage::EMessage_ResultAccept)
|
||||
{
|
||||
#ifdef DISABLE_PSN
|
||||
UIScene_SkinSelectMenu::PSNSignInReturned(pParam, true, iPad);
|
||||
#else
|
||||
#ifdef __PS3__
|
||||
SQRNetworkManager_PS3::AttemptPSNSignIn(&UIScene_SkinSelectMenu::PSNSignInReturned, pParam,true);
|
||||
#elif defined __PSVITA__
|
||||
SQRNetworkManager_Vita::AttemptPSNSignIn(&UIScene_SkinSelectMenu::PSNSignInReturned, pParam,true);
|
||||
#elif defined __ORBIS__
|
||||
SQRNetworkManager_Orbis::AttemptPSNSignIn(&UIScene_SkinSelectMenu::PSNSignInReturned, pParam,true);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user