update lcemp networking

This commit is contained in:
2026-08-02 03:33:11 +03:00
parent b87d044cf0
commit e254228cf5
15 changed files with 616 additions and 138 deletions
+65 -1
View File
@@ -50,11 +50,16 @@
#else
#include "Common\UI\UI.h"
#endif
#ifdef __PS3__
#if defined __PS3__ && !defined DISABLE_PSN
#include "PS3/Network/SonyVoiceChat.h"
#endif
#include "DLCTexturePack.h"
#if defined _WINDOWS64 || defined DISABLE_PSN || defined _DISABLE_XBLIVE
#include "Xbox\Network\NetworkPlayerXbox.h"
#include "Common\Network\PlatformNetworkManagerStub.h"
#endif
#ifdef _DURANGO
#include "..\Minecraft.World\DurangoStats.h"
#include "..\Minecraft.World\GenericStats.h"
@@ -781,6 +786,32 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet)
player->m_displayName = player->name;
#endif
#if defined _WINDOWS64 || defined DISABLE_PSN || defined _DISABLE_XBLIVE
{
PlayerUID pktXuid = player->getXuid();
const PlayerUID WIN64_XUID_BASE = (PlayerUID)0xe000d45248242f2e;
if (pktXuid >= WIN64_XUID_BASE && pktXuid < WIN64_XUID_BASE + MINECRAFT_NET_MAX_PLAYERS)
{
BYTE smallId = (BYTE)(pktXuid - WIN64_XUID_BASE);
INetworkPlayer *np = g_NetworkManager.GetPlayerBySmallId(smallId);
if (np != NULL)
{
NetworkPlayerXbox *npx = (NetworkPlayerXbox *)np;
IQNetPlayer *qp = npx->GetQNetPlayer();
if (qp != NULL)
{
wcsncpy(qp->m_gamertag, packet->name.c_str(), 31);
qp->m_gamertag[31] = L'\0';
if (g_NetworkManager.IsHost())
{
g_NetworkManager.UpdateAndSetGameSessionData();
}
}
}
}
}
#endif
// printf("\t\t\t\t%d: Add player\n",packet->id,packet->yRot);
int item = packet->carriedItem;
@@ -923,6 +954,39 @@ void ClientConnection::handleMoveEntitySmall(shared_ptr<MoveEntityPacketSmall> p
void ClientConnection::handleRemoveEntity(shared_ptr<RemoveEntitiesPacket> packet)
{
#if defined _WINDOWS64 || defined DISABLE_PSN || defined _DISABLE_XBLIVE
if (!g_NetworkManager.IsHost())
{
for (int i = 0; i < packet->ids.length; i++)
{
shared_ptr<Entity> entity = getEntity(packet->ids[i]);
if (entity != NULL && entity->GetType() == eTYPE_PLAYER)
{
shared_ptr<Player> player = dynamic_pointer_cast<Player>(entity);
if (player != NULL)
{
PlayerUID xuid = player->getXuid();
INetworkPlayer *np = g_NetworkManager.GetPlayerByXuid(xuid);
if (np != NULL)
{
NetworkPlayerXbox *npx = (NetworkPlayerXbox *)np;
IQNetPlayer *qp = npx->GetQNetPlayer();
if (qp != NULL)
{
extern CPlatformNetworkManagerStub *g_pPlatformNetworkManager;
g_pPlatformNetworkManager->NotifyPlayerLeaving(qp);
qp->m_smallId = 0;
qp->m_isRemote = false;
qp->m_isHostPlayer = false;
qp->m_gamertag[0] = 0;
qp->SetCustomDataValue(0);
}
}
}
}
}
}
#endif
for (int i = 0; i < packet->ids.length; i++)
{
level->removeEntity(packet->ids[i]);