diff --git a/admin/Default/1.6/universe_create_save_processing.php b/admin/Default/1.6/universe_create_save_processing.php index 73cd53bd6..d9b4a6974 100644 --- a/admin/Default/1.6/universe_create_save_processing.php +++ b/admin/Default/1.6/universe_create_save_processing.php @@ -147,16 +147,25 @@ foreach ($galaxies as &$eachGalaxy) { //do we have a warp to this gal? if (isset($_POST['warp' . $eachGalaxy->getGalaxyID()])) { + // Sanity check the number + $numWarps = $_POST['warp' . $eachGalaxy->getGalaxyID()]; + if ($numWarps > 10) { + create_error('Specify no more than 10 warps between two galaxies!'); + } //iterate for each warp to this gal - for ($i=1;$i<=$_POST['warp' . $eachGalaxy->getGalaxyID()];$i++) { + for ($i=1; $i<=$numWarps; $i++) { $galSector =& $galSectors[array_rand($galSectors)]; //only 1 warp per sector - while($galSector->hasWarp()) $galSector =& $galSectors[array_rand($galSectors)]; + while ($galSector->hasWarp() || $galSector->offersFederalProtection()) { + $galSector =& $galSectors[array_rand($galSectors)]; + } //get other side $otherSectors =& $eachGalaxy->getSectors(); $otherSector =& $otherSectors[array_rand($otherSectors)]; //make sure it does not go to itself - while($otherSector->hasWarp() || $otherSector->equals($galSector)) $otherSector =& $otherSectors[array_rand($otherSectors)]; + while ($otherSector->hasWarp() || $otherSector->offersFederalProtection() || $otherSector->equals($galSector)) { + $otherSector =& $otherSectors[array_rand($otherSectors)]; + } $galSector->setWarp($otherSector); } } diff --git a/admin/Default/1.6/universe_create_warps.php b/admin/Default/1.6/universe_create_warps.php index e6ad50a81..769803534 100644 --- a/admin/Default/1.6/universe_create_warps.php +++ b/admin/Default/1.6/universe_create_warps.php @@ -1,45 +1,61 @@ assign('Message', $var['message']); + SmrSession::updateVar('message', null); // Only show message once +} $galaxies =& SmrGalaxy::getGameGalaxies($var['game_id']); $galaxy =& SmrGalaxy::getGalaxy($var['game_id'],$var['gal_on']); $galSectors =& $galaxy->getSectors(); + +$template->assign('PageTopic', 'Warps for Galaxy : '.$galaxy->getName().' ('.$galaxy->getGalaxyID().')'); + + +// Initialize warps array +$warps = array(); +foreach ($galaxies as $gal1) { + $warps[$gal1->getGalaxyID()] = array(); + foreach ($galaxies as $gal2) { + $warps[$gal1->getGalaxyID()][$gal2->getGalaxyID()] = 0; + } +} + //get totals -foreach ($galSectors as &$galSector) { - if($galSector->hasWarp()) { - $otherGalaxyID = $galSector->getWarpSector()->getGalaxyID(); - if($otherGalaxyID==$galaxy->getGalaxyID()) - $warps[$otherGalaxyID]+=0.5; - else - $warps[$otherGalaxyID]++; +$db->query('SELECT * FROM warp WHERE game_id='.$db->escapeNumber($var['game_id'])); +while ($db->nextRecord()) { + $warp1 = SmrSector::getSector($db->getInt('game_id'), $db->getInt('sector_id_1')); + $warp2 = SmrSector::getSector($db->getInt('game_id'), $db->getInt('sector_id_2')); + if ($warp1->getGalaxyID() == $warp2->getGalaxyID()) { + $warps[$warp1->getGalaxyID()][$warp2->getGalaxyID()]++; + } else { + $warps[$warp1->getGalaxyID()][$warp2->getGalaxyID()]++; + $warps[$warp2->getGalaxyID()][$warp1->getGalaxyID()]++; } } -//universe_create_warps.php +// Get links to other pages +$container = create_container('skeleton.php', '1.6/universe_create_warps.php'); +$container['game_id'] = $var['game_id']; +$galLinks = array(); +foreach ($galaxies as $gal) { + $container['gal_on'] = $gal->getGalaxyID(); + $galLinks[$gal->getGalaxyID()] = SmrSession::getNewHREF($container); +} +$template->assign('GalLinks', $galLinks); + $container = $var; $container['url'] = '1.6/universe_create_save_processing.php'; -$container['body'] = '1.6/universe_create_sectors.php'; -$PHP_OUTPUT.= create_echo_form($container); -$PHP_OUTPUT.= 'Working on Galaxy : ' . $galaxy->getName() . ' (' . $galaxy->getGalaxyID() . ')
'; -$PHP_OUTPUT.= ''; -foreach ($galaxies as &$eachGalaxy) { - $PHP_OUTPUT.= ''; -} -$PHP_OUTPUT.= '
' . $eachGalaxy->getName() . ''; - $PHP_OUTPUT.= '
'; +$container['body'] = '1.6/universe_create_warps.php'; +$template->assign('SubmitHREF', SmrSession::getNewHREF($container)); + $container = $var; $container['body'] = '1.6/universe_create_sectors.php'; -$PHP_OUTPUT.= '

Cancel'; -$PHP_OUTPUT.= '
'; +$template->assign('CancelHREF', SmrSession::getNewHREF($container)); -$PHP_OUTPUT.= 'Note: When you press "Create Warps" this will rearrange all current warps.
'; -$PHP_OUTPUT.= 'To add new warps without rearranging everything use the edit sector feature.'; -$PHP_OUTPUT.= 'Keep in mind this removes both sides of the warp, so 2 gals are changed for each warp.
'; +$template->assign('Galaxy', $galaxy); +$template->assign('Galaxies', $galaxies); +$template->assign('Warps', $warps); -?> \ No newline at end of file +?> diff --git a/templates/Default/admin/Default/1.6/universe_create_warps.php b/templates/Default/admin/Default/1.6/universe_create_warps.php new file mode 100644 index 000000000..2a5bfd8a7 --- /dev/null +++ b/templates/Default/admin/Default/1.6/universe_create_warps.php @@ -0,0 +1,81 @@ +

+ + + + + + + +
+
+ + + + + + + + + + + + +
GalaxyNumber of Warps
getName(); ?>
+ +

+ << Back to Map +
+
+
+
+ Warps will be placed randomly in the galaxies, with these exceptions: +
    +
  • Only one warp per sector
  • +
  • No warps in sectors with Federal Beacons
  • +
+ Note: When you press "Create Warps" this will rearrange all current warps. + To add new warps without rearranging everything use the edit sector feature. + Keep in mind this removes both sides of the warp, so 2 galaxies are changed for each warp. +
+
+
+ + + +

Warp Summary

+

Click on a galaxy name to edit warps for that galaxy.

+ + + + + + + + getGalaxyID()][$galCol->getGalaxyID()]; + $display = $count == 0 ? '' : $count; ?> + + + +
+

+ getName(); ?> +

+

Total

getName(); ?>getGalaxyID()]); ?>