Merge branch 'master' into Core-Rewrite

Conflicts:
	src/level/LevelImport.php
	src/pmf/LevelFormat.php
This commit is contained in:
Shoghi Cervantes 2014-03-08 03:34:53 +01:00
commit 8d75bff34b
6 changed files with 318 additions and 355 deletions

View File

@ -1,12 +1,12 @@
![](http://www.pocketmine.net/favicon.png) ![](http://cdn.pocketmine.net/img/PocketMine-MP-h.png)
# PocketMine-MP Contribution Guidelines # PocketMine-MP Contribution Guidelines
Before contributing to PocketMine-MP, please read this. Before contributing to PocketMine-MP, please read this. Also, take a look if your contribution fits the PocketMine-MP goals below.
## I've a question ## I've a question
* For questions, please refer to the _#pocketmine_ or _#mcpedevs_ IRC channel on Freenode. There is a [WebIRC](http://webchat.freenode.net?channels=pockdetmine,mcpedevs&uio=d4) if you want. * For questions, please refer to the _#pocketmine_ or _#mcpedevs_ IRC channel on Freenode. There is a [WebIRC](http://webchat.freenode.net?channels=pocketmine,mcpedevs&uio=d4) if you want.
* You can ask directly to _[@PocketMine](https://twitter.com/PocketMine)_ in Twitter, but don't expect an inmediate reply. * You can ask directly to _[@PocketMine](https://twitter.com/PocketMine)_ in Twitter, but don't expect an inmediate reply.
## I want to create an issue ## I want to create an issue
@ -28,8 +28,7 @@ __Thanks for contributing to PocketMine-MP!__
### Code syntax
#### Code syntax
It is mainly [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) with a few exceptions. It is mainly [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) with a few exceptions.
* Opening braces MUST go on the same line. * Opening braces MUST go on the same line.
@ -39,7 +38,7 @@ It is mainly [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accept
* Long arrays MAY be split across multiple lines, where each subsequent line is indented once. * Long arrays MAY be split across multiple lines, where each subsequent line is indented once.
* Files MUST use only the `<?php` tag. * Files MUST use only the `<?php` tag.
* Files MUST NOT have an ending `?>` tag. * Files MUST NOT have an ending `?>` tag.
* Code MUST NOT use namespaces. _(This restriction will be lifted on the Alpha_1.4 code)_ * Code MUST NOT use namespaces. Descriptive and unique class names are enforced.
* Strings SHOULD use the double quote `"` except when the single quote is required. * Strings SHOULD use the double quote `"` except when the single quote is required.
* Arrays SHOULD be declared using `array()`, not the `[]` shortcut. * Arrays SHOULD be declared using `array()`, not the `[]` shortcut.
* Argument lists MAY NOT be split across multiple lines, except long arrays. * Argument lists MAY NOT be split across multiple lines, except long arrays.
@ -70,4 +69,4 @@ class ExampleClass{
} }
} }
``` ```

