$areaToLoad = MAXMAPSTRAAL + MAXMAPSTRAAL * 0.1; // The whole wide world: $sizeX = $areaToLoad; $sizeY = $areaToLoad; $zoom = max(0, $zoom); $zoom = pow(2, $zoom); $dx = $areaToLoad * 2 / $zoom / $width; $dy = $areaToLoad * 2 / $zoom / $height; $startX = $areaToLoad * 2 / $zoom * $x - $areaToLoad; $startY = $areaToLoad * 2 / $zoom * $y - $areaToLoad; // Show all these pixels for ($i = 0; $i < $width; $i++) { for ($j = 0; $j < $height; $j++) { $lx = round($startX + $dx * $i); $ly = round($startY + $dy * $j); $location = Dolumar_Map_Map::getLocation($lx, $ly, false, false); $px = $i; $py = $height - $j; $c = $location->getHeightIntencity(); $col = $location->getMapColor(); $col[0] = floor($col[0] * $c); $col[1] = floor($col[1] * $c); $col[2] = floor($col[2] * $c); $color = color_cache($im, $col); imagesetpixel($im, $i, $j, $color); } } $locations = array(array($startX + 125, $startY + 125)); // Load buildings from SQL /* $buildingSQL = Dolumar_Map_Map::getBuildingsFromLocations ($locations, 125);
public static function getLocation($x, $y, $hasBuilding = false) { return Dolumar_Map_Map::getLocation($x, $y, $hasBuilding); }
private function doPrepareCircle($start, $end) { $start = intval($start); $end = intval($end); // Power the start & end to make everything run faster $pStart = $start * $start; $pEnd = $end * $end; $pi = pi(); // Count the values in the database, // maybe we don't have to run this check! $toFind = 0; for ($x = 0 - $end; $x < $end; $x++) { for ($y = 0 - $end; $y < $end; $y++) { $distance = $x * $x + $y * $y; if ($distance > $pStart && $distance < $pEnd) { $toFind++; } } } // Now count all values in the circle $db = Neuron_DB_Database::getInstance(); $check = $db->query("\n\t\t\tSELECT\n\t\t\t\tt_distance AS distance\n\t\t\tFROM\n\t\t\t\tz_cache_tiles\n\t\t\tHAVING\n\t\t\t\tdistance > {$start} AND \n\t\t\t\tdistance < {$end}\n\t\t"); $aantal = count($check); if ($aantal == $toFind) { echo "[" . date("d/m/Y H:i:s") . "]" . " Skipping since the database contains enough tiles...\n"; return; } for ($x = 0 - $end; $x < $end; $x++) { for ($y = 0 - $end; $y < $end; $y++) { // Check the distance! $distance = $x * $x + $y * $y; if ($distance > $pStart && $distance < $pEnd) { Dolumar_Map_Map::getLocation($x, $y); } } } }
private function isValidLocation($village, $x, $y) { if ($x == $this->lx && $y == $this->ly) { return false; } // Fetch location $location = Dolumar_Map_Map::getLocation($x, $y); if (!$location->canBuildBuilding()) { return false; } return !$village->buildings->isBuildingOnLocation($x, $y); }
<?php echo '<h2>Current key</h2>'; echo '<p>Config key: "' . RANDMAPFACTOR . '"</p>'; if (isset($_POST['key'])) { $keys = explode(',', $_POST['key']); foreach ($keys as $key) { $key = trim($key); $GLOBALS['MAP_CONFIG_RANDMAPFACTOR'] = $key; echo '<h2>Checking hash "' . $key . '" against local cache:</h2>'; echo '<ul>'; // Check the first 25 square for a match for ($i = 0; $i < 2; $i++) { for ($j = 0; $j < 2; $j++) { $d1 = Dolumar_Map_Map::getLocation($i, $j, false, false); $d2 = Dolumar_Map_Map::getLocation($i, $j, false, true); // Check if equal $img1 = $d1->getImage(); $img2 = $d2->getImage(); echo '<li>'; if ($d1->getHeight() == $d2->getHeight() && $img1['image'] == $img2['image']) { echo '<span style="color: green;">Location ' . $i . ',' . $j . ' does match!</span>'; } else { echo '<span style="color: red;">Location ' . $i . ',' . $j . ' does not match (' . $img1['image'] . ' != ' . $img2['image'] . ').</span>'; echo '<pre>'; echo "Fresh data:\n"; print_r($d1); echo "Cache:\n"; print_r($d2); echo '</pre>'; break 2;