mirror of
https://github.com/Minecraft-Community-Edition/client.git
synced 2026-06-27 02:35:38 +00:00
Whisper Yelled At me 😢
This commit is contained in:
@@ -142,36 +142,6 @@ void Packet::staticCtor()
|
||||
//map(253, true, false, ServerAuthDataPacket.class);
|
||||
map(254, false, true, false, false, typeid(GetInfoPacket), GetInfoPacket::create); // TODO New for 1.8.2 - Needs sendToAny?
|
||||
map(255, true, true, true, false, typeid(DisconnectPacket), DisconnectPacket::create);
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
// P2P Routing Modes: Mark movement/visual packets as P2P-eligible
|
||||
// These packets are safe for direct peer delivery (visual only, no game state)
|
||||
|
||||
// Player movement - high frequency, latency-sensitive
|
||||
SetRoutingMode(10, ROUTING_PREFER_DIRECT); // MovePlayerPacket
|
||||
SetRoutingMode(11, ROUTING_PREFER_DIRECT); // MovePlayerPacket::Pos
|
||||
SetRoutingMode(12, ROUTING_PREFER_DIRECT); // MovePlayerPacket::Rot
|
||||
SetRoutingMode(13, ROUTING_PREFER_DIRECT); // MovePlayerPacket::PosRot
|
||||
|
||||
// Entity movement - visual interpolation
|
||||
SetRoutingMode(30, ROUTING_PREFER_DIRECT); // MoveEntityPacket
|
||||
SetRoutingMode(31, ROUTING_PREFER_DIRECT); // MoveEntityPacket::Pos
|
||||
SetRoutingMode(32, ROUTING_PREFER_DIRECT); // MoveEntityPacket::Rot
|
||||
SetRoutingMode(33, ROUTING_PREFER_DIRECT); // MoveEntityPacket::PosRot
|
||||
SetRoutingMode(162, ROUTING_PREFER_DIRECT); // MoveEntityPacketSmall
|
||||
SetRoutingMode(163, ROUTING_PREFER_DIRECT); // MoveEntityPacketSmall::Pos
|
||||
SetRoutingMode(164, ROUTING_PREFER_DIRECT); // MoveEntityPacketSmall::Rot
|
||||
SetRoutingMode(165, ROUTING_PREFER_DIRECT); // MoveEntityPacketSmall::PosRot
|
||||
|
||||
// Animations and visual effects
|
||||
SetRoutingMode(18, ROUTING_PREFER_DIRECT); // AnimatePacket
|
||||
SetRoutingMode(35, ROUTING_PREFER_DIRECT); // RotateHeadPacket
|
||||
|
||||
// Non-critical audio
|
||||
SetRoutingMode(62, ROUTING_PREFER_DIRECT); // LevelSoundPacket
|
||||
|
||||
// All other packets default to ROUTING_HOST_ONLY (game state, inventory, spawns, etc.)
|
||||
#endif
|
||||
}
|
||||
|
||||
IllegalArgumentException::IllegalArgumentException(const wstring& information)
|
||||
@@ -195,21 +165,6 @@ unordered_set<int> Packet::clientReceivedPackets = unordered_set<int>();
|
||||
unordered_set<int> Packet::serverReceivedPackets = unordered_set<int>();
|
||||
unordered_set<int> Packet::sendToAnyClientPackets = unordered_set<int>();
|
||||
|
||||
unordered_map<int, EPacketRoutingMode> Packet::packetRoutingModes = unordered_map<int, EPacketRoutingMode>();
|
||||
|
||||
EPacketRoutingMode Packet::GetRoutingMode(int packetId)
|
||||
{
|
||||
auto it = packetRoutingModes.find(packetId);
|
||||
if (it != packetRoutingModes.end())
|
||||
return it->second;
|
||||
return ROUTING_HOST_ONLY; // Default: everything goes through host
|
||||
}
|
||||
|
||||
void Packet::SetRoutingMode(int packetId, EPacketRoutingMode mode)
|
||||
{
|
||||
packetRoutingModes[packetId] = mode;
|
||||
}
|
||||
|
||||
// 4J Added
|
||||
unordered_map<int, Packet::PacketStatistics *> Packet::outgoingStatistics = unordered_map<int, Packet::PacketStatistics *>();
|
||||
vector<Packet::PacketStatistics *> Packet::renderableStats = vector<Packet::PacketStatistics *>();
|
||||
|
||||
@@ -8,14 +8,6 @@ class DataOutputStream;
|
||||
|
||||
#define PACKET_ENABLE_STAT_TRACKING 0
|
||||
|
||||
enum EPacketRoutingMode
|
||||
{
|
||||
ROUTING_HOST_ONLY = 0, // Must go through host (game state, actions, spawns)
|
||||
ROUTING_PREFER_DIRECT, // Use P2P if available, fall back to host
|
||||
ROUTING_DIRECT_ONLY, // Only send via P2P (keepalives, P2P-specific)
|
||||
ROUTING_BROADCAST // Send to all peers (host broadcasts)
|
||||
};
|
||||
|
||||
class Packet;
|
||||
|
||||
typedef shared_ptr<Packet> (*packetCreateFn)();
|
||||
@@ -61,10 +53,6 @@ public:
|
||||
static unordered_set<int> serverReceivedPackets;
|
||||
static unordered_set<int> sendToAnyClientPackets;
|
||||
|
||||
static unordered_map<int, EPacketRoutingMode> packetRoutingModes;
|
||||
static EPacketRoutingMode GetRoutingMode(int packetId);
|
||||
static void SetRoutingMode(int packetId, EPacketRoutingMode mode);
|
||||
|
||||
// 4J Stu - Added the sendToAnyClient param so we can limit some packets to be only sent to one player on a system
|
||||
// 4J Stu - Added renderStats param for use in debugging
|
||||
static void map(int id, bool receiveOnClient, bool receiveOnServer, bool sendToAnyClient, bool renderStats, const type_info& clazz, packetCreateFn );
|
||||
|
||||
@@ -6,10 +6,6 @@
|
||||
#include "..\Minecraft.Client\ServerConnection.h"
|
||||
#include <algorithm>
|
||||
#include "..\Minecraft.Client\PS3\PS3Extras\ShutdownManager.h"
|
||||
#ifdef _WINDOWS64
|
||||
#include "..\Minecraft.Client\Common\Network\PacketRouter.h"
|
||||
#include "..\Minecraft.Client\Common\Network\P2PConnectionManager.h"
|
||||
#endif
|
||||
|
||||
// This current socket implementation is for the creation of a single local link. 2 sockets can be created, one for either end of this local
|
||||
// link, the end (0 or 1) is passed as a parameter to the ctor.
|
||||
@@ -20,10 +16,6 @@ Socket::SocketOutputStreamLocal *Socket::s_hostOutStream[2];
|
||||
Socket::SocketInputStreamLocal *Socket::s_hostInStream[2];
|
||||
ServerConnection *Socket::s_serverConnection = NULL;
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
IP2PConnectionManager* Socket::s_p2pManager = NULL;
|
||||
#endif
|
||||
|
||||
void Socket::Initialise(ServerConnection *serverConnection)
|
||||
{
|
||||
s_serverConnection = serverConnection;
|
||||
@@ -508,36 +500,29 @@ void Socket::SocketOutputStreamNetwork::writeWithFlags(byteArray b, unsigned int
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
// Only attempt P2P for server->client sends (host broadcasting to clients)
|
||||
if( m_queueIdx == SOCKET_SERVER_END && s_p2pManager != NULL && g_PacketRouter.IsP2PEnabled() )
|
||||
{
|
||||
// Try to identify the packet ID from the serialized data
|
||||
// Packet format: first byte(s) contain the packet ID
|
||||
if( length >= 1 )
|
||||
{
|
||||
int packetId = (int)b[offset];
|
||||
EPacketRoutingMode routingMode = Packet::GetRoutingMode(packetId);
|
||||
|
||||
if( routingMode == ROUTING_PREFER_DIRECT || routingMode == ROUTING_DIRECT_ONLY )
|
||||
{
|
||||
if( s_p2pManager->IsDirectConnectionAvailable(socketPlayer) )
|
||||
{
|
||||
EP2PChannel channel = PacketRouter::GetChannelForPacket(packetId);
|
||||
s_p2pManager->SendDirect(socketPlayer, buffer.pbyData, buffer.dwDataSize, channel);
|
||||
return; // Sent via P2P, skip QNet
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if( m_queueIdx == SOCKET_SERVER_END )
|
||||
{
|
||||
//printf( "Sent %u bytes of data from \"%ls\" to \"%ls\"\n",
|
||||
//buffer.dwDataSize,
|
||||
//hostPlayer->GetGamertag(),
|
||||
//m_socket->networkPlayer->GetGamertag());
|
||||
|
||||
hostPlayer->SendData(socketPlayer, buffer.pbyData, buffer.dwDataSize, QNET_SENDDATA_RELIABLE | QNET_SENDDATA_SEQUENTIAL | flags);
|
||||
|
||||
// DWORD queueSize = hostPlayer->GetSendQueueSize( NULL, QNET_GETSENDQUEUESIZE_BYTES );
|
||||
// if( queueSize > 24000 )
|
||||
// {
|
||||
// //printf("Queue size is: %d, forcing doWork()\n",queueSize);
|
||||
// g_NetworkManager.DoWork();
|
||||
// }
|
||||
}
|
||||
else
|
||||
{
|
||||
//printf( "Sent %u bytes of data from \"%ls\" to \"%ls\"\n",
|
||||
//buffer.dwDataSize,
|
||||
//m_socket->networkPlayer->GetGamertag(),
|
||||
//hostPlayer->GetGamertag());
|
||||
|
||||
socketPlayer->SendData(hostPlayer, buffer.pbyData, buffer.dwDataSize, QNET_SENDDATA_RELIABLE | QNET_SENDDATA_SEQUENTIAL | flags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
#define SOCKET_CLIENT_END 0
|
||||
#define SOCKET_SERVER_END 1
|
||||
|
||||
// Forward declare P2P types
|
||||
class IP2PConnectionManager;
|
||||
enum EP2PChannel;
|
||||
|
||||
class SocketAddress;
|
||||
class ServerConnection;
|
||||
|
||||
@@ -135,11 +131,4 @@ public:
|
||||
|
||||
bool isClosing() { return m_endClosed[SOCKET_CLIENT_END] || m_endClosed[SOCKET_SERVER_END]; }
|
||||
BYTE getSmallId() { return networkPlayerSmallId; }
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
// P2P direct connection support
|
||||
static IP2PConnectionManager* s_p2pManager;
|
||||
static void SetP2PManager(IP2PConnectionManager* manager) { s_p2pManager = manager; }
|
||||
static IP2PConnectionManager* GetP2PManager() { return s_p2pManager; }
|
||||
#endif
|
||||
};
|
||||
Reference in New Issue
Block a user