View File

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
PHP_VERSION="5.5.9" PHP_VERSION="5.5.10"
ZEND_VM="GOTO" ZEND_VM="GOTO"
ZLIB_VERSION="1.2.8" ZLIB_VERSION="1.2.8"
OPENSSL_VERSION="0.9.8y" OPENSSL_VERSION="1.0.0l"
CURL_VERSION="curl-7_35_0" CURL_VERSION="curl-7_35_0"
LIBEDIT_VERSION="0.3" LIBEDIT_VERSION="0.3"
PTHREADS_VERSION="0.1.0" PTHREADS_VERSION="0.1.0"
@ -41,36 +41,60 @@ export CC="gcc"
COMPILE_FOR_ANDROID=no COMPILE_FOR_ANDROID=no
RANLIB=ranlib RANLIB=ranlib
HAVE_MYSQLI="--with-mysqli=mysqlnd" HAVE_MYSQLI="--with-mysqli=mysqlnd"
if [ "$1" == "rpi" ]; then COMPILE_TARGET=""
[ -z "$march" ] && march=armv6zk; COMPILE_OPENSSL="no"
[ -z "$mtune" ] && mtune=arm1176jzf-s; COMPILE_CURL="default"
[ -z "$CFLAGS" ] && CFLAGS="-mfloat-abi=hard -mfpu=vfp"; COMPILE_LIBEDIT="no"
OPENSSL_TARGET="linux-armv4" IS_CROSSCOMPILE="no"
echo "[INFO] Compiling for Raspberry Pi ARMv6zk hard float" DO_OPTIMIZE="no"
elif [ "$1" == "mac" ]; then while getopts "t:oj:cxf::" OPTION; do
[ -z "$march" ] && march=prescott; case $OPTION in
[ -z "$mtune" ] && mtune=generic; t)
[ -z "$CFLAGS" ] && CFLAGS="-m32 -arch i386 -fomit-frame-pointer -mmacosx-version-min=10.5"; echo "[opt] Set target to $OPTARG"
[ -z "$LDFLAGS" ] && LDFLAGS="-Wl,-rpath,@loader_path/../lib"; COMPILE_TARGET="$OPTARG"
export DYLD_LIBRARY_PATH="@loader_path/../lib" ;;
OPENSSL_TARGET="darwin-i386-cc" j)
echo "[INFO] Compiling for Intel MacOS x86" echo "[opt] Set make threads to $OPTARG"
elif [ "$1" == "mac64" ]; then THREADS="$OPTARG"
[ -z "$march" ] && march=core2; ;;
[ -z "$mtune" ] && mtune=generic; o)
[ -z "$CFLAGS" ] && CFLAGS="-m64 -arch x86_64 -fomit-frame-pointer -mmacosx-version-min=10.5"; echo "[opt] Will compile OpenSSL"
[ -z "$LDFLAGS" ] && LDFLAGS="-Wl,-rpath,@loader_path/../lib"; COMPILE_OPENSSL="yes"
export DYLD_LIBRARY_PATH="@loader_path/../lib" ;;
OPENSSL_TARGET="darwin64-x86_64-cc" l)
echo "[INFO] Compiling for Intel MacOS x86_64" echo "[opt] Will compile libedit"
elif [ "$1" == "ios" ]; then COMPILE_LIBEDIT="yes"
[ -z "$march" ] && march=armv6; ;;
[ -z "$mtune" ] && mtune=cortex-a8; c)
echo "[INFO] Compiling for iOS ARMv6" echo "[opt] Will force compile cURL"
OPENSSL_TARGET="linux-armv4" COMPILE_CURL="yes"
elif [ "$1" == "crosscompile" ]; then ;;
HAVE_MYSQLI="--without-mysqli" x)
if [ "$2" == "android" ] || [ "$2" == "android-armv6" ]; then echo "[opt] Doing cross-compile"
IS_CROSSCOMPILE="yes"
;;
f)
echo "[opt] Enabling abusive optimizations..."
DO_OPTIMIZE="yes"
ffast_math="-fno-math-errno -funsafe-math-optimizations -fno-trapping-math -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fcx-limited-range" #workaround SQLite3 fail
CFLAGS="$CFLAGS -O2 -DSQLITE_HAVE_ISNAN $ffast_math -fno-signed-zeros -finline-functions -funsafe-loop-optimizations -fomit-frame-pointer -frename-registers -funroll-loops -funswitch-loops -fpredictive-commoning -fgcse-after-reload -ftree-vectorize -ftracer -ftree-loop-im -fprefetch-loop-arrays -ftree-parallelize-loops=4 -fomit-frame-pointer"
if [ "$OPTARG" == "arm" ]; then
CFLAGS="$CFLAGS -mfloat-abi=softfp -mfpu=vfp"
elif [ "$OPTARG" == "x86_64" ]; then
CFLAGS="$CFLAGS -mmx -msse -msse2 -msse3 -mfpmath=sse -free -msahf"
elif [ "$OPTARG" == "x86" ]; then
CFLAGS="$CFLAGS -mmx -msse -msse2 -mfpmath=sse -m128bit-long-double -malign-double"
fi
;;
\?)
echo "Invalid option: -$OPTION$OPTARG" >&2
exit 1
;;
esac
done
if [ "$IS_CROSSCOMPILE" == "yes" ]; then
if [ "$COMPILE_TARGET" == "android" ] || [ "$COMPILE_TARGET" == "android-armv6" ]; then
COMPILE_FOR_ANDROID=yes COMPILE_FOR_ANDROID=yes
[ -z "$march" ] && march=armv6; [ -z "$march" ] && march=armv6;
[ -z "$mtune" ] && mtune=arm1136jf-s; [ -z "$mtune" ] && mtune=arm1136jf-s;
@ -80,7 +104,8 @@ elif [ "$1" == "crosscompile" ]; then
CFLAGS="-static -uclibc -Wl,-Bdynamic $CFLAGS" CFLAGS="-static -uclibc -Wl,-Bdynamic $CFLAGS"
echo "[INFO] Cross-compiling for Android ARMv6" echo "[INFO] Cross-compiling for Android ARMv6"
OPENSSL_TARGET="android" OPENSSL_TARGET="android"
elif [ "$2" == "android-armv7" ]; then HAVE_MYSQLI="--without-mysqli"
elif [ "$COMPILE_TARGET" == "android-armv7" ]; then
COMPILE_FOR_ANDROID=yes COMPILE_FOR_ANDROID=yes
[ -z "$march" ] && march=armv7-a; [ -z "$march" ] && march=armv7-a;
[ -z "$mtune" ] && mtune=cortex-a8; [ -z "$mtune" ] && mtune=cortex-a8;
@ -90,7 +115,8 @@ elif [ "$1" == "crosscompile" ]; then
CFLAGS="-static -uclibc -Wl,-Bdynamic $CFLAGS" CFLAGS="-static -uclibc -Wl,-Bdynamic $CFLAGS"
echo "[INFO] Cross-compiling for Android ARMv7" echo "[INFO] Cross-compiling for Android ARMv7"
OPENSSL_TARGET="android-armv7" OPENSSL_TARGET="android-armv7"
elif [ "$2" == "rpi" ]; then HAVE_MYSQLI="--without-mysqli"
elif [ "$COMPILE_TARGET" == "rpi" ]; then
TOOLCHAIN_PREFIX="arm-linux-gnueabihf" TOOLCHAIN_PREFIX="arm-linux-gnueabihf"
[ -z "$march" ] && march=armv6zk; [ -z "$march" ] && march=armv6zk;
[ -z "$mtune" ] && mtune=arm1176jzf-s; [ -z "$mtune" ] && mtune=arm1176jzf-s;
@ -100,7 +126,7 @@ elif [ "$1" == "crosscompile" ]; then
[ -z "$CFLAGS" ] && CFLAGS="-uclibc"; [ -z "$CFLAGS" ] && CFLAGS="-uclibc";
OPENSSL_TARGET="linux-armv4" OPENSSL_TARGET="linux-armv4"
echo "[INFO] Cross-compiling for Raspberry Pi ARMv6zk hard float" echo "[INFO] Cross-compiling for Raspberry Pi ARMv6zk hard float"
elif [ "$2" == "mac" ]; then elif [ "$COMPILE_TARGET" == "mac" ]; then
[ -z "$march" ] && march=prescott; [ -z "$march" ] && march=prescott;
[ -z "$mtune" ] && mtune=generic; [ -z "$mtune" ] && mtune=generic;
[ -z "$CFLAGS" ] && CFLAGS="-fomit-frame-pointer"; [ -z "$CFLAGS" ] && CFLAGS="-fomit-frame-pointer";
@ -111,20 +137,56 @@ elif [ "$1" == "crosscompile" ]; then
RANLIB=$TOOLCHAIN_PREFIX-ranlib RANLIB=$TOOLCHAIN_PREFIX-ranlib
OPENSSL_TARGET="darwin64-x86_64-cc" OPENSSL_TARGET="darwin64-x86_64-cc"
echo "[INFO] Cross-compiling for Intel MacOS" echo "[INFO] Cross-compiling for Intel MacOS"
elif [ "$2" == "ios" ] || [ "$2" == "ios-armv6" ]; then elif [ "$COMPILE_TARGET" == "ios" ] || [ "$COMPILE_TARGET" == "ios-armv6" ]; then
[ -z "$march" ] && march=armv6; [ -z "$march" ] && march=armv6;
[ -z "$mtune" ] && mtune=generic-armv6; [ -z "$mtune" ] && mtune=arm1176jzf-s;
CONFIGURE_FLAGS="--target=arm-apple-darwin10" TOOLCHAIN_PREFIX="arm-apple-darwin10"
OPENSSL_TARGET="linux-armv4" export CC="$TOOLCHAIN_PREFIX-gcc"
elif [ "$2" == "ios-armv7" ]; then CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX --target=$TOOLCHAIN_PREFIX -miphoneos-version-min=4.2"
OPENSSL_TARGET="BSD-generic32"
HAVE_MYSQLI="--without-mysqli"
elif [ "$COMPILE_TARGET" == "ios-armv7" ]; then
[ -z "$march" ] && march=armv7-a; [ -z "$march" ] && march=armv7-a;
[ -z "$mtune" ] && mtune=generic-armv7-a; [ -z "$mtune" ] && mtune=cortex-a8;
CONFIGURE_FLAGS="--target=arm-apple-darwin10" TOOLCHAIN_PREFIX="arm-apple-darwin10"
OPENSSL_TARGET="linux-armv4" export CC="$TOOLCHAIN_PREFIX-gcc"
CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX --target=$TOOLCHAIN_PREFIX -miphoneos-version-min=4.2"
OPENSSL_TARGET="BSD-generic32"
HAVE_MYSQLI="--without-mysqli"
if [ "$DO_OPTIMIZE" == "yes" ]; then
CFLAGS="$CFLAGS -mfpu=neon"
fi
else else
echo "Please supply a proper platform [android android-armv6 android-armv7 rpi mac ios ios-armv6 ios-armv7] 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 exit 1
fi fi
elif [ "$COMPILE_TARGET" == "rpi" ]; then
[ -z "$march" ] && march=armv6zk;
[ -z "$mtune" ] && mtune=arm1176jzf-s;
[ -z "$CFLAGS" ] && CFLAGS="-mfloat-abi=hard -mfpu=vfp";
OPENSSL_TARGET="linux-armv4"
echo "[INFO] Compiling for Raspberry Pi ARMv6zk hard float"
elif [ "$COMPILE_TARGET" == "mac" ] || [ "$COMPILE_TARGET" == "mac32" ]; then
[ -z "$march" ] && march=prescott;
[ -z "$mtune" ] && mtune=generic;
[ -z "$CFLAGS" ] && CFLAGS="-m32 -arch i386 -fomit-frame-pointer -mmacosx-version-min=10.5";
[ -z "$LDFLAGS" ] && LDFLAGS="-Wl,-rpath,@loader_path/../lib";
export DYLD_LIBRARY_PATH="@loader_path/../lib"
OPENSSL_TARGET="darwin-i386-cc"
echo "[INFO] Compiling for Intel MacOS x86"
elif [ "$COMPILE_TARGET" == "mac64" ]; then
[ -z "$march" ] && march=core2;
[ -z "$mtune" ] && mtune=generic;
[ -z "$CFLAGS" ] && CFLAGS="-m64 -arch x86_64 -fomit-frame-pointer -mmacosx-version-min=10.5";
[ -z "$LDFLAGS" ] && LDFLAGS="-Wl,-rpath,@loader_path/../lib";
export DYLD_LIBRARY_PATH="@loader_path/../lib"
OPENSSL_TARGET="darwin64-x86_64-cc"
echo "[INFO] Compiling for Intel MacOS x86_64"
elif [ "$COMPILE_TARGET" == "ios" ]; then
[ -z "$march" ] && march=armv7-a;
[ -z "$mtune" ] && mtune=cortex-a8;
echo "[INFO] Compiling for iOS ARMv7"
OPENSSL_TARGET="linux-armv4"
elif [ -z "$CFLAGS" ]; then elif [ -z "$CFLAGS" ]; then
if [ `getconf LONG_BIT` == "64" ]; then if [ `getconf LONG_BIT` == "64" ]; then
echo "[INFO] Compiling for current machine using 64-bit" echo "[INFO] Compiling for current machine using 64-bit"
@ -188,7 +250,7 @@ download_file "http://php.net/get/php-$PHP_VERSION.tar.gz/from/this/mirror" | ta
mv php-$PHP_VERSION php mv php-$PHP_VERSION php
echo " done!" echo " done!"
if [ "$1" == "crosscompile" ] || [ "$1" == "rpi" ] || [ "$1" == "mac" ]; then if [ "$IS_CROSSCOMPILE" == "yes" ] || [ "$COMPILE_TARGET" == "rpi" ] || [ "$COMPILE_TARGET" == "mac" ] || [ "$COMPILE_LIBEDIT" != "yes" ]; then
HAVE_LIBEDIT="--without-readline --without-libedit" HAVE_LIBEDIT="--without-readline --without-libedit"
else else
#libedit #libedit
@ -234,7 +296,7 @@ cd ..
rm -r -f ./zlib rm -r -f ./zlib
echo " done!" echo " done!"
if [ "$2" == "openssl" ] || [ "$2" == "curl" ] && [ "$1" != "crosscompile" ]; then if [ "$COMPILE_OPENSSL" == "yes" ] || [ "$COMPILE_CURL" != "no" ] && [ "$IS_CROSSCOMPILE" != "yes" ]; then
#OpenSSL #OpenSSL
WITH_SSL="--with-ssl=$DIR/bin/php5" WITH_SSL="--with-ssl=$DIR/bin/php5"
WITH_OPENSSL="--with-openssl=$DIR/bin/php5" WITH_OPENSSL="--with-openssl=$DIR/bin/php5"
@ -247,10 +309,12 @@ if [ "$2" == "openssl" ] || [ "$2" == "curl" ] && [ "$1" != "crosscompile" ]; th
$OPENSSL_TARGET \ $OPENSSL_TARGET \
--prefix="$DIR/bin/php5" \ --prefix="$DIR/bin/php5" \
--openssldir="$DIR/bin/php5" \ --openssldir="$DIR/bin/php5" \
zlib \
zlib-dynamic \
--with-zlib-lib="$DIR/bin/php5/lib" \ --with-zlib-lib="$DIR/bin/php5/lib" \
--with-zlib-include="$DIR/bin/php5/include" \ --with-zlib-include="$DIR/bin/php5/include" \
zlib-dynamic \
shared \ shared \
no-ssl2 \
no-asm \ no-asm \
no-hw \ no-hw \
no-engines \ no-engines \
@ -268,12 +332,12 @@ if [ "$2" == "openssl" ] || [ "$2" == "curl" ] && [ "$1" != "crosscompile" ]; th
else else
WITH_SSL="--with-ssl" WITH_SSL="--with-ssl"
WITH_OPENSSL="--without-ssl" WITH_OPENSSL="--without-ssl"
if [ "$(uname -s)" == "Darwin" ] && [ "$1" != "crosscompile" ]; then if [ "$(uname -s)" == "Darwin" ] && [ "$COMPILE_TARGET" != "crosscompile" ]; then
WITH_SSL="--with-darwinssl" WITH_SSL="--with-darwinssl"
fi fi
fi fi
if [ "$(uname -s)" == "Darwin" ] && [ "$1" != "crosscompile" ] && [ "$2" != "curl" ]; then if [ "$(uname -s)" == "Darwin" ] && [ "$IS_CROSSCOMPILE" != "yes" ] && [ "$COMPILE_CURL" != "yes" ]; then
HAVE_CURL="shared,/usr" HAVE_CURL="shared,/usr"
else else
#curl #curl
@ -354,31 +418,25 @@ rm -r -f ./yaml
echo " done!" echo " done!"
echo -n "[PHP]" echo -n "[PHP]"
set +e
if which free >/dev/null; then if [ "$DO_OPTIMIZE" != "no" ]; then
MAX_MEMORY=$(free -m | awk '/^Mem:/{print $2}')
else
MAX_MEMORY=$(top -l 1 | grep PhysMem: | awk '{print $10}' | tr -d 'a-zA-Z')
fi
if [ $MAX_MEMORY -gt 512 2>> /dev/null ] && [ "$1" != "crosscompile" ]; then
echo -n " enabling optimizations..." echo -n " enabling optimizations..."
OPTIMIZATION="--enable-inline-optimization " PHP_OPTIMIZATION="--enable-inline-optimization "
else else
OPTIMIZATION="--disable-inline-optimization " PHP_OPTIMIZATION="--disable-inline-optimization "
fi fi
set -e
echo -n " checking..." echo -n " checking..."
cd php cd php
rm -rf ./aclocal.m4 >> "$DIR/install.log" 2>&1 rm -rf ./aclocal.m4 >> "$DIR/install.log" 2>&1
rm -rf ./autom4te.cache/ >> "$DIR/install.log" 2>&1 rm -rf ./autom4te.cache/ >> "$DIR/install.log" 2>&1
rm -f ./configure >> "$DIR/install.log" 2>&1 rm -f ./configure >> "$DIR/install.log" 2>&1
./buildconf --force >> "$DIR/install.log" 2>&1 ./buildconf --force >> "$DIR/install.log" 2>&1
if [ "$1" == "crosscompile" ]; then if [ "$IS_CROSSCOMPILE" == "yes" ]; then
sed -i 's/pthreads_working=no/pthreads_working=yes/' ./configure sed -i=".backup" 's/pthreads_working=no/pthreads_working=yes/' ./configure
export LIBS="-lpthread -ldl" export LIBS="-lpthread -ldl -lresolv"
CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-opcache=no" CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-opcache=no"
fi fi
RANLIB=$RANLIB ./configure $OPTIMIZATION--prefix="$DIR/bin/php5" \ RANLIB=$RANLIB ./configure $PHP_OPTIMIZATION--prefix="$DIR/bin/php5" \
--exec-prefix="$DIR/bin/php5" \ --exec-prefix="$DIR/bin/php5" \
--with-curl="$HAVE_CURL" \ --with-curl="$HAVE_CURL" \
--with-zlib="$DIR/bin/php5" \ --with-zlib="$DIR/bin/php5" \
@ -393,11 +451,11 @@ $HAVE_LIBEDIT \
--disable-cgi \ --disable-cgi \
--disable-session \ --disable-session \
--disable-debug \ --disable-debug \
--disable-phar \
--disable-pdo \ --disable-pdo \
--without-pear \ --without-pear \
--without-iconv \ --without-iconv \
--without-pdo-sqlite \ --without-pdo-sqlite \
--enable-phar \
--enable-ctype \ --enable-ctype \
--enable-sockets \ --enable-sockets \
--enable-shared=no \ --enable-shared=no \
@ -415,14 +473,16 @@ $HAVE_MYSQLI \
--with-zend-vm=$ZEND_VM \ --with-zend-vm=$ZEND_VM \
$CONFIGURE_FLAGS >> "$DIR/install.log" 2>&1 $CONFIGURE_FLAGS >> "$DIR/install.log" 2>&1
echo -n " compiling..." echo -n " compiling..."
if [ $COMPILE_FOR_ANDROID == "yes" ]; then if [ "$COMPILE_FOR_ANDROID" == "yes" ]; then
sed -i 's/-export-dynamic/-all-static/g' Makefile sed -i=".backup" 's/-export-dynamic/-all-static/g' Makefile
fi fi
sed -i=".backup" 's/PHP_BINARIES. pharcmd$/PHP_BINARIES)/g' Makefile
sed -i=".backup" 's/install-programs install-pharcmd$/install-programs/g' Makefile
make -j $THREADS >> "$DIR/install.log" 2>&1 make -j $THREADS >> "$DIR/install.log" 2>&1
echo -n " installing..." echo -n " installing..."
make install >> "$DIR/install.log" 2>&1 make install >> "$DIR/install.log" 2>&1
if [ "$(uname -s)" == "Darwin" ] && [ "$1" != "crosscompile" ]; then if [ "$(uname -s)" == "Darwin" ] && [ "$IS_CROSSCOMPILE" != "yes" ]; then
set +e set +e
install_name_tool -delete_rpath "$DIR/bin/php5/lib" "$DIR/bin/php5/bin/php" >> "$DIR/install.log" 2>&1 install_name_tool -delete_rpath "$DIR/bin/php5/lib" "$DIR/bin/php5/bin/php" >> "$DIR/install.log" 2>&1
install_name_tool -change "$DIR/bin/php5/lib/libz.1.dylib" "@loader_path/../lib/libz.1.dylib" "$DIR/bin/php5/bin/php" >> "$DIR/install.log" 2>&1 install_name_tool -change "$DIR/bin/php5/lib/libz.1.dylib" "@loader_path/../lib/libz.1.dylib" "$DIR/bin/php5/bin/php" >> "$DIR/install.log" 2>&1
@ -441,7 +501,9 @@ TIMEZONE=$(date +%Z)
echo "date.timezone=$TIMEZONE" > "$DIR/bin/php5/bin/php.ini" echo "date.timezone=$TIMEZONE" > "$DIR/bin/php5/bin/php.ini"
echo "short_open_tag=0" >> "$DIR/bin/php5/bin/php.ini" echo "short_open_tag=0" >> "$DIR/bin/php5/bin/php.ini"
echo "asp_tags=0" >> "$DIR/bin/php5/bin/php.ini" echo "asp_tags=0" >> "$DIR/bin/php5/bin/php.ini"
if [ "$1" != "crosscompile" ]; then echo "phar.readonly=0" >> "$DIR/bin/php5/bin/php.ini"
echo "phar.require_hash=1" >> "$DIR/bin/php5/bin/php.ini"
if [ "$IS_CROSSCOMPILE" != "crosscompile" ]; then
echo "zend_extension=opcache.so" >> "$DIR/bin/php5/bin/php.ini" echo "zend_extension=opcache.so" >> "$DIR/bin/php5/bin/php.ini"
echo "opcache.enable=1" >> "$DIR/bin/php5/bin/php.ini" echo "opcache.enable=1" >> "$DIR/bin/php5/bin/php.ini"
echo "opcache.enable_cli=1" >> "$DIR/bin/php5/bin/php.ini" echo "opcache.enable_cli=1" >> "$DIR/bin/php5/bin/php.ini"

