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:
NaN
2026-08-04 22:49:46 +00:00
committed by pieeebot
parent 2840b7620b
commit 4b0520c938
8 changed files with 115 additions and 39 deletions
@@ -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");