function scan_vessels($vessel_id, $range, $scans, $i) { list($src_distance, $src_angle) = get_correct_da($vessel_id); // Scan for vessels $result = sql_query("SELECT * FROM g_vessels ORDER BY user_id"); while ($vessel = sql_fetchrow($result)) { if ($vessel['id'] == $vessel_id) { continue; } $race = user_get_race($vessel['user_id']); if ($vessel['sector_id'] == 0) { $distance = calc_distance($src_distance, $src_angle, $vessel['distance'], $vessel['angle']); if ($distance <= $range and $distance != 0) { $scans[$i]['str'] = "<tr class=bl><td> Vessel </td><td> " . $vessel['name'] . " (" . $race . ") </td><td> " . $vessel['distance'] . " / " . $vessel['angle'] . " </td><td> " . $distance . " </td></tr>\n"; $scans[$i]['range'] = $distance; $i++; } } else { $vessel_sector = sector_get_sector($vessel['sector_id']); $distance = calc_distance($src_distance, $src_angle, $vessel_sector['distance'], $vessel_sector['angle']); if ($distance <= $range and $distance != 0) { // Check if it's not inside a nebula $planet = anomaly_get_anomaly($vessel['planet_id']); if (!(vessel_is_in_orbit($vessel) and anomaly_is_nebula($planet['id']))) { $scans[$i]['str'] = "<tr class=bl><td> Vessel </td><td> " . $vessel['name'] . " (" . $race . ") </td><td> SECTOR: " . $vessel_sector['distance'] . " / " . $vessel_sector['angle'] . " </td><td> " . $distance . " </td></tr>\n"; $scans[$i]['range'] = $distance; $i++; } } } } return array($scans, $i); }
function nebula_show_nebula($nebula_id) { assert(!empty($nebula_id)); global $_GALAXY; if (!anomaly_is_nebula($nebula_id)) { return; } $nebula = anomaly_get_anomaly($nebula_id); $sector = sector_get_sector($nebula['sector_id']); $race = user_get_race($nebula['user_id']); if ($race == "") { $race = "-"; } echo "<table border=1 width=500 align=center>"; echo " <tr><td align=center><b><i>Sector: " . $sector['name'] . " / Anomaly: " . $nebula['name'] . "</i></b></td></tr>"; echo " <tr><td>"; echo " <table border=0 cellpadding=0 cellspacing=0 width=100%>"; echo " <tr><td width=200>"; echo " <table border=0 cellpadding=0 cellspacing=0 width=100%>"; echo " <tr><th>Anomaly View</th></tr>"; echo " <tr><td width=100%><center><img src=\"" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/nebulas/" . $nebula['image'] . ".jpg\" width=150 height=150></center></td></tr>"; echo " <tr><th> </th></tr>"; echo " </table>"; echo " </td>"; echo " <td> </td>"; echo " <td nowrap valign=top>"; echo " <table border=0 cellpadding=0 cellspacing=0 width=100%>"; echo " <tr><td nowrap width=40%><strong>Nebula Name </strong></td><td nowrap width=1%><b>:</b></td>"; if ($nebula['unknown'] == 1) { form_start(); echo "<td nowrap>"; echo " <input type=hidden name=aid value=" . encrypt_get_vars($nebula_id) . ">"; echo " <input type=hidden name=cmd value=" . encrypt_get_vars("claim") . ">"; echo " <input type=text size=15 maxlength=30 name=ne_name> "; echo " <input name=submit type=submit value=\"Claim\">"; echo "</td>"; form_end(); } else { echo "<td nowrap>" . $nebula['name'] . "</td>"; } echo " </tr>"; echo " <tr><td colspan=3> </td></tr>"; echo " <tr><td nowrap width=40%><strong>Caretaker </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $race . "</td></tr>"; echo " <tr><td nowrap width=40%><strong>Cloud Radius </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $nebula['radius'] . " km</td></tr>"; echo " <tr><td nowrap width=40%><strong>Distance to sun </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $nebula['distance'] . " km (10<sup>6</sup>)</td></tr>"; echo " </table>"; echo " </td>"; echo " </tr>"; echo " </table>"; echo " </td>"; echo " </tr>"; echo "</table>"; echo "<br><br>"; }
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; }
function show_anomaly($anomaly_id) { assert(is_numeric($anomaly_id)); if (anomaly_is_starbase($anomaly_id)) { starbase_show_starbase($anomaly_id); } if (anomaly_is_planet($anomaly_id)) { planet_show_planet($anomaly_id); } if (anomaly_is_wormhole($anomaly_id)) { wormhole_show_wormhole($anomaly_id); } if (anomaly_is_blackhole($anomaly_id)) { blackhole_show_blackhole($anomaly_id); } if (anomaly_is_nebula($anomaly_id)) { nebula_show_nebula($anomaly_id); } }