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

@ -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{*/