push current progress

This commit is contained in:
2026-08-01 15:55:57 -04:00
parent 01abe05b18
commit fb1144f552
2 changed files with 1211 additions and 46 deletions
@@ -58,6 +58,12 @@ bool g_Win64MultiplayerJoin = true;
int g_Win64MultiplayerPort = WIN64_NET_DEFAULT_PORT;
char g_Win64MultiplayerIP[256] = "127.0.0.1";
// LCEOnline Shit
char g_LCEOnlineServerIP[256] = "relay.mclegacyedition.xyz";
wchar_t g_LCEOnlineServerIPW[256] = L"relay.mclegacyedition.xyz";
int g_LCEOnlineServerPort = 2052;
char g_GameVersion[] = "TU19"; //str1ker - LCEOnline uses this to divide the game versions so TU46 cant see TU19 clients and servers and vice versa.
bool WinsockNetLayer::Initialize()
{
if (s_initialized) return true;
@@ -205,10 +211,11 @@ bool WinsockNetLayer::HostGame(int port)
char portStr[16];
sprintf_s(portStr, "%d", port);
iResult = getaddrinfo(NULL, portStr, &hints, &result);
int iResult = getaddrinfo(g_LCEOnlineServerIP, portStr, &hints, &result);
if (iResult != 0)
{
app.DebugPrintf("getaddrinfo failed: %d\n", iResult);
app.DebugPrintf("getaddrinfo failed for relay server %s:%d - %d\n",
g_LCEOnlineServerIP, g_LCEOnlineServerPort, iResult);
return false;
}
@@ -249,69 +256,47 @@ bool WinsockNetLayer::HostGame(int port)
setsockopt(s_listenSocket, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof(opt));
#if defined _WINDOWS64
iResult = ::bind(s_listenSocket, result->ai_addr, (int)result->ai_addrlen);
iResult = connect(s_listenSocket, result->ai_addr, (int)result->ai_addrlen);
freeaddrinfo(result);
if (iResult == SOCKET_ERROR)
{
app.DebugPrintf("bind() failed: %d\n", WSAGetLastError());
closesocket(s_listenSocket);
s_listenSocket = INVALID_SOCKET;
return false;
}
iResult = listen(s_listenSocket, SOMAXCONN);
if (iResult == SOCKET_ERROR)
{
app.DebugPrintf("listen() failed: %d\n", WSAGetLastError());
app.DebugPrintf("connect() to LCEOnline Server %s:%d failed: %d\n",
g_LCEOnlineServerIP, g_LCEOnlineServerPort, WSAGetLastError());
closesocket(s_listenSocket);
s_listenSocket = INVALID_SOCKET;
return false;
}
#elif defined _XBOX
iResult = ::bind(s_listenSocket, (struct sockaddr*)&addr, sizeof(addr));
iResult = connect(s_listenSocket, (struct sockaddr*)&addr, sizeof(addr));
XNetDnsRelease(pDns);
if (iResult == SOCKET_ERROR)
{
app.DebugPrintf("bind() failed: %d\n", WSAGetLastError());
closesocket(s_listenSocket);
s_listenSocket = INVALID_SOCKET;
return false;
}
iResult = listen(s_listenSocket, SOMAXCONN);
if (iResult == SOCKET_ERROR)
{
app.DebugPrintf("listen() failed: %d\n", WSAGetLastError());
app.DebugPrintf("connect() to LCEOnline Server %s:%d failed: %d\n",
g_LCEOnlineServerIP, g_LCEOnlineServerPort, WSAGetLastError());
closesocket(s_listenSocket);
s_listenSocket = INVALID_SOCKET;
return false;
}
#elif defined __PS3__
iResult = ::bind(s_listenSocket, (struct sockaddr*)&addr, sizeof(addr));
iResult = connect(s_listenSocket, (struct sockaddr*)&addr, sizeof(addr));
if (iResult < 0)
{
app.DebugPrintf("bind() failed: %d\n", iResult);
closesocket(s_listenSocket);
s_listenSocket = -1;
return false;
}
iResult = listen(s_listenSocket, 5);
if (iResult < 0)
{
app.DebugPrintf("listen() failed: %d\n", iResult);
app.DebugPrintf("connect() to LCEOnline Server %s: failed: %d\n",
g_LCEOnlineServerIP, s_listenSocket);
closesocket(s_listenSocket);
s_listenSocket = -1;
return false;
}
#endif
s_active = true;
s_connected = true;
s_acceptThread = new C4JThread(AcceptThreadProc, NULL, "AcceptThreadProc");
s_acceptThread->Run();
app.DebugPrintf("LAN: Hosting on port %d\n", port);
app.DebugPrintf("LAN: Hosting on Relay Server %s:%d\n",
g_LCEOnlineServerIP != NULL ? g_LCEOnlineServerIP : "*",
g_LCEOnlineServerPort);
return true;
}
@@ -331,12 +316,13 @@ bool WinsockNetLayer::JoinGame(const char *ip, int port)
hints.ai_protocol = IPPROTO_TCP;
char portStr[16];
sprintf_s(portStr, "%d", port);
sprintf_s(portStr, "%d", g_LCEOnlineServerPort);
int iResult = getaddrinfo(ip, portStr, &hints, &result);
int iResult = getaddrinfo(g_LCEOnlineServerIP, portStr, &hints, &result);
if (iResult != 0)
{
app.DebugPrintf("getaddrinfo failed for %s:%d - %d\n", ip, port, iResult);
app.DebugPrintf("getaddrinfo failed for LCEOnline server %s:%d - %d\n",
g_LCEOnlineServerIP, g_LCEOnlineServerPort, iResult);
return false;
}
@@ -362,10 +348,11 @@ bool WinsockNetLayer::JoinGame(const char *ip, int port)
}
#elif defined _XBOX
XNDNS *pDns = NULL;
int iResult = XNetDnsLookup(ip, NULL, &pDns);
int iResult = XNetDnsLookup(g_LCEOnlineServerIP, NULL, &pDns); // str1k3r - possibly wont work havent overlooked docs enough
if (iResult != 0 || pDns == NULL)
{
app.DebugPrintf("XNetDnsLookup failed for %s - %d\n", ip, iResult);
app.DebugPrintf("XNetDnsLookup failed for LCEOnline server %s - %d\n",
g_LCEOnlineServerIP, iResult);
return false;
}
@@ -376,7 +363,8 @@ bool WinsockNetLayer::JoinGame(const char *ip, int port)
if (pDns->iStatus != 0 || pDns->cina == 0)
{
app.DebugPrintf("pDns->iStatus failed for %s - %d\n", ip, iResult);
app.DebugPrintf("pDns->iStatus failed for %s - %d\n",
g_LCEOnlineServerIP, iResult);
XNetDnsRelease(pDns);
return false;
}
@@ -449,7 +437,7 @@ bool WinsockNetLayer::JoinGame(const char *ip, int port)
}
s_localSmallId = assignBuf[0];
app.DebugPrintf("Win64 LAN: Connected to %s:%d, assigned smallId=%d\n", ip, port, s_localSmallId);
app.DebugPrintf("LAN: Connected via LCEOnline to Session %s, Assigned Small ID=%d\n", ip, s_localSmallId);
s_active = true;
s_connected = true;
@@ -597,14 +585,14 @@ int WinsockNetLayer::AcceptThreadProc(LPVOID param)
if (clientSocket == INVALID_SOCKET)
{
if (s_active)
app.DebugPrintf("accept() failed: %d\n", WSAGetLastError());
app.DebugPrintf("LCEOnline socket disconnected: %d\n", WSAGetLastError());
break;
}
#elif __PS3__
if (clientSocket < 0)
{
if (s_active)
app.DebugPrintf("accept() failed: %d\n", clientSocket);
app.DebugPrintf("LCEOnline socket disconnected: %d\n", clientSocket);
break;
}
#endif