View File

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
PMMP_VERSION="" PMMP_VERSION=""
LINUX_32_BUILD="PHP_5.5.9_x86_Linux" LINUX_32_BUILD="PHP_5.5.10_x86_Linux"
LINUX_64_BUILD="PHP_5.5.9_x86-64_Linux" LINUX_64_BUILD="PHP_5.5.10_x86-64_Linux"
MAC_32_BUILD="PHP_5.5.9_x86_MacOS" MAC_32_BUILD="PHP_5.5.10_x86_MacOS"
MAC_64_BUILD="PHP_5.5.9_x86-64_MacOS" MAC_64_BUILD="PHP_5.5.10_x86-64_MacOS"
RPI_BUILD="PHP_5.5.9_ARM_Raspbian_hard" RPI_BUILD="PHP_5.5.9_ARM_Raspbian_hard"
# Temporal build # Temporal build
ODROID_BUILD="PHP_5.5.9_ARM_Raspbian_hard" ODROID_BUILD="PHP_5.5.9_ARM_Raspbian_hard"
@ -74,7 +74,7 @@ rm -f -r PocketMine-MP-$PMMP_VERSION/
rm -f ./start.cmd rm -f ./start.cmd
chmod +x ./start.sh chmod +x ./start.sh
chmod +x ./src/build/compile.sh chmod +x ./src/build/compile.sh
if [ $update == on ]; then if [ "$update" == "on" ]; then
echo "[3/3] Skipping PHP recompilation due to user request" echo "[3/3] Skipping PHP recompilation due to user request"
else else
echo -n "[3/3] Obtaining PHP:" echo -n "[3/3] Obtaining PHP:"
@ -84,7 +84,7 @@ else
UNAME_M=$(uname -m) UNAME_M=$(uname -m)
IS_IOS=$(expr match $UNAME_M 'iP[a-zA-Z0-9,]*' 2> /dev/null) IS_IOS=$(expr match $UNAME_M 'iP[a-zA-Z0-9,]*' 2> /dev/null)
set -e set -e
if [[ $IS_IOS -gt 0 ]]; then if [[ "$IS_IOS" -gt 0 ]]; then
rm -r -f bin/ >> /dev/null 2>&1 rm -r -f bin/ >> /dev/null 2>&1
echo -n "[3/3] iOS PHP build available, downloading $IOS_BUILD.tar.gz..." echo -n "[3/3] iOS PHP build available, downloading $IOS_BUILD.tar.gz..."
download_file "http://sourceforge.net/projects/pocketmine/files/builds/$IOS_BUILD.tar.gz" | tar -zx > /dev/null 2>&1 download_file "http://sourceforge.net/projects/pocketmine/files/builds/$IOS_BUILD.tar.gz" | tar -zx > /dev/null 2>&1
@ -92,9 +92,12 @@ else
echo -n " checking..." echo -n " checking..."
if [ $(./bin/php5/bin/php -r 'echo "yes";' 2>/dev/null) == "yes" ]; then if [ $(./bin/php5/bin/php -r 'echo "yes";' 2>/dev/null) == "yes" ]; then
echo -n " regenerating php.ini..." echo -n " regenerating php.ini..."
TIMEZONE=$(date +%Z)
echo "date.timezone=$TIMEZONE" >> "./bin/php5/bin/php.ini" echo "date.timezone=$TIMEZONE" >> "./bin/php5/bin/php.ini"
echo "short_open_tag=0" >> "./bin/php5/bin/php.ini" echo "short_open_tag=0" >> "./bin/php5/bin/php.ini"
echo "asp_tags=0" >> "./bin/php5/bin/php.ini" echo "asp_tags=0" >> "./bin/php5/bin/php.ini"
echo "phar.readonly=0" >> "./bin/php5/bin/php.ini"
echo "phar.require_hash=1" >> "./bin/php5/bin/php.ini"
echo " done" echo " done"
alldone=yes alldone=yes
else else
@ -104,16 +107,17 @@ else
rm -r -f bin/ >> /dev/null 2>&1 rm -r -f bin/ >> /dev/null 2>&1
if [ `getconf LONG_BIT` == "64" ]; then if [ `getconf LONG_BIT` == "64" ]; then
echo -n "[3/3] MacOS 64-bit PHP build available, downloading $MAC_64_BUILD.tar.gz..." echo -n "[3/3] MacOS 64-bit PHP build available, downloading $MAC_64_BUILD.tar.gz..."
MAC_BUILD=$MAC_64_BUILD MAC_BUILD="$MAC_64_BUILD"
else else
echo -n "[3/3] MacOS 32-bit PHP build available, downloading $MAC_32_BUILD.tar.gz..." echo -n "[3/3] MacOS 32-bit PHP build available, downloading $MAC_32_BUILD.tar.gz..."
MAC_BUILD=$MAC_32_BUILD MAC_BUILD="$MAC_32_BUILD"
fi fi
download_file "http://sourceforge.net/projects/pocketmine/files/builds/$MAC_BUILD.tar.gz" | tar -zx > /dev/null 2>&1 download_file "http://sourceforge.net/projects/pocketmine/files/builds/$MAC_BUILD.tar.gz" | tar -zx > /dev/null 2>&1
chmod +x ./bin/php5/bin/* chmod +x ./bin/php5/bin/*
echo -n " checking..." echo -n " checking..."
if [ $(./bin/php5/bin/php -r 'echo "yes";' 2>/dev/null) == "yes" ]; then if [ $(./bin/php5/bin/php -r 'echo "yes";' 2>/dev/null) == "yes" ]; then
echo -n " regenerating php.ini..." echo -n " regenerating php.ini..."
TIMEZONE=$(date +%Z)
OPCACHE_PATH="$(find $(pwd) -name opcache.so)" OPCACHE_PATH="$(find $(pwd) -name opcache.so)"
echo "zend_extension=\"$OPCACHE_PATH\"" > "./bin/php5/bin/php.ini" echo "zend_extension=\"$OPCACHE_PATH\"" > "./bin/php5/bin/php.ini"
echo "opcache.enable=1" >> "./bin/php5/bin/php.ini" echo "opcache.enable=1" >> "./bin/php5/bin/php.ini"
@ -127,6 +131,8 @@ else
echo "date.timezone=$TIMEZONE" >> "./bin/php5/bin/php.ini" echo "date.timezone=$TIMEZONE" >> "./bin/php5/bin/php.ini"
echo "short_open_tag=0" >> "./bin/php5/bin/php.ini" echo "short_open_tag=0" >> "./bin/php5/bin/php.ini"
echo "asp_tags=0" >> "./bin/php5/bin/php.ini" echo "asp_tags=0" >> "./bin/php5/bin/php.ini"
echo "phar.readonly=0" >> "./bin/php5/bin/php.ini"
echo "phar.require_hash=1" >> "./bin/php5/bin/php.ini"
echo " done" echo " done"
alldone=yes alldone=yes
else else
@ -138,7 +144,7 @@ else
IS_RPI=$? IS_RPI=$?
grep -q ODROID /proc/cpuinfo > /dev/null 2>&1 grep -q ODROID /proc/cpuinfo > /dev/null 2>&1
IS_ODROID=$? IS_ODROID=$?
if [ $IS_RPI -eq 0 ] && [ "$forcecompile" == "off" ]; then if [ "$IS_RPI" -eq 0 ] && [ "$forcecompile" == "off" ]; then
rm -r -f bin/ >> /dev/null 2>&1 rm -r -f bin/ >> /dev/null 2>&1
echo -n "[3/3] Raspberry Pi PHP build available, downloading $RPI_BUILD.tar.gz..." echo -n "[3/3] Raspberry Pi PHP 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 download_file "http://sourceforge.net/projects/pocketmine/files/builds/$RPI_BUILD.tar.gz" | tar -zx > /dev/null 2>&1
@ -146,6 +152,7 @@ else
echo -n " checking..." echo -n " checking..."
if [ $(./bin/php5/bin/php -r 'echo "yes";' 2>/dev/null) == "yes" ]; then if [ $(./bin/php5/bin/php -r 'echo "yes";' 2>/dev/null) == "yes" ]; then
echo -n " regenerating php.ini..." echo -n " regenerating php.ini..."
TIMEZONE=$(date +%Z)
OPCACHE_PATH="$(find $(pwd) -name opcache.so)" OPCACHE_PATH="$(find $(pwd) -name opcache.so)"
echo "zend_extension=\"$OPCACHE_PATH\"" > "./bin/php5/bin/php.ini" echo "zend_extension=\"$OPCACHE_PATH\"" > "./bin/php5/bin/php.ini"
echo "opcache.enable=1" >> "./bin/php5/bin/php.ini" echo "opcache.enable=1" >> "./bin/php5/bin/php.ini"
@ -159,12 +166,14 @@ else
echo "date.timezone=$TIMEZONE" >> "./bin/php5/bin/php.ini" echo "date.timezone=$TIMEZONE" >> "./bin/php5/bin/php.ini"
echo "short_open_tag=0" >> "./bin/php5/bin/php.ini" echo "short_open_tag=0" >> "./bin/php5/bin/php.ini"
echo "asp_tags=0" >> "./bin/php5/bin/php.ini" echo "asp_tags=0" >> "./bin/php5/bin/php.ini"
echo "phar.readonly=0" >> "./bin/php5/bin/php.ini"
echo "phar.require_hash=1" >> "./bin/php5/bin/php.ini"
echo " done" echo " done"
alldone=yes alldone=yes
else else
echo " invalid build detected" echo " invalid build detected"
fi fi
elif [ $IS_ODROID -eq 0 ] && [ "$forcecompile" == "off" ]; then elif [ "$IS_ODROID" -eq 0 ] && [ "$forcecompile" == "off" ]; then
rm -r -f bin/ >> /dev/null 2>&1 rm -r -f bin/ >> /dev/null 2>&1
echo -n "[3/3] ODROID PHP build available, downloading $ODROID_BUILD.tar.gz..." echo -n "[3/3] ODROID PHP build available, downloading $ODROID_BUILD.tar.gz..."
download_file "http://sourceforge.net/projects/pocketmine/files/builds/$ODROID_BUILD.tar.gz" | tar -zx > /dev/null 2>&1 download_file "http://sourceforge.net/projects/pocketmine/files/builds/$ODROID_BUILD.tar.gz" | tar -zx > /dev/null 2>&1
@ -185,6 +194,8 @@ else
echo "date.timezone=$TIMEZONE" >> "./bin/php5/bin/php.ini" echo "date.timezone=$TIMEZONE" >> "./bin/php5/bin/php.ini"
echo "short_open_tag=0" >> "./bin/php5/bin/php.ini" echo "short_open_tag=0" >> "./bin/php5/bin/php.ini"
echo "asp_tags=0" >> "./bin/php5/bin/php.ini" echo "asp_tags=0" >> "./bin/php5/bin/php.ini"
echo "phar.readonly=0" >> "./bin/php5/bin/php.ini"
echo "phar.require_hash=1" >> "./bin/php5/bin/php.ini"
echo " done" echo " done"
alldone=yes alldone=yes
else else
@ -194,10 +205,10 @@ else
rm -r -f bin/ >> /dev/null 2>&1 rm -r -f bin/ >> /dev/null 2>&1
if [ `getconf LONG_BIT` = "64" ]; then if [ `getconf LONG_BIT` = "64" ]; then
echo -n "[3/3] Linux 64-bit PHP build available, downloading $LINUX_64_BUILD.tar.gz..." echo -n "[3/3] Linux 64-bit PHP build available, downloading $LINUX_64_BUILD.tar.gz..."
LINUX_BUILD=$LINUX_64_BUILD LINUX_BUILD="$LINUX_64_BUILD"
else else
echo -n "[3/3] Linux 32-bit PHP build available, downloading $LINUX_32_BUILD.tar.gz..." echo -n "[3/3] Linux 32-bit PHP build available, downloading $LINUX_32_BUILD.tar.gz..."
LINUX_BUILD=$LINUX_32_BUILD LINUX_BUILD="$LINUX_32_BUILD"
fi fi
download_file "http://sourceforge.net/projects/pocketmine/files/builds/$LINUX_BUILD.tar.gz" | tar -zx > /dev/null 2>&1 download_file "http://sourceforge.net/projects/pocketmine/files/builds/$LINUX_BUILD.tar.gz" | tar -zx > /dev/null 2>&1
chmod +x ./bin/php5/bin/* chmod +x ./bin/php5/bin/*
@ -217,6 +228,8 @@ else
echo "date.timezone=$TIMEZONE" >> "./bin/php5/bin/php.ini" echo "date.timezone=$TIMEZONE" >> "./bin/php5/bin/php.ini"
echo "short_open_tag=0" >> "./bin/php5/bin/php.ini" echo "short_open_tag=0" >> "./bin/php5/bin/php.ini"
echo "asp_tags=0" >> "./bin/php5/bin/php.ini" echo "asp_tags=0" >> "./bin/php5/bin/php.ini"
echo "phar.readonly=0" >> "./bin/php5/bin/php.ini"
echo "phar.require_hash=1" >> "./bin/php5/bin/php.ini"
echo " done" echo " done"
alldone=yes alldone=yes
else else

View File

@ -1,7 +1,7 @@
#!/bin/bash -x #!/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 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 export THREADS=2
PHP_VERSION="5.5.9" PHP_VERSION="5.5.10"
#Needed to use aliases #Needed to use aliases
shopt -s expand_aliases shopt -s expand_aliases
@ -21,18 +21,18 @@ rm -rf $WORKSPACE/compile.sh
download_file "https://github.com/PocketMine/PocketMine-MP/raw/master/src/build/compile.sh" > $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 chmod +x $WORKSPACE/compile.sh
SCRIPT="$WORKSPACE/compile.sh" SCRIPT="$WORKSPACE/compile.sh"
ARCHIVE=$WORKSPACE/archive ARCHIVE="$WORKSPACE/archive"
COMPILEDIR=$WORKSPACE/compile COMPILEDIR="$WORKSPACE/compile"
rm -rf $ARCHIVE $COMPILEDIR rm -rf "$ARCHIVE" "$COMPILEDIR"
mkdir -p $ARCHIVE mkdir -p "$ARCHIVE"
mkdir -p $COMPILEDIR mkdir -p "$COMPILEDIR"
if [ "$COMPILE_LINUX_32BIT" = "true" ]; if [ "$COMPILE_LINUX_32BIT" = "true" ];
then then
mkdir -p {$COMPILEDIR,$ARCHIVE}/linux/32bit mkdir -p {$COMPILEDIR,$ARCHIVE}/linux/32bit
cd $COMPILEDIR/linux/32bit cd $COMPILEDIR/linux/32bit
OPENSSL_TARGET="linux-generic32" CFLAGS="-m32" march=i386 mtune=none $SCRIPT linux openssl OPENSSL_TARGET="linux-generic32" CFLAGS="-m32" march=i686 mtune=pentium4 $SCRIPT -t linux -o -j 1 -c -f x86
tar -czf PHP_${PHP_VERSION}_x86_Linux.tar.gz bin/ tar -czf PHP_${PHP_VERSION}_x86_Linux.tar.gz bin/
cp -r $COMPILEDIR/linux/32bit/{install.log,PHP_${PHP_VERSION}_x86_Linux.tar.gz,install_data/*} $ARCHIVE/linux/32bit/ cp -r $COMPILEDIR/linux/32bit/{install.log,PHP_${PHP_VERSION}_x86_Linux.tar.gz,install_data/*} $ARCHIVE/linux/32bit/
@ -46,7 +46,7 @@ then
mkdir -p {$COMPILEDIR,$ARCHIVE}/linux/64bit mkdir -p {$COMPILEDIR,$ARCHIVE}/linux/64bit
cd $COMPILEDIR/linux/64bit cd $COMPILEDIR/linux/64bit
OPENSSL_TARGET="linux-x86_64" CFLAGS="-m64" march=x86-64 mtune=none $SCRIPT linux openssl OPENSSL_TARGET="linux-x86_64" CFLAGS="-m64" march=x86-64 mtune=nocona $SCRIPT -t linux -o -j 1 -c -f x86_64
tar -czf PHP_${PHP_VERSION}_x86-64_Linux.tar.gz bin/ tar -czf PHP_${PHP_VERSION}_x86-64_Linux.tar.gz bin/
cp -r $COMPILEDIR/linux/64bit/{install.log,PHP_${PHP_VERSION}_x86-64_Linux.tar.gz,install_data/*} $ARCHIVE/linux/64bit/ cp -r $COMPILEDIR/linux/64bit/{install.log,PHP_${PHP_VERSION}_x86-64_Linux.tar.gz,install_data/*} $ARCHIVE/linux/64bit/
@ -69,7 +69,7 @@ then
rm -rf libtool-2.4.2 rm -rf libtool-2.4.2
export LIBTOOL="$COMPILEDIR/mac/libtool/bin/libtool" export LIBTOOL="$COMPILEDIR/mac/libtool/bin/libtool"
export LIBTOOLIZE="$COMPILEDIR/mac/libtool/bin/libtoolize" export LIBTOOLIZE="$COMPILEDIR/mac/libtool/bin/libtoolize"
$SCRIPT mac curl $SCRIPT -t mac32 -o -j 1 -c -f x86
tar -czf PHP_${PHP_VERSION}_x86_MacOS.tar.gz bin/ tar -czf PHP_${PHP_VERSION}_x86_MacOS.tar.gz bin/
cp -r $COMPILEDIR/mac32/{install.log,PHP_${PHP_VERSION}_x86_MacOS.tar.gz,install_data/*} $ARCHIVE/mac32/ cp -r $COMPILEDIR/mac32/{install.log,PHP_${PHP_VERSION}_x86_MacOS.tar.gz,install_data/*} $ARCHIVE/mac32/
@ -92,7 +92,7 @@ then
rm -rf libtool-2.4.2 rm -rf libtool-2.4.2
export LIBTOOL="$COMPILEDIR/mac/libtool/bin/libtool" export LIBTOOL="$COMPILEDIR/mac/libtool/bin/libtool"
export LIBTOOLIZE="$COMPILEDIR/mac/libtool/bin/libtoolize" export LIBTOOLIZE="$COMPILEDIR/mac/libtool/bin/libtoolize"
$SCRIPT mac64 curl $SCRIPT -t mac64 -o -j 1 -c -f x86_64
tar -czf PHP_${PHP_VERSION}_x86-64_MacOS.tar.gz bin/ tar -czf PHP_${PHP_VERSION}_x86-64_MacOS.tar.gz bin/
cp -r $COMPILEDIR/mac64/{install.log,PHP_${PHP_VERSION}_x86-64_MacOS.tar.gz,install_data/*} $ARCHIVE/mac64 cp -r $COMPILEDIR/mac64/{install.log,PHP_${PHP_VERSION}_x86-64_MacOS.tar.gz,install_data/*} $ARCHIVE/mac64
@ -106,7 +106,7 @@ then
mkdir -p {$COMPILEDIR,$ARCHIVE}/rpi mkdir -p {$COMPILEDIR,$ARCHIVE}/rpi
cd $COMPILEDIR/rpi cd $COMPILEDIR/rpi
$SCRIPT rpi $SCRIPT -t rpi -o -j 1 -c -f arm
tar -czf PHP_${PHP_VERSION}_ARM_Raspbian_hard.tar.gz bin/ tar -czf PHP_${PHP_VERSION}_ARM_Raspbian_hard.tar.gz bin/
cp -r $COMPILEDIR/rpi/{install.log,PHP_${PHP_VERSION}_ARM_Raspbian_hard.tar.gz,install_data/*} $ARCHIVE/rpi/ cp -r $COMPILEDIR/rpi/{install.log,PHP_${PHP_VERSION}_ARM_Raspbian_hard.tar.gz,install_data/*} $ARCHIVE/rpi/
@ -120,7 +120,7 @@ then
mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/android-armv6 mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/android-armv6
cd $COMPILEDIR/crosscompile/android-armv6 cd $COMPILEDIR/crosscompile/android-armv6
$SCRIPT crosscompile android-armv6 $SCRIPT -t android-armv6 -o -j 1 -c -x -f arm
tar -czf PHP_${PHP_VERSION}_ARMv6_Android.tar.gz bin/ tar -czf PHP_${PHP_VERSION}_ARMv6_Android.tar.gz bin/
cp -r $COMPILEDIR/crosscompile/android-armv6/{install.log,PHP_${PHP_VERSION}_ARMv6_Android.tar.gz,install_data/*} $ARCHIVE/crosscompile/android-armv6/ cp -r $COMPILEDIR/crosscompile/android-armv6/{install.log,PHP_${PHP_VERSION}_ARMv6_Android.tar.gz,install_data/*} $ARCHIVE/crosscompile/android-armv6/
@ -134,7 +134,7 @@ then
mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/android-armv7 mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/android-armv7
cd $COMPILEDIR/crosscompile/android-armv7 cd $COMPILEDIR/crosscompile/android-armv7
$SCRIPT crosscompile android-armv7 $SCRIPT -t android-armv7 -o -j 1 -c -x -f arm
tar -czf PHP_${PHP_VERSION}_ARMv7_Android.tar.gz bin/ tar -czf PHP_${PHP_VERSION}_ARMv7_Android.tar.gz bin/
cp -r $COMPILEDIR/crosscompile/android-armv7/{install.log,PHP_${PHP_VERSION}_ARMv7_Android.tar.gz,install_data/*} $ARCHIVE/crosscompile/android-armv7/ cp -r $COMPILEDIR/crosscompile/android-armv7/{install.log,PHP_${PHP_VERSION}_ARMv7_Android.tar.gz,install_data/*} $ARCHIVE/crosscompile/android-armv7/
@ -156,7 +156,7 @@ then
rm -rf libtool-2.4.2 rm -rf libtool-2.4.2
export LIBTOOL="$COMPILEDIR/crosscompile/ios-armv6/libtool/bin/libtool" export LIBTOOL="$COMPILEDIR/crosscompile/ios-armv6/libtool/bin/libtool"
export LIBTOOLIZE="$COMPILEDIR/crosscompile/ios-armv6/libtool/bin/libtoolize" export LIBTOOLIZE="$COMPILEDIR/crosscompile/ios-armv6/libtool/bin/libtoolize"
PATH="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH" $SCRIPT crosscompile ios-armv6 PATH="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH" $SCRIPT -t ios-armv6 -o -j 1 -c -x
cp -r $COMPILEDIR/crosscompile/ios-armv6/{install.log,bin/*,install_data/*} $ARCHIVE/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 if [ ! -f $COMPILEDIR/crosscompile/ios-armv6/bin/php5/bin/php ]; then
@ -177,7 +177,7 @@ then
rm -rf libtool-2.4.2 rm -rf libtool-2.4.2
export LIBTOOL="$COMPILEDIR/crosscompile/ios-armv7/libtool/bin/libtool" export LIBTOOL="$COMPILEDIR/crosscompile/ios-armv7/libtool/bin/libtool"
export LIBTOOLIZE="$COMPILEDIR/crosscompile/ios-armv7/libtool/bin/libtoolize" export LIBTOOLIZE="$COMPILEDIR/crosscompile/ios-armv7/libtool/bin/libtoolize"
PATH="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH" $SCRIPT crosscompile ios-armv7 PATH="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH" $SCRIPT -t ios-armv6 -o -j 1 -c -x
cp -r $COMPILEDIR/crosscompile/ios-armv7/{install.log,bin/*,install_data/*} $ARCHIVE/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 if [ ! -f $COMPILEDIR/crosscompile/ios-armv7/bin/php5/bin/php ]; then
@ -190,8 +190,8 @@ then
mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/rpi mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/rpi
cd $COMPILEDIR/crosscompile/rpi cd $COMPILEDIR/crosscompile/rpi
$SCRIPT crosscompile rpi $SCRIPT -t rpi -o -j 1 -c -x -f arm
tar -czf PHP_${PHP_VERSION}_ARM_Raspbian_hard.tar.gz bin/ tar -czf PHP_${PHP_VERSION}_ARM_Raspbian_hard.tar.gz bin/
cp -r $COMPILEDIR/crosscompile/rpi/{install.log,PHP_${PHP_VERSION}_ARM_Raspbian_hard.tar.gz,install_data/*} $ARCHIVE/crosscompile/rpi/ cp -r $COMPILEDIR/crosscompile/rpi/{install.log,PHP_${PHP_VERSION}_ARM_Raspbian_hard.tar.gz,install_data/*} $ARCHIVE/crosscompile/rpi/
if [ ! -f $COMPILEDIR/crosscompile/rpi/bin/php5/bin/php ]; then if [ ! -f $COMPILEDIR/crosscompile/rpi/bin/php5/bin/php ]; then
@ -204,7 +204,7 @@ then
mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/mac mkdir -p {$COMPILEDIR,$ARCHIVE}/crosscompile/mac
cd $COMPILEDIR/crosscompile/mac cd $COMPILEDIR/crosscompile/mac
$SCRIPT crosscompile mac curl $SCRIPT -t mac -o -j 1 -c -f -x
cp -r $COMPILEDIR/crosscompile/mac/{install.log,bin/*,install_data/*} $ARCHIVE/crosscompile/mac/ cp -r $COMPILEDIR/crosscompile/mac/{install.log,bin/*,install_data/*} $ARCHIVE/crosscompile/mac/
if [ ! -f $COMPILEDIR/crosscompile/mac/bin/php5/bin/php ]; then if [ ! -f $COMPILEDIR/crosscompile/mac/bin/php5/bin/php ]; then

View File

@ -1,6 +1,6 @@
<?php <?php
/* /**
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
@ -19,65 +19,58 @@
* *
*/ */
namespace PocketMine\Level;
use PocketMine\PMF\LevelFormat as LevelFormat;
use PocketMine\Utils\Config as Config;
use PocketMine;
class LevelImport{ class LevelImport{
private $path; private $path;
public function __construct($path){ public function __construct($path){
$this->path = $path; $this->path = $path;
} }
public function import(){ public function import(){
if(file_exists($this->path . "tileEntities.dat")){ //OldPM if(file_exists($this->path."tileEntities.dat")){ //OldPM
$level = unserialize(file_get_contents($this->path . "level.dat")); $level = unserialize(file_get_contents($this->path."level.dat"));
console("[INFO] Importing OldPM level \"" . $level["LevelName"] . "\" to PMF format"); console("[INFO] Importing OldPM level \"".$level["LevelName"]."\" to PMF format");
$entities = new Config($this->path . "entities.yml", Config::YAML, unserialize(file_get_contents($this->path . "entities.dat"))); $entities = new Config($this->path."entities.yml", CONFIG_YAML, unserialize(file_get_contents($this->path."entities.dat")));
$entities->save(); $entities->save();
$tiles = new Config($this->path . "tiles.yml", Config::YAML, unserialize(file_get_contents($this->path . "tileEntities.dat"))); $tiles = new Config($this->path."tiles.yml", CONFIG_YAML, unserialize(file_get_contents($this->path."tileEntities.dat")));
$tiles->save(); $tiles->save();
} elseif(file_exists($this->path . "chunks.dat") and file_exists($this->path . "level.dat")){ //Pocket }elseif(file_exists($this->path."chunks.dat") and file_exists($this->path."level.dat")){ //Pocket
$nbt = new NBT(NBT::LITTLE_ENDIAN); $nbt = new NBT(NBT::LITTLE_ENDIAN);
$nbt->read(substr(file_get_contents($this->path . "level.dat"), 8)); $nbt->read(substr(file_get_contents($this->path."level.dat"), 8));
$level = $nbt->getData(); $level = $nbt->getData();
if($level->LevelName == ""){ if($level->LevelName == ""){
$level->LevelName = "world" . time(); $level->LevelName = "world".time();
} }
console("[INFO] Importing Pocket level \"" . $level->LevelName . "\" to PMF format"); console("[INFO] Importing Pocket level \"".$level->LevelName."\" to PMF format");
unset($level->Player); unset($level->Player);
$nbt->read(substr(file_get_contents($this->path . "entities.dat"), 12)); $nbt->read(substr(file_get_contents($this->path."entities.dat"), 12));
$entities = $nbt->getData(); $entities = $nbt->getData();
if(!isset($entities->TileEntities)){ if(!isset($entities->TileEntities)){
$entities->TileEntities = array(); $entities->TileEntities = array();
} }
$tiles = $entities->TileEntities; $tiles = $entities->TileEntities;
$entities = $entities->Entities; $entities = $entities->Entities;
$entities = new Config($this->path . "entities.yml", Config::YAML, $entities); $entities = new Config($this->path."entities.yml", CONFIG_YAML, $entities);
$entities->save(); $entities->save();
$tiles = new Config($this->path . "tiles.yml", Config::YAML, $tiles); $tiles = new Config($this->path."tiles.yml", CONFIG_YAML, $tiles);
$tiles->save(); $tiles->save();
} else{ }else{
return false; return false;
} }
$pmf = new LevelFormat($this->path . "level.pmf", array( $pmf = new PMFLevel($this->path."level.pmf", array(
"name" => $level["LevelName"], "name" => $level->LevelName,
"seed" => $level["RandomSeed"], "seed" => $level->RandomSeed,
"time" => $level["Time"], "time" => $level->Time,
"spawnX" => $level["SpawnX"], "spawnX" => $level->SpawnX,
"spawnY" => $level["SpawnY"], "spawnY" => $level->SpawnY,
"spawnZ" => $level["SpawnZ"], "spawnZ" => $level->SpawnZ,
"height" => 8, "height" => 8,
"generator" => "NormalGenerator", "generator" => "default",
"generatorSettings" => "", "generatorSettings" => "",
"extra" => "" "extra" => ""
)); ));
$chunks = new PocketChunkParser(); $chunks = new PocketChunkParser();
$chunks->loadFile($this->path . "chunks.dat"); $chunks->loadFile($this->path."chunks.dat");
$chunks->loadMap(); $chunks->loadMap();
for($Z = 0; $Z < 16; ++$Z){ for($Z = 0; $Z < 16; ++$Z){
for($X = 0; $X < 16; ++$X){ for($X = 0; $X < 16; ++$X){
@ -89,7 +82,7 @@ class LevelImport{
4 => "", 4 => "",
5 => "", 5 => "",
6 => "", 6 => "",
7 => "" 7 => ""
); );
for($z = 0; $z < 16; ++$z){ for($z = 0; $z < 16; ++$z){
for($x = 0; $x < 16; ++$x){ for($x = 0; $x < 16; ++$x){
@ -108,19 +101,18 @@ class LevelImport{
$pmf->setPopulated($X, $Z); $pmf->setPopulated($X, $Z);
$pmf->saveChunk($X, $Z); $pmf->saveChunk($X, $Z);
} }
console("[NOTICE] Importing level " . ceil(($Z + 1) / 0.16) . "%"); console("[NOTICE] Importing level ".ceil(($Z + 1)/0.16)."%");
} }
$chunks->map = null; $chunks->map = null;
$chunks = null; $chunks = null;
@unlink($this->path . "level.dat"); @unlink($this->path."level.dat");
@unlink($this->path . "level.dat_old"); @unlink($this->path."level.dat_old");
@unlink($this->path . "player.dat"); @unlink($this->path."player.dat");
@unlink($this->path . "entities.dat"); @unlink($this->path."entities.dat");
@unlink($this->path . "chunks.dat"); @unlink($this->path."chunks.dat");
@unlink($this->path . "chunks.dat.gz"); @unlink($this->path."chunks.dat.gz");
@unlink($this->path . "tiles.dat"); @unlink($this->path."tiles.dat");
unset($chunks, $level, $entities, $tiles, $nbt); unset($chunks, $level, $entities, $tiles, $nbt);
return true; return true;
} }

View File

@ -86,40 +86,47 @@ class LevelFormat extends PMF{
} }
} }
} }
public function saveData(){ public function saveData(){
$this->levelData["version"] = self::VERSION; $this->levelData["version"] = PMFLevel::VERSION;
@ftruncate($this->fp, 5); @ftruncate($this->fp, 5);
$this->seek(5); $this->seek(5);
$this->write(chr($this->levelData["version"])); $this->write(chr($this->levelData["version"]));
$this->write(Utils::writeShort(strlen($this->levelData["name"])) . $this->levelData["name"]); $this->write(Utils::writeShort(strlen($this->levelData["name"])).$this->levelData["name"]);
$this->write(Utils::writeInt($this->levelData["seed"])); $this->write(Utils::writeInt($this->levelData["seed"]));
$this->write(Utils::writeInt($this->levelData["time"])); $this->write(Utils::writeInt($this->levelData["time"]));
$this->write(Utils::writeFloat($this->levelData["spawnX"])); $this->write(Utils::writeFloat($this->levelData["spawnX"]));
$this->write(Utils::writeFloat($this->levelData["spawnY"])); $this->write(Utils::writeFloat($this->levelData["spawnY"]));
$this->write(Utils::writeFloat($this->levelData["spawnZ"])); $this->write(Utils::writeFloat($this->levelData["spawnZ"]));
$this->write(chr($this->levelData["height"])); $this->write(chr($this->levelData["height"]));
$this->write(Utils::writeShort(strlen($this->levelData["generator"])) . $this->levelData["generator"]); $this->write(Utils::writeShort(strlen($this->levelData["generator"])).$this->levelData["generator"]);
$settings = serialize($this->levelData["generatorSettings"]); $settings = serialize($this->levelData["generatorSettings"]);
$this->write(Utils::writeShort(strlen($settings)) . $settings); $this->write(Utils::writeShort(strlen($settings)).$settings);
$extra = zlib_encode($this->levelData["extra"], self::ZLIB_ENCODING, self::ZLIB_LEVEL); $extra = gzdeflate($this->levelData["extra"], PMFLevel::DEFLATE_LEVEL);
$this->write(Utils::writeShort(strlen($extra)) . $extra); $this->write(Utils::writeShort(strlen($extra)).$extra);
} }
private function createBlank(){ private function createBlank(){
$this->saveData(); $this->saveData();
@mkdir(dirname($this->file) . "/chunks/", 0755); @mkdir(dirname($this->file)."/chunks/", 0755);
if(!file_exists(dirname($this->file)."/entities.yml")){
$entities = new Config(dirname($this->file)."/entities.yml", CONFIG_YAML);
$entities->save();
}
if(!file_exists(dirname($this->file)."/tiles.yml")){
$tiles = new Config(dirname($this->file)."/tiles.yml", CONFIG_YAML);
$tiles->save();
}
} }
protected function parseLevel(){ protected function parseLevel(){
if($this->getType() !== 0x00){ if($this->getType() !== 0x00){
return false; return false;
} }
$this->seek(5); $this->seek(5);
$this->levelData["version"] = ord($this->read(1)); $this->levelData["version"] = ord($this->read(1));
if($this->levelData["version"] > self::VERSION){ if($this->levelData["version"] > PMFLevel::VERSION){
console("[ERROR] New unsupported PMF Level format version #" . $this->levelData["version"] . ", current version is #" . self::VERSION); console("[ERROR] New unsupported PMF Level format version #".$this->levelData["version"].", current version is #".PMFLevel::VERSION);
return false; return false;
} }
$this->levelData["name"] = $this->read(Utils::readShort($this->read(2), false)); $this->levelData["name"] = $this->read(Utils::readShort($this->read(2), false));
@ -131,32 +138,22 @@ class LevelFormat extends PMF{
if($this->levelData["version"] === 0){ if($this->levelData["version"] === 0){
$this->read(1); $this->read(1);
$this->levelData["height"] = ord($this->read(1)); $this->levelData["height"] = ord($this->read(1));
} else{ }else{
$this->levelData["height"] = ord($this->read(1)); $this->levelData["height"] = ord($this->read(1));
if($this->levelData["height"] !== 8){ if($this->levelData["height"] !== 8){
return false; return false;
} }
$this->levelData["generator"] = $this->read(Utils::readShort($this->read(2), false)); $this->levelData["generator"] = $this->read(Utils::readShort($this->read(2), false));
$this->levelData["generatorSettings"] = unserialize($this->read(Utils::readShort($this->read(2), false))); $this->levelData["generatorSettings"] = unserialize($this->read(Utils::readShort($this->read(2), false)));
} }
$this->levelData["extra"] = @zlib_decode($this->read(Utils::readShort($this->read(2), false))); $this->levelData["extra"] = @gzinflate($this->read(Utils::readShort($this->read(2), false)));
$upgrade = false;
if($this->levelData["version"] === 0){ if($this->levelData["version"] === 0){
$this->upgrade_From0_To1(); $this->upgrade_From0_To1();
$upgrade = true;
}
if($this->levelData["version"] === 1){
$this->upgrade_From1_To2();
$upgrade = true;
}
if($upgrade === true){
$this->saveData();
} }
} }
private function upgrade_From0_To1(){ private function upgrade_From0_To1(){
console("[NOTICE] Old PMF Level format version #0 detected, upgrading to version #1"); console("[NOTICE] Old PMF Level format version #0 detected, upgrading to version #1");
for($index = 0; $index < 256; ++$index){ for($index = 0; $index < 256; ++$index){
@ -164,11 +161,11 @@ class LevelFormat extends PMF{
$Z = $index >> 4; $Z = $index >> 4;
$bitflags = Utils::readShort($this->read(2)); $bitflags = Utils::readShort($this->read(2));
$oldPath = dirname($this->file) . "/chunks/" . $Z . "." . $X . ".pmc"; $oldPath = dirname($this->file)."/chunks/".$Z.".".$X.".pmc";
$chunkOld = gzopen($oldPath, "rb"); $chunkOld = gzopen($oldPath, "rb");
$newPath = dirname($this->file) . "/chunks/" . (($X ^ $Z) & 0xff) . "/" . $Z . "." . $X . ".pmc"; $newPath = dirname($this->file)."/chunks/".(($X ^ $Z) & 0xff)."/".$Z.".".$X.".pmc";
@mkdir(dirname($newPath)); @mkdir(dirname($newPath));
$chunkNew = gzopen($newPath, "wb1"); $chunkNew = gzopen($newPath, "wb".PMFLevel::DEFLATE_LEVEL);
gzwrite($chunkNew, chr($bitflags) . "\x00\x00\x00\x01"); gzwrite($chunkNew, chr($bitflags) . "\x00\x00\x00\x01");
while(gzeof($chunkOld) === false){ while(gzeof($chunkOld) === false){
gzwrite($chunkNew, gzread($chunkOld, 65535)); gzwrite($chunkNew, gzread($chunkOld, 65535));
@ -207,18 +204,18 @@ class LevelFormat extends PMF{
public static function getIndex($X, $Z){ public static function getIndex($X, $Z){
return ($Z << 16) | ($X < 0 ? (~--$X & 0x7fff) | 0x8000 : $X & 0x7fff); return ($Z << 16) | ($X < 0 ? (~--$X & 0x7fff) | 0x8000 : $X & 0x7fff);
} }
public static function getXZ($index, &$X = null, &$Z = null){ public static function getXZ($index, &$X = null, &$Z = null){
$Z = $index >> 16; $Z = $index >> 16;
$X = ($index & 0x8000) === 0x8000 ? -($index & 0x7fff) : $index & 0x7fff; $X = ($index & 0x8000) === 0x8000 ? -($index & 0x7fff) : $index & 0x7fff;
return array($X, $Z); return array($X, $Z);
} }
private function getChunkPath($X, $Z){ private function getChunkPath($X, $Z){
return dirname($this->file) . "/chunks/" . (($X ^ $Z) & 0xff) . "/" . $Z . "." . $X . ".pmc"; return dirname($this->file)."/chunks/".(((int) $X ^ (int) $Z) & 0xff)."/".$Z.".".$X.".pmc";
} }
public function generateChunk($X, $Z){ public function generateChunk($X, $Z){
$path = $this->getChunkPath($X, $Z); $path = $this->getChunkPath($X, $Z);
if(!file_exists(dirname($path))){ if(!file_exists(dirname($path))){
@ -236,31 +233,29 @@ class LevelFormat extends PMF{
$this->populateChunk($X + 1, $Z - 1); $this->populateChunk($X + 1, $Z - 1);
$this->populateChunk($X - 1, $Z - 1); $this->populateChunk($X - 1, $Z - 1);
$this->populateChunk($X - 1, $Z + 1); $this->populateChunk($X - 1, $Z + 1);
return $ret; return $ret;
} }
} }
public function populateChunk($X, $Z){ public function populateChunk($X, $Z){
if($this->level instanceof Level){ if($this->level instanceof Level){
if($this->isGenerating === 0 and if($this->isGenerating === 0 and
$this->isChunkLoaded($X, $Z) and $this->isChunkLoaded($X, $Z) and
!$this->isPopulated($X, $Z) and !$this->isPopulated($X, $Z) and
$this->isGenerated($X - 1, $Z) and $this->isGenerated($X - 1, $Z) and
$this->isGenerated($X, $Z - 1) and $this->isGenerated($X, $Z - 1) and
$this->isGenerated($X + 1, $Z) and $this->isGenerated($X + 1, $Z) and
$this->isGenerated($X, $Z + 1) and $this->isGenerated($X, $Z + 1) and
$this->isGenerated($X + 1, $Z + 1) and $this->isGenerated($X + 1, $Z + 1) and
$this->isGenerated($X - 1, $Z - 1) and $this->isGenerated($X - 1, $Z - 1) and
$this->isGenerated($X + 1, $Z - 1) and $this->isGenerated($X + 1, $Z - 1) and
$this->isGenerated($X - 1, $Z + 1) $this->isGenerated($X - 1, $Z + 1)){
){
$this->level->populateChunk($X, $Z); $this->level->populateChunk($X, $Z);
$this->saveChunk($X, $Z); $this->saveChunk($X, $Z);
} }
} }
} }
public function loadChunk($X, $Z){ public function loadChunk($X, $Z){
if($this->isChunkLoaded($X, $Z)){ if($this->isChunkLoaded($X, $Z)){
return true; return true;
@ -272,59 +267,45 @@ class LevelFormat extends PMF{
return false; return false;
} }
if($this->isGenerating === 0){ if($this->isGenerating === 0){
$this->populateChunk($X, $Z); $this->populateChunk($X, $Z);
} }
return true; return true;
} }
$chunk = file_get_contents($path); $chunk = @gzopen($path, "rb");
if($chunk === false){ if($chunk === false){
return false; return false;
} }
$chunk = zlib_decode($chunk);
$offset = 0;
$this->chunkInfo[$index] = array( $this->chunkInfo[$index] = array(
0 => ord($chunk{0}), 0 => ord(gzread($chunk, 1)),
1 => Utils::readInt(substr($chunk, 1, 4)), 1 => Utils::readInt(gzread($chunk, 4)),
); );
$offset += 5;
$len = Utils::readInt(substr($chunk, $offset, 4));
$offset += 4;
$nbt = new NBT(NBT::BIG_ENDIAN);
$nbt->read(substr($chunk, $offset, $len));
$this->chunkInfo[$index][2] = $nbt;
$offset += $len;
$this->chunks[$index] = array(); $this->chunks[$index] = array();
$this->chunkChange[$index] = array(-1 => false); $this->chunkChange[$index] = array(-1 => false);
$this->chunkInfo[$index][3] = substr($chunk, $offset, 256); //Biome data
$offset += 256;
for($Y = 0; $Y < 8; ++$Y){ for($Y = 0; $Y < 8; ++$Y){
if(($this->chunkInfo[$index][0] & (1 << $Y)) !== 0){ if(($this->chunkInfo[$index][0] & (1 << $Y)) !== 0){
// 4096 + 2048 + 2048, Block Data, Meta, Light // 4096 + 2048 + 2048, Block Data, Meta, Light
if(strlen($this->chunks[$index][$Y] = substr($chunk, $offset, 8192)) < 8192){ if(strlen($this->chunks[$index][$Y] = gzread($chunk, 8192)) < 8192){
console("[NOTICE] Empty corrupt chunk detected [$X,$Z,:$Y], recovering contents", true, true, 2); console("[NOTICE] Empty corrupt chunk detected [$X,$Z,:$Y], recovering contents", true, true, 2);
$this->fillMiniChunk($X, $Z, $Y); $this->fillMiniChunk($X, $Z, $Y);
} }
$offset += 8192; }else{
} else{
$this->chunks[$index][$Y] = false; $this->chunks[$index][$Y] = false;
} }
} }
@gzclose($chunk);
if($this->isGenerating === 0 and !$this->isPopulated($X, $Z)){ if($this->isGenerating === 0 and !$this->isPopulated($X, $Z)){
$this->populateChunk($X, $Z); $this->populateChunk($X, $Z);
} }
return true; return true;
} }
public function unloadChunk($X, $Z, $save = true){ public function unloadChunk($X, $Z, $save = true){
$X = (int) $X; $X = (int) $X;
$Z = (int) $Z; $Z = (int) $Z;
if(!$this->isChunkLoaded($X, $Z)){ if(!$this->isChunkLoaded($X, $Z)){
return false; return false;
} elseif($save !== false){ }elseif($save !== false){
$this->saveChunk($X, $Z); $this->saveChunk($X, $Z);
} }
$index = self::getIndex($X, $Z); $index = self::getIndex($X, $Z);
@ -332,40 +313,27 @@ class LevelFormat extends PMF{
$this->chunkChange[$index] = null; $this->chunkChange[$index] = null;
$this->chunkInfo[$index] = null; $this->chunkInfo[$index] = null;
unset($this->chunks[$index], $this->chunkChange[$index], $this->chunkInfo[$index]); unset($this->chunks[$index], $this->chunkChange[$index], $this->chunkInfo[$index]);
return true; return true;
} }
public function isChunkLoaded($X, $Z){ public function isChunkLoaded($X, $Z){
$index = self::getIndex($X, $Z); $index = self::getIndex($X, $Z);
if(!isset($this->chunks[$index])){ if(!isset($this->chunks[$index])){
return false; return false;
} }
return true; return true;
} }
protected function cleanChunk($X, $Z){
$index = self::getIndex($X, $Z);
if(isset($this->chunks[$index])){
for($Y = 0; $Y < 8; ++$Y){
if($this->chunks[$index][$Y] !== false and substr_count($this->chunks[$index][$Y], "\x00") === 8192){
$this->chunks[$index][$Y] = false;
$this->chunkInfo[$index][0] &= ~(1 << $Y);
}
}
}
}
public function isMiniChunkEmpty($X, $Z, $Y){ public function isMiniChunkEmpty($X, $Z, $Y){
$index = self::getIndex($X, $Z); $index = self::getIndex($X, $Z);
if(!isset($this->chunks[$index]) or $this->chunks[$index][$Y] === false){ if(isset($this->chunks[$index]) and $this->chunks[$index][$Y] !== false){
return true; if(substr_count($this->chunks[$index][$Y], "\x00") < 8192){
return false;
}
} }
return true;
return false;
} }
protected function fillMiniChunk($X, $Z, $Y){ protected function fillMiniChunk($X, $Z, $Y){
if($this->isChunkLoaded($X, $Z) === false){ if($this->isChunkLoaded($X, $Z) === false){
return false; return false;
@ -375,10 +343,9 @@ class LevelFormat extends PMF{
$this->chunkChange[$index][-1] = true; $this->chunkChange[$index][-1] = true;
$this->chunkChange[$index][$Y] = 8192; $this->chunkChange[$index][$Y] = 8192;
$this->chunkInfo[$index][0] |= 1 << $Y; $this->chunkInfo[$index][0] |= 1 << $Y;
return true; return true;
} }
public function getMiniChunk($X, $Z, $Y){ public function getMiniChunk($X, $Z, $Y){
if($this->isChunkLoaded($X, $Z) === false and $this->loadChunk($X, $Z) === false){ if($this->isChunkLoaded($X, $Z) === false and $this->loadChunk($X, $Z) === false){
return str_repeat("\x00", 8192); return str_repeat("\x00", 8192);
@ -387,10 +354,9 @@ class LevelFormat extends PMF{
if(!isset($this->chunks[$index][$Y]) or $this->chunks[$index][$Y] === false){ if(!isset($this->chunks[$index][$Y]) or $this->chunks[$index][$Y] === false){
return str_repeat("\x00", 8192); return str_repeat("\x00", 8192);
} }
return $this->chunks[$index][$Y]; return $this->chunks[$index][$Y];
} }
public function initCleanChunk($X, $Z){ public function initCleanChunk($X, $Z){
$index = self::getIndex($X, $Z); $index = self::getIndex($X, $Z);
if(!isset($this->chunks[$index])){ if(!isset($this->chunks[$index])){
@ -402,7 +368,7 @@ class LevelFormat extends PMF{
4 => false, 4 => false,
5 => false, 5 => false,
6 => false, 6 => false,
7 => false, 7 => false,
); );
$this->chunkChange[$index] = array( $this->chunkChange[$index] = array(
-1 => true, -1 => true,
@ -415,26 +381,17 @@ class LevelFormat extends PMF{
6 => 8192, 6 => 8192,
7 => 8192, 7 => 8192,
); );
$nbt = new NBT(NBT::BIG_ENDIAN);
$nbt->setData(new Compound("", array(
"Entities" => new Enum("Entities", array()),
"TileEntities" => new Enum("TileEntities", array())
)));
$nbt->Entities->setTagType(NBT::TAG_Compound);
$nbt->TileEntities->setTagType(NBT::TAG_Compound);
$this->chunkInfo[$index] = array( $this->chunkInfo[$index] = array(
0 => 0, 0 => 0,
1 => 0, 1 => 0,
2 => $nbt,
3 => str_repeat("\x00", 256),
); );
} }
} }
public function setMiniChunk($X, $Z, $Y, $data){ public function setMiniChunk($X, $Z, $Y, $data){
if($this->isGenerating > 0){ if($this->isGenerating > 0){
$this->initCleanChunk($X, $Z); $this->initCleanChunk($X, $Z);
} elseif($this->isChunkLoaded($X, $Z) === false){ }elseif($this->isChunkLoaded($X, $Z) === false){
$this->loadChunk($X, $Z); $this->loadChunk($X, $Z);
} }
if(strlen($data) !== 8192){ if(strlen($data) !== 8192){
@ -445,10 +402,9 @@ class LevelFormat extends PMF{
$this->chunkChange[$index][-1] = true; $this->chunkChange[$index][-1] = true;
$this->chunkChange[$index][$Y] = 8192; $this->chunkChange[$index][$Y] = 8192;
$this->chunkInfo[$index][0] |= 1 << $Y; $this->chunkInfo[$index][0] |= 1 << $Y;
return true; return true;
} }
public function getBlockID($x, $y, $z){ public function getBlockID($x, $y, $z){
if($y > 127 or $y < 0){ if($y > 127 or $y < 0){
return 0; return 0;
@ -464,38 +420,9 @@ class LevelFormat extends PMF{
$aZ = $z - ($Z << 4); $aZ = $z - ($Z << 4);
$aY = $y - ($Y << 4); $aY = $y - ($Y << 4);
$b = ord($this->chunks[$index][$Y]{(int) ($aY + ($aX << 5) + ($aZ << 9))}); $b = ord($this->chunks[$index][$Y]{(int) ($aY + ($aX << 5) + ($aZ << 9))});
return $b;
return $b;
} }
public function getBiome($x, $z){
$X = $x >> 4;
$Z = $z >> 4;
$index = self::getIndex($X, $Z);
if(!isset($this->chunks[$index])){
return 0;
}
$aX = $x - ($X << 4);
$aZ = $z - ($Z << 4);
return ord($this->chunkInfo[$index][3]{$aX + ($aZ << 4)});
}
public function setBiome($x, $z, $biome){
$X = $x >> 4;
$Z = $z >> 4;
$index = self::getIndex($X, $Z);
if(!isset($this->chunks[$index])){
return false;
}
$aX = $x - ($X << 4);
$aZ = $z - ($Z << 4);
$this->chunkInfo[$index][3]{$aX + ($aZ << 4)} = chr((int) $biome);
return true;
}
public function setBlockID($x, $y, $z, $block){ public function setBlockID($x, $y, $z, $block){
if($y > 127 or $y < 0){ if($y > 127 or $y < 0){
return false; return false;
@ -514,14 +441,13 @@ class LevelFormat extends PMF{
$this->chunks[$index][$Y]{(int) ($aY + ($aX << 5) + ($aZ << 9))} = chr($block); $this->chunks[$index][$Y]{(int) ($aY + ($aX << 5) + ($aZ << 9))} = chr($block);
if(!isset($this->chunkChange[$index][$Y])){ if(!isset($this->chunkChange[$index][$Y])){
$this->chunkChange[$index][$Y] = 1; $this->chunkChange[$index][$Y] = 1;
} else{ }else{
++$this->chunkChange[$index][$Y]; ++$this->chunkChange[$index][$Y];
} }
$this->chunkChange[$index][-1] = true; $this->chunkChange[$index][-1] = true;
return true; return true;
} }
public function getBlockDamage($x, $y, $z){ public function getBlockDamage($x, $y, $z){
if($y > 127 or $y < 0){ if($y > 127 or $y < 0){
return 0; return 0;
@ -539,13 +465,12 @@ class LevelFormat extends PMF{
$m = ord($this->chunks[$index][$Y]{(int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9))}); $m = ord($this->chunks[$index][$Y]{(int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9))});
if(($y & 1) === 0){ if(($y & 1) === 0){
$m = $m & 0x0F; $m = $m & 0x0F;
} else{ }else{
$m = $m >> 4; $m = $m >> 4;
} }
return $m;
return $m;
} }
public function setBlockDamage($x, $y, $z, $damage){ public function setBlockDamage($x, $y, $z, $damage){
if($y > 127 or $y < 0){ if($y > 127 or $y < 0){
return false; return false;
@ -565,7 +490,7 @@ class LevelFormat extends PMF{
$old_m = ord($this->chunks[$index][$Y]{$mindex}); $old_m = ord($this->chunks[$index][$Y]{$mindex});
if(($y & 1) === 0){ if(($y & 1) === 0){
$m = ($old_m & 0xF0) | $damage; $m = ($old_m & 0xF0) | $damage;
} else{ }else{
$m = ($damage << 4) | ($old_m & 0x0F); $m = ($damage << 4) | ($old_m & 0x0F);
} }
@ -573,14 +498,12 @@ class LevelFormat extends PMF{
$this->chunks[$index][$Y]{$mindex} = chr($m); $this->chunks[$index][$Y]{$mindex} = chr($m);
if(!isset($this->chunkChange[$index][$Y])){ if(!isset($this->chunkChange[$index][$Y])){
$this->chunkChange[$index][$Y] = 1; $this->chunkChange[$index][$Y] = 1;
} else{ }else{
++$this->chunkChange[$index][$Y]; ++$this->chunkChange[$index][$Y];
} }
$this->chunkChange[$index][-1] = true; $this->chunkChange[$index][-1] = true;
return true; return true;
} }
return false; return false;
} }
@ -589,13 +512,13 @@ class LevelFormat extends PMF{
$Z = $z >> 4; $Z = $z >> 4;
$Y = $y >> 4; $Y = $y >> 4;
if($y < 0 or $y > 127){ if($y < 0 or $y > 127){
return array(0, 0); return array(AIR, 0);
} }
$index = self::getIndex($X, $Z); $index = self::getIndex($X, $Z);
if(!isset($this->chunks[$index]) and $this->loadChunk($X, $Z) === false){ if(!isset($this->chunks[$index]) and $this->loadChunk($X, $Z) === false){
return array(0, 0); return array(AIR, 0);
} elseif($this->chunks[$index][$Y] === false){ }elseif($this->chunks[$index][$Y] === false){
return array(0, 0); return array(AIR, 0);
} }
$aX = $x - ($X << 4); $aX = $x - ($X << 4);
$aZ = $z - ($Z << 4); $aZ = $z - ($Z << 4);
@ -604,13 +527,12 @@ class LevelFormat extends PMF{
$m = ord($this->chunks[$index][$Y]{(int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9))}); $m = ord($this->chunks[$index][$Y]{(int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9))});
if(($y & 1) === 0){ if(($y & 1) === 0){
$m = $m & 0x0F; $m = $m & 0x0F;
} else{ }else{
$m = $m >> 4; $m = $m >> 4;
} }
return array($b, $m);
return array($b, $m);
} }
public function setBlock($x, $y, $z, $block, $meta = 0){ public function setBlock($x, $y, $z, $block, $meta = 0){
if($y > 127 or $y < 0){ if($y > 127 or $y < 0){
return false; return false;
@ -623,7 +545,7 @@ class LevelFormat extends PMF{
$index = self::getIndex($X, $Z); $index = self::getIndex($X, $Z);
if(!isset($this->chunks[$index]) and $this->loadChunk($X, $Z) === false){ if(!isset($this->chunks[$index]) and $this->loadChunk($X, $Z) === false){
return false; return false;
} elseif($this->chunks[$index][$Y] === false){ }elseif($this->chunks[$index][$Y] === false){
$this->fillMiniChunk($X, $Z, $Y); $this->fillMiniChunk($X, $Z, $Y);
} }
$aX = $x - ($X << 4); $aX = $x - ($X << 4);
@ -635,7 +557,7 @@ class LevelFormat extends PMF{
$old_m = ord($this->chunks[$index][$Y]{$mindex}); $old_m = ord($this->chunks[$index][$Y]{$mindex});
if(($y & 1) === 0){ if(($y & 1) === 0){
$m = ($old_m & 0xF0) | $meta; $m = ($old_m & 0xF0) | $meta;
} else{ }else{
$m = ($meta << 4) | ($old_m & 0x0F); $m = ($meta << 4) | ($old_m & 0x0F);
} }
@ -644,78 +566,54 @@ class LevelFormat extends PMF{
$this->chunks[$index][$Y]{$mindex} = chr($m); $this->chunks[$index][$Y]{$mindex} = chr($m);
if(!isset($this->chunkChange[$index][$Y])){ if(!isset($this->chunkChange[$index][$Y])){
$this->chunkChange[$index][$Y] = 1; $this->chunkChange[$index][$Y] = 1;
} else{ }else{
++$this->chunkChange[$index][$Y]; ++$this->chunkChange[$index][$Y];
} }
$this->chunkChange[$index][-1] = true; $this->chunkChange[$index][-1] = true;
return true; return true;
} }
return false; return false;
} }
public function getChunkNBT($X, $Z){ public function saveChunk($X, $Z){
if(!$this->isChunkLoaded($X, $Z) and $this->loadChunk($X, $Z) === false){
return false;
}
$index = self::getIndex($X, $Z);
return $this->chunkInfo[$index][2];
}
public function setChunkNBT($X, $Z, NBT $nbt){
if(!$this->isChunkLoaded($X, $Z) and $this->loadChunk($X, $Z) === false){
return false;
}
$index = self::getIndex($X, $Z);
$this->chunkChange[$index][-1] = true;
$this->chunkInfo[$index][2] = $nbt;
}
public function saveChunk($X, $Z, $force = false){
$X = (int) $X; $X = (int) $X;
$Z = (int) $Z; $Z = (int) $Z;
if(!$this->isChunkLoaded($X, $Z)){ if(!$this->isChunkLoaded($X, $Z)){
return false; return false;
} }
$index = self::getIndex($X, $Z); $index = self::getIndex($X, $Z);
if($force !== true and (!isset($this->chunkChange[$index]) or $this->chunkChange[$index][-1] === false)){ //No changes in chunk if(!isset($this->chunkChange[$index]) or $this->chunkChange[$index][-1] === false){//No changes in chunk
return true; return true;
} }
$path = $this->getChunkPath($X, $Z); $path = $this->getChunkPath($X, $Z);
if(!file_exists(dirname($path))){ if(!file_exists(dirname($path))){
@mkdir(dirname($path), 0755); @mkdir(dirname($path), 0755);
} }
$bitmap = 0; $bitmap = 0;
$this->cleanChunk($X, $Z);
for($Y = 0; $Y < 8; ++$Y){ for($Y = 0; $Y < 8; ++$Y){
if($this->chunks[$index][$Y] !== false and ((isset($this->chunkChange[$index][$Y]) and $this->chunkChange[$index][$Y] === 0) or !$this->isMiniChunkEmpty($X, $Z, $Y))){ if($this->chunks[$index][$Y] !== false and ((isset($this->chunkChange[$index][$Y]) and $this->chunkChange[$index][$Y] === 0) or !$this->isMiniChunkEmpty($X, $Z, $Y))){
$bitmap |= 1 << $Y; $bitmap |= 1 << $Y;
} else{ }else{
$this->chunks[$index][$Y] = false; $this->chunks[$index][$Y] = false;
} }
$this->chunkChange[$index][$Y] = 0; $this->chunkChange[$index][$Y] = 0;
} }
$this->chunkInfo[$index][0] = $bitmap; $chunk = @gzopen($path, "wb".PMFLevel::DEFLATE_LEVEL);
$this->chunkChange[$index][-1] = false; gzwrite($chunk, chr($bitmap));
$chunk = b""; gzwrite($chunk, Utils::writeInt($this->chunkInfo[$index][1]));
$chunk .= chr($bitmap);
$chunk .= Utils::writeInt($this->chunkInfo[$index][1]);
$namedtag = $this->chunkInfo[$index][2]->write();
$chunk .= Utils::writeInt(strlen($namedtag)) . $namedtag;
$chunk .= $this->chunkInfo[$index][3]; //biomes
for($Y = 0; $Y < 8; ++$Y){ for($Y = 0; $Y < 8; ++$Y){
$t = 1 << $Y; $t = 1 << $Y;
if(($bitmap & $t) === $t){ if(($bitmap & $t) === $t){
$chunk .= $this->chunks[$index][$Y]; gzwrite($chunk, $this->chunks[$index][$Y]);
} }
} }
file_put_contents($path, zlib_encode($chunk, self::ZLIB_ENCODING, self::ZLIB_LEVEL)); gzclose($chunk);
$this->chunkChange[$index][-1] = false;
$this->chunkInfo[$index][0] = $bitmap;
return true; return true;
} }
public function setPopulated($X, $Z){ public function setPopulated($X, $Z){
if(!$this->isChunkLoaded($X, $Z)){ if(!$this->isChunkLoaded($X, $Z)){
return false; return false;
@ -723,32 +621,31 @@ class LevelFormat extends PMF{
$index = self::getIndex($X, $Z); $index = self::getIndex($X, $Z);
$this->chunkInfo[$index][1] |= 0b00000000000000000000000000000001; $this->chunkInfo[$index][1] |= 0b00000000000000000000000000000001;
} }
public function unsetPopulated($X, $Z){ public function unsetPopulated($X, $Z){
if(!$this->isChunkLoaded($X, $Z)){ if(!$this->isChunkLoaded($X, $Z)){
return false; return false;
} }
$index = self::getIndex($X, $Z); $index = self::getIndex($X, $Z);
$this->chunkInfo[$index][1] &= ~0b00000000000000000000000000000001; $this->chunkInfo[$index][1] &= ~0b00000000000000000000000000000001;
} }
public function isPopulated($X, $Z){ public function isPopulated($X, $Z){
if(!$this->isChunkLoaded($X, $Z)){ if(!$this->isChunkLoaded($X, $Z)){
return false; return false;
} }
$index = self::getIndex($X, $Z); $index = self::getIndex($X, $Z);
return ($this->chunkInfo[$index][1] & 0b00000000000000000000000000000001) > 0; return ($this->chunkInfo[$index][1] & 0b00000000000000000000000000000001) > 0;
} }
public function isGenerated($X, $Z){ public function isGenerated($X, $Z){
return file_exists($this->getChunkPath($X, $Z)); return file_exists($this->getChunkPath($X, $Z));
} }
public function doSaveRound($force = false){ public function doSaveRound(){
foreach($this->chunks as $index => $chunk){ foreach($this->chunks as $index => $chunk){
self::getXZ($index, $X, $Z); self::getXZ($index, $X, $Z);
$this->saveChunk($X, $Z, $force); $this->saveChunk($X, $Z);
} }
} }