From 4766424cb34d074c49dc8c888cdd1fc72fa991bf Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Tue, 21 May 2013 18:40:00 +0200 Subject: [PATCH] Fixed moving to fast message during Player blocking --- src/Player.php | 4 +++- src/utils/MersenneTwister.php | 44 ++++++----------------------------- 2 files changed, 10 insertions(+), 38 deletions(-) diff --git a/src/Player.php b/src/Player.php index c7bfb71b62..91dae8e971 100644 --- a/src/Player.php +++ b/src/Player.php @@ -962,7 +962,9 @@ class Player{ if($this->lastCorrect instanceof Vector3){ $this->teleport($this->lastCorrect, $this->entity->yaw, $this->entity->pitch, false); } - console("[WARNING] ".$this->username." moved too quickly!"); + if($this->blocked !== true){ + console("[WARNING] ".$this->username." moved too quickly!"); + } }else{ $this->entity->setPosition(new Vector3($data["x"], $data["y"], $data["z"]), $data["yaw"], $data["pitch"]); } diff --git a/src/utils/MersenneTwister.php b/src/utils/MersenneTwister.php index a4253152b4..b5da54a65f 100644 --- a/src/utils/MersenneTwister.php +++ b/src/utils/MersenneTwister.php @@ -106,7 +106,7 @@ class twister { */ $i++; $j++; if ($i>=N) { $mt[0] = $mt[N-1]; $i=1; } - if ($j>=$key_length) $j=0; + if ($j>=$key_length){ $j=0; } } for ($k=N-1; $k; $k--) { $mt[$i] = sub($mt[$i] ^ @@ -125,8 +125,9 @@ class twister { function init_with_string($string) { $remainder = strlen($string) % 4; - if($remainder > 0) + if($remainder > 0){ $string .= str_repeat("\0", 4 - $remainder); + } $integer_array = array_values(unpack("N*", $string)); @@ -136,9 +137,9 @@ class twister { function init_with_files(array $filenames, $max_ints = -1) { $limit_applies = $max_ints !== -1; - if($limit_applies) + if($limit_applies){ $limit = $max_ints * 4; # 32 bits is 4 characters - + } $data = ""; foreach ($filenames as $filename) { @@ -329,38 +330,6 @@ class twister { return $rand; } - function test() { - ob_start(); - $this->exercise(); - $output = ob_get_clean(); - - if(md5($output) !== "cb33e6acc162cbe20f7fcac26adddd02") { - print "Test failed.\n"; - } - } - - private function exercise() { - /* - we keep the names "genrand_int32" and "genrand_real2" because - we want the output of this function to be identical to that - produced by mtTest.c. (The file mtTest.c is part of the archive - mt19937ar.sep.tgz, mentioned above.) - */ - - $this->init_with_array(array(0x123, 0x234, 0x345, 0x456)); - printf("1000 outputs of genrand_int32()\n"); - for ($i=0; $i<1000; $i++) { - printf("%10lu ", $this->int32()); - if ($i%5==4) printf("\n"); - } - printf("\n1000 outputs of genrand_real2()\n"); - for ($i=0; $i<1000; $i++) { - printf("%10.8f ", $this->real_halfopen()); - if ($i%5==4) printf("\n"); - } - } -} - function signed2unsigned($signed_integer) { ## assert(is_integer($signed_integer)); ## assert(($signed_integer & ~MASK32) === 0); @@ -403,8 +372,9 @@ function force_32_bit_int($x) { $x = fmod($x, TWO_TO_THE_32); - if($x < 0) + if($x < 0){ $x += TWO_TO_THE_32; + } return unsigned2signed($x); }