コード例 #1
0
function upgrade_speed($_USER, $vessel_id)
{
    // Get global information
    $user = user_get_user($_USER['id']);
    $result = sql_query("SELECT * FROM g_flags WHERE user_id=" . $_USER['id']);
    $flags = sql_fetchrow($result);
    $vessel = vessel_get_vessel($vessel_id);
    // Show Ship and User Capabilities
    echo "<table align=center border=1>";
    echo "<tr><td>";
    echo "<table width=100% border=0 cellpadding=0 cellspacing=0>";
    echo "<tr><th colspan=2>Current Ship Capabilities</th></tr>";
    echo "<tr><td>Impulse Speed: </td><td>" . $vessel['impulse'] . "%</td></tr>";
    echo "<tr><td>Warp Speed:    </td><td>" . number_format($vessel['warp'] / 10, 1) . "</td></tr>";
    echo "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>";
    echo "</table>";
    echo "</td><td>";
    echo "<table width=100% border=0 cellpadding=0 cellspacing=0>";
    echo "<tr><th colspan=2>User Statistics</th></tr>";
    echo "<tr><td>Credits:</td><td>" . $user['credits'] . "</td></tr>";
    echo "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>";
    echo "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>";
    echo "</table>";
    echo "</td></tr>";
    echo "</table>";
    echo "<br>";
    echo "<br>";
    if ($vessel['impulse'] == $user['impulse'] and $vessel['warp'] == $user['warp']) {
        echo "  <table align=center>";
        echo "    <tr><td>Ship Name:          </td><td>" . $vessel['name'] . "</td></tr>";
        echo "    <tr><td>&nbsp;</td><td>No upgrade Possible</td></tr>";
        echo "  </table>";
    }
    // Stage 1: Create Ship and ship name
    if (!isset($stage) || $stage == 1) {
        form_start();
        echo "<input type=hidden name=vid value={$vid}>";
        echo "  <table align=center>";
        echo "    <tr><td>Ship Name:          </td><td>" . $vessel['name'] . "</td></tr>";
        echo "    <tr><td colspan=2></td></tr>";
        echo "    <tr><td>Impulse speed: </td><td>";
        if ($flags['can_warp'] == 1) {
            echo "<input type=hidden name=impulse value=100>100 % (" . $config['s_impulse_costs'] * 100 . " Credits)";
        } else {
            echo " <select name='impulse'>";
            for ($i = $vessel['impulse'] + 1; $i != $user['impulse'] + 1; $i++) {
                echo "<option value=" . $i . ">" . $i . " % (" . ($i - $vessel['impulse']) * $config['s_impulse_costs'] . " Credits)</option>";
            }
            echo " </select>";
        }
        echo "    </td></tr>";
        echo "    <tr><td>Warp Speed: </td><td>";
        if ($flags['can_warp'] == 1) {
            echo " <select name=warp>";
            for ($i = $vessel['warp'] + 1; $i != $user['warp'] + 1; $i++) {
                echo "<option value=" . $i . "> Warp " . number_format($i / 10, 1) . " (" . ($i - $vessel['warp']) * $config['s_warp_costs'] . " Credits)</option>";
            }
            echo " </select>";
        } else {
            echo "<input type=hidden name=warp value=0>";
            echo "None";
        }
        echo "    </td></tr>";
        echo "    <tr><td>&nbsp;</td><td><input type=submit name=submit value=\"Upgrade Ship\"></td></tr>";
        echo "  </table>";
        form_end();
    }
    //  Stage 2: Add or Delete weaponary
    if ($stage == 2 and ($vessel['type'] == VESSEL_TYPE_TRADE or $vessel['type'] == VESSEL_TYPE_EXPLORE)) {
        $stage = 3;
    }
    if ($stage == 2) {
        // Get all weapons we can view
        $visible_weapons = array();
        $result = sql_query("SELECT * FROM g_weapons WHERE user_id=" . $_USER['id']);
        $visible_weapons = csl_create_array($result, "csl_weapon_id");
        // And dump them into the table
        echo "<table border=1 align=center>";
        echo "<tr><th colspan=8>Weaponary</th></tr>";
        echo "<tr>";
        echo "<th>Name</th>";
        echo "<th>Costs</th>";
        echo "<th>Power</th>";
        echo "<th>Attack</th>";
        echo "<th>Defense</th>";
        echo "<th>Qty</th>";
        echo "<th colspan=2>Action</th>";
        echo "</tr>";
        reset($visible_weapons);
        while (list($key, $weapon_id) = each($visible_weapons)) {
            $result = sql_query("SELECT * FROM s_weapons WHERE id=" . $weapon_id);
            $weapon = sql_fetchrow($result);
            echo "<tr>";
            echo "<td>" . $weapon['name'] . "</td>";
            echo "<td>" . $weapon['costs'] . "</td>";
            echo "<td>" . $weapon['power'] . "</td>";
            echo "<td>" . $weapon['attack'] . "</td>";
            echo "<td>" . $weapon['defense'] . "</td>";
            echo "<td><input type=text size=3 maxlength=3 value=0 name=T1></td>";
            echo "<td><b>Add</b></td>";
            echo "<td><b>Delete</b></td>";
            echo "</tr>";
        }
        echo "</table>";
        echo "<br><br>";
    }
    if ($stage == 3) {
        $ok = "Vessel upgrade in process..\n";
        $errors['PARAMS'] = "Incorrect parameters specified...\n";
        $errors['SPEED'] = "Incorrect speed settings...\n";
        $errors['CREDITS'] = "Not enough credits...\n";
        $data['impulse'] = $_POST['impulse'];
        $data['warp'] = $_POST['warp'];
        $data['vid'] = decrypt_get_vars($_POST['vid']);
        comm_send_to_server("VESSELUPGRADE", $data, $ok, $errors);
    }
}
コード例 #2
0
function get_correct_da($vessel_id)
{
    assert(isset($vessel_id));
    $vessel = vessel_get_vessel($vessel_id);
    if (vessel_is_in_orbit($vessel_id) and $vessel['planet_id'] == 0) {
        $src_distance = $vessel['distance'];
        $src_angle = $vessel['angle'];
    } elseif (vessel_is_in_orbit($vessel_id) and $vessel['planet_id'] != 0) {
        $planet = anomaly_get_anomaly($vessel['planet_id']);
        $sector = sector_get_sector($planet['sector_id']);
        $src_distance = $sector['distance'];
        $src_angle = $sector['angle'];
    } else {
        $src_distance = $vessel['distance'];
        $src_angle = $vessel['angle'];
    }
    return array($src_distance, $src_angle);
}
コード例 #3
0
ファイル: queue.php プロジェクト: jaytaph/perihelion-oldcode
function queue_print($user_id)
{
    assert(is_numeric($user_id));
    global $_RUN;
    $totalcount = 0;
    $template = new Smarty();
    $template->debugging = true;
    // Buildings
    $count = 0;
    $tmpvar = array();
    $result = sql_query("SELECT * FROM h_queue WHERE type='" . QUEUE_BUILD . "' AND user_id=" . $user_id);
    while ($queue = sql_fetchrow($result)) {
        $totalcount++;
        $count++;
        $building = building_get_building($queue['building_id']);
        $planet = anomaly_get_anomaly($queue['planet_id']);
        $tmpvar['what'][] = "Building " . $building['name'] . " on " . $planet['name'];
        $tmpvar['ticks'][] = $queue['ticks'];
    }
    $tmpvar['count'] = $count;
    $template->assign("building", $tmpvar);
    // Items
    $count = 0;
    $tmpvar = array();
    $result = sql_query("SELECT * FROM h_queue WHERE type='" . QUEUE_INVENTION . "' AND user_id=" . $user_id);
    while ($queue = sql_fetchrow($result)) {
        $totalcount++;
        $count++;
        $item = item_get_item($queue['building_id']);
        $planet = anomaly_get_anomaly($queue['planet_id']);
        $tmpvar['what'][] = "Manufacturing " . $item['name'] . " on " . $planet['name'];
        $tmpvar['ticks'][] = $queue['ticks'];
    }
    $tmpvar['count'] = $count;
    $template->assign("item", $tmpvar);
    // Vessels
    $count = 0;
    $tmpvar = array();
    $result = sql_query("SELECT * FROM h_queue WHERE type='" . QUEUE_VESSEL . "' AND user_id=" . $user_id);
    while ($queue = sql_fetchrow($result)) {
        $totalcount++;
        $count++;
        $vessel = vessel_get_vessel($queue['vessel_id']);
        $planet = anomaly_get_anomaly($queue['planet_id']);
        $tmpvar['what'][] = "Building " . $vessel['name'] . " on " . $planet['name'];
        $tmpvar['ticks'][] = $queue['ticks'];
    }
    $tmpvar['count'] = $count;
    $template->assign("vessel", $tmpvar);
    // Upgrade (NOTE: THESE ARE ALSO PART OF THE VESSEL[] ARRAY
    $count = 0;
    $tmpvar = array();
    $result = sql_query("SELECT * FROM h_queue WHERE type='" . QUEUE_UPGRADE . "' AND user_id=" . $user_id);
    while ($queue = sql_fetchrow($result)) {
        $totalcount++;
        $count++;
        $vessel = vessel_get_vessel($queue['vessel_id']);
        $planet = anomaly_get_anomaly($queue['planet_id']);
        $tmpvar['what'][] = "Upgrading " . $vessel['name'] . " on " . $planet['name'];
        $tmpvar['ticks'][] = $queue['ticks'];
    }
    $tmpvar['count'] = $count;
    $template->assign("vessel", $tmpvar);
    // Flights
    $count = 0;
    $tmpvar = array();
    $result = sql_query("SELECT * FROM h_queue WHERE type='" . QUEUE_FLIGHT . "' AND user_id=" . $user_id);
    while ($queue = sql_fetchrow($result)) {
        $totalcount++;
        $count++;
        $result2 = sql_query("SELECT * FROM g_vessels WHERE id=" . $queue['vessel_id']);
        $vessel = sql_fetchrow($result2);
        if ($vessel['dst_planet_id'] == 0) {
            if ($vessel['dst_sector_id'] == 0) {
                $tmpvar['what'][] = "Flying " . $vessel['name'] . " to outer space.";
            } else {
                $sector = sector_get_sector($vessel['dst_sector_id']);
                $tmpvar['what'][] = "Flying " . $vessel['name'] . " to sector " . $sector['name'];
            }
        } else {
            $planet = anomaly_get_anomaly($vessel['dst_planet_id']);
            $tmpvar['what'][] = "Flying " . $vessel['name'] . " to " . $planet['name'];
        }
        $tmpvar['ticks'][] = $queue['ticks'];
    }
    $tmpvar['count'] = $count;
    $template->assign("flight", $tmpvar);
    $template->assign("itemcount", $totalcount);
    $template->display($_RUN['theme_path'] . "/order-queue.tpl");
}
コード例 #4
0
ファイル: convoy.php プロジェクト: jaytaph/perihelion-oldcode
function show_participated_convoys($_USER)
{
    echo "<table border=1 align=center>";
    echo "  <tr><th colspan=5>All participated convoys</th></tr>";
    echo "  <tr>";
    echo "    <th>Vessel Name</th>";
    echo "    <th>Convoy Name</th>";
    echo "    <th>Flag Ship</th>";
    echo "    <th>Ships</th>";
    echo "    <th>Status</th>";
    echo "  </tr>";
    $result = sql_query("SELECT * FROM g_vessels WHERE user_id=" . $_USER['id']);
    while ($vessel = sql_fetchrow($result)) {
        if ($vessel['convoy_id'] == 0) {
            continue;
        }
        $result2 = sql_query("SELECT * FROM s_convoys WHERE id=" . $vessel['convoy_id']);
        $convoy = sql_fetchrow($result2);
        // Get the flag ship of the convoy
        $flagvessel = vessel_get_vessel($convoy['vessel_id']);
        // Count the number of ships
        $result2 = sql_query("SELECT c.* FROM s_convoys c, g_vessels v WHERE c.vessel_id=v.id AND v.user_id=" . $_USER['id']);
        $tmp = csl_create_array($result2, "csl_vessel_id");
        $shipcount = count($tmp);
        // Get the status of the convoy
        $status = $convoy['status'];
        echo "<tr>";
        echo "<td>&nbsp;" . $vessel['name'] . "&nbsp;</td>";
        echo "<td>&nbsp;" . $convoy['name'] . "&nbsp;</td>";
        echo "<td>&nbsp;" . $flagvessel['name'] . "&nbsp;</td>";
        echo "<td>&nbsp;" . $shipcount . "&nbsp;</td>";
        echo "<td>&nbsp;" . $status . "&nbsp;</td>";
        echo "</tr>";
    }
    echo "</table>";
}
コード例 #5
0
ファイル: vessel.php プロジェクト: jaytaph/perihelion-oldcode
function vessel_show_cargo($vessel_id)
{
    assert(is_numeric($vessel_id));
    global $_GALAXY;
    $vessel = vessel_get_vessel($vessel_id);
    // Get all buildings that are currently build on the planet
    $result = sql_query("SELECT * FROM i_vessels WHERE vessel_id=" . $vessel_id);
    $vessel_cargo = csl_create_array($result, "csl_cargo_id");
    $vessel_cargo = array_count_values($vessel_cargo);
    // Find out if we just travelled through a wormhole, or if we are nearby a wormhole.
    $located_in_wormhole = false;
    $result = sql_query("SELECT * FROM w_wormhole");
    while ($wormhole = sql_fetchrow($result)) {
        if ($vessel['distance'] == $wormhole['distance'] and $vessel['angle'] == $wormhole['angle']) {
            $located_in_wormhole = true;
        }
    }
    // Do not show the array when it's empty...
    if (count($vessel_cargo) == 0) {
        //    echo "<table align=center border=0 width=75%>";
        //    echo "<tr class=wb><th colspan=2>No items on board</th></tr>";
        //    echo "</table>";
        //    echo "<br><br>";
    } else {
        echo "<table align=center border=0 width=75%>";
        echo "<tr class=wb><th colspan=3>Vessel Items</th></tr>";
        echo "<tr class=bl>";
        echo "<th>Quantity</th>";
        echo "<th width=100%>Name</th>";
        echo "<th>&nbsp;</th>";
        echo "</tr>";
        reset($vessel_cargo);
        while (list($cargo_id, $q) = each($vessel_cargo)) {
            $invention = item_get_item($cargo_id);
            if (invention_is_active_on_vessel($invention, $vessel)) {
                $activeimg = "alt=Active src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/active.gif";
            } else {
                $activeimg = "alt=Inactive src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/inactive.gif";
            }
            echo "<tr class=bl>";
            echo "  <td>&nbsp;" . $q . "&nbsp;</td>";
            echo "  <td>&nbsp;<img " . $activeimg . ">&nbsp;" . $invention['name'] . "&nbsp;</td>";
            if ($vessel['planet_id'] == 0) {
                echo "  <td nowrap>&nbsp;&nbsp;</td>";
            } else {
                echo "  <td nowrap>&nbsp;<a href=vessel.php?cmd=" . encrypt_get_vars("load_v2p") . "&vid=" . encrypt_get_vars($vessel['id']) . "&aid=" . encrypt_get_vars($vessel['planet_id']) . "&iid=" . encrypt_get_vars($invention['id']) . ">Move to planet</a>&nbsp;</td>";
            }
            echo "</tr>";
        }
        echo "</table>";
        echo "<br><br>";
    }
    // Only show planet cargo when there we are orbitting a planet.
    if ($vessel['planet_id'] == 0) {
        return;
    }
    // Get all buildings that are currently build on the planet
    $surface = planet_get_surface($vessel['planet_id']);
    $planet_cargo = csl($surface['csl_cargo_id']);
    $planet_cargo = array_count_values($planet_cargo);
    // Do not show the array when it's empty...
    if (count($planet_cargo) == 0) {
        //    echo "<table align=center border=0 width=75%>\n";
        //    echo "  <tr class=wb><th colspan=3>No items on planet</th></tr>\n";
        //    echo "</table>\n";
        //    echo "<br><br>\n";
    } else {
        form_start();
        echo "<table align=center border=0 width=75%>\n";
        echo "  <tr class=wb><th colspan=3>Planet Items</th></tr>\n";
        echo "  <tr class=bl>";
        echo "<th>Qty</th>";
        echo "<th width=100%>Name</th>";
        echo "<th>&nbsp;</th>";
        echo "</tr>\n";
        reset($planet_cargo);
        while (list($cargo_id, $q) = each($planet_cargo)) {
            $invention = item_get_item($cargo_id);
            if (invention_is_active_on_planet($invention)) {
                $activeimg = "alt=Active src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/active.gif";
            } else {
                $activeimg = "alt=Inactive src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/inactive.gif";
            }
            echo "  <tr class=bl>\n";
            echo "    <td>&nbsp;" . $q . "&nbsp;</td>\n";
            echo "    <td>&nbsp;<img " . $activeimg . ">&nbsp;" . $invention['name'] . "&nbsp;</td>\n";
            echo "    <td nowrap>&nbsp;<a href=vessel.php?cmd=" . encrypt_get_vars("load_p2v") . "&vid=" . encrypt_get_vars($vessel['id']) . "&aid=" . encrypt_get_vars($vessel['planet_id']) . "&iid=" . encrypt_get_vars($invention['id']) . ">Move to vessel</a>&nbsp;</td>\n";
            echo "  </tr>\n";
        }
        echo "</table>\n";
        form_end();
        echo "<br><br>\n";
    }
}
コード例 #6
0
function vessel_get_current_status($vessel_id, $create_hyperlink = true)
{
    assert(is_numeric($vessel_id));
    assert(is_bool($create_hyperlink));
    $vessel = vessel_get_vessel($vessel_id);
    $status = "Unknown status";
    // Are we in orbit?
    if (vessel_is_in_orbit($vessel_id)) {
        $anomaly = anomaly_get_anomaly($vessel['planet_id']);
        if (anomaly_is_planet($anomaly['id'])) {
            if ($create_hyperlink) {
                $status = "Orbiting planet <a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly['id']) . ">" . $anomaly['name'] . "</a>";
            } else {
                $status = "Orbiting planet " . $anomaly['name'];
            }
        }
        if (anomaly_is_nebula($anomaly['id'])) {
            if ($create_hyperlink) {
                $status = "Hiding in nebula <a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly['id']) . ">" . $anomaly['name'] . "</a>";
            } else {
                $status = "Hiding in nebula " . $anomaly['name'];
            }
        }
        if (anomaly_is_starbase($anomaly['id'])) {
            if ($create_hyperlink) {
                $status = "Docking at starbase <a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly['id']) . ">" . $anomaly['name'] . "</a>";
            } else {
                $status = "Docking at starbase " . $anomaly['name'];
            }
        }
    }
    // Is the vessel flying?
    if (vessel_is_flying($vessel_id)) {
        if ($vessel['dst_planet_id'] == 0) {
            // Are we flying to a sector or deep space?
            if ($vessel['dst_sector_id'] == 0) {
                $status = "Flying to " . $vessel['dst_distance'] . " / " . $vessel['dst_angle'];
            } else {
                $tmp = sector_get_sector($vessel['dst_sector_id']);
                if ($create_hyperlink) {
                    $status = "Flying to sector <a href=sector.php?id=" . encrypt_get_vars($tmp['id']) . ">" . $tmp['name'] . "</a>";
                } else {
                    $status = "Flying to sector " . $tmp['name'];
                }
            }
        } else {
            // Are we flying to a planet?
            $tmp_anomaly = anomaly_get_anomaly($vessel['dst_planet_id']);
            if (anomaly_is_planet($tmp_anomaly['id'])) {
                if (anomaly_is_discovered_by_user($tmp_anomaly['id'], user_ourself())) {
                    if ($create_hyperlink) {
                        $status = "Flying to planet <a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($tmp_anomaly['id']) . ">" . $tmp_anomaly['name'] . "</a>";
                    } else {
                        $status = "Flying to planet " . $tmp_anomaly['name'];
                    }
                } else {
                    $status = "Flying to an unknown anomaly.";
                }
            }
            if (anomaly_is_starbase($tmp_anomaly['id'])) {
                $status = "Flying to starbase " . $tmp_anomaly['name'];
            }
            if (anomaly_is_nebula($tmp_anomaly['id'])) {
                $status = "Flying to nebula " . $tmp_anomaly['name'];
            }
            if (anomaly_is_wormhole($tmp_anomaly['id'])) {
                $status = "Flying to wormhole " . $tmp_anomaly['name'];
            }
        }
    }
    // Are we halted in deep space?
    if (vessel_is_in_space($vessel_id) and $vessel['sector_id'] == 0) {
        $status = "Located in deep space (" . $vessel['distance'] . " / " . $vessel['angle'] . ")";
    }
    // Or are we bordering a sector?
    if (vessel_is_in_space($vessel_id) and $vessel['sector_id'] != 0) {
        $sector = sector_get_sector($vessel['sector_id']);
        $status = "Bordering sector " . $sector['name'];
    }
    if (vessel_in_traderoute($vessel_id)) {
        $status = "Part of traderoute.";
    }
    // TODO: change this into vessel_is_in_convoy ($vessel_id)
    if ($vessel['status'] == "CONVOY") {
        $result = sql_query("SELECT * FROM s_convoys WHERE id=" . $vessel['convoy_id']);
        $tmp = sql_fetchrow($result);
        if ($create_hyperlink) {
            $status = "Part of convoy <a href=convoy.php?id=" . encrypt_get_vars($tmp['id']) . ">" . $tmp['name'] . "</a>";
        } else {
            $status = "Part of convoy " . $tmp['name'];
        }
    }
    return $status;
}
コード例 #7
0
ファイル: trade.php プロジェクト: jaytaph/perihelion-oldcode
function trade_show_routes($user_id)
{
    assert(is_numeric($user_id));
    global $_GALAXY;
    $firstrow = 1;
    $result = sql_query("SELECT * FROM a_trades");
    while ($traderoute = sql_fetchrow($result)) {
        $src_planet = anomaly_get_anomaly($traderoute['src_planet_id']);
        $dst_planet = anomaly_get_anomaly($traderoute['dst_planet_id']);
        // We don't own the source or destination planet... skip it..
        if ($src_planet['user_id'] != $user_id and $dst_planet['user_id'] != $user_id) {
            continue;
        }
        $vessel = vessel_get_vessel($traderoute['vessel_id']);
        $ore1 = "";
        $ore2 = "";
        if ($traderoute['src_ore'] == ORE_NONE) {
            $ore1 = "None, ";
        } elseif ($traderoute['src_ore'] == ORE_ALL) {
            $ore1 = "All ores, ";
        } else {
            $ores = csl($traderoute['src_ore']);
            foreach ($ores as $ore) {
                $ore1 .= ore_get_ore_name($ore) . ", ";
            }
        }
        // Chop off last comma
        $ore1 = substr_replace($ore1, "", -2);
        if ($traderoute['dst_ore'] == ORE_NONE) {
            $ore2 = "None, ";
        } elseif ($traderoute['dst_ore'] == ORE_ALL) {
            $ore2 = "All ores, ";
        } else {
            $ores = csl($traderoute['dst_ore']);
            foreach ($ores as $ore) {
                $ore2 .= ore_get_ore_name($ore) . ", ";
            }
        }
        // Chop off last comma
        $ore2 = substr_replace($ore2, "", -2);
        if ($firstrow == 1) {
            $firstrow = 0;
            print_remark("Vessel table");
            echo "<table align=center width=80% border=0>\n";
            echo "  <tr class=wb>";
            echo "<th>Vessel</th>";
            echo "<th>Source</th>";
            echo "<th>Ores</th>";
            echo "<th>Destination</th>";
            echo "<th>Ores</th>";
            echo "</tr>\n";
        }
        echo "  <tr class=bl>\n";
        echo "    <td>&nbsp;<img src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/ships/trade.jpg>&nbsp;<a href=vessel.php?cmd=" . encrypt_get_vars("showvid") . "&vid=" . encrypt_get_vars($vessel['id']) . ">" . $vessel['name'] . "</a>&nbsp;</td>\n";
        echo "    <td>&nbsp;<a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($src_planet['id']) . ">" . $src_planet['name'] . "</a>&nbsp;</td>\n";
        echo "    <td>&nbsp;" . $ore1 . "&nbsp;</td>\n";
        echo "    <td>&nbsp;<a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($dst_planet['id']) . ">" . $dst_planet['name'] . "</a>&nbsp;</td>\n";
        echo "    <td>&nbsp;" . $ore2 . "&nbsp;</td>\n";
        echo "  </tr>\n";
    }
    if ($firstrow == 0) {
        echo "</table>\n";
        echo "<br><br>\n";
    } else {
        print_line("There are currently no traderoutes available.");
    }
}
コード例 #8
0
function show_sector($vessel_id, $unknowns_too)
{
    assert(is_numeric($vessel_id));
    assert(is_string($unknowns_too));
    // Get sector information
    $vessel = vessel_get_vessel($vessel_id);
    $user = user_get_user($vessel['user_id']);
    $sector = sector_get_sector($vessel['sector_id']);
    $result = sql_query("SELECT * FROM g_anomalies WHERE user_id=" . $vessel['user_id']);
    $anomalies = csl_create_array($result, "csl_discovered_id");
    if ($unknowns_too == "Y") {
        $undiscovered_anomalies = csl_create_array($result, "csl_undiscovered_id");
        $anomalies = csl_merge_fields($anomalies, $undiscovered_anomalies);
    } else {
        $undiscovered_anomalies = "";
    }
    // Get planet information for all planets in the sector
    $result = sql_query("SELECT * FROM s_anomalies WHERE sector_id=" . $sector['id'] . " ORDER BY distance");
    while ($anomaly = sql_fetchrow($result)) {
        // If we can't view the planet, then don't show it...
        if (!in_array($anomaly['id'], $anomalies)) {
            continue;
        }
        $ticks = calc_planet_ticks($anomaly['distance'], $sector['angle'], $vessel['sun_distance'], $vessel['angle'], $vessel['impulse'], $vessel['warp']);
        // Check if ticks = 0 and the id of the planet is not the same as the
        // id of the planet we're curently orbitting...
        // If that's the case, the planet is really nearby, and we give it at
        // least 1 tick...
        if ($ticks == 0 && $anomaly['id'] != $vessel['planet_id']) {
            $ticks = 1;
        }
        // Don't show planet if it's 0 tick away (which means: it's our orbit)
        if ($ticks == 0) {
            continue;
        }
        // Thread undiscovered planets different...
        if (in_array($planet['id'], $undiscovered_anomalies)) {
            echo "<option value=" . encrypt_get_vars($anomaly['id']) . ">" . $sector['name'] . " / Unknown ({$ticks} ticks)</option>";
        } else {
            echo "<option value=" . encrypt_get_vars($anomaly['id']) . ">" . $sector['name'] . " / " . $anomaly['name'] . " ({$ticks} ticks)</option>";
        }
    }
}
コード例 #9
0
ファイル: info.php プロジェクト: jaytaph/perihelion-oldcode
function show_info($user_id)
{
    global $_USER;
    global $_CONFIG;
    global $_RUN;
    $user = user_get_user($user_id);
    // User Information
    $template = new Smarty();
    help_set_template_vars($template, "INFO");
    $planets_owned = info_get_planetown_count($user_id);
    $template->assign("stardate", info_get_stardate());
    $template->assign("credits", $user['credits']);
    $template->assign("population", info_get_population_count($user_id));
    $template->assign("sectors_owned", info_get_sectorown_count($user_id));
    $template->assign("planets_owned", $planets_owned);
    list($minable_count, $habitable_count, $unusable_count, $starbase_count, $wormhole_count, $blackhole_count, $anomalie_count) = info_get_anomaly_statistics($user_id);
    $template->assign("minable_count", $minable_count);
    $template->assign("minable_percentage", round($minable_count / $planets_owned * 100, 2));
    $template->assign("habitable_count", $habitable_count);
    $template->assign("habitable_percentage", round($habitable_count / $planets_owned * 100, 2));
    $template->assign("unusable_count", $unusable_count);
    $template->assign("unusable_percentage", round($unusable_count / $planets_owned * 100, 2));
    $template->assign("wormhole_count", $wormhole_count);
    $template->assign("wormhole_percentage", round($wormhole_count / $planets_owned * 100, 2));
    $template->assign("starbase_count", $starbase_count);
    $template->assign("starbase_percentage", round($starbase_count / $planets_owned * 100, 2));
    $template->assign("anomalie_count", $anomalie_count);
    $template->assign("anomalie_percentage", round($anomalie_count / $planets_owned * 100, 2));
    // Tactical Information
    list($total_vessels, $evd, $tvd, $bvd) = info_get_vessel_statistics($user_id);
    $template->assign("total_vessels", $total_vessels);
    $template->assign("bvd", $bvd);
    $template->assign("bvd_percentage", round($bvd / $total_vessels * 100, 2));
    $template->assign("tvd", $tvd);
    $template->assign("tvd_percentage", round($tvd / $total_vessels * 100, 2));
    $template->assign("evd", $evd);
    $template->assign("evd_percentage", round($evd / $total_vessels * 100, 2));
    list($weak_ship_id, $ws_a) = user_get_weakest_ship($user_id);
    $weak_ship = vessel_get_vessel($weak_ship_id);
    $template->assign("weakship_name", $weak_ship['name']);
    $template->assign("weakship_href", "vessel.php?cmd=" . encrypt_get_vars("show") . "&vid=" . encrypt_get_vars($weak_ship_id));
    $template->assign("weakship_percentage", $ws_a);
    list($strong_ship_id, $ss_a) = user_get_strongest_ship($user_id);
    $strong_ship = vessel_get_vessel($strong_ship_id);
    $template->assign("strongship_name", $strong_ship['name']);
    $template->assign("strongship_href", "vessel.php?cmd=" . encrypt_get_vars("show") . "&vid=" . encrypt_get_vars($strong_ship_id));
    $template->assign("strongship_percentage", $ss_a);
    list($weak_planet_id, $wp_a) = user_get_weakest_planet($user_id);
    $weak_planet = anomaly_get_anomaly($weak_planet_id);
    $template->assign("weakplanet_name", $weak_planet['name']);
    $template->assign("weakplanet_href", "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($weak_planet_id));
    $template->assign("weakplanet_percentage", $wp_a);
    list($strong_planet_id, $sp_a) = user_get_strongest_planet($user_id);
    $strong_planet = anomaly_get_anomaly($strong_planet_id);
    $template->assign("strongplanet_name", $strong_planet['name']);
    $template->assign("strongplanet_href", "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($strong_planet_id));
    $template->assign("strongplanet_percentage", $sp_a);
    // Other Information
    list($bd, $vd, $id) = info_get_invention_statistics($user_id);
    $template->assign("buildings_discovered_percentage", $bd);
    $template->assign("vessels_discovered_percentage", $vd);
    $template->assign("inventions_discovered_percentage", $id);
    $template->assign("impulse_discovered", $user['impulse']);
    $template->assign("warp_discovered", number_format($user['warp'] / 10, 1));
    // Server status
    if (check_heartbeat_online()) {
        $template->assign("heartbeat_status", "online");
    } else {
        $template->assign("heartbeat_status", "offline");
    }
    if (check_server_online()) {
        $template->assign("commserver_status", "online");
        $result = sql_query("SELECT * FROM perihelion.pxs_info WHERE galaxy_id LIKE '" . $_USER['galaxy_db'] . "'");
        $server_status = sql_fetchrow($result);
        $result = sql_query("SELECT UNIX_TIMESTAMP()");
        $row = sql_fetchrow($result);
        $server_status['uptime'] = $row['0'] - $server_status['uptime'];
        $template->assign("commserver_uptime", calculate_uptime($server_status['uptime']));
        $template->assign("commserver_spawns", $server_status['spawns']);
        $template->assign("commserver_commands", $server_status['commands']);
        $template->assign("commserver_status_ok", $server_status['status_ok']);
        $template->assign("commserver_status_err", $server_status['status_err']);
    } else {
        $template->assign("commserver_status", "offline");
    }
    if (check_mysql_online()) {
        $template->assign("mysql_status", "online");
        // Get the mysql status and make it a nice hash
        $result = sql_query("SHOW STATUS");
        while ($row = sql_fetchrow($result)) {
            $sql_status[$row['Variable_name']] = $row['Value'];
        }
        $template->assign("mysql_uptime", calculate_uptime($sql_status['Uptime']));
        $template->assign("mysql_queries", $sql_status['Questions']);
        $template->assign("mysql_select", $sql_status['Com_select']);
        $template->assign("mysql_insert", $sql_status['Com_insert']);
        $template->assign("mysql_update", $sql_status['Com_update']);
        $template->assign("mysql_bytes_received", $sql_status['Bytes_received']);
        $template->assign("mysql_bytes_sent", $sql_status['Bytes_sent']);
    } else {
        $template->assign("mysql_status", "offline");
    }
    $template->display($_RUN['theme_path'] . "/info.tpl");
}