update lcemp networking

This commit is contained in:
2026-08-14 07:02:50 +03:00
parent 125819419f
commit 6853eab85f
51 changed files with 629 additions and 183 deletions
@@ -35,7 +35,7 @@
#define NETWORK_LAN_DEFAULT_PORT 25565
#define NETWORK_LAN_MAX_CLIENTS 7
#define NETWORK_LAN_RECV_BUFFER_SIZE 65536
#define NETWORK_LAN_MAX_PACKET_SIZE (4 * 1024 * 1024)
#define NETWORK_LAN_MAX_PACKET_SIZE (3 * 1024 * 1024)
#define NETWORK_LAN_DISCOVERY_PORT 25566
#define NETWORK_LAN_BROADCAST_MAGIC 0x4D434C4E
@@ -141,6 +141,7 @@ struct RemoteConnection
BYTE smallId;
C4JThread* recvThread;
volatile bool active;
CRITICAL_SECTION sendLock;
};
class NetworkSocketLayer
@@ -170,6 +171,10 @@ public:
static void PushFreeSmallId(BYTE smallId);
static void CloseConnectionBySmallId(BYTE smallId);
static bool PopPendingJoinSmallId(BYTE *outSmallId);
static bool IsSmallIdConnected(BYTE smallId);
static bool StartAdvertising(int gamePort, const wchar_t *hostName, unsigned int gameSettings, unsigned int texPackId, unsigned char subTexId, unsigned short netVer);
static void StopAdvertising();
static void UpdateAdvertisePlayerCount(BYTE count);
@@ -206,7 +211,7 @@ private:
static CRITICAL_SECTION s_sendLock;
static CRITICAL_SECTION s_connectionsLock;
static std::vector<RemoteConnection> s_connections;
static RemoteConnection s_connections[NETWORK_LAN_MAX_CLIENTS + 1];
static SOCKET s_advertiseSock;
static C4JThread* s_advertiseThread;
@@ -224,6 +229,9 @@ private:
static CRITICAL_SECTION s_disconnectLock;
static std::vector<BYTE> s_disconnectedSmallIds;
static CRITICAL_SECTION s_pendingJoinLock;
static std::vector<BYTE> s_pendingJoinSmallIds;
static CRITICAL_SECTION s_freeSmallIdLock;
static std::vector<BYTE> s_freeSmallIds;
};