Fixed packet-related stuff

This commit is contained in:
Shoghi Cervantes
2013-05-21 20:29:10 +02:00
parent acc373525f
commit 49716cfb18
2 changed files with 14 additions and 19 deletions

View File

@@ -90,11 +90,13 @@ class MinecraftInterface{
"ip" => $source, "ip" => $source,
"port" => $port "port" => $port
)) !== true){ )) !== true){
console("[ERROR] Unknown Packet ID 0x".Utils::strToHex(chr($pid)), true, true, 0); if(LOG === true and DEBUG >= 3){
$p = "[".(microtime(true) - $this->start)."] [".((($origin === "client" and $this->client === true) or ($origin === "server" and $this->client === false)) ? "CLIENT->SERVER":"SERVER->CLIENT")." ".$ip.":".$port."]: Error, bad packet id 0x".Utils::strToHex(chr($pid))." [length ".strlen($buf)."]".PHP_EOL; console("[ERROR] Unknown Packet ID 0x".Utils::strToHex(chr($pid)), true, true, 0);
$p .= Utils::hexdump($buf); $p = "[".(microtime(true) - $this->start)."] [CLIENT->SERVER ".$source.":".$port."]: Error, bad packet id 0x".Utils::strToHex(chr($pid))." [length ".strlen($buf)."]".PHP_EOL;
$p .= PHP_EOL; $p .= Utils::hexdump($buf);
logg($p, "packets", true, 2); $p .= PHP_EOL;
logg($p, "packets", true, 2);
}
} }
return false; return false;
} }

View File

@@ -194,26 +194,22 @@ class twister {
/* generates a random number on [0,1]-real-interval */ /* generates a random number on [0,1]-real-interval */
function real_closed() { function real_closed() {
return return signed2unsigned($this->int32()) * (1.0 / 4294967295.0);
signed2unsigned($this->int32()) * (1.0 / 4294967295.0);
} }
/* generates a random number on [0,1)-real-interval */ /* generates a random number on [0,1)-real-interval */
function real_halfopen() { function real_halfopen() {
return return signed2unsigned($this->int32()) * (1.0 / 4294967296.0);
signed2unsigned($this->int32()) * (1.0 / 4294967296.0);
} }
/* generates a random number on (0,1)-real-interval */ /* generates a random number on (0,1)-real-interval */
function real_open() { function real_open() {
return (signed2unsigned($this->int32()) + .5) * return (signed2unsigned($this->int32()) + .5) * (1.0 / 4294967296.0);
(1.0 / 4294967296.0);
} }
/* generates a random number on [0,1) with 53-bit resolution */ /* generates a random number on [0,1) with 53-bit resolution */
function real_halfopen2() { function real_halfopen2() {
return return ((($this->int32() & MASK27) * 67108864.0) +
((($this->int32() & MASK27) * 67108864.0) +
($this->int32() & MASK26)) * ($this->int32() & MASK26)) *
(1.0 / 9007199254740992.0); (1.0 / 9007199254740992.0);
} }
@@ -386,8 +382,7 @@ function force_32_bit_int($x) {
function add_2($n1, $n2) { function add_2($n1, $n2) {
$x = ($n1 & 0xffff) + ($n2 & 0xffff); $x = ($n1 & 0xffff) + ($n2 & 0xffff);
return return (((($n1 >> 16) & 0xffff) +
(((($n1 >> 16) & 0xffff) +
(($n2 >> 16) & 0xffff) + (($n2 >> 16) & 0xffff) +
($x >> 16)) << 16) | ($x & 0xffff); ($x >> 16)) << 16) | ($x & 0xffff);
} }
@@ -400,8 +395,7 @@ function add_2($n1, $n2) {
function add_3($n1, $n2, $n3) { function add_3($n1, $n2, $n3) {
$x = ($n1 & 0xffff) + ($n2 & 0xffff) + ($n3 & 0xffff); $x = ($n1 & 0xffff) + ($n2 & 0xffff) + ($n3 & 0xffff);
return return (((($n1 >> 16) & 0xffff) +
(((($n1 >> 16) & 0xffff) +
(($n2 >> 16) & 0xffff) + (($n2 >> 16) & 0xffff) +
(($n3 >> 16) & 0xffff) + (($n3 >> 16) & 0xffff) +
($x >> 16)) << 16) | ($x & 0xffff); ($x >> 16)) << 16) | ($x & 0xffff);
@@ -443,8 +437,7 @@ function mul($a, $b) {
variables, but that would probably hurt performance. variables, but that would probably hurt performance.
*/ */
return return unsigned2signed(
unsigned2signed(
fmod( fmod(
TWO_TO_THE_16 * TWO_TO_THE_16 *
/* /*