Esempio n. 1
0
         $topLeft =& $player->getSector();
     }
     if (!$galaxy->contains($topLeft->getSectorID())) {
         $topLeft =& SmrSector::getSector($player->getGameID(), $galaxy->getStartSector());
     } else {
         $template->assign('FocusSector', $topLeft->getSectorID());
         //go left then up
         for ($i = 0; $i < floor($galaxy->getWidth() / 2); $i++) {
             $topLeft =& $topLeft->getNeighbourSector('Left');
         }
         for ($i = 0; $i < floor($galaxy->getHeight() / 2); $i++) {
             $topLeft =& $topLeft->getNeighbourSector('Up');
         }
     }
 } else {
     $topLeft =& SmrSector::getSector($player->getGameID(), $galaxy->getStartSector());
 }
 $mapSectors = array();
 $leftMostSec =& $topLeft;
 for ($i = 0; $i < $galaxy->getHeight(); $i++) {
     $mapSectors[$i] = array();
     //new row
     if ($i != 0) {
         $leftMostSec =& $leftMostSec->getNeighbourSector('Down');
     }
     //get left most sector for this row
     $thisSec =& $leftMostSec;
     //iterate through the columns
     for ($j = 0; $j < $galaxy->getWidth(); $j++) {
         //new sector
         if ($j != 0) {
Esempio n. 2
0
function getGoodDistanceOld(SmrSector &$sector, $goodID, $transaction)
{
    // if we buy a good we're looking for the nearest sector that sells that good
    if ($transaction == 'Buy') {
        $neg_transaction = 'Sell';
    } elseif ($transaction == 'Sell') {
        $neg_transaction = 'Buy';
    }
    // initialize the queue. all sectors we have to visit are in here
    $sector_queue = array();
    // keeps the distance to the start sector
    $sector_distance = array();
    // putting start sector in queue
    array_push($sector_queue, $sector->getSectorID());
    // it has a null distance
    $sector_distance[$sector->getSectorID()] = 0;
    $good_distance = 0;
    while (sizeof($sector_queue) > 0) {
        // get current sector and
        $curr_sector_id = array_shift($sector_queue);
        // get the distance for this sector from the start sector
        $distance = $sector_distance[$curr_sector_id];
        // create a new sector object
        $curr_sector =& SmrSector::getSector($sector->getGameID(), $curr_sector_id);
        // does the current sector buy/sell the good we're looking for?
        if ($good_distance != 0) {
            if ($curr_sector->hasPort() && $curr_sector->getPort()->hasGood($goodID, $neg_transaction) && $distance < $good_distance) {
                $good_distance = $distance;
            }
        } else {
            if ($curr_sector->hasPort() && $curr_sector->getPort()->hasGood($goodID, $neg_transaction)) {
                $good_distance = $distance;
            }
        }
        // if we already found a port that buy or sell our product we don't need
        // to go further than this one.
        if ($good_distance != 0 && $good_distance <= $distance) {
            continue;
        }
        // enqueue all neighbours
        if ($curr_sector->getLinkUp() > 0 && (!isset($sector_distance[$curr_sector->getLinkUp()]) || $sector_distance[$curr_sector->getLinkUp()] > $distance + 1)) {
            array_push($sector_queue, $curr_sector->getLinkUp());
            $sector_distance[$curr_sector->getLinkUp()] = $distance + 1;
        }
        if ($curr_sector->getLinkDown() > 0 && (!isset($sector_distance[$curr_sector->getLinkDown()]) || $sector_distance[$curr_sector->getLinkDown()] > $distance + 1)) {
            array_push($sector_queue, $curr_sector->getLinkDown());
            $sector_distance[$curr_sector->getLinkDown()] = $distance + 1;
        }
        if ($curr_sector->getLinkLeft() > 0 && (!isset($sector_distance[$curr_sector->getLinkLeft()]) || $sector_distance[$curr_sector->getLinkLeft()] > $distance + 1)) {
            array_push($sector_queue, $curr_sector->getLinkLeft());
            $sector_distance[$curr_sector->getLinkLeft()] = $distance + 1;
        }
        if ($curr_sector->getLinkRight() > 0 && (!isset($sector_distance[$curr_sector->getLinkRight()]) || $sector_distance[$curr_sector->getLinkRight()] > $distance + 1)) {
            array_push($sector_queue, $curr_sector->getLinkRight());
            $sector_distance[$curr_sector->getLinkRight()] = $distance + 1;
        }
        if ($curr_sector->getWarp() > 0 && (!isset($sector_distance[$curr_sector->getWarp()]) || $sector_distance[$curr_sector->getWarp()] > $distance + 5)) {
            array_push($sector_queue, $curr_sector->getWarp());
            $sector_distance[$curr_sector->getWarp()] = $distance + 5;
        }
    }
    $container['good_distance'] = $good_distance;
    return $good_distance;
}
<?php

$sector =& SmrSector::getSector($var['game_id'], $var['sector_id']);
$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 .= '<table class="create"><tr><td class="center';
if (!$sector->hasLinkUp()) {
    $PHP_OUTPUT .= ' border_top';
}
if (!$sector->hasLinkDown()) {
    $PHP_OUTPUT .= ' border_bottom';
}
if (!$sector->hasLinkLeft()) {
    $PHP_OUTPUT .= ' border_left';
}
if (!$sector->hasLinkRight()) {
    $PHP_OUTPUT .= ' border_right';
}
$PHP_OUTPUT .= '"><table><tr><td width="5%">&nbsp;</td><td width="90%" class="center"><input type="checkbox" name="up" value="up"';
if ($sector->hasLinkUp()) {
    $PHP_OUTPUT .= ' checked';
}
$PHP_OUTPUT .= '></td><td width="5%">&nbsp;</td></tr>';
$PHP_OUTPUT .= '<tr><td width="5%" class="center"><input type="checkbox" name="left" value="left"';
if ($sector->hasLinkLeft()) {
    $PHP_OUTPUT .= ' checked';
}
$PHP_OUTPUT .= '></td><td width="90%" class="center">';
$PHP_OUTPUT .= 'Sector: ' . $sector->getSectorID() . '<br /><br />';
Esempio n. 4
0
<?php

$sector =& $player->getSector();
if (!$sector->isLinked($var['target_sector']) && $sector->getSectorID() != $var['target_sector']) {
    create_error('You cannot scan a sector you are not linked to.');
}
// initialize vars
$scanSector =& SmrSector::getSector($player->getGameID(), $var['target_sector']);
$template->assign('PageTopic', 'Sector Scan of #' . $scanSector->getSectorID() . ' (' . $scanSector->getGalaxyName() . ')');
$friendly_forces = 0;
$enemy_forces = 0;
$friendly_vessel = 0;
$enemy_vessel = 0;
// iterate over all forces in the target sector
$scanSectorAllForces =& $scanSector->getForces();
foreach ($scanSectorAllForces as &$scanSectorForces) {
    // decide if it's a friendly or enemy stack
    if ($player->sameAlliance($scanSectorForces->getOwner())) {
        $friendly_forces += $scanSectorForces->getMines() * 3 + $scanSectorForces->getCDs() * 2 + $scanSectorForces->getSDs();
    } else {
        $enemy_forces += $scanSectorForces->getMines() * 3 + $scanSectorForces->getCDs() * 2 + $scanSectorForces->getSDs();
    }
}
unset($scanSectorForces);
$scanSectorPlayers =& $scanSector->getOtherTraders($player);
foreach ($scanSectorPlayers as &$scanSectorPlayer) {
    $scanSectorShip =& $scanSectorPlayer->getShip();
    // he's a friend if he's in our alliance (and we are not in a 0 alliance
    if ($player->traderMAPAlliance($scanSectorPlayer)) {
        $friendly_vessel += $scanSectorShip->getAttackRating();
    } else {
    create_error('Hmmmm...if ' . $player->getSectorID() . '=' . $target . ' then that means...YOU\'RE ALREADY THERE! *cough*you\'re real smart*cough*');
}
if ($sector->hasForces()) {
    $sectorForces =& $sector->getForces();
    foreach ($sectorForces as &$forces) {
        if ($forces->hasMines() && !$player->forceNAPAlliance($forces->getOwner())) {
            create_error('You cant jump when there are unfriendly forces in the sector!');
        }
    }
    unset($forces);
}
if (!SmrGalaxy::getGalaxyContaining($player->getGameID(), $target)) {
    create_error('The target sector doesn\'t exist!');
}
// create sector object for target sector
$targetSector =& SmrSector::getSector($player->getGameID(), $target);
require_once get_file_loc('Plotter.class.inc');
$path =& Plotter::findDistanceToX($targetSector, $player->getSector(), true);
if ($path === false) {
    create_error('Unable to plot from ' . $start . ' to ' . $target . '.');
}
// send scout msg
$sector->leavingSector($player, MOVEMENT_JUMP);
// Move the user around
// TODO: (Must be done while holding both sector locks)
$distance = $path->getRelativeDistance();
$turnsToJump = max(TURNS_JUMP_MINIMUM, round($distance * TURNS_PER_JUMP_DISTANCE));
// check for turns
if ($player->getTurns() < $turnsToJump) {
    create_error('You don\'t have enough turns for that jump!');
}
Esempio n. 6
0
$container['max_rank'] = $max_rank;
$PHP_OUTPUT .= create_echo_form($container);
$PHP_OUTPUT .= '<p><input type="number" name="min_rank" value="' . $min_rank . '" size="3" id="InputFields" class="center">&nbsp;-&nbsp;<input type="number" name="max_rank" value="' . $max_rank . '" size="3" id="InputFields" class="center">&nbsp;';
$PHP_OUTPUT .= create_submit('Show');
$PHP_OUTPUT .= '</p></form>';
$PHP_OUTPUT .= '<table class="standard" width="95%">';
$PHP_OUTPUT .= '<tr>';
$PHP_OUTPUT .= '<th>Rank</th>';
$PHP_OUTPUT .= '<th>Sector</th>';
$PHP_OUTPUT .= '<th>Battles</th>';
$PHP_OUTPUT .= '</tr>';
$db->query('SELECT * FROM sector WHERE game_id = ' . $db->escapeNumber($player->getGameID()) . ' ORDER BY battles DESC, sector_id LIMIT ' . ($min_rank - 1) . ', ' . ($max_rank - $min_rank + 1));
$rank = $min_rank - 1;
while ($db->nextRecord()) {
    // get current player
    $curr_sector =& SmrSector::getSector($player->getGameID(), $db->getField('sector_id'));
    // increase rank counter
    $rank++;
    $PHP_OUTPUT .= '<tr>';
    $PHP_OUTPUT .= '<td valign="top" class="center';
    if ($player->getSectorID() == $curr_sector->getSectorID()) {
        $PHP_OUTPUT .= ' bold';
    }
    $PHP_OUTPUT .= '">' . $rank . '</td>';
    $PHP_OUTPUT .= '<td valign="top" class="center';
    if ($player->getSectorID() == $curr_sector->getSectorID()) {
        $PHP_OUTPUT .= ' bold';
    }
    $PHP_OUTPUT .= '">' . $curr_sector->getSectorID() . '</td>';
    $PHP_OUTPUT .= '<td valign="top" class="center';
    if ($player->getSectorID() == $curr_sector->getSectorID()) {
<?php

require_once get_file_loc('SmrSector.class.inc');
$sector =& SmrSector::getSector(SmrSession::$game_id, $player->getSectorID(), SmrSession::$account_id);
require_once get_file_loc('smr_force.inc');
if ($player->getNewbieTurns() > 0) {
    create_error('You are under newbie protection!');
}
//turns are taken b4 player fires.
$forces = new SMR_FORCE($owner_id, $player->getSectorID(), $player->getGameID());
if ($forces->mines == 0) {
    create_error('No mines in sector! You should never be see this! Why are you looking at this! STOP! NOW! GO AWAY! PLEASE!!! STOP READING THIS NOW!!! PLEASE!!!');
}
// delete plotted course
$player->deletePlottedCourse();
// send message if scouts are present
if ($forces->scout_drones > 0) {
    $message = 'Your forces in sector ' . $forces->sector_id . ' are being attacked by ' . $player->getPlayerName();
    $player->sendMessage($forces->owner_id, $SCOUTMSG, $db->escape_string($message, false));
    //insert into ticker
    $db->query('SELECT * FROM player_has_ticker WHERE account_id = ' . $owner_id . ' AND game_id = ' . $player->getGameID() . ' AND type = \'scout\'');
    if ($db->next_record()) {
        $db->query('SELECT * FROM player_has_ticker WHERE account_id = ' . $player->getAccountID() . ' AND type = \'block\'');
        if (!$db->next_record()) {
            $db->query('UPDATE player_has_ticker SET recent = ' . $db->escape_string($message, false) . ', time = ' . TIME . ' WHERE account_id = ' . $owner_id . ' AND game_id = ' . $player->getGameID());
        }
    }
}
$force_msg = array();
$container = array();
$container['url'] = 'skeleton.php';
<?php

require_once get_file_loc('SmrGalaxy.class.inc');
if (!isset($var['game_id'])) {
    SmrSession::updateVar('game_id', $_REQUEST['game_id']);
}
if (!isset($var['gal_on'])) {
    SmrSession::updateVar('gal_on', 1);
}
//generate sector array
$galaxy =& SmrGalaxy::getGalaxy($var['game_id'], $var['gal_on']);
$galaxies =& SmrGalaxy::getGameGalaxies($var['game_id']);
$topLeft =& SmrSector::getSector($var['game_id'], $galaxy->getStartSector());
$mapSectors = array();
$leftMostSec =& $topLeft;
for ($i = 0; $i < $galaxy->getHeight(); $i++) {
    $mapSectors[$i] = array();
    //new row
    if ($i != 0) {
        $leftMostSec =& $leftMostSec->getNeighbourSector('Down');
    }
    //get left most sector for this row
    $thisSec =& $leftMostSec;
    //iterate through the columns
    for ($j = 0; $j < $galaxy->getWidth(); $j++) {
        //new sector
        if ($j != 0) {
            $thisSec =& $thisSec->getNeighbourSector('Right');
        }
        $mapSectors[$i][$j] =& $thisSec;
    }
Esempio n. 9
0
$PHP_OUTPUT .= '</td><td style="padding:0px;vertical-align:top;width:32em">';
// get the array back
$full = implode(' - ', $path->getPath());
// throw start sector away
// it's useless for the route
$path->removeStart();
// now get the sector we are going to but don't remove it (sector_move_processing does it)
$next_sector = $path->getNextOnPath();
if ($sector->isLinked($next_sector)) {
    // save this to db (if we still have something
    if ($path->getTotalSectors() > 0) {
        $player->setPlottedCourse($path);
    }
    //$PHP_OUTPUT.=create_echo_form($container);
    if (!$player->isLandedOnPlanet()) {
        $nextSector =& SmrSector::getSector($player->getGameID(), $path->getNextOnPath(), $player->getAccountID());
        $PHP_OUTPUT .= '<table class="nobord" width="100%">
			<tr>
				<td class="top right">
					<div class="buttonA">
						<a class="buttonA" href="' . $nextSector->getCurrentSectorHREF() . '">&nbsp; Follow Course (' . $path->getNextOnPath() . ') &nbsp;</a>
					</div>
				</td>
			</tr>';
        if ($ship->hasScanner()) {
            $PHP_OUTPUT .= '<tr>
				<td class="top right">
					<div class="buttonA">
						<a class="buttonA" href="' . $nextSector->getScanSectorHREF() . '">&nbsp; Scan Course (' . $path->getNextOnPath() . ') &nbsp;</a>
					</div>
				</td>
Esempio n. 10
0
foreach ($galaxies as &$galaxy) {
    if ($galaxy->contains($start)) {
        $startExists = true;
    }
    if ($galaxy->contains($target)) {
        $targetExists = true;
    }
}
unset($galaxy);
if ($startExists === false || $targetExists === false) {
    create_error('The sectors have to exist!');
}
$account->log(LOG_TYPE_MOVEMENT, 'Player plots to ' . $target . '.', $player->getSectorID());
$container = array();
$container['url'] = 'skeleton.php';
$container['body'] = 'course_plot_result.php';
require_once get_file_loc('Plotter.class.inc');
$path =& Plotter::findDistanceToX(SmrSector::getSector($player->getGameID(), max($target, $start)), SmrSector::getSector($player->getGameID(), min($target, $start)), true);
if ($path === false) {
    create_error('Unable to plot from ' . $start . ' to ' . $target . '.');
}
if ($start > $target) {
    //We always plot lowest to highest, so reverse if need be.
    $path->reversePath();
}
$container['Distance'] = serialize($path);
$path->removeStart();
if ($sector->isLinked($path->getNextOnPath()) && $path->getTotalSectors() > 0) {
    $player->setPlottedCourse($path);
}
forward($container);
                }
            }
            $sector->removeAllLocations();
            foreach ($locationsToKeep as &$locationToAdd) {
                $sector->addLocation($locationToAdd);
            }
            foreach ($locationsToAdd as &$locationToAdd) {
                addLocationToSector($locationToAdd, $sector);
            }
            if ($sector->hasWarp() && $sector->getWarp() != $_POST['warp']) {
                $sector->getWarpSector()->removeWarp();
                $sector->removeWarp();
            }
            if ($_POST['warp'] > 0) {
                //add warp to other side
                $sector->setWarp(SmrSector::getSector($var['game_id'], $_POST['warp']));
            }
            $var['message'] = '<span class="green">Success</span> : Succesfully edited sector.';
            SmrSector::saveSectors();
        }
    }
}
$container = $var;
$container['url'] = 'skeleton.php';
forward($container);
function checkSectorAllowedForLoc(SmrSector &$sector, SmrLocation &$location)
{
    if (!$location->isHQ()) {
        return sizeof($sector->getLocations()) < 4 && !$sector->offersFederalProtection();
    } else {
        //HQs are here