summaryrefslogtreecommitdiffstats
path: root/includes/mapclass.php
diff options
context:
space:
mode:
authorPatrick Davison <snapwilliam@gmail.com>2013-01-26 01:31:40 -0800
committerPatrick Davison <snapwilliam@gmail.com>2013-01-26 01:31:40 -0800
commit0879eecfe919597de05895087327bfb0b1a6e9bd (patch)
treec3187a582ce488b58afaebcf07ecbb4e7cf0003a /includes/mapclass.php
parent8e348cfd94360aee814a2dd629b4279818ddfc58 (diff)
downloadpathery-0879eecfe919597de05895087327bfb0b1a6e9bd.tar.xz
Tiny bit of cleanup
Diffstat (limited to 'includes/mapclass.php')
-rw-r--r--includes/mapclass.php13
1 files changed, 9 insertions, 4 deletions
diff --git a/includes/mapclass.php b/includes/mapclass.php
index 21c7778..fa4d865 100644
--- a/includes/mapclass.php
+++ b/includes/mapclass.php
@@ -39,9 +39,10 @@ class map {
public $code;
public function __construct($code = NULL) {
+ //TODO: Use new code by default.
if ($code !== NULL)
$this->applyMapFromOldCode($code);
- //echo "Construct complete";
+ //$this->applyMapFromCode($code);
}
public function applyMapFromOldCode($code) {
@@ -125,7 +126,8 @@ class map {
//From the newer mapcode.
public function applyMapFromCode($code) {
- //echo "decoding mapcode: [$code]";
+ //TODO: Uncomment this when testing is complete; to boost getCode() speed;
+ //$this->$code = $code;
unset($this->tiles);
$tmp = explode( ":", $code);
@@ -149,9 +151,9 @@ class map {
$this->checkpoints = 0;
$distance = -1;
- $index = 0;
//First Element
+ $index = 0;
$codePart = explode(',', $splitCode[$index]);
$next = $codePart[0];
@@ -201,7 +203,10 @@ class map {
for ($y = 0; $y < $this->height; $y++) { //Number of Rows
for ($x = 0; $x < $this->width; $x++) { //Number of Columns
if ($this->tiles[$y][$x][TileType] !== TileEmpty) {
- $code .= $position.','.$this->tiles[$y][$x][TileType].$this->tiles[$y][$x][TileValue].'.';
+ $positionOutput = $position;
+ if ($position == 0)
+ $positionOutput = '';
+ $code .= $positionOutput.','.$this->tiles[$y][$x][TileType].$this->tiles[$y][$x][TileValue].'.';
$position = -1;
}
$position++;