forked from cafeberry/cafeberry
Revert LCEMP dedicated server changes
Apparently smartcmd used their own dedicated server and not LCEMP's, starting from scratch!
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user