Revert LCEMP dedicated server changes

Apparently smartcmd used their own dedicated server and not LCEMP's, starting from scratch!
This commit is contained in:
pieeebot committed 2026-08-15 03:28:51 +03:00
1 parent 9e3077c3bc
commit a1541c590d
29 files changed
+58 -283

No files matched your search

@@ -873,14 +873,12 @@ int CGameNetworkManager::JoinFromInvite_SignInReturned(void *pParam,bool bContin
void CGameNetworkManager::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving)
{
#ifndef _DEDICATED_SERVER
Minecraft *pMinecraft = Minecraft::GetInstance();
TexturePack *tPack = pMinecraft->skins->getSelected();
s_pPlatformNetworkManager->SetSessionTexturePackParentId( tPack->getDLCParentPackId() );
s_pPlatformNetworkManager->SetSessionSubTexturePackId( tPack->getDLCSubPackId() );
s_pPlatformNetworkManager->UpdateAndSetGameSessionData( pNetworkPlayerLeaving );
#endif
}
void CGameNetworkManager::SendInviteGUI(int quadrant)
@@ -1542,7 +1540,6 @@ void CGameNetworkManager::CreateSocket( INetworkPlayer *pNetworkPlayer, bool loc
// Add this user to the game server if the game is started already
if( g_NetworkManager.IsHost() && g_NetworkManager.IsInGameplay() )
{
app.DebugPrintf("Adding incoming socket for smallId=%d\n", pNetworkPlayer->GetSmallId());
Socket::addIncomingSocket(socket);
}
@@ -61,9 +61,6 @@ std::vector<BYTE> NetworkSocketLayer::s_pendingJoinSmallIds;
CRITICAL_SECTION NetworkSocketLayer::s_freeSmallIdLock;
std::vector<BYTE> NetworkSocketLayer::s_freeSmallIds;
CRITICAL_SECTION NetworkSocketLayer::s_earlyDataLock;
std::vector<BYTE> NetworkSocketLayer::s_earlyDataBuffers[NETWORK_LAN_MAX_CLIENTS + 1];
// only goes true on a successful Initialize(), and a failed one gets retried
static bool s_locksCreated = false;
#if defined _WINDOWS64
@@ -91,7 +88,6 @@ bool NetworkSocketLayer::Initialize()
InitializeCriticalSection(&s_disconnectLock);
InitializeCriticalSection(&s_pendingJoinLock);
InitializeCriticalSection(&s_freeSmallIdLock);
InitializeCriticalSection(&s_earlyDataLock);
for (int i = 0; i < NETWORK_LAN_MAX_CLIENTS + 1; i++)
{
@@ -143,9 +139,7 @@ bool NetworkSocketLayer::Initialize()
s_initialized = true;
#ifndef _DEDICATED_SERVER
StartDiscovery();
#endif
return true;
}
@@ -807,9 +801,6 @@ bool NetworkSocketLayer::JoinGame(const char *ip, int port)
}
s_localSmallId = assignedSmallId;
DWORD noTimeout = 0;
setsockopt(s_hostConnectionSocket, SOL_SOCKET, SO_RCVTIMEO, (const char *)&noTimeout, sizeof(noTimeout));
app.DebugPrintf("LAN: Connected to %s:%d, assigned smallId=%d\n", ip, port, s_localSmallId);
s_active = true;
@@ -935,13 +926,9 @@ void NetworkSocketLayer::HandleDataReceived(BYTE fromSmallId, BYTE toSmallId, un
if (pPlayerFrom == NULL || pPlayerTo == NULL)
{
if (s_isHost && fromSmallId > 0 && fromSmallId < NETWORK_LAN_MAX_CLIENTS + 1)
{
EnterCriticalSection(&s_earlyDataLock);
s_earlyDataBuffers[fromSmallId].insert(
s_earlyDataBuffers[fromSmallId].end(), data, data + dataSize);
LeaveCriticalSection(&s_earlyDataLock);
}
// dropping here is silent and looks identical to the peer never sending
app.DebugPrintf("LAN: DROPPED %u bytes - from smallId=%d(%s) to smallId=%d(%s)\n",
dataSize, fromSmallId, pPlayerFrom ? "ok" : "NULL", toSmallId, pPlayerTo ? "ok" : "NULL");
return;
}
@@ -950,13 +937,6 @@ void NetworkSocketLayer::HandleDataReceived(BYTE fromSmallId, BYTE toSmallId, un
::Socket *pSocket = pPlayerFrom->GetSocket();
if (pSocket != NULL)
pSocket->pushDataToQueue(data, dataSize, false);
else
{
EnterCriticalSection(&s_earlyDataLock);
s_earlyDataBuffers[fromSmallId].insert(
s_earlyDataBuffers[fromSmallId].end(), data, data + dataSize);
LeaveCriticalSection(&s_earlyDataLock);
}
}
else
{
@@ -966,26 +946,6 @@ void NetworkSocketLayer::HandleDataReceived(BYTE fromSmallId, BYTE toSmallId, un
}
}
void NetworkSocketLayer::FlushPendingData()
{
EnterCriticalSection(&s_earlyDataLock);
for (int i = 1; i < NETWORK_LAN_MAX_CLIENTS + 1; i++)
{
if (s_earlyDataBuffers[i].empty()) continue;
INetworkPlayer *pPlayer = g_NetworkManager.GetPlayerBySmallId((BYTE)i);
if (pPlayer == NULL) continue;
::Socket *pSocket = pPlayer->GetSocket();
if (pSocket == NULL) continue;
pSocket->pushDataToQueue(s_earlyDataBuffers[i].data(),
(DWORD)s_earlyDataBuffers[i].size(), false);
s_earlyDataBuffers[i].clear();
}
LeaveCriticalSection(&s_earlyDataLock);
}
int NetworkSocketLayer::AcceptThreadProc(LPVOID param)
{
while (s_active)
@@ -1212,11 +1172,6 @@ void NetworkSocketLayer::CloseConnectionBySmallId(BYTE smallId)
app.DebugPrintf("Win64 LAN: Force-closed TCP connection for smallId=%d\n", smallId);
}
LeaveCriticalSection(&s_connectionsLock);
EnterCriticalSection(&s_earlyDataLock);
if (smallId < NETWORK_LAN_MAX_CLIENTS + 1)
s_earlyDataBuffers[smallId].clear();
LeaveCriticalSection(&s_earlyDataLock);
}
int NetworkSocketLayer::ClientRecvThreadProc(LPVOID param)
@@ -1288,11 +1243,6 @@ bool NetworkSocketLayer::StartAdvertising(int gamePort, const wchar_t *hostName,
s_advertiseData.texturePackParentId = texPackId;
s_advertiseData.subTexturePackId = subTexId;
s_advertiseData.isJoinable = 0;
#ifdef _DEDICATED_SERVER
s_advertiseData.isDedicatedServer = 1;
#else
s_advertiseData.isDedicatedServer = 0;
#endif
s_hostGamePort = gamePort;
LeaveCriticalSection(&s_advertiseLock);
@@ -1673,7 +1623,6 @@ int NetworkSocketLayer::DiscoveryThreadProc(LPVOID param)
s_discoveredSessions[i].texturePackParentId = broadcast->texturePackParentId;
s_discoveredSessions[i].subTexturePackId = broadcast->subTexturePackId;
s_discoveredSessions[i].isJoinable = (broadcast->isJoinable != 0);
s_discoveredSessions[i].isDedicatedServer = (broadcast->isDedicatedServer != 0);
s_discoveredSessions[i].lastSeenTick = now;
memcpy(s_discoveredSessions[i].playerNames, broadcast->playerNames, sizeof(broadcast->playerNames));
found = true;
@@ -1707,7 +1656,6 @@ int NetworkSocketLayer::DiscoveryThreadProc(LPVOID param)
session.texturePackParentId = broadcast->texturePackParentId;
session.subTexturePackId = broadcast->subTexturePackId;
session.isJoinable = (broadcast->isJoinable != 0);
session.isDedicatedServer = (broadcast->isDedicatedServer != 0);
session.lastSeenTick = now;
memcpy(session.playerNames, broadcast->playerNames, sizeof(broadcast->playerNames));
s_discoveredSessions.push_back(session);
@@ -116,7 +116,6 @@ struct LANBroadcast
DWORD texturePackParentId;
BYTE subTexturePackId;
BYTE isJoinable;
BYTE isDedicatedServer;
char playerNames[NETWORK_LAN_BROADCAST_PLAYERS][NETWORK_LAN_PLAYER_NAME_SIZE];
};
#pragma pack(pop)
@@ -133,7 +132,6 @@ struct LANSession
unsigned int texturePackParentId;
unsigned char subTexturePackId;
bool isJoinable;
bool isDedicatedServer;
DWORD lastSeenTick;
char playerNames[NETWORK_LAN_BROADCAST_PLAYERS][NETWORK_LAN_PLAYER_NAME_SIZE];
};
@@ -169,7 +167,6 @@ public:
static SOCKET GetSocketForSmallId(BYTE smallId);
static void HandleDataReceived(BYTE fromSmallId, BYTE toSmallId, unsigned char *data, unsigned int dataSize);
static void FlushPendingData();
static bool PopDisconnectedSmallId(BYTE *outSmallId);
static void PushFreeSmallId(BYTE smallId);
@@ -238,9 +235,6 @@ private:
static CRITICAL_SECTION s_freeSmallIdLock;
static std::vector<BYTE> s_freeSmallIds;
static CRITICAL_SECTION s_earlyDataLock;
static std::vector<BYTE> s_earlyDataBuffers[NETWORK_LAN_MAX_CLIENTS + 1];
};
extern bool g_MultiplayerHost;
@@ -354,10 +354,6 @@ bool CPlatformNetworkManagerStub::LeaveGame(bool bMigrateHost)
if( m_bLeavingGame ) return true;
m_bLeavingGame = true;
extern bool g_connectedToDedicatedServer;
g_connectedToDedicatedServer = false;
NetworkSocketLayer::StopAdvertising();
// If we are the host wait for the game server to end
@@ -407,10 +403,10 @@ void CPlatformNetworkManagerStub::HostGame(int localUsersMask, bool bOnlineGame,
IQNet::m_player[0].m_smallId = 0;
IQNet::m_player[0].m_isRemote = false;
IQNet::m_player[0].m_isHostPlayer = true;
IQNet::s_playerCount = 1;
#if defined _WINDOWS64 && !defined WITH_SERVER_CODE
#ifdef _WINDOWS64
extern wchar_t g_Win64UsernameW[17];
wcscpy_s(IQNet::m_player[0].m_gamertag, 32, g_Win64UsernameW);
IQNet::s_playerCount = 1;
#endif
if (getNetworkPlayer(&IQNet::m_player[0]) == NULL)
@@ -458,9 +454,6 @@ int CPlatformNetworkManagerStub::JoinGame(FriendSessionInfo *searchResult, int l
wcsncpy(IQNet::m_player[0].m_gamertag, searchResult->data.hostName, 31);
IQNet::m_player[0].m_gamertag[31] = L'\0';
extern bool g_connectedToDedicatedServer;
g_connectedToDedicatedServer = searchResult->data.isDedicatedServer;
NetworkSocketLayer::StopDiscovery();
if (!NetworkSocketLayer::JoinGame(hostIP, hostPort))
@@ -808,7 +801,6 @@ void CPlatformNetworkManagerStub::SearchForGames()
info->data.subTexturePackId = lanSessions[i].subTexturePackId;
info->data.isReadyToJoin = lanSessions[i].isJoinable;
info->data.isJoinable = lanSessions[i].isJoinable;
info->data.isDedicatedServer = lanSessions[i].isDedicatedServer;
strncpy(info->data.hostIP, lanSessions[i].hostIP, sizeof(info->data.hostIP) - 1);
info->data.hostIP[sizeof(info->data.hostIP) - 1] = '\0';
info->data.hostPort = lanSessions[i].hostPort;
@@ -79,7 +79,6 @@ typedef struct _GameSessionData
bool isReadyToJoin; // 1 byte
bool isJoinable; // 1 byte
bool isDedicatedServer; // 1 byte
char hostIP[64]; // 64 bytes
int hostPort; // 4 bytes
@@ -98,7 +97,6 @@ typedef struct _GameSessionData
subTexturePackId = 0;
isReadyToJoin = false;
isJoinable = true;
isDedicatedServer = false;
memset(hostIP, 0, sizeof(hostIP));
hostPort = 0;
memset(hostName, 0, sizeof(hostName));