<?php require_once get_file_loc('menu.inc'); if (!isset($var['race_id'])) { SmrSession::updateVar('race_id', $player->getRaceID()); } $raceID = $var['race_id']; $template->assign('PageTopic', 'Ruling Council Of ' . Globals::getRaceName($raceID)); // echo menu create_council_menu($raceID); $RACES =& Globals::getRaces(); $raceRelations =& Globals::getRaceRelations($player->getGameID(), $raceID); $peaceRaces = array(); $neutralRaces = array(); $warRaces = array(); foreach ($RACES as $otherRaceID => $raceInfo) { if ($otherRaceID != RACE_NEUTRAL && $raceID != $otherRaceID) { if ($raceRelations[$otherRaceID] >= 300) { $peaceRaces[$otherRaceID] = $raceInfo; } else { if ($raceRelations[$otherRaceID] <= -300) { $warRaces[$otherRaceID] = $raceInfo; } else { $neutralRaces[$otherRaceID] = $raceInfo; } } } } $template->assignByRef('PeaceRaces', $peaceRaces); $template->assignByRef('NeutralRaces', $neutralRaces); $template->assignByRef('WarRaces', $warRaces);
function &findRoutes(&$player) { debug('Finding Routes'); $galaxies =& SmrGalaxy::getGameGalaxies($player->getGameID()); $tradeGoods = array(GOOD_NOTHING => false); $goods =& Globals::getGoods(); foreach ($goods as $goodID => &$good) { if ($player->meetsAlignmentRestriction($good['AlignRestriction'])) { $tradeGoods[$goodID] = true; } else { $tradeGoods[$goodID] = false; } } unset($good); $tradeRaces = array(); $races =& Globals::getRaces(); foreach ($races as $raceID => &$race) { $tradeRaces[$raceID] = false; } unset($race); $tradeRaces[$player->getRaceID()] = true; $galaxy =& $player->getSector()->getGalaxy(); $maxNumberOfPorts = 2; $routesForPort = -1; $numberOfRoutes = 1000; $maxDistance = 15; $startSectorID = $galaxy->getStartSector(); $endSectorID = $galaxy->getEndSector(); $db = new SmrMySqlDatabase(); $db->query('SELECT routes FROM route_cache WHERE game_id=' . $db->escapeNumber($player->getGameID()) . ' AND max_ports=' . $db->escapeNumber($maxNumberOfPorts) . ' AND goods_allowed=' . $db->escapeObject($tradeGoods) . ' AND races_allowed=' . $db->escapeObject($tradeRaces) . ' AND start_sector_id=' . $db->escapeNumber($startSectorID) . ' AND end_sector_id=' . $db->escapeNumber($endSectorID) . ' AND routes_for_port=' . $db->escapeNumber($routesForPort) . ' AND max_distance=' . $db->escapeNumber($maxDistance)); if ($db->nextRecord()) { $routes = unserialize(gzuncompress($db->getField('routes'))); debug('Using Cached Routes: #' . count($routes)); return $routes; } else { debug('Generating Routes'); $allSectors = array(); foreach ($galaxies as &$galaxy) { $allSectors += $galaxy->getSectors(); //Merge arrays } unset($galaxy); $distances =& Plotter::calculatePortToPortDistances($allSectors, $maxDistance, $startSectorID, $endSectorID); if ($maxNumberOfPorts == 1) { $allRoutes = RouteGenerator::generateOneWayRoutes($allSectors, $distances, $tradeGoods, $tradeRaces, $routesForPort); } else { $allRoutes = RouteGenerator::generateMultiPortRoutes($maxNumberOfPorts, $allSectors, $tradeGoods, $tradeRaces, $distances, $routesForPort, $numberOfRoutes); } unset($distances); $allRoutes =& $allRoutes[RouteGenerator::EXP_ROUTE]; $routesMerged = array(); foreach ($allRoutes as $multi => &$routesByMulti) { $routesMerged += $routesByMulti; //Merge arrays } unset($routesByMulti); unset($allSectors); SmrPort::clearCache(); SmrSector::clearCache(); $db->query('INSERT INTO route_cache ' . '(game_id, max_ports, goods_allowed, races_allowed, start_sector_id, end_sector_id, routes_for_port, max_distance, routes)' . ' VALUES (' . $db->escapeNumber($player->getGameID()) . ', ' . $db->escapeNumber($maxNumberOfPorts) . ', ' . $db->escapeObject($tradeGoods) . ', ' . $db->escapeObject($tradeRaces) . ', ' . $db->escapeNumber($startSectorID) . ', ' . $db->escapeNumber($endSectorID) . ', ' . $db->escapeNumber($routesForPort) . ', ' . $db->escapeNumber($maxDistance) . ', ' . $db->escapeObject($routesMerged, true) . ')'); debug('Found Routes: #' . count($routesMerged)); return $routesMerged; } }
$PHP_OUTPUT .= 'Working on Galaxy : ' . $galaxy->getName() . ' (' . $galaxy->getGalaxyID() . ')<br />'; $PHP_OUTPUT .= '<table width="100%"><tr><th>Ports</th><th>Port Races</th><th>Starting Mines</th></tr><tr><td class="center">'; $PHP_OUTPUT .= '<table class="standard">'; for ($i = 1; $i <= 9; $i++) { $PHP_OUTPUT .= '<tr><td class="right">Level ' . $i . ' Ports</td><td>'; $PHP_OUTPUT .= '<input type="number" value="'; $PHP_OUTPUT .= $totalPorts[$i]; $PHP_OUTPUT .= '" size="5" name="port' . $i . '" onFocus="startCalc();" onBlur="stopCalc();"></td></tr>'; } $PHP_OUTPUT .= '<tr><td type="number" class="right">Total Ports</td><td><input type="number" size="5" name="total" value="'; $PHP_OUTPUT .= $total['Ports']; $PHP_OUTPUT .= '"></td></tr>'; $PHP_OUTPUT .= '</table>'; $PHP_OUTPUT .= '</td><td class="center">'; $PHP_OUTPUT .= '<table class="standard"><tr><th colspan="2">Port Race % Distribution</th></tr>'; $races =& Globals::getRaces(); foreach ($races as &$race) { $PHP_OUTPUT .= '<tr><td class="right">' . $race['Race Name'] . '</td><td><input type="number" size="5" name="race' . $race['Race ID'] . '" value="0" onFocus="startRaceCalc();" onBlur="stopRaceCalc();"></td></tr>'; } $PHP_OUTPUT .= '<tr><td class="right">Total</td><td><input type="number" size="5" name="racedist" value="0"></td></tr>'; $PHP_OUTPUT .= '<tr><td class="center" colspan="2">'; $PHP_OUTPUT .= '<div class="buttonA"><a class="buttonA" onClick="setEven();"> Set All Equal </a></div></td></tr>'; $PHP_OUTPUT .= '</table>'; $PHP_OUTPUT .= '</td><td class="center"><table class="standard">'; for ($i = 1; $i <= 20; $i++) { $PHP_OUTPUT .= '<tr><td class="right">Level ' . $i . ' Mines</td><td>'; $PHP_OUTPUT .= '<input type="number" value="'; $PHP_OUTPUT .= $totalMines[$i]; $PHP_OUTPUT .= '" size="5" name="mine' . $i . '" onFocus="startCalcM();" onBlur="stopCalcM();"></td></tr>'; } $PHP_OUTPUT .= '<tr><td class="right">Total Mines</td><td><input type="number" size="5" name="totalM" value="';
// do we have enough if ($account->getTotalSmrCredits() < $game['GameCreditsRequired']) { create_error('Sorry you do not have enough SMR Credits to play this game.<br />To get SMR credits you need to donate to SMR.'); } } // is the game already full? if (SmrGame::getGame($var['game_id'])->getTotalPlayers() >= $game['GameMaxPlayers']) { create_error('The maximum number of players in that game is reached!'); } //if (TIME < $game['StartDate']) // create_error('You want to join a game that hasn\'t started yet?'); if (TIME > $game['EndDate']) { create_error('You want to join a game that is already over?'); } $template->assign('PageTopic', 'Join Game'); $raceInfo =& Globals::getRaces(); $raceDescriptions = ''; $first = true; foreach ($raceInfo as $race) { if ($first) { $raceDescriptions .= '\'' . str_replace('\'', '\\\'"', $race['Description']) . '\''; $first = false; } else { $raceDescriptions .= ', \'' . str_replace('\'', '\\\'', $race['Description']) . '\''; } } $template->assign('RaceDescriptions', $raceDescriptions); // create a container that will hold next url and additional variables. $container = array(); $container['game_id'] = $var['game_id']; $container['url'] = 'game_join_processing.php';