Merge remote-tracking branch 'origin/master' into Faster-Network

This commit is contained in:
Shoghi Cervantes 2014-02-06 14:48:00 +01:00
commit 5700235f80
21 changed files with 636 additions and 104 deletions

View File

@ -110,7 +110,7 @@ class EntityAPI{
public function spawnToAll(Entity $e){
foreach($this->server->api->player->getAll($e->level) as $player){
if($player->eid !== false and $player->eid !== $e->eid and $e->class !== ENTITY_PLAYER){
if($player->eid !== false and $player->eid !== $e->eid and $e->class !== ENTITY_PLAYER and $e instanceof Entity){
$e->spawn($player);
}
}

View File

@ -32,7 +32,7 @@ class PlayerAPI{
$this->server->api->console->register("kill", "<player>", array($this, "commandHandler"));
$this->server->api->console->register("gamemode", "<mode> [player]", array($this, "commandHandler"));
$this->server->api->console->register("tp", "[target player] <destination player|w:world> OR /tp [target player] <x> <y> <z>", array($this, "commandHandler"));
$this->server->api->console->register("spawnpoint", "[player] [x] [y] [z]", array($this, "commandHandler"));
$this->server->api->console->register("setspawn", "[player] [x] [y] [z]", array($this, "commandHandler"));
$this->server->api->console->register("spawn", "", array($this, "commandHandler"));
$this->server->api->console->register("ping", "", array($this, "commandHandler"));
$this->server->api->console->alias("lag", "ping");
@ -118,7 +118,7 @@ class PlayerAPI{
public function commandHandler($cmd, $params, $issuer, $alias){
$output = "";
switch($cmd){
case "spawnpoint":
case "setspawn":
if(!($issuer instanceof Player)){
$output .= "Please run this command in-game.\n";
break;
@ -306,17 +306,34 @@ class PlayerAPI{
return false;
}
public function get($name, $alike = true){
public function get($name, $alike = true, $multiple = false){
$name = trim(strtolower($name));
if($name === ""){
return false;
}
$CID = $this->server->query("SELECT ip,port FROM players WHERE name ".($alike === true ? "LIKE '%".$name."%'":"= '".$name."'").";", true);
$CID = PocketMinecraftServer::clientID($CID["ip"], $CID["port"]);
if(isset($this->server->clients[$CID])){
return $this->server->clients[$CID];
}
return false;
$query = $this->server->query("SELECT ip,port,name FROM players WHERE name ".($alike === true ? "LIKE '%".$name."%'":"= '".$name."'").";");
$players = array();
if($query !== false and $query !== true){
while(($d = $query->fetchArray(SQLITE3_ASSOC)) !== false){
$CID = PocketMinecraftServer::clientID($d["ip"], $d["port"]);
if(isset($this->server->clients[$CID])){
$players[$CID] = $this->server->clients[$CID];
if($multiple === false and $d["name"] === $name){
return $players[$CID];
}
}
}
}
if($multiple === false){
if(count($players) > 0){
return array_shift($players);
}else{
return false;
}
}else{
return $players;
}
}
public function getAll($level = null){
@ -429,7 +446,7 @@ class PlayerAPI{
$this->server->query("DELETE FROM players WHERE name = '".$player->username."';");
if($player->entity instanceof Entity){
unset($player->entity->player);
unset($player->entity);
//unset($player->entity);
}
$this->server->api->entity->remove($player->eid);
$player = null;

View File

@ -179,11 +179,11 @@ class PluginAPI extends stdClass{
}
public function readYAML($file){
return Spyc::YAMLLoad(file_get_contents($file));
return yaml_parse(preg_replace("#^([ ]*)([a-zA-Z_]{1}[^\:]*)\:#m", "$1\"$2\":", file_get_contents($file)));
}
public function writeYAML($file, $data){
return file_put_contents($file, Spyc::YAMLDump($data));
return file_put_contents($file, yaml_emit($data, YAML_UTF8_ENCODING));
}
public function init(){

View File

@ -145,7 +145,7 @@ class ServerAPI{
$this->server->api = $this;
self::$serverRequest = $this->server;
console("[INFO] This server is running PocketMine-MP version ".($version->isDev() ? FORMAT_YELLOW:"").MAJOR_VERSION.FORMAT_RESET." \"".CODENAME."\" (MCPE: ".CURRENT_MINECRAFT_VERSION.") (API ".CURRENT_API_VERSION.")", true, true, 0);
console("[INFO] PocketMine-MP is distibuted under the LGPL License", true, true, 0);
console("[INFO] PocketMine-MP is distributed under the LGPL License", true, true, 0);
if(ADVANCED_CACHE == true){
console("[INFO] Advanced cache enabled");

View File

@ -219,6 +219,9 @@ class Player{
"z" => $Z,
"data" => $this->level->getOrderedChunk($X, $Z, $Yndex),
));
if($cnt === false){
return false;
}
$this->chunkCount = array();
foreach($cnt as $i => $count){
$this->chunkCount[$count] = true;
@ -1282,6 +1285,8 @@ class Player{
$this->username = $data["username"];
$this->iusername = strtolower($this->username);
}else{
$this->username = $data["username"];
$this->iusername = strtolower($this->username);
$this->close("Bad username", false);
break;
}
@ -1417,7 +1422,7 @@ class Player{
if($this->spawned !== false){
break;
}
$this->entity->setHealth($this->data->get("health"));
$this->entity->setHealth($this->data->get("health"), "spawn", true);
$this->spawned = true;
$this->server->api->player->spawnAllPlayers($this);
$this->server->api->player->spawnToAllPlayers($this);
@ -1840,7 +1845,7 @@ class Player{
if($this->spawned === false){
break;
}
if($this->entity->dead === false){
if(@$this->entity->dead === false){
break;
}
$this->craftingItems = array();
@ -1849,7 +1854,7 @@ class Player{
if($this->entity instanceof Entity){
$this->entity->fire = 0;
$this->entity->air = 300;
$this->entity->setHealth(20, "respawn");
$this->entity->setHealth(20, "respawn", true);
$this->entity->updateMetadata();
}else{
break;
@ -1874,7 +1879,7 @@ class Player{
switch($data["event"]){
case 9: //Eating
$items = array(
APPLE => 2,
APPLE => 4,
MUSHROOM_STEW => 10,
BEETROOT_SOUP => 10,
BREAD => 5,

View File

@ -9,7 +9,7 @@ ZLIB_VERSION="1.2.8"
PTHREADS_VERSION="0.1.0"
PHPYAML_VERSION="1.1.1"
YAML_VERSION="0.1.4"
CURL_VERSION="curl-7_34_0"
CURL_VERSION="curl-7_35_0"
echo "[PocketMine] PHP installer and compiler for Linux & Mac"
DIR="$(pwd)"
@ -21,12 +21,27 @@ type autoconf >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \
type automake >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"automake\""; read -p "Press [Enter] to continue..."; exit 1; }
type libtool >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"libtool\""; read -p "Press [Enter] to continue..."; exit 1; }
type m4 >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"m4\""; read -p "Press [Enter] to continue..."; exit 1; }
type wget >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"wget\""; read -p "Press [Enter] to continue..."; exit 1; }
type wget >> "$DIR/install.log" 2>&1 || type curl >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"wget\" or \"curl\""; read -p "Press [Enter] to continue..."; exit 1; }
type getconf >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"getconf\""; read -p "Press [Enter] to continue..."; exit 1; }
#Needed to use aliases
shopt -s expand_aliases
type wget >> "$DIR/install.log" 2>&1
if [ $? -eq 0 ]; then
alias download_file="wget --no-check-certificate -q -O -"
else
type curl >> "$DIR/install.log" 2>&1
if [ $? -eq 0 ]; then
alias download_file="curl --insecure --silent --location"
else
echo "error, curl or wget not found"
fi
fi
export CC="gcc"
COMPILE_FOR_ANDROID=no
RANLIB=ranlib
HAVE_MYSQLI="--with-mysqli=mysqlnd"
if [ "$1" == "rpi" ]; then
[ -z "$march" ] && march=armv6zk;
[ -z "$mtune" ] && mtune=arm1176jzf-s;
@ -37,24 +52,31 @@ elif [ "$1" == "mac" ]; then
[ -z "$mtune" ] && mtune=generic;
[ -z "$CFLAGS" ] && CFLAGS="-fomit-frame-pointer";
echo "[INFO] Compiling for Intel MacOS"
elif [ "$1" == "ios" ]; then
[ -z "$march" ] && march=armv6;
[ -z "$mtune" ] && mtune=cortex-a8;
echo "[INFO] Compiling for iOS ARMv6"
elif [ "$1" == "crosscompile" ]; then
HAVE_MYSQLI="--without-mysqli"
if [ "$2" == "android" ] || [ "$2" == "android-armv6" ]; then
COMPILE_FOR_ANDROID=yes
[ -z "$march" ] && march=armv6;
[ -z "$mtune" ] && mtune=generic;
TOOLCHAIN_PREFIX="arm-none-linux-gnueabi"
[ -z "$mtune" ] && mtune=arm1136jf-s;
TOOLCHAIN_PREFIX="arm-unknown-linux-uclibcgnueabi"
export CC="$TOOLCHAIN_PREFIX-gcc"
CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX"
[ -z "$CFLAGS" ] && CFLAGS="-uclibc";
CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX --enable-static-link --disable-ipv6"
CFLAGS="-uclibc --static $CFLAGS";
LDFLAGS="--static"
echo "[INFO] Cross-compiling for Android ARMv6"
elif [ "$2" == "android-armv7" ]; then
COMPILE_FOR_ANDROID=yes
[ -z "$march" ] && march=armv7a;
[ -z "$mtune" ] && mtune=generic-armv7-a;
TOOLCHAIN_PREFIX="arm-none-linux-gnueabi"
[ -z "$march" ] && march=armv7-a;
[ -z "$mtune" ] && mtune=cortex-a8;
TOOLCHAIN_PREFIX="arm-unknown-linux-uclibcgnueabi"
export CC="$TOOLCHAIN_PREFIX-gcc"
CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX"
[ -z "$CFLAGS" ] && CFLAGS="-uclibc";
CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX --enable-static-link --disable-ipv6"
CFLAGS="-uclibc --static $CFLAGS";
LDFLAGS="--static"
echo "[INFO] Cross-compiling for Android ARMv7"
elif [ "$2" == "rpi" ]; then
TOOLCHAIN_PREFIX="arm-linux-gnueabihf"
@ -75,8 +97,16 @@ elif [ "$1" == "crosscompile" ]; then
#zlib doesn't use the correct ranlib
RANLIB=$TOOLCHAIN_PREFIX-ranlib
echo "[INFO] Cross-compiling for Intel MacOS"
elif [ "$2" == "ios" ] || [ "$2" == "ios-armv6" ]; then
[ -z "$march" ] && march=armv6;
[ -z "$mtune" ] && mtune=generic-armv6;
CONFIGURE_FLAGS="--target=arm-apple-darwin10"
elif [ "$2" == "ios-armv7" ]; then
[ -z "$march" ] && march=armv7-a;
[ -z "$mtune" ] && mtune=generic-armv7-a;
CONFIGURE_FLAGS="--target=arm-apple-darwin10"
else
echo "Please supply a proper platform [android android-armv6 android-armv7 rpi mac] to cross-compile"
echo "Please supply a proper platform [android android-armv6 android-armv7 rpi mac ios ios-armv6 ios-armv7] to cross-compile"
exit 1
fi
elif [ -z "$CFLAGS" ]; then
@ -89,26 +119,41 @@ elif [ -z "$CFLAGS" ]; then
fi
fi
cat > test.c <<'CTEST'
#include <stdio.h>
main(){
printf("Hello world\n");
}
CTEST
type $CC >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"$CC\""; read -p "Press [Enter] to continue..."; exit 1; }
[ -z "$THREADS" ] && THREADS=1;
[ -z "$march" ] && march=native;
[ -z "$mtune" ] && mtune=native;
[ -z "$CFLAGS" ] && CFLAGS="";
[ -z "$LDFLAGS" ] && LDFLAGS="";
[ -z "$CONFIGURE_FLAGS" ] && CONFIGURE_FLAGS="";
$CC -O2 -pipe -march=$march -mtune=$mtune -fno-gcse $CFLAGS -Q --help=target >> "$DIR/install.log" 2>&1
if [ $? -ne 0 ]; then
$CC -O2 -fno-gcse $CFLAGS -Q --help=target >> "$DIR/install.log" 2>&1
if [ $? -ne 0 ]; then
export CFLAGS="-O2 -fno-gcse "
else
export CFLAGS="-O2 -fno-gcse $CFLAGS"
if [ "$mtune" != "none" ]; then
$CC -march=$march -mtune=$mtune $CFLAGS -o test test.c >> "$DIR/install.log" 2>&1
if [ $? -eq 0 ]; then
CFLAGS="-march=$march -mtune=$mtune -fno-gcse $CFLAGS"
fi
else
export CFLAGS="-O2 -pipe -march=$march -mtune=$mtune -fno-gcse $CFLAGS"
$CC -march=$march $CFLAGS -o test test.c >> "$DIR/install.log" 2>&1
if [ $? -eq 0 ]; then
CFLAGS="-march=$march -fno-gcse $CFLAGS"
fi
fi
rm test >> "$DIR/install.log" 2>&1
rm test.c >> "$DIR/install.log" 2>&1
export CFLAGS="-O2 $CFLAGS"
export LDFLAGS="$LDFLAGS"
rm -r -f install_data/ >> "$DIR/install.log" 2>&1
rm -r -f bin/ >> "$DIR/install.log" 2>&1
@ -119,7 +164,7 @@ set -e
#PHP 5
echo -n "[PHP] downloading $PHP_VERSION..."
wget http://php.net/get/php-$PHP_VERSION.tar.gz/from/this/mirror -q -O - | tar -zx >> "$DIR/install.log" 2>&1
download_file "http://php.net/get/php-$PHP_VERSION.tar.gz/from/this/mirror" | tar -zx >> "$DIR/install.log" 2>&1
mv php-$PHP_VERSION php
echo " done!"
@ -128,7 +173,7 @@ if [ 1 ] || [ "$1" == "crosscompile" ] || [ "$1" == "rpi" ]; then
else
#libedit
echo -n "[libedit] downloading $LIBEDIT_VERSION..."
wget http://download.sourceforge.net/project/libedit/libedit/libedit-$LIBEDIT_VERSION/libedit-$LIBEDIT_VERSION.tar.gz -q -O - | tar -zx >> "$DIR/install.log" 2>&1
download_file "http://download.sourceforge.net/project/libedit/libedit/libedit-$LIBEDIT_VERSION/libedit-$LIBEDIT_VERSION.tar.gz" | tar -zx >> "$DIR/install.log" 2>&1
echo -n " checking..."
cd libedit
./configure --prefix="$DIR/install_data/php/ext/libedit" --enable-static >> "$DIR/install.log" 2>&1
@ -149,7 +194,7 @@ fi
#zlib
echo -n "[zlib] downloading $ZLIB_VERSION..."
wget http://zlib.net/zlib-$ZLIB_VERSION.tar.gz -q -O - | tar -zx >> "$DIR/install.log" 2>&1
download_file "http://zlib.net/zlib-$ZLIB_VERSION.tar.gz" | tar -zx >> "$DIR/install.log" 2>&1
mv zlib-$ZLIB_VERSION zlib
echo -n " checking..."
cd zlib
@ -165,16 +210,19 @@ rm -r -f ./zlib
echo " done!"
if [ "$(uname -s)" == "Darwin" ] && [ "$1" != "crosscompile" ] && [ "$2" != "curl" ]; then
HAVE_CURL="shared,/usr/local"
HAVE_CURL="shared,/usr"
else
#curl
echo -n "[cURL] downloading $CURL_VERSION..."
wget https://github.com/bagder/curl/archive/$CURL_VERSION.tar.gz --no-check-certificate -q -O - | tar -zx >> "$DIR/install.log" 2>&1
download_file "https://github.com/bagder/curl/archive/$CURL_VERSION.tar.gz" | tar -zx >> "$DIR/install.log" 2>&1
mv curl-$CURL_VERSION curl
echo -n " checking..."
cd curl
./buildconf >> "$DIR/install.log" 2>&1
./configure --enable-ipv6 \
if [ ! -f ./configure ]; then
./buildconf --force >> "$DIR/install.log" 2>&1
fi
./configure --disable-dependency-tracking \
--enable-ipv6 \
--enable-optimize \
--enable-http \
--enable-ftp \
@ -187,8 +235,13 @@ else
--disable-smtp \
--disable-telnet \
--disable-tftp \
--disable-ldap \
--disable-ldaps \
--without-libidn \
--enable-threaded-resolver \
--prefix="$DIR/install_data/php/ext/curl" \
--disable-shared \
--enable-static \
$CONFIGURE_FLAGS >> "$DIR/install.log" 2>&1
echo -n " compiling..."
make -j $THREADS >> "$DIR/install.log" 2>&1
@ -203,24 +256,27 @@ fi
#pthreads
echo -n "[PHP pthreads] downloading $PTHREADS_VERSION..."
wget http://pecl.php.net/get/pthreads-$PTHREADS_VERSION.tgz --no-check-certificate -q -O - | tar -zx >> "$DIR/install.log" 2>&1
download_file "http://pecl.php.net/get/pthreads-$PTHREADS_VERSION.tgz" | tar -zx >> "$DIR/install.log" 2>&1
mv pthreads-$PTHREADS_VERSION "$DIR/install_data/php/ext/pthreads"
echo " done!"
#PHP YAML
echo -n "[PHP YAML] downloading $PHPYAML_VERSION..."
wget http://pecl.php.net/get/yaml-$PHPYAML_VERSION.tgz --no-check-certificate -q -O - | tar -zx >> "$DIR/install.log" 2>&1
download_file "http://pecl.php.net/get/yaml-$PHPYAML_VERSION.tgz" | tar -zx >> "$DIR/install.log" 2>&1
mv yaml-$PHPYAML_VERSION "$DIR/install_data/php/ext/yaml"
echo " done!"
#YAML
echo -n "[YAML] downloading $YAML_VERSION..."
wget http://pyyaml.org/download/libyaml/yaml-$YAML_VERSION.tar.gz -q -O - | tar -zx >> "$DIR/install.log" 2>&1
download_file "http://pyyaml.org/download/libyaml/yaml-$YAML_VERSION.tar.gz" | tar -zx >> "$DIR/install.log" 2>&1
mv yaml-$YAML_VERSION yaml
echo -n " checking..."
cd yaml
RANLIB=$RANLIB ./configure --prefix="$DIR/install_data/php/ext/yaml" \
--enable-static --disable-shared >> "$DIR/install.log" 2>&1
RANLIB=$RANLIB ./configure \
--prefix="$DIR/install_data/php/ext/yaml" \
--enable-static \
--disable-shared \
$CONFIGURE_FLAGS >> "$DIR/install.log" 2>&1
echo -n " compiling..."
make -j $THREADS >> "$DIR/install.log" 2>&1
echo -n " installing..."
@ -286,7 +342,7 @@ $HAVE_LIBEDIT \
--enable-pthreads \
--enable-maintainer-zts \
--enable-zend-signals \
--with-mysqli=mysqlnd \
$HAVE_MYSQLI \
--enable-embedded-mysqli \
--enable-bcmath \
--enable-cli \
@ -300,6 +356,29 @@ fi
make -j $THREADS >> "$DIR/install.log" 2>&1
echo -n " installing..."
make install >> "$DIR/install.log" 2>&1
echo " generating php.ini..."
TIMEZONE=$(date +%Z)
touch "$DIR/bin/php5/lib/php.ini"
if [ "$1" != "crosscompile" ]; then
OPCACHE_PATH=$(find "$DIR/bin/php5" -name opcache.so)
echo "zend_extension=\"$OPCACHE_PATH\"" >> "$DIR/bin/php5/lib/php.ini"
echo "opcache.enable=1" >> "$DIR/bin/php5/lib/php.ini"
echo "opcache.enable_cli=1" >> "$DIR/bin/php5/lib/php.ini"
echo "opcache.save_comments=0" >> "$DIR/bin/php5/lib/php.ini"
echo "opcache.fast_shutdown=1" >> "$DIR/bin/php5/lib/php.ini"
echo "opcache.max_accelerated_files=4096" >> "$DIR/bin/php5/lib/php.ini"
echo "opcache.interned_strings_buffer=8" >> "$DIR/bin/php5/lib/php.ini"
echo "opcache.memory_consumption=128" >> "$DIR/bin/php5/lib/php.ini"
echo "opcache.optimization_level=0xffffffff" >> "$DIR/bin/php5/lib/php.ini"
fi
if [ "$HAVE_CURL" == "shared,/usr" ]; then
echo "extension=curl.so" >> "$DIR/bin/php5/lib/php.ini"
fi
echo "date.timezone=$TIMEZONE" >> "$DIR/bin/php5/lib/php.ini"
echo "short_open_tag=0" >> "$DIR/bin/php5/lib/php.ini"
echo "asp_tags=0" >> "$DIR/bin/php5/lib/php.ini"
echo " done!"
cd "$DIR"
echo -n "[INFO] Cleaning up..."

128
src/build/installer.sh Normal file
View File

@ -0,0 +1,128 @@
#!/bin/bash
PMMP_VERSION=""
MAC_BUILD="PHP_5.5.8_x86_MacOS"
RPI_BUILD="PHP_5.5.8_ARM_Raspbian_hard"
AND_BUILD="PHP_5.5.8_ARMv7_Android"
update=off
#Needed to use aliases
shopt -s expand_aliases
type wget > /dev/null 2>&1
if [ $? -eq 0 ]; then
alias download_file="wget --no-check-certificate -q -O -"
else
type curl >> /dev/null 2>&1
if [ $? -eq 0 ]; then
alias download_file="curl --insecure --silent --location"
else
echo "error, curl or wget not found"
fi
fi
while getopts "udv:" opt; do
case $opt in
u)
update=on
;;
d)
PMMP_VERSION="master"
;;
v)
PMMP_VERSION="$OPTARG"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
if [ "$PMMP_VERSION" == "" ]; then
PMMP_VERSION=$(download_file "https://api.github.com/repos/PocketMine/PocketMine-MP/tags" | grep '"name": "[A-Za-z0-9_\.]*",' | head -1 | sed -r 's/[ ]*"name": "([A-Za-z0-9_\.]*)",[ ]*/\1/')
if [ "$PMMP_VERSION" == "" ]; then
echo "[ERROR] Couldn't get the latest PocketMine-MP version"
exit 1
fi
fi
echo "[INFO] PocketMine-MP $PMMP_VERSION downloader & installer for Linux & Mac"
echo "[0/3] Cleaning..."
rm -r -f src/
rm -f PocketMine-MP.php
rm -f README.md
rm -f CONTRIBUTING.md
rm -f LICENSE
rm -f start.sh
rm -f start.bat
echo "[1/3] Downloading PocketMine-MP $PMMP_VERSION..."
set -e
download_file "https://github.com/shoghicp/PocketMine-MP/archive/$PMMP_VERSION.tar.gz" | tar -zx > /dev/null
mv -f PocketMine-MP-$PMMP_VERSION/* ./
rm -f -r PocketMine-MP-$PMMP_VERSION/
rm -f ./start.cmd
chmod +x ./start.sh
chmod +x ./src/build/compile.sh
if [ $update == on ]; then
echo "[3/3] Skipping PHP recompilation due to user request"
else
echo -n "[3/3] Obtaining PHP:"
echo " detecting if build is available..."
if [ "$(uname -s)" == "Darwin" ]; then
if ["$(uname -s)" == iPhone*] || ["$(uname -s)" == iPod*] || ["$(uname -s)" == iPad*]; then
echo -n "[3/3] No binaries for iOS available"
else
rm -r -f bin/ >> /dev/null 2>&1
echo -n "[3/3] Mac OSX PHP build available, downloading $MAC_BUILD.tar.gz..."
download_file "http://sourceforge.net/projects/pocketmine/files/builds/$MAC_BUILD.tar.gz" | tar -zx > /dev/null 2>&1
chmod +x ./bin/php5/bin/*
echo -n " regenerating php.ini..."
OPCACHE_PATH=$(find "./bin/php5" -name opcache.so)
echo "zend_extension=\"$OPCACHE_PATH\"" > "./bin/php5/lib/php.ini"
echo "opcache.enable=1" >> "./bin/php5/lib/php.ini"
echo "opcache.enable_cli=1" >> "./bin/php5/lib/php.ini"
echo "opcache.save_comments=0" >> "./bin/php5/lib/php.ini"
echo "opcache.fast_shutdown=1" >> "./bin/php5/lib/php.ini"
echo "opcache.max_accelerated_files=4096" >> "./bin/php5/lib/php.ini"
echo "opcache.interned_strings_buffer=8" >> "./bin/php5/lib/php.ini"
echo "opcache.memory_consumption=128" >> "./bin/php5/lib/php.ini"
echo "opcache.optimization_level=0xffffffff" >> "./bin/php5/lib/php.ini"
echo "date.timezone=$TIMEZONE" >> "./bin/php5/lib/php.ini"
echo "short_open_tag=0" >> "./bin/php5/lib/php.ini"
echo "asp_tags=0" >> "./bin/php5/lib/php.ini"
echo " done"
fi
else
set +e
grep -q BCM2708 /proc/cpuinfo > /dev/null 2>&1
if [ $? -eq 0 ]; then
set -e
rm -r -f bin/ >> /dev/null 2>&1
echo -n "[3/3] Raspberry Pi build available, downloading $RPI_BUILD.tar.gz..."
download_file "http://sourceforge.net/projects/pocketmine/files/builds/$RPI_BUILD.tar.gz" | tar -zx > /dev/null 2>&1
chmod +x ./bin/php5/bin/*
echo -n " regenerating php.ini..."
OPCACHE_PATH=$(find "./bin/php5" -name opcache.so)
echo "zend_extension=\"$OPCACHE_PATH\"" > "./bin/php5/lib/php.ini"
echo "opcache.enable=1" >> "./bin/php5/lib/php.ini"
echo "opcache.enable_cli=1" >> "./bin/php5/lib/php.ini"
echo "opcache.save_comments=0" >> "./bin/php5/lib/php.ini"
echo "opcache.fast_shutdown=1" >> "./bin/php5/lib/php.ini"
echo "opcache.max_accelerated_files=4096" >> "./bin/php5/lib/php.ini"
echo "opcache.interned_strings_buffer=8" >> "./bin/php5/lib/php.ini"
echo "opcache.memory_consumption=128" >> "./bin/php5/lib/php.ini"
echo "opcache.optimization_level=0xffffffff" >> "./bin/php5/lib/php.ini"
echo "date.timezone=$TIMEZONE" >> "./bin/php5/lib/php.ini"
echo "short_open_tag=0" >> "./bin/php5/lib/php.ini"
echo "asp_tags=0" >> "./bin/php5/lib/php.ini"
echo " done"
else
set -e
echo "[3/3] no build found, compiling PHP"
exec ./src/build/compile.sh
fi
fi
fi
echo "[INFO] Everything done! Run ./start.sh to start PocketMine-MP"
exit 0

182
src/build/jenkins.sh Normal file
View File

@ -0,0 +1,182 @@
#!/bin/bash -x
export PATH=/opt/arm-2013.05/bin:/opt/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin:/opt/arm-unknown-linux-uclibcgnueabi/bin:$PATH
export THREADS=2
#Needed to use aliases
shopt -s expand_aliases
type wget > /dev/null 2>&1
if [ $? -eq 0 ]; then
alias download_file="wget --no-check-certificate -q -O -"
else
type curl >> /dev/null 2>&1
if [ $? -eq 0 ]; then
alias download_file="curl --insecure --silent --location"
else
echo "error, curl or wget not found"
fi
fi
rm -rf $WORKSPACE/compile.sh
download_file "https://github.com/PocketMine/PocketMine-MP/raw/master/src/build/compile.sh" > $WORKSPACE/compile.sh
chmod +x $WORKSPACE/compile.sh
SCRIPT="$WORKSPACE/compile.sh"
ARCHIVE=$WORKSPACE/archive
COMPILEDIR=$WORKSPACE/compile
rm -rf $ARCHIVE $COMPILEDIR
mkdir -p $ARCHIVE
mkdir -p $COMPILEDIR
if [ "$COMPILE_LINUX_32BIT" = "true" ];
then
mkdir -p {$COMPILEDIR,$ARCHIVE}/linux/32bit
cd $COMPILEDIR/linux/32bit
CFLAGS=-m32 march=i686 mtune=generic $SCRIPT
cp -r $COMPILEDIR/linux/32bit/{install.log,bin/*,install_data/*} $ARCHIVE/linux/32bit/
if [ ! -f $COMPILEDIR/linux/32bit/bin/php5/bin/php ]; then
exit 1
fi
fi
if [ "$COMPILE_LINUX_64BIT" = "true" ];
then
mkdir -p {$COMPILEDIR,$ARCHIVE}/linux/64bit
cd $COMPILEDIR/linux/64bit
$SCRIPT
cp -r $COMPILEDIR/linux/64bit/{install.log,bin/*,install_data/*} $ARCHIVE/linux/64bit/
if [ ! -f $COMPILEDIR/linux/64bit/bin/php5/bin/php ]; then
exit 1
fi
fi
if [ "$COMPILE_MAC" = "true" ];
then
mkdir -p {$COMPILEDIR,$ARCHIVE}/mac
cd $COMPILEDIR/mac
curl -L http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz | tar -xz > /dev/null
cd libtool-2.4.2
./configure --prefix="$COMPILEDIR/mac/libtool" > /dev/null
make > /dev/null
make install
cd ../
rm -rf libtool-2.4.2
export LIBTOOL="$COMPILEDIR/mac/libtool/bin/libtool"
export LIBTOOLIZE="$COMPILEDIR/mac/libtool/bin/libtoolize"
$SCRIPT mac curl
cp -r $COMPILEDIR/mac/{install.log,bin/*,install_data/*} $ARCHIVE/mac/
if [ ! -f $COMPILEDIR/mac/bin/php5/bin/php ]; then
exit 1
fi
fi
if [ "$COMPILE_RPI" = "true" ];
then
mkdir -p {$COMPILEDIR,$ARCHIVE}/rpi
cd $COMPILEDIR/rpi
$SCRIPT rpi
cp -r $COMPILEDIR/rpi/{install.log,bin/*,install_data/*} $ARCHIVE/rpi/
if [ ! -f $COMPILEDIR/rpi/bin/php5/bin/php ]; then
exit 1
fi
fi
if [ "$CROSSCOMPILE_ANDROID_ARMV6" = "true" ];
then
mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/android-armv6
cd $COMPILEDIR/crosscompile/android-armv6
$SCRIPT crosscompile android-armv6
cp -r $COMPILEDIR/crosscompile/android-armv6/{install.log,bin/*,install_data/*} $ARCHIVE/crosscompile/android-armv6/
if [ ! -f $COMPILEDIR/crosscompile/android-armv6/bin/php5/bin/php ]; then
exit 1
fi
fi
if [ "$CROSSCOMPILE_ANDROID_ARMV7" = "true" ];
then
mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/android-armv7
cd $COMPILEDIR/crosscompile/android-armv7
$SCRIPT crosscompile android-armv7
cp -r $COMPILEDIR/crosscompile/android-armv7/{install.log,bin/*,install_data/*} $ARCHIVE/crosscompile/android-armv7/
if [ ! -f $COMPILEDIR/crosscompile/android-armv7/bin/php5/bin/php ]; then
exit 1
fi
fi
if [ "$CROSSCOMPILE_IOS_ARMV6" = "true" ];
then
mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/ios-armv6
cd $COMPILEDIR/crosscompile/ios-armv6
curl -L http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz | tar -xz > /dev/null
cd libtool-2.4.2
./configure --prefix="$COMPILEDIR/crosscompile/ios-armv6/libtool" > /dev/null
make > /dev/null
make install
cd ../
rm -rf libtool-2.4.2
export LIBTOOL="$COMPILEDIR/crosscompile/ios-armv6/libtool/bin/libtool"
export LIBTOOLIZE="$COMPILEDIR/crosscompile/ios-armv6/libtool/bin/libtoolize"
PATH="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH" $SCRIPT crosscompile ios-armv6
cp -r $COMPILEDIR/crosscompile/ios-armv6/{install.log,bin/*,install_data/*} $ARCHIVE/crosscompile/ios-armv6/
if [ ! -f $COMPILEDIR/crosscompile/ios-armv6/bin/php5/bin/php ]; then
exit 1
fi
fi
if [ "$CROSSCOMPILE_IOS_ARMV7" = "true" ];
then
mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/ios-armv7
cd $COMPILEDIR/crosscompile/ios-armv7
curl -L http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz | tar -xz > /dev/null
cd libtool-2.4.2
./configure --prefix="$COMPILEDIR/crosscompile/ios-armv7/libtool" > /dev/null
make > /dev/null
make install
cd ../
rm -rf libtool-2.4.2
export LIBTOOL="$COMPILEDIR/crosscompile/ios-armv7/libtool/bin/libtool"
export LIBTOOLIZE="$COMPILEDIR/crosscompile/ios-armv7/libtool/bin/libtoolize"
PATH="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH" $SCRIPT crosscompile ios-armv7
cp -r $COMPILEDIR/crosscompile/ios-armv7/{install.log,bin/*,install_data/*} $ARCHIVE/crosscompile/ios-armv7/
if [ ! -f $COMPILEDIR/crosscompile/ios-armv7/bin/php5/bin/php ]; then
exit 1
fi
fi
if [ "$CROSSCOMPILE_RPI" = "true" ];
then
mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/rpi
cd $COMPILEDIR/crosscompile/rpi
$SCRIPT crosscompile rpi
cp -r $COMPILEDIR/crosscompile/rpi/{install.log,bin/*,install_data/*} $ARCHIVE/crosscompile/rpi/
if [ ! -f $COMPILEDIR/crosscompile/rpi/bin/php5/bin/php ]; then
exit 1
fi
fi
if [ "$CROSSCOMPILE_MAC" = "true" ];
then
mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/mac
cd $COMPILEDIR/crosscompile/mac
$SCRIPT crosscompile mac curl
cp -r $COMPILEDIR/crosscompile/mac/{install.log,bin/*,install_data/*} $ARCHIVE/crosscompile/mac/
if [ ! -f $COMPILEDIR/crosscompile/mac/bin/php5/bin/php ]; then
exit 1
fi
fi

View File

@ -21,26 +21,36 @@
set_time_limit(0);
date_default_timezone_set("GMT");
if(strpos(" ".strtoupper(php_uname("s")), " WIN") !== false){
$time = time();
$time -= $time % 60;
//TODO: Parse different time & date formats by region. ¬¬ world
//Example: USA
exec("time.exe /T", $hour);
$i = array_map("intval", explode(":", trim($hour[0])));
exec("date.exe /T", $date);
$j = array_map("intval", explode(substr($date[0], 2, 1), trim($date[0])));
$offset = round((mktime($i[0], $i[1], 0, $j[1], $j[0], $j[2]) - $time) / 60) * 60;
if(ini_get("date.timezone") == ""){ //No Timezone set
date_default_timezone_set("GMT");
if(strpos(" ".strtoupper(php_uname("s")), " WIN") !== false){
$time = time();
$time -= $time % 60;
//TODO: Parse different time & date formats by region. ¬¬ world
//Example: USA
exec("time.exe /T", $hour);
$i = array_map("intval", explode(":", trim($hour[0])));
exec("date.exe /T", $date);
$j = array_map("intval", explode(substr($date[0], 2, 1), trim($date[0])));
$offset = round((mktime($i[0], $i[1], 0, $j[1], $j[0], $j[2]) - $time) / 60) * 60;
}else{
exec("date +%s", $t);
$offset = round((intval(trim($t[0])) - time()) / 60) * 60;
}
$daylight = (int) date("I");
$d = timezone_name_from_abbr("", $offset, $daylight);
ini_set("date.timezone", $d);
date_default_timezone_set($d);
}else{
exec("date +%s", $t);
$offset = round((intval(trim($t[0])) - time()) / 60) * 60;
$d = @date_default_timezone_get();
if(strpos($d, "/") === false){
$d = timezone_name_from_abbr($d);
ini_set("date.timezone", $d);
date_default_timezone_set($d);
}
}
$daylight = (int) date("I");
date_default_timezone_set(timezone_name_from_abbr("", $offset, $daylight));
gc_enable();
error_reporting(E_ALL | E_STRICT);
ini_set("allow_url_fopen", 1);

View File

@ -113,6 +113,7 @@ define("SUGARCANE", 338);
define("SUGAR_CANE", 338);
define("SUGAR_CANES", 338);
define("PAPER", 339);
define("BOOK", 340);
define("SLIMEBALL", 341);
define("EGG", 344);
@ -163,4 +164,4 @@ define("CAMERA", 456);
define("BEETROOT", 457);
define("BEETROOT_SEEDS", 458);
define("BEETROOT_SEED", 458);
define("BEETROOT_SOUP", 459);
define("BEETROOT_SOUP", 459);

View File

@ -222,7 +222,25 @@ function error_handler($errno, $errstr, $errfile, $errline){
if(error_reporting() === 0){ //@ error-control
return false;
}
console("[ERROR] A level ".$errno." error happened: \"$errstr\" in \"$errfile\" at line $errline", true, true, 0);
$errorConversion = array(
E_ERROR => "E_ERROR",
E_WARNING => "E_WARNING",
E_PARSE => "E_PARSE",
E_NOTICE => "E_NOTICE",
E_CORE_ERROR => "E_CORE_ERROR",
E_CORE_WARNING => "E_CORE_WARNING",
E_COMPILE_ERROR => "E_COMPILE_ERROR",
E_COMPILE_WARNING => "E_COMPILE_WARNING",
E_USER_ERROR => "E_USER_ERROR",
E_USER_WARNING => "E_USER_WARNING",
E_USER_NOTICE => "E_USER_NOTICE",
E_STRICT => "E_STRICT",
E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR",
E_DEPRECATED => "E_DEPRECATED",
E_USER_DEPRECATED => "E_USER_DEPRECATED",
);
$errno = isset($errorConversion[$errno]) ? $errorConversion[$errno]:$errno;
console("[ERROR] A ".$errno." error happened: \"$errstr\" in \"$errfile\" at line $errline", true, true, 0);
return true;
}

View File

@ -210,7 +210,7 @@ LICENSE;
//"lv" => "Latviešu",
"nl" => "Nederlands",
//"pt" => "Português",
//"sv" => "Svenska",
"sv" => "Svenska",
"fi" => "Suomi",
"tr" => "Türkçe",
//"et" => "Eesti",

View File

@ -29,6 +29,4 @@ class Window{
public function __construct(){
$this->server = ServerAPI::request();
}
}
?>
}

View File

@ -1,6 +1,21 @@
language_has_been_selected=وقد تم اختيار اللغة الإنجليزية بشكل صحيح.
skip_installer=هل تريد تخطي معالج الإعداد؟
welcome_to_pocketmine=مرحبا بكم في PocketMine-MP! \ nBefore بدء إعداد ملقم جديد لديك لقبول الترخيص. \ مرخص nPocketMine-MP تحت رخصة LGPL، \ n التي يمكنك أن تقرأ فتح ملف الترخيص على هذا folder.Do كنت ترغب في تخطي المعالج انشاء؟
accept_license=هل تقبل رخصة؟
you_have_to_accept_the_license=عليك أن تقبل رخصة LGPL إلى الاستمرار في استخدام PocketMine-MP
setting_up_server_now=أنت ذاهب لإعداد الخادم الخاص بك الآن.
default_values_info=إذا كنت لا تريد تغيير القيمة الافتراضية، فقط اضغط على Enter.
server_properties=يمكنك تحريرها في وقت لاحق على الملف server.properties.
name_your_server=إعطاء اسم على الخادم الخاص بك
port_warning=لا تقم بتغيير قيمة المنفذ الافتراضي إذا كان هذا هو الخادم الخاص بك أولا.
server_port=منفذ خادم
invalid_port=منفذ خادم غير صالحة
ram_warning=ذاكرة الوصول العشوائي هو الحد الأقصى لمقدار الذاكرة سوف تستخدم PocketMine-MP. ينصح قيمة 128-256 ميغا بايت
server_ram=RAM الخادم في ميغا بايت
gamemode_info=الاختيار بين العمل الإبداعي (1) أو البقاء على قيد الحياة (0)

View File

@ -1,6 +1,20 @@
language_has_been_selected=Norsk har blitt valgt.
skip_installer=Vil du hoppe over utpakking trollmannen?
welcome_to_pocketmine=Velkommen til PocketMine-MP!\nFør vi starter med å sette opp din nye server må du akseptere vår lisens.\nPocketMine-MP er lisensiert under LGPL lisensen,\nat du kan lese LISENS filen i denne mappen.
accept_license=Aksepterer du lisensen?
you_have_to_accept_the_license=Du må akseptere LGPL lisensen for å fortsette med å bruke PocketMine-MP
setting_up_server_now=Nå skal du sette opp din server.
default_values_info=Hvis du ikke vil gjøre forskjell med den ordinære verdien, så trenger du bare å trykke Enter.
server_properties=Du kan redigere dem senere i server.properties filen.
name_your_server=Gi et navn til din server
port_warning=Ikke bytt på den vanlige port verdien vis dette er din første server.
server_port=Server port
invalid_port=Ugyldig server port
ram_warning=RAMMEN er den maksimale beløpet PocketMine-MP vil bruke. A verdien av 128-256 MB er anbefalt
server_ram=Server RAMMEN i MB

View File

@ -1,6 +1,45 @@
language_has_been_selected=Svenska har bilvit valt.
skip_installer=Vill du hoppa över Installations programmet?
welcome_to_pocketmine=Välkommen till PocketMine-MP! Före du börja ställa in din server måste du godkänna licensen. PocketMIne-MP är licenserat under LGPL Licensen som du kan läsa genom att öppna LICENSE filen i den här mappen.
accept_license=Accepterar du Licensen?
you_have_to_accept_the_license=Du måste godkänna LGPL licensen för att fortsätta använda PocketMine-MP
setting_up_server_now=Du håller på att börja ställa in din server nu.
default_values_info=Om du inte vill ändra standard värdet, tryck bara ENTER.
server_properties=Du kan redigera dem senare i server.properies filen.
name_your_server=Ge ett namn till din server
port_warning=ändra INTE standard porten om detta är din första server.
server_port=Server port
invalid_port=Ogiltig Server port
ram_warning=RAM är max mängden minne PocketMine-MP kommer använda. Ett väre av 128-256 MB är rekommenderat
server_ram=Server RAM i MB
gamemode_info=Välj mellan Kreativt läge (1) eller Överlevnad (0)
default_gamemode=Standard spelläge
max_players=Max spelare online
spawn_protection_info=Spawn skydd stoppar spelare från att bygga / krossa block i Spawn-zonen förutom för OPs
spawn_protection=Aktivera Spawn-skydd?
op_info=En OP är en spelar Administratör på servern. OPs kan köra fler kommandon än vanliga spelare
op_who=OP spelar namn (Ditt IGN här)
op_warning=Du kommer kunna lägga till fler OPs senare me /op <spelare>
whitelist_info=whitelisten är en lista på spelare som får komma in på servern.
whitelist_enable=Vill du aktivera whitelisten?
whitelist_warning=Du måste i så fall lägga till spelare på whitelisten
query_warning1=Query är ett protokoll som används av olika verktyg för att samla in information om din server och spelare loggade in.
query_warning2=Om du stänger av den så kommer du inte kunna använda serverlistor.
query_disable=Vill du stänga av Query?
rcon_info=RCON är ett protocol för att trådlöst ansluta till server konsolen med ett lösenord.
rcon_enable=Vill du aktivera RCON?
rcon_password=RCON lösenord (kan bytas senare)
usage_info=Anonym data användning tillåter oss att räkna ut global statistik för PocketMine-MP och dess plugin. Du kan se dessa på stats.pocketmine.net
usage_disable=Vill du stänga av anonym data använding?
ip_get=Hämtar din externa IP och interna IP
ip_warning=Din externa Ip är {{EXTERNAL_IP}}} Du kan behöva göra en "port-foward" till din Interna IP {{INTERNAL_IP}}
ip_confirm=Var säker på att du kollar den. Om du måste göra en "port-foward" men skippar det så kommer inga externa spelare att kunna logga in på din server. [Tryck på ENTER]
you_have_finished=Du är nu klar. Allt har genomförts korrekt
pocketmine_will_start=Din Server kommer nu att starta. skriv /help eller /? för en list på tillgängliga kommandon.
pocketmine_plugins=Kolla in Plugin Hemsidan för att lägga till nya saker till din server, minispel, eller avancerat skydd

View File

@ -1,6 +1,31 @@
language_has_been_selected=Tiếng Anh đã được chọn.
skip_installer=Bạn có muốn bỏ qua hướng dẫn set-up?
welcome_to_pocketmine=Chào mừng tới PocketMine-MP!\nTrước khi bắt đầu, bạn phải chấp nhận hợp đồng. \nPocketMine-MP được hợp đồng bởi LGPL License,\nbạn có thể đọc file LICENSE trong thư mục này.
accept_license=Bạn có chấp nhận hợp đồng ?
you_have_to_accept_the_license=Bạn phải chấp nhận LGPL license để sử dụng PocketMine-MP
setting_up_server_now=Bạn sẽ bắt đầu set up server của bạn ngay.
default_values_info=Nếu bạn không muốn đổi giá trị mặc định, nhấn Enter.
server_properties=Bạn có thể chỉnh sửa lại vào file server.properties .
name_your_server=Đặt tên server
port_warning=Không được đổi giá trị port mặc định nếu đây là server đầu tiên của bạn.
server_port=Server port
invalid_port=Server port không đúng
ram_warning=RAM là tất cả bộ nhớ mà PocketMine-MP sẽ sử dụng. 128/256 MB là cần thiết
server_ram=Server RAM theo MB
gamemode_info=Chọn Creative (1) hoặc Survival (0)
default_gamemode=Chế độ mặc định
max_players=Giới hạn lượng người chơi
spawn_protection_info=Spawn protection không cho phép đặt/đập trong khu vực hồi sinh trừ OPs
spawn_protection=Mở Spawn protection?
op_info=OP là chủ/quản lí server. OPs có nhiều quyền hạn hơn người thường
op_who=Tên OP (ví dụ, tên bạn)
op_warning=Bạn có thể thêm OP bằng lệnh /op <player>
whitelist_info=White-list chỉ cho người có phép của quản lí tham gia.
whitelist_enable=Bạn có muốn bật white-list?
whitelist_warning=Bạn sẽ phải thêm người chơi vào white-list

View File

@ -283,7 +283,7 @@ class PMFLevel extends PMF{
return str_repeat("\x00", 8192);
}
$index = $this->getIndex($X, $Z);
if($this->chunks[$index][$Y] === false){
if(!isset($this->chunks[$index][$Y]) or $this->chunks[$index][$Y] === false){
return str_repeat("\x00", 8192);
}
return $this->chunks[$index][$Y];

View File

@ -23,11 +23,12 @@ class Cache{
public static $cached = array();
public static function add($identifier, $blob, $minTTL = 30){
self::$cached[$identifier] = array($blob, microtime(true) + $minTTL);
self::$cached[$identifier] = array($blob, microtime(true) + $minTTL, $minTTL);
}
public static function get($identifier){
if(isset(self::$cached[$identifier])){
self::$cached[$identifier][1] += $minTTL;
return self::$cached[$identifier][0];
}
return false;

View File

@ -121,7 +121,7 @@ class Utils{
}
public static function readTriad($str){
list(,$unpacked) = unpack("N", "\x00".$str);
list(,$unpacked) = @unpack("N", "\x00".$str);
return $unpacked;
}
@ -457,7 +457,7 @@ class Utils{
}
public static function readShort($str, $signed = true){
list(,$unpacked) = unpack("n", $str);
list(,$unpacked) = @unpack("n", $str);
if($unpacked > 0x7fff and $signed === true){
$unpacked -= 0x10000; // Convert unsigned short to signed short
}
@ -472,7 +472,7 @@ class Utils{
}
public static function readLShort($str, $signed = true){
list(,$unpacked) = unpack("v", $str);
list(,$unpacked) = @unpack("v", $str);
if($unpacked > 0x7fff and $signed === true){
$unpacked -= 0x10000; // Convert unsigned short to signed short
}
@ -487,7 +487,7 @@ class Utils{
}
public static function readInt($str){
list(,$unpacked) = unpack("N", $str);
list(,$unpacked) = @unpack("N", $str);
if($unpacked >= 2147483648){
$unpacked -= 4294967296;
}
@ -502,7 +502,7 @@ class Utils{
}
public static function readLInt($str){
list(,$unpacked) = unpack("V", $str);
list(,$unpacked) = @unpack("V", $str);
if($unpacked >= 2147483648){
$unpacked -= 4294967296;
}
@ -517,7 +517,7 @@ class Utils{
}
public static function readFloat($str){
list(,$value) = ENDIANNESS === BIG_ENDIAN ? unpack("f", $str):unpack("f", strrev($str));
list(,$value) = ENDIANNESS === BIG_ENDIAN ? @unpack("f", $str):@unpack("f", strrev($str));
return $value;
}
@ -526,7 +526,7 @@ class Utils{
}
public static function readLFloat($str){
list(,$value) = ENDIANNESS === BIG_ENDIAN ? unpack("f", strrev($str)):unpack("f", $str);
list(,$value) = ENDIANNESS === BIG_ENDIAN ? @unpack("f", strrev($str)):@unpack("f", $str);
return $value;
}
@ -539,7 +539,7 @@ class Utils{
}
public static function readDouble($str){
list(,$value) = ENDIANNESS === BIG_ENDIAN ? unpack("d", $str):unpack("d", strrev($str));
list(,$value) = ENDIANNESS === BIG_ENDIAN ? @unpack("d", $str):@unpack("d", strrev($str));
return $value;
}
@ -548,7 +548,7 @@ class Utils{
}
public static function readLDouble($str){
list(,$value) = ENDIANNESS === BIG_ENDIAN ? unpack("d", strrev($str)):unpack("d", $str);
list(,$value) = ENDIANNESS === BIG_ENDIAN ? @unpack("d", strrev($str)):@unpack("d", $str);
return $value;
}

View File

@ -80,15 +80,15 @@ class Entity extends Position{
$this->name = "";
$this->tickCounter = 0;
$this->server->query("INSERT OR REPLACE INTO entities (EID, level, type, class, health, hasUpdate) VALUES (".$this->eid.", '".$this->level->getName()."', ".$this->type.", ".$this->class.", ".$this->health.", 0);");
$this->x = isset($this->data["x"]) ? $this->data["x"]:0;
$this->y = isset($this->data["y"]) ? $this->data["y"]:0;
$this->z = isset($this->data["z"]) ? $this->data["z"]:0;
$this->speedX = isset($this->data["speedX"]) ? $this->data["speedX"]:0;
$this->speedY = isset($this->data["speedY"]) ? $this->data["speedY"]:0;
$this->speedZ = isset($this->data["speedZ"]) ? $this->data["speedZ"]:0;
$this->x = isset($this->data["x"]) ? (float) $this->data["x"]:0;
$this->y = isset($this->data["y"]) ? (float) $this->data["y"]:0;
$this->z = isset($this->data["z"]) ? (float) $this->data["z"]:0;
$this->speedX = isset($this->data["speedX"]) ? (float) $this->data["speedX"]:0;
$this->speedY = isset($this->data["speedY"]) ? (float) $this->data["speedY"]:0;
$this->speedZ = isset($this->data["speedZ"]) ? (float) $this->data["speedZ"]:0;
$this->speed = 0;
$this->yaw = isset($this->data["yaw"]) ? $this->data["yaw"]:0;
$this->pitch = isset($this->data["pitch"]) ? $this->data["pitch"]:0;
$this->yaw = isset($this->data["yaw"]) ? (float) $this->data["yaw"]:0;
$this->pitch = isset($this->data["pitch"]) ? (float) $this->data["pitch"]:0;
$this->position = array("level" => $this->level, "x" => &$this->x, "y" => &$this->y, "z" => &$this->z, "yaw" => &$this->yaw, "pitch" => &$this->pitch);
switch($this->class){
case ENTITY_PLAYER:
@ -971,7 +971,7 @@ class Entity extends Position{
}else{
return false; //Entity inmunity
}
}elseif($health === $this->health){
}elseif($health === $this->health and !$this->dead){
return false;
}
if($this->server->api->dhandle("entity.health.change", array("entity" => $this, "eid" => $this->eid, "health" => $health, "cause" => $cause)) !== false or $force === true){