Lots of typos fixed, undefined variables, unused code

This commit is contained in:
Shoghi Cervantes
2014-02-19 01:55:42 +01:00
parent 3d3111fef6
commit f1b5f83fd4
35 changed files with 63 additions and 251 deletions

View File

@ -43,8 +43,16 @@ class Entity extends Position{
public $attach;
public $closed;
public $player;
public $status;
public $fallY;
public $health;
public $fire;
public $crouched;
public $invincible;
public $fallStart;
public $stack;
public $meta;
private $position;
private $tickCounter;
private $speedMeasure = array(0, 0, 0, 0, 0, 0, 0);
private $server;
@ -526,8 +534,8 @@ class Entity extends Position{
}
}elseif($this->fallY !== false){ //Fall damage!
if($y < $this->fallY){
$d = $this->level->getBlock(new Vector3($x, $y + 1, $z));
$d2 = $this->level->getBlock(new Vector3($x, $y + 2, $z));
$d = $this->level->getBlock(new Vector3($this->x, $y + 1, $this->z));
$d2 = $this->level->getBlock(new Vector3($this->x, $y + 2, $this->z));
$dmg = ($this->fallY - $y) - 3;
if($dmg > 0 and !($d instanceof LiquidBlock) and $d->getID() !== LADDER and $d->getID() !== COBWEB and !($d2 instanceof LiquidBlock) and $d2->getID() !== LADDER and $d2->getID() !== COBWEB){
$this->harm($dmg, "fall");
@ -562,10 +570,10 @@ class Entity extends Position{
if($this->isStatic === false and ($this->last[0] != $this->x or $this->last[1] != $this->y or $this->last[2] != $this->z or $this->last[3] != $this->yaw or $this->last[4] != $this->pitch)){
if($this->class === ENTITY_PLAYER or ($this->last[5] + 8) < $now){
if($this->server->api->handle("entity.move", $this) === false){
if($this->class === ENTITY_PLAYER){
if($this->class === ENTITY_PLAYER and $this->player instanceof Player){
$this->player->teleport(new Vector3($this->last[0], $this->last[1], $this->last[2]), $this->last[3], $this->last[4]);
}else{
$this->setPosition($this->last[0], $this->last[1], $this->last[2], $this->last[3], $this->last[4]);
$this->setPosition(new Vector3($this->last[0], $this->last[1], $this->last[2]), $this->last[3], $this->last[4]);
}
}else{
$this->updateLast();
@ -593,7 +601,7 @@ class Entity extends Position{
}
}
}else{
$this->updatePosition($this->x, $this->y, $this->z, $this->yaw, $this->pitch);
$this->updatePosition();
}
}
$this->lastUpdate = $now;
@ -658,7 +666,7 @@ class Entity extends Position{
}
switch($this->class){
case ENTITY_PLAYER:
if($this->player->connected !== true or $this->player->spawned === false){
if(!($this->player instanceof Player) or $this->player->connected !== true or $this->player->spawned === false){
return false;
}

View File

@ -19,14 +19,19 @@
*
*/
/**
* WARNING: This code is old, and only supports the file format partially (reverse engineering)
* It can break, lock, or hit you in the face in any moment.
*
*/
class PocketChunkParser{
private $location, $raw = b"", $file;
var $sectorLength = 4096; //16 * 16 * 16
var $chunkLength = 86016; //21 * $sectorLength
var $map;
public $sectorLength = 4096; //16 * 16 * 16
public $chunkLength = 86016; //21 * $sectorLength
public $map = array();
function __construct(){
$map = array();
public function __construct(){
}
private function loadLocationTable(){

View File

@ -31,6 +31,8 @@ class Tile extends Position{
public $attach;
public $metadata;
public $closed;
private $lastUpdate;
private $scheduledUpdate;
private $server;
function __construct(Level $level, $id, $class, $x, $y, $z, $data = array()){
$this->server = ServerAPI::request();

View File

@ -80,6 +80,7 @@ class NormalGenerator implements LevelGenerator{
public function generateChunk($chunkX, $chunkZ){
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
$hills = array();
$patches = array();
$patchesSmall = array();
$base = array();
for($z = 0; $z < 16; ++$z){

View File

@ -24,7 +24,7 @@ require_once("LevelGenerator.php");
/***REM_END***/
class SuperflatGenerator implements LevelGenerator{
private $level, $random, $structure, $chunks, $options, $floorLevel, $populators = array();
private $level, $random, $structure, $chunks, $options, $floorLevel, $preset, $populators = array();
public function getSettings(){
return $this->options;

View File

@ -20,7 +20,7 @@
*/
class WorldGenerator{
private $seed, $level, $path, $random, $generator, $width;
private $seed, $level, $path, $random, $generator, $height;
public function __construct(LevelGenerator $generator, $name, $seed = false, $height = 8){
$this->seed = $seed !== false ? (int) $seed:Utils::readInt(Utils::getRandomBytes(4, false));
$this->random = new Random($this->seed);

View File

@ -1,108 +0,0 @@
<?php
/**
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
abstract class OctaveGenerator{
protected $octaves;
protected $xScale = 1;
protected $yScale = 1;
protected $zScale = 1;
public function __construct(array $octaves){
$this->octaves = $octaves;
}
public function setScale($scale){
$this->setXScale($scale);
$this->setYScale($scale);
$this->setZScale($scale);
}
public function getXScale(){
return $this->xScale;
}
public function setXScale($scale){
$this->xScale = $scale;
}
public function getYScale(){
return $this->yScale;
}
public function setYScale($scale){
$this->yScale = $scale;
}
public function getZScale(){
return $this->zScale;
}
public function setZScale($scale){
$this->zScale = $scale;
}
public function getOctaves(){
$array = array();
foreach($this->octaves as $index => $value){
$array[$index] = clone $value;
}
return $array;
}
//1D-noise
public function noise1D($x, $frequency, $amplitude, $normalized = false){
return $this->noise3D($x, 0, 0, $frequency, $amplitude, $normalized);
}
//2D-noise
public function noise2D($x, $y, $frequency, $amplitude, $normalized = false){
return $this->noise3D($x, $y, 0, $frequency, $amplitude, $normalized);
}
//3D-noise
public function noise3D($x, $y, $z, $frequency, $amplitude, $normalized = false){
$result = 0;
$amp = 1;
$freq = 1;
$max = 0;
$x *= $this->xScale;
$y *= $this->yScale;
$z *= $this->zScale;
foreach($this->octaves as $noiseGenerator){
$result += $octave->noise($x * $freq, $y * $freq, $z * $freq) * $amp;
$max += $amp;
$freq *= $frequency;
$amp *= $amplitude;
}
if($normalized === true){
$result /= $max;
}
return $result;
}
/*public function generateNoiseOctaves($x, $y, $z, $frequency, $amplitude){
}*/
}

View File

@ -1,63 +0,0 @@
<?php
/**
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
/***REM_START***/
require_once("OctaveGenerator.php");
/***REM_END***/
class PerlinOctaveGenerator extends OctaveGenerator{
public function __construct(Random $random, $octaves){
$this->octaves = array();
for($o = 0; $o < $octaves; ++$o){
$this->octaves[$o] = new NoiseGeneratorPerlin($random);
}
}
/*public function generateNoiseOctaves($x, $y, $z, $sizeX, $sizeY, $sizeZ, $fX, $fY, $fZ){
$adouble = array_fill(0, $sizeX * $sizeY * $sizeZ, 0.0);
$d3 = 1.0;
foreach($this->octaves as $octave){
$dX = $x * $d3 * $fX;
$dY = $y * $d3 * $fY;
$dZ = $x * $d3 * $fZ;
$x1 = NoiseGenerator::floor($dX);
$z1 = NoiseGenerator::floor($dZ);
$dX -= $x1;
$dZ -= $z1;
$x1 %= 16777216;
$z1 %= 16777216;
//$x1 &= 0xFFFFFF;
//$z1 &= 0xFFFFFF;
$dX += $x1;
$dZ += $z1;
$octave->populateNoiseArray($adouble, $dX, $dY, $dZ, $sizeX, $sizeY, $sizeZ, $fX * $d3, $fY * $d3, $fZ * $d3, $d3);
$d3 *= 0.5;
}
return $adouble;
}*/
}

View File

@ -55,7 +55,7 @@ class SpruceTreeObject extends TreeObject{
public function placeObject(Level $level, Vector3 $pos, Random $random){
if($this->leavesBottomY === -1 or $this->leavesMaxRadius === -1) {
$this->findRandomLeavesSize();
$this->findRandomLeavesSize($random);
}
$level->setBlockRaw(new Vector3($pos->x, $pos->y - 1, $pos->z), new DirtBlock());
$leavesRadius = 0;

View File

@ -47,8 +47,8 @@ class TreeObject{
$tree = new SmallTreeObject();
$tree->type = SaplingBlock::JUNGLE;
break;
default:
case SaplingBlock::OAK:
default:
/*if($random->nextRange(0, 9) === 0){
$tree = new BigTreeObject();
}else{*/