aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Connection.cpp
diff options
context:
space:
mode:
authorLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
committerLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
commit42aec6dac53dffa6afe072560a7e1d4986112538 (patch)
tree0836426857391df1b6a83f6368a183f83ec9b104 /Minecraft.World/Connection.cpp
parentc9d58eeac7c72f0b3038e084667b4d89a6249fce (diff)
parentef9b6fd500dfabd9463267b0dd9e29577eea8a2b (diff)
Merge branch 'main' into pr/win64-world-saves
# Conflicts: # Minecraft.Client/MinecraftServer.cpp # README.md
Diffstat (limited to 'Minecraft.World/Connection.cpp')
-rw-r--r--Minecraft.World/Connection.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/Minecraft.World/Connection.cpp b/Minecraft.World/Connection.cpp
index 4392fe54..09f72be0 100644
--- a/Minecraft.World/Connection.cpp
+++ b/Minecraft.World/Connection.cpp
@@ -174,8 +174,10 @@ void Connection::send(shared_ptr<Packet> packet)
void Connection::queueSend(shared_ptr<Packet> packet)
{
if (quitting) return;
+ EnterCriticalSection(&writeLock);
estimatedRemaining += packet->getEstimatedSize() + 1;
outgoing_slow.push(packet);
+ LeaveCriticalSection(&writeLock);
}
bool Connection::writeTick()
@@ -204,8 +206,20 @@ bool Connection::writeTick()
#ifndef _CONTENT_PACKAGE
// 4J Added for debugging
+ int playerId = 0;
if( !socket->isLocal() )
- Packet::recordOutgoingPacket(packet);
+ {
+ Socket *socket = getSocket();
+ if( socket )
+ {
+ INetworkPlayer *player = socket->getPlayer();
+ if( player )
+ {
+ playerId = player->GetSmallId();
+ }
+ }
+ Packet::recordOutgoingPacket(packet,playerId);
+ }
#endif
// 4J Stu - Changed this so that rather than writing to the network stream through a buffered stream we want to:
@@ -241,7 +255,11 @@ bool Connection::writeTick()
// 4J Stu - Changed this so that rather than writing to the network stream through a buffered stream we want to:
// a) Only push whole "game" packets to QNet, rather than amalgamated chunks of data that may include many packets, and partial packets
// b) To be able to change the priority and queue of a packet if required
+#ifdef _XBOX
int flags = QNET_SENDDATA_LOW_PRIORITY | QNET_SENDDATA_SECONDARY;
+#else
+ int flags = NON_QNET_SENDDATA_ACK_REQUIRED;
+#endif
sos->writeWithFlags( baos->buf, 0, baos->size(), flags );
baos->reset();
}
@@ -253,7 +271,22 @@ bool Connection::writeTick()
#ifndef _CONTENT_PACKAGE
// 4J Added for debugging
if( !socket->isLocal() )
- Packet::recordOutgoingPacket(packet);
+ {
+ int playerId = 0;
+ if( !socket->isLocal() )
+ {
+ Socket *socket = getSocket();
+ if( socket )
+ {
+ INetworkPlayer *player = socket->getPlayer();
+ if( player )
+ {
+ playerId = player->GetSmallId();
+ }
+ }
+ Packet::recordOutgoingPacket(packet,playerId);
+ }
+ }
#endif
writeSizes[packet->getId()] += packet->getEstimatedSize() + 1;