diff options
author | EvilSeph <evilseph@unaligned.org> | 2011-05-09 14:51:01 -0400 |
---|---|---|
committer | EvilSeph <evilseph@unaligned.org> | 2011-05-09 14:51:01 -0400 |
commit | 0faaf5af8a5c8b1c804ee8f6f07afedd88814aeb (patch) | |
tree | f1021d66c76846e2871348fb5edcb4410dfd2b10 /src/main | |
parent | 98633a9f1693b339e8c86e169b6530318ba6442f (diff) | |
download | craftbukkit-0faaf5af8a5c8b1c804ee8f6f07afedd88814aeb.tar craftbukkit-0faaf5af8a5c8b1c804ee8f6f07afedd88814aeb.tar.gz craftbukkit-0faaf5af8a5c8b1c804ee8f6f07afedd88814aeb.tar.lz craftbukkit-0faaf5af8a5c8b1c804ee8f6f07afedd88814aeb.tar.xz craftbukkit-0faaf5af8a5c8b1c804ee8f6f07afedd88814aeb.zip |
Made the movement speed check more reliable on high load servers.
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/net/minecraft/server/MinecraftServer.java | 2 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/NetServerHandler.java | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index ce5df414..2acd3f93 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -55,6 +55,7 @@ public class MinecraftServer implements Runnable, ICommandListener { public OptionSet options; public ColouredConsoleSender console; public ConsoleReader reader; + public static int currentTick; // Craftbukkit end public MinecraftServer(OptionSet options) { // CraftBukkit - adds argument OptionSet @@ -281,6 +282,7 @@ public class MinecraftServer implements Runnable, ICommandListener { j = 0L; } else { while (j > 50L) { + MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit j -= 50L; this.h(); } diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index d314c7c0..84a04d09 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -38,6 +38,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { private double z; private boolean m = true; private Map n = new HashMap(); + private int lastTick = MinecraftServer.currentTick; // CraftBukkit public NetServerHandler(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) { this.minecraftServer = minecraftserver; @@ -277,11 +278,15 @@ public class NetServerHandler extends NetHandler implements ICommandListener { double d7 = d3 - this.player.locZ; double d8 = d4 * d4 + d6 * d6 + d7 * d7; - if (d8 > 100.0D) { - a.warning(this.player.name + " moved too quickly!"); + // CraftBukkit start - make the movement speed check behave properly under tick degradation. + int elapsedTicks = MinecraftServer.currentTick - this.lastTick; + if (d8 > 100.0D * (elapsedTicks == 0 ? 1 : elapsedTicks)) { + a.warning(this.player.name + " moved too quickly! Elapsed ticks: " + (elapsedTicks == 0 ? 1 : elapsedTicks) + ", Distance change: " + d8); this.disconnect("You moved too quickly :( (Hacking?)"); return; } + this.lastTick = MinecraftServer.currentTick; + // CraftBukkit end float f4 = 0.0625F; // CraftBukkit |