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 -11
View File
@@ -20,7 +20,7 @@
#include "../Minecraft.World/net.minecraft.network.h"
#include "Windows64/Windows64_Xuid.h"
#ifdef _WINDOWS64
#include "Windows64/Network/WinsockNetLayer.h"
#include "Windows64/Network/PlatformNetworkManagerWindows.h"
#endif
#include "../Minecraft.World/Pos.h"
#include "../Minecraft.World/ProgressListener.h"
@@ -31,8 +31,10 @@
#include "../Minecraft.World/net.minecraft.world.level.saveddata.h"
#include "../Minecraft.World/JavaMath.h"
#include "../Minecraft.World/EntityIO.h"
#if defined(_XBOX) || defined(_WINDOWS64)
#if defined(_XBOX)
#include "Xbox/Network/NetworkPlayerXbox.h"
#elif defined(_WINDOWS64)
#include "Windows64/Network/NetworkPlayerWindows.h"
#elif defined(__PS3__) || defined(__ORBIS__)
#include "Common/Network/Sony/NetworkPlayerSony.h"
#endif
@@ -151,15 +153,16 @@ bool PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
#ifdef _WINDOWS64
if (networkPlayer != nullptr)
{
NetworkPlayerXbox* nxp = static_cast<NetworkPlayerXbox *>(networkPlayer);
IQNetPlayer* qnp = nxp->GetQNetPlayer();
if (qnp != nullptr)
NetworkPlayerWindows* windowsPlayer = dynamic_cast<NetworkPlayerWindows*>(networkPlayer);
if (windowsPlayer != nullptr)
{
if (!networkPlayer->IsLocal())
{
wcsncpy_s(qnp->m_gamertag, 32, player->name.c_str(), _TRUNCATE);
windowsPlayer->SetDisplayName(player->name);
}
qnp->m_resolvedXuid = player->getXuid();
windowsPlayer->SetUID(networkPlayer->IsHost()
? Win64Xuid::GetLegacyEmbeddedHostXuid()
: player->getXuid());
}
}
#endif
@@ -872,8 +875,6 @@ shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlay
player->connection->send( std::make_shared<RespawnPacket>( static_cast<char>(player->dimension), player->level->getSeed(), player->level->getMaxBuildHeight(),
player->gameMode->getGameModeForPlayer(), level->difficulty, level->getLevelData()->getGenerator(),
player->level->useNewSeaLevel(), player->entityId, level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale(), level->getLevelData()->isHardcore(), level->getLevelData()->isModernEnd() ) );
player->connection->teleport(player->x, player->y, player->z, player->yRot, player->xRot);
player->connection->send( std::make_shared<SetExperiencePacket>( player->experienceProgress, player->totalExperience, player->experienceLevel) );
if(keepAllPlayerData)
{
@@ -894,6 +895,10 @@ shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlay
players.push_back(player);
LeaveCriticalSection(&m_playersCS);
player->doTick(true, true, true);
player->connection->teleport(player->x, player->y, player->z, player->yRot, player->xRot);
player->connection->send( std::make_shared<SetExperiencePacket>( player->experienceProgress, player->totalExperience, player->experienceLevel) );
player->initMenu();
player->setHealth(player->getHealth());
@@ -1201,8 +1206,8 @@ void PlayerList::tick()
// The old Connection's read/write threads are now dead (disconnect waits
// for them). Safe to recycle the smallId — no stale write thread can
// resolve getPlayer() to a new connection that reuses this slot.
WinsockNetLayer::PushFreeSmallId(smallId);
WinsockNetLayer::ClearSocketForSmallId(smallId);
if (g_pPlatformNetworkManagerWindows != nullptr)
g_pPlatformNetworkManagerWindows->ReleaseSmallId(smallId);
#endif
}
}