summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvilSeph <evilseph@unaligned.org>2011-06-10 03:42:36 -0400
committerEvilSeph <evilseph@unaligned.org>2011-06-10 03:52:49 -0400
commitad95bf409540f39bf2a2788cee3c84856d2638fc (patch)
tree08d0706b8fb95692e2a5dfaac398679016efef3a
parentcb9c7d1b2a27965f5a3336ef073800d10adcd56f (diff)
downloadcraftbukkit-ad95bf409540f39bf2a2788cee3c84856d2638fc.tar
craftbukkit-ad95bf409540f39bf2a2788cee3c84856d2638fc.tar.gz
craftbukkit-ad95bf409540f39bf2a2788cee3c84856d2638fc.tar.lz
craftbukkit-ad95bf409540f39bf2a2788cee3c84856d2638fc.tar.xz
craftbukkit-ad95bf409540f39bf2a2788cee3c84856d2638fc.zip
Redid packet prioritisation to fix chunk loss bug encountered when teleporting, also addresses issues caused by teleport fixes.
-rw-r--r--src/main/java/net/minecraft/server/NetworkManager.java29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
index b8b5f4b4..04300731 100644
--- a/src/main/java/net/minecraft/server/NetworkManager.java
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
@@ -93,32 +93,39 @@ public class NetworkManager {
try {
Object object;
- Packet packet = null; // CraftBukkit
+ Packet packet;
int i;
int[] aint;
- // CraftBukkit start - thread safety and prioitizing packets in this.n (high prioirty queue) over those in this.o (low priority queue).
- object = this.g;
- synchronized (this.g) {
- long time = System.currentTimeMillis();
- if (!this.n.isEmpty() && (this.f == 0 || time - ((Packet) this.n.get(0)).timestamp >= (long) this.f)) {
+ if (!this.n.isEmpty() && (this.f == 0 || System.currentTimeMillis() - ((Packet) this.n.get(0)).timestamp >= (long) this.f)) {
+ object = this.g;
+ synchronized (this.g) {
packet = (Packet) this.n.remove(0);
this.x -= packet.a() + 1;
- } else if (this.y-- <= 0 && !this.o.isEmpty() && (this.f == 0 || time - ((Packet) this.o.get(0)).timestamp >= (long) this.f)) {
+ }
+
+ Packet.a(packet, this.output);
+ aint = e;
+ i = packet.b();
+ aint[i] += packet.a() + 1;
+ flag = true;
+ }
+
+ // CraftBukkit - don't allow low priority packet to be sent unless it was placed in the queue before the first packet on the high priority queue
+ if ((flag || this.y-- <= 0) && !this.o.isEmpty() && (this.n.isEmpty() || ((Packet) this.n.get(0)).timestamp > ((Packet) this.o.get(0)).timestamp)) {
+ object = this.g;
+ synchronized (this.g) {
packet = (Packet) this.o.remove(0);
this.x -= packet.a() + 1;
- this.y = 0;
}
- }
- if (packet != null) {
Packet.a(packet, this.output);
aint = e;
i = packet.b();
aint[i] += packet.a() + 1;
+ this.y = 0;
flag = true;
}
- // CraftBukkit end
return flag;
} catch (Exception exception) {