forked from cafeberry/cafeberry
fix PS4 networking support (#20)
gonna mark this a WIP till i test more with large worlds and achievements issues i dont wanna break the PS3 and other builds by enabling it freely, ideally i can get it to work without it also i wanna remove the GetLocalIPv4Interfaces auto discovery feature i just did that cause i had so many local networks it got confusing, will remove on Final PR editReviewed-on: pieeebot/cafeberry#20 Co-authored-by: NaN <nan@str1k3r.xyz>
This commit is contained in:
@@ -61,9 +61,16 @@ std::vector<BYTE> NetworkSocketLayer::s_freeSmallIds;
|
||||
static bool s_locksCreated = false;
|
||||
|
||||
bool g_MultiplayerHost = false;
|
||||
#if defined __ORBIS__
|
||||
// Orbis has direct lan networking so it can bypass psn account checks
|
||||
bool g_MultiplayerJoin = true;
|
||||
int g_MultiplayerPort = NETWORK_LAN_DEFAULT_PORT;
|
||||
char g_MultiplayerIP[256] = "";
|
||||
#else
|
||||
bool g_MultiplayerJoin = false;
|
||||
int g_MultiplayerPort = NETWORK_LAN_DEFAULT_PORT;
|
||||
char g_MultiplayerIP[256] = "127.0.0.1";
|
||||
#endif
|
||||
|
||||
bool NetworkSocketLayer::Initialize()
|
||||
{
|
||||
@@ -588,6 +595,9 @@ bool NetworkSocketLayer::JoinGame(const char *ip, int port)
|
||||
struct sockaddr_in addr = {};
|
||||
#endif
|
||||
|
||||
#if defined(__ORBIS__)
|
||||
addr.sin_len = sizeof(addr);
|
||||
#endif
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons((uint16_t)port);
|
||||
|
||||
@@ -1336,8 +1346,15 @@ bool NetworkSocketLayer::StartDiscovery()
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
DWORD timeout = 500;
|
||||
setsockopt(s_discoverySock, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeout, sizeof(timeout));
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 500000;
|
||||
setsockopt(s_discoverySock, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeout, sizeof(timeout));
|
||||
#endif
|
||||
|
||||
s_discovering = true;
|
||||
s_discoveryThread = new C4JThread(DiscoveryThreadProc, NULL, "DiscoveryThreadProc");
|
||||
|
||||
@@ -47,8 +47,8 @@ typedef int SOCKET;
|
||||
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 sys_net_errno errno
|
||||
#define SYS_NET_EINPROGRESS EINPROGRESS
|
||||
#define socketselect select
|
||||
#define closesocket sceNetSocketClose
|
||||
#define socketclose sceNetSocketClose
|
||||
@@ -229,4 +229,4 @@ private:
|
||||
extern bool g_MultiplayerHost;
|
||||
extern bool g_MultiplayerJoin;
|
||||
extern int g_MultiplayerPort;
|
||||
extern char g_MultiplayerIP[256];
|
||||
extern char g_MultiplayerIP[256];
|
||||
|
||||
@@ -477,6 +477,8 @@ bool CPlatformNetworkManagerStub::_RunNetworkGame()
|
||||
{
|
||||
extern QNET_STATE _iQNetStubState;
|
||||
_iQNetStubState = QNET_STATE_GAME_PLAY;
|
||||
if (m_pIQNet->IsHost())
|
||||
NetworkSocketLayer::UpdateAdvertiseJoinable(true);
|
||||
|
||||
for (DWORD i = 0; i < IQNet::s_playerCount; i++)
|
||||
{
|
||||
@@ -698,7 +700,7 @@ void CPlatformNetworkManagerStub::SearchForGames()
|
||||
{
|
||||
std::vector<LANSession> lanSessions = NetworkSocketLayer::GetDiscoveredSessions();
|
||||
|
||||
if (g_MultiplayerJoin)
|
||||
if (g_MultiplayerJoin && g_MultiplayerIP[0] != '\0')
|
||||
{
|
||||
bool alreadyPresent = false;
|
||||
for (size_t i = 0; i < lanSessions.size(); i++)
|
||||
|
||||
Reference in New Issue
Block a user