예제 #1
0
<?php 
    echo "  <tr height=\"20\">\n";
    echo "     <td class=\"c\"><span class=\"error\"> Флот не удалось отправить!</span></td>\n";
    echo "  </tr>\n";
    echo "{$FleetErrorText}\n";
} else {
    // Fleet lock
    $fleetlock = "temp/fleetlock_" . $aktplanet['planet_id'];
    if (file_exists($fleetlock)) {
        MyGoto("flotten1");
    }
    $f = fopen($fleetlock, 'w');
    fclose($f);
    $fleet_id = DispatchFleet($fleet, $origin, $target, $order, $flighttime, $cargo_m, $cargo_k, $cargo_d, $cons['fleet'] + $cons['probes'], time(), $union_id, $hold_time);
    $queue = GetFleetQueue($fleet_id);
    UserLog($aktplanet['owner_id'], "FLEET", "Отправка флота {$fleet_id}: " . GetMissionNameDebug($order) . " " . $origin['name'] . " [" . $origin['g'] . ":" . $origin['s'] . ":" . $origin['p'] . "] -&gt; " . $target['name'] . " [" . $target['g'] . ":" . $target['s'] . ":" . $target['p'] . "]<br>" . DumpFleet($fleet) . "<br>" . "Время полёта: " . BuildDurationFormat($flighttime) . ", удержание: " . BuildDurationFormat($hold_time) . ", затраты дейтерия: " . nicenum($cons['fleet'] + $cons['probes']) . ", союз: " . $union_id);
    if ($union_id) {
        $union_time = UpdateUnionTime($union_id, $queue['end'], $fleet_id);
        UpdateFleetTime($fleet_id, $union_time);
    }
    // Поднять флот с планеты.
    AdjustResources($cargo_m, $cargo_k, $cargo_d + $cons['fleet'] + $cons['probes'], $origin['planet_id'], '-');
    AdjustShips($fleet, $origin['planet_id'], '-');
    unlink($fleetlock);
    //    echo "<br>";
    //    print_r ( $queue);
    PageHeader("flottenversand", false, true, "flotten1", 1);
    ?>

<!-- CONTENT AREA -->
<div id='content'>
예제 #2
0
function RecallFleet($fleet_id, $now = 0)
{
    $uni = LoadUniverse();
    if ($uni['freeze']) {
        return;
    }
    if ($now == 0) {
        $now = time();
    }
    $fleet_obj = LoadFleet($fleet_id);
    $fleetmap = array(202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215);
    $fleet = array();
    foreach ($fleetmap as $i => $gid) {
        $fleet[$gid] = $fleet_obj["ship{$gid}"];
    }
    // Если флот уже развернут, ничего не делать
    if ($fleet_obj['mission'] >= 100 && $fleet_obj['mission'] < 200) {
        return;
    }
    $origin = GetPlanet($fleet_obj['start_planet']);
    $target = GetPlanet($fleet_obj['target_planet']);
    $queue = GetFleetQueue($fleet_obj['fleet_id']);
    if ($fleet_obj['mission'] < 100) {
        $new_mission = $fleet_obj['mission'] + 100;
    } else {
        $new_mission = $fleet_obj['mission'] - 100;
    }
    UserLog($fleet_obj['owner_id'], "FLEET", "Отзыв флота " . $fleet_obj['fleet_id'] . ": " . GetMissionNameDebug($new_mission) . " " . $origin['name'] . " [" . $origin['g'] . ":" . $origin['s'] . ":" . $origin['p'] . "] &lt;- " . $target['name'] . " [" . $target['g'] . ":" . $target['s'] . ":" . $target['p'] . "]<br>" . DumpFleet($fleet));
    // Для отзыва миссий с удержанием в качестве времени обратного полёта используется время удержания.
    if ($fleet_obj['mission'] < 100) {
        DispatchFleet($fleet, $origin, $target, $fleet_obj['mission'] + 100, $now - $queue['start'], $fleet_obj['m'], $fleet_obj['k'], $fleet_obj['d'], $fleet_obj['fuel'] / 2, $now);
    } else {
        DispatchFleet($fleet, $origin, $target, $fleet_obj['mission'] - 100, $fleet_obj['deploy_time'], $fleet_obj['m'], $fleet_obj['k'], $fleet_obj['d'], $fleet_obj['fuel'] / 2, $now);
    }
    DeleteFleet($fleet_obj['fleet_id']);
    // удалить флот
    RemoveQueue($queue['task_id']);
    // удалить задание
    // Если отозван последний флот союза, то удалить союз.
    $union_id = $fleet_obj['union_id'];
    if ($union_id && ($fleet_obj['mission'] == 2 || $fleet_obj['mission'] == 21)) {
        $result = EnumUnionFleets($union_id);
        if (dbrows($result) == 0) {
            RemoveUnion($union_id);
        }
        // удалить союз
    }
}
}
// Рассчитать расстояние, время полёта и затраты дейтерия.
$dist = FlightDistance($aktplanet['g'], $aktplanet['s'], $aktplanet['p'], $galaxy, $system, $planet);
$slowest_speed = FlightSpeed($fleet, $GlobalUser['r115'], $GlobalUser['r117'], $GlobalUser['r118']);
$flighttime = FlightTime($dist, $slowest_speed, $speed, $unispeed);
$arr = FlightCons($fleet, $dist, $flighttime, $GlobalUser['r115'], $GlobalUser['r117'], $GlobalUser['r118'], $unispeed);
$cons = $arr['fleet'] + $arr['probes'];
if ($aktplanet['d'] < $cons) {
    AjaxSendError(613);
}
// не хватает дейта на полёт
if ($cargo < $cons) {
    AjaxSendError(615);
}
// нет места в грузовом отсеке для дейтерия
// Fleet lock
$fleetlock = "temp/fleetlock_" . $aktplanet['planet_id'];
if (file_exists($fleetlock)) {
    AjaxSendError();
}
$f = fopen($fleetlock, 'w');
fclose($f);
// Отправить флот.
$fleet_id = DispatchFleet($fleet, $aktplanet, $target, $order, $flighttime, 0, 0, 0, $cons, time(), 0);
UserLog($aktplanet['owner_id'], "FLEET", "Отправка флота {$fleet_id} (AJAX): " . GetMissionNameDebug($order) . " " . $aktplanet['name'] . " [" . $aktplanet['g'] . ":" . $aktplanet['s'] . ":" . $aktplanet['p'] . "] -&gt; " . $target['name'] . " [" . $target['g'] . ":" . $target['s'] . ":" . $target['p'] . "]<br>" . DumpFleet($fleet) . "<br>" . "Время полёта: " . BuildDurationFormat($flighttime) . ", затраты дейтерия: " . nicenum($cons));
// Поднять флот с планеты.
AdjustResources(0, 0, $cons, $aktplanet['planet_id'], '-');
AdjustShips($fleet, $aktplanet['planet_id'], '-');
UpdatePlanetActivity($aktplanet['planet_id']);
unlink($fleetlock);
AjaxSendDone($nowfleet + 1, $probes, $recyclers, $missiles);