Page MenuHomeCode

No OneTemporary

This document is not UTF8. It was detected as Shift JIS and converted to UTF8 for display.
diff --git a/content/scenes/B00001002.tpl b/content/scenes/B00001002.tpl
index 309d6c8..719c329 100644
--- a/content/scenes/B00001002.tpl
+++ b/content/scenes/B00001002.tpl
@@ -1,56 +1,56 @@
<!--
Global location: B00001002
-->
<div class="grid_7 alpha">
{$xyz = explode(',', substr($CurrentPerso->location_local, 1, -1))}
{$x = $xyz[0]}{$y = $xyz[1]}{$z = $xyz[2]}
- {#Sector#} C<span id="sector">{GeoOctocube::get_sector($x, $y, $z)}</span>
+ {#Sector#} C<span id="sector">{GeoOctocube::getSector($x, $y, $z)}</span>
</div>
<div class="grid_2" style="text-align: center;">
{#Zone#} <span id="area">{abs($x)}-{abs($y)}</span>
</div>
<div class="grid_7 omega" style="text-align: right; margin-bottom: 1em;">
{#Level#} <span id="level">{abs($z)}</span>
</div>
<div class="clear"></div>
{if $zone}
{if $zone->type == "hotglue"}
<!-- Content iframe -->
<script type="text/javascript">
function hijacklinks(iframe){
var as = iframe.contentDocument.getElementsByTagName('a');
for(i=0;i<as.length;i++){
as[i].setAttribute('target','_parent');
}
}
</script>
<iframe src="{$HOTGLUE}?zone_{$zone->id}" width="960" height="600" id="content_iframe" frameborder="0" scrolling="no" style="margin-bottom: 1em" onload="hijacklinks(this)"></iframe>
{else}
<p>{#CantRender#}</p>
{dprint_r($zone)}
{/if}
{else}
<div class="content_wrapper">
<h1>{#Builder#}</h1>
<div class="grid_9 suffix_1 content alpha">
{#BuildInfo#}
</div>
<div class="grid_6 omega">
<p><a href="{get_url('builder')}">{#StartBuild#}</a></p>
<p><a href="{get_url('do.php')}/local_move/0,1,0?redirectTo=/">{#GoNorth#}</a><br />
<a href="{get_url('do.php')}/local_move/1,0,0?redirectTo=/">{#GoEast#}</a><br />
<a href="{get_url('do.php')}/local_move/0,-1,0?redirectTo=/">{#GoSouth#}</a><br />
<a href="{get_url('do.php')}/local_move/-1,0,0?redirectTo=/">{#GoWest#}</a></p>
<p><a href="{get_url('do.php')}/local_move/0,0,1?redirectTo=/">{#GoUp#}</a><br />
<a href="{get_url('do.php')}/local_move/0,0,-1?redirectTo=/">{#GoDown#}</a></p>
<p><a href="{get_url('builder', 'map')}">{#ViewMap#}</a></p>
<p><a href="{get_xhr_hashed_url('global_move', 'B00001001', 'T2C3')}?redirectTo={get_url()}">{#GoTower#}</a></p>
</div>
<div class="clear fixclear"></div>
</div>
{/if}
diff --git a/controllers/builder.php b/controllers/builder.php
index 1254627..c5014bc 100644
--- a/controllers/builder.php
+++ b/controllers/builder.php
@@ -1,135 +1,135 @@
<?php
/**
* Builder
*
* Zed. The immensity of stars. The HyperShip. The people.
*
* (c) 2010, Dereckson, some rights reserved.
* Released under BSD license.
*
* @package Zed
* @subpackage Controllers
* @author Sテゥbastien Santoro aka Dereckson <dereckson@espace-win.org>
* @copyright 2010 Sテゥbastien Santoro aka Dereckson
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
* @version 0.1
* @link http://scherzo.dereckson.be/doc/zed
* @link http://zed.dereckson.be/
* @filesource
*/
require_once('includes/content/zone.php');
//
// Helper methods
//
/**
* Determines if a specified location is buildable
*
* @param GeoLocation $location the location to check
* @param string if the location isn't buidable, a textual description of why.
* @return bool true if the location is buildable ; otherwise, false
*
* @todo create a build.xml document to set what's buildable, and by who
*/
function is_buildable ($location, &$error = '') {
//We currently allow build only in the hypership tower and core.
if (!$location->body->hypership) {
$error = "You can only invoke the HyperShip builder facilities inside the HyperShip.";
return false;
}
//if ($build_location->place->code == "001") {
// //Don't allow custom builds in the corridor (T?C?)
//}
if ($build_location->place->code == "003") {
message_die("Bays aren't buildable.");
return false;
}
return true;
}
//
// Determines mode and initializes resources
//
switch ($build_mode = $url[1]) {
case 'map':
require_once('includes/geo/octocube.php');
$build_mode = 'map';
//Get zones at this floor
if ($CurrentPerso->location->global == 'B00001002') {
$point = GeoPoint3D::fromString($CurrentPerso->location->local);
- $sector = GeoOctocube::get_sector_from_point3D($point);
- $pattern = GeoOctocube::get_rlike_pattern_from_sector($sector, $point->z);
+ $sector = GeoOctocube::getSectorFromPoint3D($point);
+ $pattern = GeoOctocube::getRlikePatternFromSector($sector, $point->z);
$zones = ContentZone::search($CurrentPerso->location->global, $pattern, true);
} else {
message_die(GENERAL_ERROR, "Can't map this area.", "Builder :: Map");
}
//Template
define('DOJO', true);
$smarty->assign('zones', $zones);
$template = "builder_map.tpl";
break;
case '':
case 'hotglue':
//Temporary initialization code, to allow some build during the Zed alphatest
$build_location = $CurrentPerso->location;
$build_mode = 'hotglue';
$error = '';
if (!is_buildable($build_location, $error)) {
message_die(GENERAL_ERROR, $error, "Can't build");
}
//Gets or creates a new zone at build location
$zone = ContentZone::at($build_location->global, $build_location->local, true);
switch ($zone->type) {
case 'hotglue':
//All rulez
break;
case '':
//New zone
$zone->title = "Sandbox hotglue zone for $build_location->global $build_location->local";
$zone->type = 'hotglue';
$zone->save_to_database();
break;
default:
message_die("This isn't a zone managed by hotglue.");
}
unset($error);
//Template
$smarty->assign('location', $build_location);
$smarty->assign('zone', $zone);
$smarty->assign('IFRAME_SRC', '/apps/hotglue/index.php?zone_' . $zone->id . '/edit');
$template = 'builder_hotglue.tpl';
break;
default:
message_die(GENERAL_ERROR, "Unknown build mode: $build_mode");
}
//
// HTML output
//
//Serves header
$smarty->assign('PAGE_TITLE', 'Builder');
include('header.php');
//Serves content
$smarty->display($template);
//Serves footer
include('footer.php');
diff --git a/dev/tests/GeoOctocubeTest.php b/dev/tests/GeoOctocubeTest.php
index bc49440..db598db 100644
--- a/dev/tests/GeoOctocubeTest.php
+++ b/dev/tests/GeoOctocubeTest.php
@@ -1,43 +1,43 @@
<?php
/**
* Unit testing : class GeoOctocube
*
* Zed. The immensity of stars. The HyperShip. The people.
*
* (c) 2010, Dereckson, some rights reserved.
* Released under BSD license.
*
* @package Zed
* @subpackage Tests
* @author S饕astien Santoro aka Dereckson <dereckson@espace-win.org>
* @copyright 2010 S饕astien Santoro aka Dereckson
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version 0.1
* @link http://scherzo.dereckson.be/doc/zed
* @link http://zed.dereckson.be/
* @filesource
*/
require_once('../../includes/geo/octocube.php');
/**
* Test cases for the class GeoPlace
*/
class GeoOctocubeTest extends PHPUnit_Framework_TestCase {
/**
* Tests the GeoPlace::is_valid_local_location($local_location) method.
*/
public function testGetSector () {
//Testing HyperShip Tower T2C3 format
- $this->assertTrue(GeoOctocube::get_sector(0, 0, 0) == 0);
- $this->assertTrue(GeoOctocube::get_sector(-10, 6, -4) == 1);
- $this->assertTrue(GeoOctocube::get_sector(10, 6, -4) == 2);
- $this->assertTrue(GeoOctocube::get_sector(-10, -6, -4) == 3);
- $this->assertTrue(GeoOctocube::get_sector(10, -6, -4) == 4);
- $this->assertTrue(GeoOctocube::get_sector(-10, 6, 4) == 5);
- $this->assertTrue(GeoOctocube::get_sector(10, 6, 4) == 6);
- $this->assertTrue(GeoOctocube::get_sector(-10, -6, 4) == 7);
- $this->assertTrue(GeoOctocube::get_sector(10, -6, 4) == 8);
+ $this->assertTrue(GeoOctocube::getSector(0, 0, 0) == 0);
+ $this->assertTrue(GeoOctocube::getSector(-10, 6, -4) == 1);
+ $this->assertTrue(GeoOctocube::getSector(10, 6, -4) == 2);
+ $this->assertTrue(GeoOctocube::getSector(-10, -6, -4) == 3);
+ $this->assertTrue(GeoOctocube::getSector(10, -6, -4) == 4);
+ $this->assertTrue(GeoOctocube::getSector(-10, 6, 4) == 5);
+ $this->assertTrue(GeoOctocube::getSector(10, 6, 4) == 6);
+ $this->assertTrue(GeoOctocube::getSector(-10, -6, 4) == 7);
+ $this->assertTrue(GeoOctocube::getSector(10, -6, 4) == 8);
}
}
diff --git a/includes/geo/octocube.php b/includes/geo/octocube.php
index f038445..0ea74d9 100755
--- a/includes/geo/octocube.php
+++ b/includes/geo/octocube.php
@@ -1,141 +1,141 @@
<?php
/**
* Geo octocube class.
*
* Zed. The immensity of stars. The HyperShip. The people.
*
* (c) 2010, Dereckson, some rights reserved.
* Released under BSD license.
*
* @package Zed
* @subpackage Geo
* @author S饕astien Santoro aka Dereckson <dereckson@espace-win.org>
* @copyright 2010 S饕astien Santoro aka Dereckson
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version 0.1
* @link http://scherzo.dereckson.be/doc/zed
* @link http://zed.dereckson.be/
* @filesource
*/
/**
* Geo octocube class
*
* An octocube is a cube divided in 8 parts (sliced in two in x, y and z)
*
* The coordinates (0, 0, 0) represents the octocube center.
*/
class GeoOctocube {
/**
* Gets the sector from the (x, y, z) specified coordinates
*
* Sector will be:
* <code>
* // _____ _____
* // / 5 / 6 /|
* // /- - -/- - -/ |
* // /_____/____ /| |
* // | | | |/|
* // | 7 | 8 | / | 2
* // |_____|_____|/| |
* // | | | |/
* // | 3 | 4 | /
* // |_____|_____|/
* </code>
*
* @param int $x the x coordinate
* @param int $y the y coordinate
* @param int $z the z coordinate
* @return int the number of the sector (0 if x = y = z = 0 ; otherwise, 1 to 8)
*/
- static function get_sector ($x, $y, $z) {
+ static function getSector ($x, $y, $z) {
//Cube center
if ($x == 0 && $y == 0 && $z == 0) return 0;
//One of the 8 cubes
$sector = 1;
if ($x >= 0) $sector++; //we're at right
if ($y < 0) $sector += 2; //we're at bottom
if ($z >= 0) $sector += 4; //we're on the top layer
return $sector;
}
/**
* Gets the sector from the (x, y, z) specified coordinates
- * @see get_sector
+ * @see getSector
*
* @param mixed $pt a GeoPoint3D object for the x, y, z coordinates or a parsable string
* @return int the number of the sector (0 if x = y = z 0 ; otherwise, 1 to 8)
*/
- static function get_sector_from_point3D ($pt) {
+ static function getSectorFromPoint3D ($pt) {
if (is_string($pt)) {
$pt = GeoPoint3D::fromString($pt);
}
- return self::get_sector($pt->x, $pt->y, $pt->z);
+ return self::getSector($pt->x, $pt->y, $pt->z);
}
/**
* Gets the base vector for the specified sector
*
* Example code:
*
- * $vector = GeoOctocube::get_base_vector(4);
+ * $vector = GeoOctocube::getBaseVector(4);
* //$vector is a (1, -1, -1) array
*
* @param int $sector the sector number (0-8)
* @return array if the sector is 0, (0, 0, 0) ; otherwise, an array with three signed 1 values.
*/
- static function get_base_vector ($sector) {
+ static function getBaseVector ($sector) {
switch ($sector) {
case 0: return array(0, 0, 0);
case 1: return array(-1, 1, -1);
case 2: return array(1, 1, -1);
case 3: return array(-1, -1, -1);
case 4: return array(1, -1, -1);
case 5: return array(-1, 1, 1);
case 6: return array(1, 1, 1);
case 7: return array(-1, -1, 1);
case 8: return array(1, -1, 1);
- default: message_die(GENERAL_ERROR, "Invalid sector: $sector", "GeoOctocube::get_base_vector");
+ default: message_die(GENERAL_ERROR, "Invalid sector: $sector", "GeoOctocube::getBaseVector");
}
}
/**
* Gets SQL RLIKE pattern for the specified sector
*
* @param int $sector the sector number (0-8)
* @param int $z if not null, limits the query to the specified z coordinate [optional]
* @return string a SQL clause like "([0-9]+, -[0,9]+, [0,9]+)"
*/
- static function get_rlike_pattern_from_sector ($sector, $z = null) {
+ static function getRlikePatternFromSector ($sector, $z = null) {
if ($sector == 0) return "(0, 0, 0)";
- $vector = self::get_base_vector($sector);
+ $vector = self::getBaseVector($sector);
//x
if ($vector[0] == 1)
$query = "([0-9]+, ";
else
$query = "(-[0-9]+, ";
//y
if ($vector[1] == 1)
$query .= "[0-9]+, ";
else
$query .= "-[0-9]+, ";
//z
if ($z !== null) {
$query .= "$z)";
} elseif ($vector[2] == "1") {
$query .= "[0-9]+)";
} else {
$query .= "-[0-9]+)";
}
return $query;
}
}
diff --git a/skins/zed/builder_map.tpl b/skins/zed/builder_map.tpl
index 211e6f3..dbdba27 100644
--- a/skins/zed/builder_map.tpl
+++ b/skins/zed/builder_map.tpl
@@ -1,49 +1,49 @@
<div class="grid_7 alpha">
{$xyz = explode(',', substr($CurrentPerso->location_local, 1, -1))}
{$x = $xyz[0]}{$y = $xyz[1]}{$z = $xyz[2]}
- Sector C<span id="sector">{GeoOctocube::get_sector($x, $y, $z)}</span>
+ Sector C<span id="sector">{GeoOctocube::getSector($x, $y, $z)}</span>
</div>
<div class="grid_2" style="text-align: center;" id="info_area">
Zone <span id="area">{abs($x)}-{abs($y)}</span>
</div>
<div class="grid_7 omega" style="text-align: right; margin-bottom: 1em;">
Niveau <span id="level">{abs($z)}</span>
</div>
<div class="clear"></div>
<!-- Map -->
{if $zones}
<div id="map"></div>
<style>
.zone-build img {
opacity: 0.10;
}
</style>
<script type="text/javascript" src="/js/builder/map.js"></script>
<script>
var zones = [
{foreach from=$zones item=zone name=zones}
['{$zone->location_local}', {$zone->id}, '{$zone->type}', '{$zone->params}']{if !$smarty.foreach.zones.last},{/if}
{/foreach}
];
dojo.ready(function() {
map.init('map', zones);
});
</script>
<noscript>
<p>You've zones at:</p>
<ul>
{foreach from=$zones item=zone}
<li>{$zone->location_local}</li>
{/foreach}
</ul>
<p>A patch for a pure HTML renderer to print a map without javascript is welcome.</p>
</noscript>
{else}
<div class="grid_16 alpha omega">
<div class="notify">This area is empty.</div>
</div>
<div class="clear"></div>
{/if}

File Metadata

Mime Type
text/x-diff
Expires
Sat, Nov 23, 16:38 (1 d, 2 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
20921
Default Alt Text
(15 KB)

Event Timeline