replace WinsockNetLayer with PlatformNetworkManagerWindows, implement external server stats

This commit is contained in:
DrPerkyLegit committed 2026-11-24 19:24:01 -05:00
1 parent 62b92d5c0b
commit f434aae3af
42 files changed
+2621 -3406

No files matched your search

+16 -7
View File
@@ -15,12 +15,15 @@
#include "../Minecraft.World/SharedConstants.h"
#include "Settings.h"
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
#include <winsock2.h>
#include <ws2tcpip.h>
#include "Common/Network/GameNetworkManager.h"
#include "../Minecraft.Server/ServerLogManager.h"
#include "../Minecraft.Server/Access/Access.h"
#include "../Minecraft.Server/Security/SecurityConfig.h"
#include "../Minecraft.World/Socket.h"
#include "Windows64/Network/NetworkPlayerWindows.h"
#include <FourKitBridge.h>
#include <Windows64/Network/WinsockNetLayer.h>
#endif
// #ifdef __PS3__
// #include "PS3/Network/NetworkPlayerSony.h"
@@ -35,6 +38,12 @@ bool g_bRejectDuplicateNames = true;
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
namespace
{
static SOCKET GetWindowsTransportSocket(unsigned char smallId)
{
NetworkPlayerWindows* player = dynamic_cast<NetworkPlayerWindows*>(g_NetworkManager.GetPlayerBySmallId(smallId));
return player != nullptr ? player->GetTransportSocket() : INVALID_SOCKET;
}
static unsigned char GetPendingConnectionSmallId(Connection *connection)
{
if (connection != nullptr)
@@ -125,7 +134,7 @@ void PendingConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet)
if (smallId != 0) {
if (!ServerRuntime::ServerLogManager::TryGetConnectionRemoteIp(smallId, &connectionIp))
{
SOCKET sock = WinsockNetLayer::GetSocketForSmallId(smallId);
SOCKET sock = GetWindowsTransportSocket(smallId);
if (sock != INVALID_SOCKET)
{
sockaddr_in addr;
@@ -141,7 +150,7 @@ void PendingConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet)
}
}
} else {
SOCKET sock = WinsockNetLayer::GetSocketForSmallId(smallId);
SOCKET sock = GetWindowsTransportSocket(smallId);
if (sock != INVALID_SOCKET)
{
sockaddr_in addr;
@@ -269,7 +278,7 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
if (!ServerRuntime::ServerLogManager::TryGetConnectionRemoteIp(smallId, &connectionIp))
{
SOCKET sock = WinsockNetLayer::GetSocketForSmallId(smallId);
SOCKET sock = GetWindowsTransportSocket(smallId);
if (sock != INVALID_SOCKET)
{
sockaddr_in addr;
@@ -290,7 +299,7 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
}
}
else {
SOCKET sock = WinsockNetLayer::GetSocketForSmallId(smallId);
SOCKET sock = GetWindowsTransportSocket(smallId);
if (sock != INVALID_SOCKET)
{
sockaddr_in addr;
@@ -519,7 +528,7 @@ void PendingConnection::handleAcceptedLogin(shared_ptr<LoginPacket> packet)
if (!ServerRuntime::ServerLogManager::TryGetConnectionRemoteIp(smallId, &connectionIp))
{
SOCKET sock = WinsockNetLayer::GetSocketForSmallId(smallId);
SOCKET sock = GetWindowsTransportSocket(smallId);
if (sock != INVALID_SOCKET)
{
sockaddr_in addr;
@@ -540,7 +549,7 @@ void PendingConnection::handleAcceptedLogin(shared_ptr<LoginPacket> packet)
}
}
else {
SOCKET sock = WinsockNetLayer::GetSocketForSmallId(smallId);
SOCKET sock = GetWindowsTransportSocket(smallId);
if (sock != INVALID_SOCKET)
{
sockaddr_in addr;