diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/header.php | 1 | ||||
-rw-r--r-- | includes/mapclass.php | 82 |
2 files changed, 79 insertions, 4 deletions
diff --git a/includes/header.php b/includes/header.php index 136c2eb..44d028e 100644 --- a/includes/header.php +++ b/includes/header.php @@ -10,6 +10,7 @@ function htmlHeader($css = array(), $title = 'Pathery', $desc = '', $scripts = a <link href="css/page.css?v=011013" rel="stylesheet" type="text/css" />
<link href="css/maps.css?v=122612" rel="stylesheet" type="text/css" />
+ <link rel="image_src" type="image/png" href="/images/linkdsp.png" />
<?php
foreach ($css as $c) {
echo " <link href=\"css/$c.css\" rel=\"stylesheet\" type=\"text/css\" />\n";
diff --git a/includes/mapclass.php b/includes/mapclass.php index 9e91d3f..24b9108 100644 --- a/includes/mapclass.php +++ b/includes/mapclass.php @@ -43,8 +43,15 @@ class map { public function __construct($code = NULL, $mapID = NULL) { //TODO: Use new code by default. if ($mapID !== NULL) $this->ID = $mapID; - if ($code !== NULL) $this->applyMapFromOldCode($code); - //$this->applyMapFromCode($code); + if ($code !== NULL) { + $dimensions = explode('.', explode(':', $code)[0])[0]; + if (strpos($dimensions, 'x') == true) { + $this->applyMapFromOldCode($code); + } else { + $this->applyMapFromCode($code); + } + } + } public function applyMapFromOldCode($code) { @@ -218,8 +225,7 @@ class map { //Outputs the new code. public function getCode() { //If we already have the code on hand... - if ($this->code) - return $this->code; + //if ($this->code) return $this->code; //Otherwise we need to build the code: $headers[0] = $this->width; $headers[1] = $this->height; @@ -247,6 +253,74 @@ class map { return $code; } + function getOldCode() { + + $code = ""; //The string to return to the database. + $index = 0; //The current number of tiles from the last tile saved. + + $code = $this->width.'x'.$this->height; + $code .= '.c'.$this->checkpoints; + $code .= '.r0'; //rocks... yeah. + $code .= '.w'.$this->walls; + $code .= '.t'.$this->teleports; + $code .= '.'.$this->name; + $code .= ".:"; + + $oldNames['o'] = 'o'; + + $oldNames['s'] = 's'; + $oldNames['s2'] = 'S'; + $oldNames['f'] = 'f'; + + $oldNames['c'] = 'a'; + $oldNames['c2'] = 'b'; + $oldNames['c3'] = 'c'; + $oldNames['c4'] = 'd'; + $oldNames['c5'] = 'e'; + + $oldNames['t'] = 't'; + $oldNames['t2'] = 'm'; + $oldNames['t3'] = 'g'; + $oldNames['t4'] = 'i'; + $oldNames['t5'] = 'k'; + + $oldNames['u'] = 'u'; + $oldNames['u2'] = 'n'; + $oldNames['u3'] = 'h'; + $oldNames['u4'] = 'j'; + $oldNames['u5'] = 'l'; + + $oldNames['x'] = 'x'; + $oldNames['x2'] = 'X'; + + $oldNames['r'] = 'r'; + $oldNames['r2'] = 'R'; + + for( $i = 0; $i < $this->height; $i++) { + for( $j = 0; $j < $this->width; $j++) { + if($this->tiles[$i][$j][0] != 'o') { + //As long as the tile is NOT open, embed it in the code. + + + $type = $this->tiles[$i][$j][0]; + $value = $this->tiles[$i][$j][1]; + if ($value <= 1) $value = ''; + + $code .= $index.$oldNames[$type.$value].'.'; + + + //$code .= $index.$mapMatrix[$i][$j].'.'; + //Start from 0 again. + $index = -1; + } + $index += 1; + } + } + + return $code; + + } + //Other "Magical" functions. public function __toString() { return $this->name; |