function wormhole_show_wormhole($wormhole_id) { assert(!empty($wormhole_id)); global $_GALAXY; if (!anomaly_is_wormhole($wormhole_id)) { return; } $wormhole = anomaly_get_anomaly($wormhole_id); $sector = sector_get_sector($wormhole['sector_id']); $race = user_get_race($wormhole['user_id']); $result = sql_query("SELECT * FROM w_wormhole WHERE id=" . $wormhole['id']); $dst_wormhole = sql_fetchrow($result); if ($race == "") { $race = "-"; } echo "<table border=1 width=500 align=center>\n"; echo " <tr><td align=center><b><i>Sector: " . $sector['name'] . " / Anomaly: " . $wormhole['name'] . "</i></b></td></tr>\n"; echo " <tr><td>\n"; echo " <table border=0 cellpadding=0 cellspacing=0 width=100%>\n"; echo " <tr><td width=200>\n"; echo " <table border=0 cellpadding=0 cellspacing=0 width=100%>\n"; echo " <tr><th>Anomaly View</th></tr>\n"; echo " <tr><td width=100%><center><img src=\"" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/wormholes/" . $wormhole['image'] . ".jpg\" width=150 height=150></center></td></tr>\n"; echo " <tr><th> </th></tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " <td> </td>\n"; echo " <td nowrap valign=top>\n"; echo " <table border=0 cellpadding=0 cellspacing=0 width=100%>\n"; echo " <tr><td nowrap width=40%><strong>Wormhole Name </strong></td><td nowrap width=1%><b>:</b></td>\n"; if ($wormhole['unknown'] == 1) { form_start(); echo "<td nowrap>\n"; echo " <input type=hidden name=aid value=" . encrypt_get_vars($wormhole_id) . ">\n"; echo " <input type=hidden name=cmd value=" . encrypt_get_vars("claim") . ">\n"; echo " <input type=text size=15 maxlength=30 name=ne_name>\n"; echo " <input name=submit type=submit value=\"Claim\">\n"; echo "</td>\n"; form_end(); } else { echo "<td nowrap>" . $wormhole['name'] . "</td>\n"; } echo " </tr>\n"; echo " <tr><td colspan=3> </td></tr>\n"; echo " <tr><td nowrap width=40%><strong>Caretaker </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $race . "</td></tr>\n"; echo " <tr><td nowrap width=40%><strong>Radius </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $wormhole['radius'] . " km</td></tr>\n"; echo " <tr><td nowrap width=40%><strong>Distance to sun </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $wormhole['distance'] . " km (10<sup>6</sup>)</td></tr>\n"; echo " <tr><td colspan=3> </td></tr>\n"; echo " <tr><td nowrap width=40%><strong>Destination </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $dst_wormhole['distance'] . " / " . $dst_wormhole['angle'] . "</td></tr>\n"; echo " <tr><td nowrap width=40%><strong>Stability </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . wormhole_get_wormhole_stability($dst_wormhole['next_jump']) . " </td></tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo "</table>\n"; echo "<br><br>\n"; }
function starbase_show_starbase($starbase_id) { assert(!empty($starbase_id)); global $_GALAXY; if (!anomaly_is_starbase($starbase_id)) { return; } $starbase = anomaly_get_anomaly($starbase_id); $sector = sector_get_sector($starbase['sector_id']); $race = user_get_race($starbase['user_id']); if ($race == "") { $race = "-"; } echo "<table border=1 width=500 align=center>"; echo " <tr><td align=center><b><i>Starbase: " . $starbase['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>Starbase View</th></tr>"; echo " <tr><td width=100%><center><img src=\"" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/starbase/" . $starbase['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>Starbase Name </strong></td><td nowrap width=1%><b>:</b></td>"; if ($starbase['unknown'] == 1) { form_start(); echo "<td nowrap>"; echo " <input type=hidden name=aid value=" . encrypt_get_vars($starbase_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>" . $starbase['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 colspan=3> </td></tr>"; echo " <tr><td nowrap width=40%><strong>Attack </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $starbase['cur_attack'] . "</td></tr>"; echo " <tr><td nowrap width=40%><strong>Defense </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $starbase['cur_defense'] . "</td></tr>"; echo " <tr><td nowrap width=40%><strong>Strength </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $starbase['cur_strength'] . "</td></tr>"; echo " <tr><td colspan=3> </td></tr>"; echo " </table>"; echo " </td>"; echo " </tr>"; echo " </table>"; echo " </td>"; echo " </tr>"; echo "</table>"; echo "<br><br>"; }
function blackhole_show_blackhole($blackhole_id) { assert(is_numeric($blackhole_id)); global $_GALAXY; if (!anomaly_is_blackhole($blackhole_id)) { return; } $blackhole = anomaly_get_anomaly($blackhole_id); $race = user_get_race($blackhole['user_id']); $sector = sector_get_sector($blackhole['sector_id']); if ($race == "") { $race = "-"; } echo "<table border=1 width=500 align=center>"; echo " <tr><td align=center><b><i>Sector: " . $sector['name'] . " / Anomaly: " . $blackhole['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'] . "/blackholes/" . $blackhole['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>Blackhole Name </strong></td><td nowrap width=1%><b>:</b></td>"; if ($blackhole['unknown'] == 1) { form_start(); echo "<td nowrap>"; echo " <input type=hidden name=aid value=" . encrypt_get_vars($blackhole_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>" . $blackhole['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>Radius </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $blackhole['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>" . $blackhole['distance'] . " km (10<sup>6</sup>)</td></tr>"; echo " <tr><td colspan=3> </td></tr>"; echo " <tr><td nowrap width=40%><strong>Fatalities </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . blackhole_get_fatalities($blackhole_id) . " ship(s)</td></tr>"; echo " </table>"; echo " </td>"; echo " </tr>"; echo " </table>"; echo " </td>"; echo " </tr>"; echo "</table>"; echo "<br><br>"; }
function sector_show_sector($sector_id, $user_id) { assert(!empty($sector_id)); assert(!empty($user_id)); global $_RUN; // Create the submenu where we can easily move between sectors $result = sql_query("SELECT * FROM g_sectors WHERE user_id = " . $user_id); $tmp = sql_fetchrow($result); $sectors = csl($tmp['csl_sector_id']); $idx = array_search($sector_id, $sectors); $first = reset($sectors); $last = end($sectors); if ($idx == 0) { $prev = $sectors[$idx]; } else { $prev = $sectors[$idx - 1]; } if ($idx == count($sectors) - 1) { $next = $sectors[$idx]; } else { $next = $sectors[$idx + 1]; } create_submenu(array("First Sector" => "sector.php?cmd=" . encrypt_get_vars("show") . "&sid=" . encrypt_get_vars($first), "Previous Sector" => "sector.php?cmd=" . encrypt_get_vars("show") . "&sid=" . encrypt_get_vars($prev), "Next Sector" => "sector.php?cmd=" . encrypt_get_vars("show") . "&sid=" . encrypt_get_vars($next), "Last Sector" => "sector.php?cmd=" . encrypt_get_vars("show") . "&sid=" . encrypt_get_vars($last))); $sector = sector_get_sector($sector_id); $template = new Smarty(); $template->debugging = true; help_set_template_vars($template); $template->assign("sector_id", $sector['sector']); $template->assign("sector_name", $sector['name']); $template->assign("sector_coordinate", $sector['distance'] . " / " . $sector['angle']); if ($sector['user_id'] == UID_NOBODY) { $template->assign("rename_form_visible", "true"); } else { $template->assign("rename_form_visible", "false"); } // And now, do all anomalies $tmp = user_get_all_anomalies_from_user($user_id); $anomalies = csl($tmp['csl_discovered_id']); $undiscovered_anomalies = csl($tmp['csl_undiscovered_id']); $anomalies = csl_merge_fields($anomalies, $tmp['csl_undiscovered_id']); // We didn't find any discovered anomalies in this sector per default $i = 0; $tmpvar = array(); // Get anomaly information for all anomalies in the sector $result = sql_query("SELECT * FROM s_anomalies WHERE sector_id=" . $sector_id . " ORDER BY distance"); while ($anomaly = sql_fetchrow($result)) { // We didn't discover this anomaly yet, continue with another if (!in_array($anomaly['id'], $anomalies)) { continue; } // Thread undiscovered planets different... if (in_array($anomaly['id'], $undiscovered_anomalies)) { $tmp['name'] = "Unknown"; $tmp['class'] = ""; $tmp['population'] = ""; $tmp['owner'] = ""; $tmp['status'] = ""; $tmp['radius'] = $anomaly['radius']; $tmp['distance'] = $anomaly['distance']; $tmpvar[] = $tmp; continue; } // If we are here, we have found an anomaly with we already // discovered and explored, show all the info about it... $state = sql_get_state($anomaly['state_id']); if ($anomaly['user_id'] != 0) { $race = user_get_race($anomaly['user_id']); } else { $race = "Nobody"; } // Show the population status in a different color if ($anomaly['population_capacity'] == 0) { $p = 0; } else { $p = $anomaly['population'] / $anomaly['population_capacity'] * 100; } $popcol = 'people_class1'; if ($p > 50) { $popcol = 'people_class2'; } if ($p > 75) { $popcol = 'people_class3'; } if ($p > 99) { $popcol = 'people_class4'; } if (!anomaly_is_planet($anomaly['id'])) { $anomaly['class'] = ""; $anomaly['population'] = ""; } // Show the class in different colors, A..J are orange... K..M are white... L..Z are red $classcol = "class_normal"; if (planet_is_habitable($anomaly['id'])) { $classcol = 'class_habitable'; } elseif (planet_is_minable($anomaly['id'])) { $classcol = 'class_minable'; } else { $classcol = 'class_unusable'; } $tmp = array(); $tmp['name_href'] = "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly['id']); $tmp['name'] = $anomaly['name']; $tmp['class'] = $anomaly['class']; $tmp['class_class'] = $classcol; if (planet_is_habitable($anomaly['id'])) { $tmp['population'] = $anomaly['population']; } else { $tmp['population'] = "---"; } $tmp['population_class'] = $popcol; $tmp['owner'] = $race; $tmp['status'] = $state; $tmp['radius'] = $anomaly['radius']; $tmp['distance'] = $anomaly['distance']; $tmpvar[] = $tmp; } $template->assign("anomalies", $tmpvar); $template->display($_RUN['theme_path'] . "/sectors-item.tpl"); }
function show_surface($planet_id) { global $_GALAXY; // Get global information from the user $planet = anomaly_get_anomaly($planet_id); $user = user_get_user($planet['user_id']); $sector = sector_get_sector($planet['sector_id']); $totals = calc_planet_totals($planet_id); // Generate text color for the power if ($totals['power_out'] == 0) { $power_p = 0; } else { $power_p = $totals['power_in'] / $totals['power_out'] * 100; } $power_color = "white"; if ($power_p > 50) { $power_color = "yellow"; } if ($power_p > 75) { $power_color = "orange"; } if ($power_p > 99) { $power_color = "red"; } // Generate text color for the crew if ($planet['population_capacity'] == 0) { $crew_p = 0; } else { $crew_p = $planet['population'] / $planet['population_capacity'] * 100; } $crew_color = "white"; if ($crew_p > 50) { $crew_color = "yellow"; } if ($crew_p > 75) { $crew_color = "orange"; } if ($crew_p > 99) { $crew_color = "red"; } print_subtitle("Surface View on planet " . $planet['name']); // ------------------------------------------------------------------ echo "<table width=75% align=center border=1>\n"; echo " <tr><th colspan=2>Global Information on<br>Sector " . $sector['name'] . " / Planet " . $planet['name'] . "</th></tr>\n"; echo " <tr><td>\n"; echo " <table width=100% border=0 cellpadding=0 cellspacing=0>\n"; echo " <tr><td> Power Generated </td><td> " . $totals['power_out'] . " </td></tr>\n"; echo " <tr><td> Power Needed </td><td> " . $totals['power_in'] . " </td></tr>\n"; echo " <tr><td> <font color={$power_color}><b>Power Left </b></font> </td><td> <font color={$power_color}><b>" . ($totals['power_out'] - $totals['power_in']) . "</b></font> </td></tr>\n"; echo " </table>\n"; echo " </td><td>\n"; echo " <table width=100% border=0 cellpadding=0 cellspacing=0>\n"; echo " <tr><td> <font color={$crew_color}>Inhabitants</font> </td><td> <font color={$crew_color}>" . $planet['population'] . "</font> </td></tr>\n"; echo " <tr><td> <font color={$crew_color}>Capacity</font> </td><td> <font color={$crew_color}>" . $planet['population_capacity'] . "</font> </td></tr>\n"; echo " <tr><td> </td><td> </td></tr>\n"; echo " </table>\n"; echo " </td></tr>\n"; echo "</table>\n"; echo "<br>\n"; echo "<br>\n"; // Get all buildings and cargo on the planet $surface = planet_get_surface($planet_id); $current_buildings = csl($surface['csl_building_id']); $current_buildings = array_count_values($current_buildings); $current_cargo = csl($surface['csl_cargo_id']); $current_cargo = array_count_values($current_cargo); // ------------------------------------------------------------------ // Show current buildings on the surface // echo "<table width=75% align=center border=0 cellpadding=0 cellspacing=0>\n"; echo "<table width=75% align=center border=0>\n"; echo " <tr class=wb><th colspan=5>Buildings on the planet</th></tr>\n"; echo " <tr class=bl>"; echo "<th>Qty</th>"; echo "<th>Name</th>"; echo "<th>Power In</th>"; echo "<th>Power Out</th>"; echo "<th>Description</th>"; echo "</tr>\n"; reset($current_buildings); while (list($building_id, $quantity) = each($current_buildings)) { $building = building_get_building(building_active_or_inactive($building_id)); if (building_is_active($building_id)) { } else { } if (building_is_active($building_id)) { $active = "<img alt=Active src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/active.gif>"; echo " <tr class=bl>\n"; echo " <td> " . $quantity . " </td>\n"; echo " <td> " . $active . " " . $building['name'] . " </td>\n"; echo " <td> " . $building['power_in'] . " </td>\n"; echo " <td> " . $building['power_out'] . " </td>\n"; echo " <td> " . $building['rule'] . " </td>\n"; echo " </tr>\n"; } else { $active = "<img alt=Inactive src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/inactive.gif>"; echo " <tr class=bl>\n"; echo " <td><font color=red> " . $quantity . " </font></td>\n"; echo " <td><font color=red> " . $active . " " . $building['name'] . " </font></td>\n"; echo " <td colspan=3><font color=red> Building not active </font></td>\n"; echo " </tr>\n"; } } echo "</table>\n"; echo "<br><br>\n"; // ------------------------------------------------------------------ // Show current items on the surface echo "<table width=75% align=center border=0>\n"; echo " <tr class=wb><th colspan=5>Cargo and machines on planet</th></tr>\n"; echo " <tr class=bl>"; echo "<th>Qty</th>"; echo "<th>Name</th>"; echo "<th>Description</th>"; echo "</tr>\n"; reset($current_cargo); while (list($item_id, $quantity) = each($current_cargo)) { $invention = item_get_item($item_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> " . $quantity . " </td>\n"; echo " <td> <img " . $activeimg . "> " . $invention['name'] . " </td>\n"; echo " <td> " . $invention['rule'] . " </td>\n"; echo " </tr>\n"; } echo "</table>\n"; echo "<br><br>\n"; }
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); }
function stock_show_sector($sector_id, $user_id) { assert(!empty($sector_id)); assert(!empty($user_id)); global $_CONFIG; // Check how many planets we own in this sector. If none, don't show anything... $result = sql_query("SELECT COUNT(*) AS count FROM s_anomalies WHERE sector_id = " . $sector_id . " AND user_id=" . $user_id); $tmp = sql_fetchrow($result); if ($tmp['count'] == 0) { return; } // Get sector information $sector = sector_get_sector($sector_id); // Only show a table if we got rows in it... $first_row = true; // Get planet information for all planets in the sector $result = sql_query("SELECT * from s_anomalies WHERE user_id=" . $user_id . " AND type='P' AND sector_id=" . $sector['id']); while ($planet = sql_fetchrow($result)) { $result2 = sql_query("SELECT * FROM g_ores WHERE planet_id=" . $planet['id']); $ores = sql_fetchrow($result2); $stock_ores = ore_csl_to_list($ores['stock_ores']); $upkeep_ores = ore_csl_to_list($planet['upkeep_ores']); for ($i = 0; $i != ore_get_ore_count(); $i++) { $fo = "ore" . $i . "c"; ${$fo} = "white"; if ($upkeep_ores[$i] == 0) { $ticks_left = 0; } else { $ticks_left = $stock_ores[$i] / $upkeep_ores[$i]; if ($ticks_left < 50) { ${$fo} = "yellow"; } if ($ticks_left < 25) { ${$fo} = "orange"; } if ($ticks_left < 10) { ${$fo} = "red"; } } } $user = user_get_user($planet['user_id']); if ($user['science_ratio'] == 100 or $planet['happieness'] == 0) { $planet_income = 0; } else { $planet_income = $planet['population'] / (100 / (100 - $user['science_ratio'])); $planet_income = $planet_income / $_CONFIG['h_credits_dividor']; $planet_income = $planet_income / (100 / $planet['happieness']); } $planet_upkeep = $planet['upkeep_costs']; $delta_upkeep = intval($planet_income - $planet_upkeep); // Only show a table if we have rows in it... if ($first_row) { $first_row = false; print_remark("Sector table"); echo "<table align=center border=0>\n"; echo " <tr class=wb><td colspan=" . (ore_get_ore_count() + 2) . "><b><i>Sector " . $sector['sector'] . ": " . $sector['name'] . "</i></b></td></tr>\n"; echo " <tr class=bl><th colspan=2>Name</th>"; for ($i = 0; $i != ore_get_ore_count(); $i++) { echo "<th>" . ore_get_ore_name($i) . "</th>"; } echo "</tr>\n"; } echo " <tr class=bl>\n"; echo " <td rowspan=2 valign=top>\n"; echo " <a href=\"anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']) . "\">Planet " . $planet['name'] . "</a> <br>\n"; if ($delta_upkeep < 0) { echo " <font color=red>Delta Upkeep: " . $delta_upkeep . "</font> \n"; } else { echo " Delta Upkeep: " . $delta_upkeep . " \n"; } echo " </td>\n"; echo "<td> Current in stock </td>"; for ($i = 0; $i != ore_get_ore_count(); $i++) { $fo = "ore" . $i . "c"; echo "<td align=right><font color=" . ${$fo} . ">" . $stock_ores[$i] . "</font></td>"; } echo "</tr>\n"; echo " <tr class=bl>"; echo "<td> Upkeep per tick </td>"; for ($i = 0; $i != ore_get_ore_count(); $i++) { $fo = "ore" . $i . "c"; echo "<td align=right><font color=" . ${$fo} . ">" . $upkeep_ores[$i] . "</font></td>"; } echo "</tr>\n"; } // while if ($first_row == false) { echo "</table>\n"; // Close last sector echo "<br><br>\n"; } }
function graphics_print_wormhole($img, $startX, $startY, $size, $wormhole) { global $red; $font = 2; if ($size == 400) { $font = 1; } $result = sql_query("SELECT * FROM w_wormhole WHERE id=" . $wormhole['id']); $worminfo = sql_fetchrow($result); $sector = sector_get_sector($wormhole['sector_id']); list($x1, $y1) = graphics_calc_xy($startX, $startY, $size, $sector['distance'], $sector['angle'], "YES"); list($x2, $y2) = graphics_calc_xy($startX, $startY, $size, $worminfo['distance'], $worminfo['angle'], "YES"); imageline($img, $x1, $y1, $x2, $y2, $red); graphics_set_point($img, $font, $x2, $y2, $wormhole['name'], $red); }
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"); }
function conview_show_sector($user_id, $sector_id, $planets) { assert(is_numeric($user_id)); assert(is_numeric($sector_id)); assert(is_array($planets)); global $_RUN; $tmpvar3 = array(); // Check how many planets we own in this sector. If none, don't show anything... $result = sql_query("SELECT COUNT(*) AS count FROM s_anomalies WHERE sector_id = " . $sector_id . " AND user_id=" . $user_id, JUST_ONE_ALLOWED); $tmp = sql_fetchrow($result); if ($tmp['count'] == 0) { return; } // Get sector information $sector = sector_get_sector($sector_id); // Get planet information for all planets in the sector $result = sql_query("SELECT * FROM s_anomalies WHERE sector_id=" . $sector_id . " AND user_id=" . $user_id . " ORDER BY distance", MULTIPLE_ALLOWED); while ($planet = sql_fetchrow($result)) { // If we can't view the planet, then don't show it... if (!in_array($planet['id'], $planets)) { continue; } // Can we show this planet (eg, is it in our $planets-array) if (!empty($visible_planets) && !in_array($planet['id'], $visible_planets)) { continue; } $tmpvar = array(); $tmpvar['name'] = $planet['name']; $tmpvar['href'] = "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']); if (anomaly_is_planet($planet['id'])) { $tmpvar['viewstring'] = "View Planet"; } else { $tmpvar['viewstring'] = "View Anomaly"; } $tmpvar2 = array(); if (planet_is_habitable($planet['id']) or planet_is_minable($planet['id'])) { $tmpvar2['href'] = "surface.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']); $tmpvar2['str'] = "Surface View"; $tmpvar['href_array'][] = $tmpvar2; $tmpvar2['href'] = "construct.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']); $tmpvar2['str'] = "Construction"; $tmpvar['href_array'][] = $tmpvar2; $tmpvar2['href'] = "manufacture.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']); $tmpvar2['str'] = "Manufacturing"; $tmpvar['href_array'][] = $tmpvar2; if (planet_has_vesselbuilding_capability($planet['id'])) { $tmpvar2['href'] = "vesselcreate.php?cmd=" . encrypt_get_vars("showaid") . "&aid=" . encrypt_get_vars($planet['id']); $tmpvar2['str'] = "Create Vessel"; $tmpvar['href_array'][] = $tmpvar2; } else { $tmpvar2['href'] = ""; $tmpvar2['str'] = ""; $tmpvar['href_array'][] = $tmpvar2; } } else { $tmpvar2['href'] = ""; $tmpvar2['str'] = ""; $tmpvar['href_array'][] = $tmpvar2; $tmpvar['href_array'][] = $tmpvar2; $tmpvar['href_array'][] = $tmpvar2; $tmpvar['href_array'][] = $tmpvar2; } $tmpvar3[] = $tmpvar; } // while $template = new Smarty(); $template->debugging = true; $template->assign("sector_id", $sector['sector']); $template->assign("sector_name", $sector['name']); $template->assign("planets", $tmpvar3); $template->display($_RUN['theme_path'] . "/conview.tpl"); }
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 trade_create_route($user_id) { assert(is_numeric($user_id)); $found_at_least_one_ship = false; $result = sql_query("SELECT g.* FROM g_vessels AS g, s_vessels AS s WHERE g.user_id={$user_id} AND s.id = g.vessel_id AND s.type='" . VESSEL_TYPE_TRADE . "'"); while ($vessel = sql_fetchrow($result)) { if (!vessel_in_traderoute($vessel['id'])) { $found_at_least_one_ship = true; } } if ($found_at_least_one_ship == false) { print_line("You do not have any tradeships currently available for setting up a traderoute"); return; } print_remark("Create form"); form_start(); echo " <input type=hidden name=cmd value=" . encrypt_get_vars("create2") . ">\n"; echo " <table align=center>\n"; echo " <tr>\n"; echo " <td> Vessel: </td>\n"; echo " <td>\n"; echo " <select name=vid>\n"; $result = sql_query("SELECT g.* FROM g_vessels AS g, s_vessels AS s WHERE g.user_id={$user_id} AND s.id = g.vessel_id AND s.type='" . VESSEL_TYPE_TRADE . "'"); while ($vessel = sql_fetchrow($result)) { if (!trade_is_vessel_in_route($vessel['id'])) { echo " <option value=" . encrypt_get_vars($vessel['id']) . ">" . $vessel['name'] . "</option>\n"; } } echo " </select>\n"; echo " </td>\n"; echo " </tr>\n"; echo " <tr><td> </td></tr>\n"; echo " <tr>\n"; echo " <td> Source Planet: </td>\n"; echo " <td>\n"; echo " <select name=src_pid>\n"; $result = sql_query("SELECT a.*,s.name AS sectorname FROM s_anomalies AS a, s_sectors AS s WHERE a.user_id={$user_id} AND a.type='P' AND a.sector_id = s.id"); while ($planet = sql_fetchrow($result)) { if (anomaly_is_planet($planet['id']) and planet_is_minable($planet['id'])) { echo " <option value=" . encrypt_get_vars($planet['id']) . ">" . $planet['sectorname'] . " / " . $planet['name'] . "</option>\n"; } } echo " </select>\n"; echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td> Ores: </td>\n"; echo " <td>"; echo " <table border=0 cellspacing=0 colspacing=0>\n"; echo " <tr>"; for ($i = 0; $i != ore_get_ore_count(); $i++) { if ($i % 3 == 0) { echo " </tr>\n"; echo " <tr>\n"; } echo " <td><input type=checkbox name=src_ore_" . $i . ">" . ore_get_ore_name($i) . "</td>\n"; } echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " <tr><td colspan=2> </td></tr>\n"; echo " <tr>\n"; echo " <td> Destination Planet: </td>\n"; echo " <td>\n"; echo " <select name=dst_pid>\n"; $result = sql_query("SELECT * FROM g_anomalies WHERE user_id={$user_id}"); $planetlist = csl_create_array($result, 'csl_discovered_id'); // Get all planets which we own... foreach ($planetlist as $planet_id) { $planet = anomaly_get_anomaly($planet_id); if ($planet['user_id'] == 0) { continue; } if ($planet['user_id'] != $user_id) { continue; } if (user_is_mutual_friend($user_id, $planet['user_id']) and anomaly_is_planet($planet['id']) and planet_is_minable($planet['id'])) { $sector = sector_get_sector($planet['sector_id']); echo " <option value=" . encrypt_get_vars($planet['id']) . ">" . $sector['name'] . " / " . $planet['name'] . "</option>\n"; } } // And now, all other planets with a different user_id foreach ($planetlist as $planet_id) { $planet = anomaly_get_anomaly($planet_id); if ($planet['user_id'] == 0) { continue; } if ($planet['user_id'] == $user_id) { continue; } if (user_is_mutual_friend($user_id, $planet['user_id']) and anomaly_is_planet($planet['id']) and planet_is_minable($planet)) { $sector = sector_get_sector($planet['sector_id']); $race = user_get_race($planet['user_id']); echo " <option value=" . encrypt_get_vars($planet['id']) . ">(" . $race . ") " . $sector['name'] . " / " . $planet['name'] . "</option>\n"; } } echo " </select>\n"; echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td> Ores: </td>\n"; echo " <td>\n"; echo " <table border=0 cellspacing=0 colspacing=0>\n"; echo " <tr>\n"; for ($i = 0; $i != ore_get_ore_count(); $i++) { if ($i % 3 == 0) { echo " </tr>\n"; echo " <tr>\n"; } echo " <td><input type=checkbox name=dst_ore_" . $i . ">" . ore_get_ore_name($i) . "</td>\n"; } echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " <tr><td colspan=2> </td></tr>\n"; echo " <tr><td></td><td><input type=submit name=submit value='create traderoute'></td></tr>\n"; echo " </table>\n"; form_end(); }
function user_showinfo($user_id, $extended_info = USER_SHOWINFO_NORMAL) { assert(is_numeric($user_id)); $user = user_get_user($user_id); $px_user = user_get_perihelion_user($user_id); $result = sql_query("SELECT * FROM perihelion.u_access WHERE user_id=" . $user_id . " ORDER BY login DESC LIMIT 1"); $access = sql_fetchrow($result); sql_query("USE " . $px_user['galaxy_db']); $result = sql_query("SELECT SUM(population) FROM s_anomalies WHERE user_id=" . $user_id); $row = sql_fetchrow($result); $people = $row['0']; $result = sql_query("SELECT COUNT(*) FROM s_sectors WHERE user_id=" . $user_id); $row = sql_fetchrow($result); $sectors_owned = $row['0']; $result = sql_query("SELECT COUNT(*) FROM s_anomalies WHERE user_id=" . $user_id); $row = sql_fetchrow($result); $planets_owned = $row['0']; $result = sql_query("SELECT DISTINCT sector_id, COUNT(*) FROM s_anomalies WHERE user_id=" . $user_id . " GROUP BY sector_id"); $sector_count = sql_countrows($result); $sector = sector_get_sector(user_get_home_sector($user_id)); $planet = anomaly_get_anomaly(user_get_home_planet($user_id)); $race = user_get_race($user_id); $result = sql_query("SELECT * FROM g_alliance WHERE id=" . $user['alliance_id']); $alliance = sql_fetchrow($result); if ($user['alliance_id'] != 0) { $result = sql_query("SELECT COUNT(*) AS count FROM g_users WHERE alliance_id = " . $alliance['id']); $tmp = sql_fetchrow($result); $alliance_size = $tmp['count']; } $status = "Unknown"; if (user_is_friend(user_ourself(), $user_id)) { $status = "Single side friend"; } if (user_is_mutual_friend(user_ourself(), $user_id)) { $status = "Mutual friend"; } if (user_is_neutral(user_ourself(), $user_id)) { $status = "Neutral"; } if (user_is_enemy(user_ourself(), $user_id)) { $status = "Enemy"; } if (user_ourself() == $user_id) { $status = ""; } echo "<table border=0 align=center width=60%>"; echo "<tr><th class=white colspan=2>" . $px_user['name'] . "</th><th> </th></tr>"; echo "<tr><th colspan=2><b>" . $px_user['tag'] . "</b></th></tr>"; echo "<tr valign=top>"; echo " <td width=120>"; echo " <img width=100 height=100 src='images/users/" . $px_user['avatar'] . "'><br>"; echo " <br>"; if ($user['alliance_id'] != 0) { echo " <img width=100 height=100 src='images/users/" . $alliance['avatar'] . "'><br>"; } echo " </td>"; echo " <td><table border=0 nowrap>"; echo " <tr class=bl><td> Full Name </td><td>:</td><td> " . $px_user['name'] . " </td></tr>"; echo " <tr class=bl><td> User ID </td><td>:</td><td> " . $px_user['id'] . " </td></tr>"; echo " <tr class=bl><td> City </td><td>:</td><td> " . $px_user['city'] . " </td></tr>"; echo " <tr class=bl><td> Country </td><td>:</td><td> " . $px_user['country'] . " </td></tr>"; echo " <tr><td colspan=3> </td></tr>"; if ($status != "") { echo " <tr class=bl><td> Diplomatic Status </td><td>:</td><td> " . $status . " </td></tr>"; } echo " <tr class=bl><td> Race </td><td>:</td><td> " . $race . " </td></tr>"; echo " <tr class=bl><td> Home Planet </td><td>:</td><td> " . $planet['name'] . " </td></tr>"; echo " <tr class=bl><td> Home Sector </td><td>:</td><td> " . $sector['name'] . " </td></tr>"; echo " <tr class=bl><td> Population </td><td>:</td><td> " . $people . " </td></tr>"; echo " <tr class=bl><td> Sectors Owned </td><td>:</td><td> " . $sectors_owned . " </td></tr>"; echo " <tr class=bl><td> Planets Owned </td><td>:</td><td> " . $planets_owned . " planet(s) in " . $sector_count . " sector(s) </td></tr>"; if ($user['alliance_id'] != 0) { echo " <tr class=bl><td> Alliance </td><td>:</td><td> <a href=alliance.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($alliance['id']) . ">" . $alliance['name'] . "</a> </td></tr>"; echo " <tr class=bl><td> Alliance Size </td><td>:</td><td> " . $alliance_size . " user(s) </td></tr>"; } echo " <tr><td colspan=3> </td></tr>"; echo " <tr class=bl><td> Times logged in </td><td>:</td><td> " . $px_user['login_count'] . " </td></tr>"; echo " <tr class=bl><td> Last login </td><td>:</td><td> " . $access['login'] . " </td></tr>"; echo " <tr class=bl><td> Last action </td><td>:</td><td> " . $access['logout'] . " </td></tr>"; if ($extended_info == USER_SHOWINFO_EXTENDED) { if ($px_user['gender'] == "M") { $gender = "Male"; } else { $gender = "Female"; } echo " <tr><td colspan=3> </td></tr>"; echo " <tr class=bl><td> Email </td><td>:</td><td> " . $px_user['email'] . " </td></tr>"; echo " <tr class=bl><td> Login Name </td><td>:</td><td> " . $px_user['login_name'] . " </td></tr>"; echo " <tr><td colspan=3> </td></tr>"; echo " <tr class=bl><td> City </td><td>:</td><td> " . $px_user['city'] . " </td></tr>"; echo " <tr class=bl><td> Country </td><td>:</td><td> " . $px_user['country'] . " </td></tr>"; echo " <tr><td colspan=3> </td></tr>"; echo " <tr class=bl><td> Birthday </td><td>:</td><td> " . $px_user['birthday'] . " </td></tr>"; echo " <tr class=bl><td> Gender </td><td>:</td><td> " . $gender . " </td></tr>"; } if ($user_id != user_ourself()) { echo "<tr><th colspan=3>"; echo "[ <a href=message.php?uid=" . encrypt_get_vars($user_id) . ">Send Message</a> ]"; echo "</th></tr>"; echo "<tr><th colspan=3>"; echo "[ <a href=user.php?cmd=" . encrypt_get_vars("relation") . "&uid=" . encrypt_get_vars($user_id) . "&wid=" . encrypt_get_vars(RELATION_FRIEND) . ">Set as friend</a> ] - "; echo "[ <a href=user.php?cmd=" . encrypt_get_vars("relation") . "&uid=" . encrypt_get_vars($user_id) . "&wid=" . encrypt_get_vars(RELATION_NEUTRAL) . ">Set as neutral</a> ] - "; echo "[ <a href=user.php?cmd=" . encrypt_get_vars("relation") . "&uid=" . encrypt_get_vars($user_id) . "&wid=" . encrypt_get_vars(RELATION_ENEMY) . ">Set as enemy</a> ]"; echo "</th></tr>"; } echo " </table></td>"; echo "</tr>"; echo "</table>"; echo "<br><br>"; }
function planet_show_planet($planet_id) { assert(!empty($planet_id)); global $_GALAXY; global $_CONFIG; global $_RUN; if (!anomaly_is_planet($planet_id)) { return; } $planet = anomaly_get_anomaly($planet_id); $result = sql_query("SELECT * FROM g_ores WHERE planet_id=" . $planet_id); $ore = sql_fetchrow($result); $stock_ore = ore_csl_to_list($ore['stock_ores']); $race = user_get_race($planet['user_id']); $sector = sector_get_sector($planet['sector_id']); $result = sql_query("SELECT * FROM s_state WHERE id=" . $planet['state_id']); $state = sql_fetchrow($result); if ($race == "") { $race = "-"; } $extra_attack = 0; $extra_defense = 0; $attack = $planet['cur_attack']; $defense = $planet['cur_attack']; // Count all ships and their attack/defense currently in orbit around the planet $result = sql_query("SELECT COUNT(*) FROM g_vessels AS g, s_vessels AS s WHERE g.planet_id=" . $planet_id . " AND s.id = g.vessel_id AND s.type='" . VESSEL_TYPE_BATTLE . "' AND status='ORBIT' AND created=1"); $tmp = sql_fetchrow($result); $battle_vessels = $tmp[0]; $result = sql_query("SELECT COUNT(*) FROM g_vessels AS g, s_vessels AS s WHERE g.planet_id=" . $planet_id . " AND s.id = g.vessel_id AND s.type='" . VESSEL_TYPE_TRADE . "' AND status='ORBIT' AND created=1"); $tmp = sql_fetchrow($result); $trade_vessels = $tmp[0]; $result = sql_query("SELECT COUNT(*) FROM g_vessels AS g, s_vessels AS s WHERE g.planet_id=" . $planet_id . " AND s.id = g.vessel_id AND s.type='" . VESSEL_TYPE_EXPLORE . "' AND status='ORBIT' AND created=1"); $tmp = sql_fetchrow($result); $explore_vessels = $tmp[0]; $result = sql_query("SELECT SUM(cur_attack) AS CA, SUM(cur_defense) AS CD FROM g_vessels AS g WHERE g.planet_id=" . $planet_id . " AND status='ORBIT' AND created=1"); $tmp = sql_fetchrow($result); if (isset($tmp['CA'])) { $extra_attack = $extra_attack + $tmp['CA']; } if (isset($tmp['CD'])) { $extra_defense = $extra_defense + $tmp['CD']; } $template = new Smarty(); $template->debugging = true; $template->assign("sector_name", $sector['name']); $template->assign("planet_name", $planet['name']); $template->assign("image", $_CONFIG['IMAGE_URL'] . $_GALAXY['image_dir'] . "/planets/" . $planet['image'] . ".jpg"); if ($planet['unknown'] == 1) { $template->assign("cmd", encrypt_get_vars("claim")); $template->assign("formid", generate_form_id()); $template->assign("aid", encrypt_get_vars($planet_id)); $template->assign("rename_form_visible", "true"); } else { $template->assign("rename_form_visible", "false"); } $template->assign("class", $planet['class']); $template->assign("race", $race); $template->assign("state", $state['name']); $template->assign("happieness", planet_get_happy_string($planet['happieness'])); $template->assign("healtieness", planet_get_healty_string($planet['sickness'])); $template->assign("population", $planet['population']); $template->assign("radius", $planet['radius']); $template->assign("distance", $planet['distance']); $template->assign("water", $planet['water']); $template->assign("temperature", $planet['temperature']); for ($i = 0; $i != ore_get_ore_count(); $i++) { $tmp = array(); $tmp['name'] = ore_get_ore_name($i); $tmp['stock'] = $stock_ore[$i]; $tmpvar[] = $tmp; } $template->assign("ores", $tmpvar); $template->assign("attack", $attack); $template->assign("extra_attack", $extra_attack); $template->assign("defense", $defense); $template->assign("extra_defense", $extra_defense); $template->assign("strength", $planet['cur_strength']); $template->assign("orbit_battle", $trade_vessels); $template->assign("orbit_trade", $battle_vessels); $template->assign("orbit_explore", $explore_vessels); $template->assign("description", convert_px_to_html_tags($planet['description'])); $template->display($_RUN['theme_path'] . "/planet-details.tpl"); $commands = array(); // If we have at least 1 ship in orbit, we can view them here... if ($explore_vessels + $trade_vessels + $battle_vessels > 0) { $commands['View Vessels'] = "vessel.php?cmd=" . encrypt_get_vars("showaid") . "&aid=" . encrypt_get_vars($planet_id); } // If it's a solid-class planet (lower than M), we can view the surface. if (planet_is_habitable($planet_id) or planet_is_minable($planet_id)) { $commands['View Surface'] = "surface.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet_id); } // If it's our planet we might construct and manufacture,.. if (anomaly_am_i_owner($planet['id'])) { $commands['Change Description'] = "anomaly.php?cmd=" . encrypt_get_vars("description") . "&aid=" . encrypt_get_vars($planet_id); // Only minable or habitable or lower can construct if (planet_is_habitable($planet_id) or planet_is_minable($planet_id)) { $commands['Construct'] = "construct.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet_id); $commands['Manufacture'] = "manufacture.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet_id); } if (planet_has_vesselbuilding_capability($planet_id)) { $commands['Create Vessel'] = "vesselcreate.php?cmd=" . encrypt_get_vars("showaid") . "&aid=" . encrypt_get_vars($planet_id); } } create_submenu($commands); }
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>"; } } }
function mining_show_sector($sector_id, $user_id) { assert(!empty($sector_id)); assert(!empty($user_id)); // Check how many planets we own in this sector. If none, don't show anything... $result = sql_query("SELECT COUNT(*) AS count FROM s_anomalies WHERE sector_id = " . $sector_id . " AND user_id=" . $user_id); $tmp = sql_fetchrow($result); if ($tmp['count'] == 0) { return; } // Get sector information $sector = sector_get_sector($sector_id); // Only show a table if we got rows in it... $first_row = true; // Get planet information for all planets in the sector $result = sql_query("SELECT * from s_anomalies WHERE user_id=" . $user_id . " AND type='P' AND sector_id=" . $sector['id']); while ($planet = sql_fetchrow($result)) { # if (!in_array ($planet['id'], $planets)) continue; $result2 = sql_query("SELECT * FROM g_ores WHERE planet_id=" . $planet['id']); $ores = sql_fetchrow($result2); $cur_ores = ore_csl_to_list($ores['cur_ores']); $max_ores = ore_csl_to_list($ores['max_ores']); for ($i = 0; $i != ore_get_ore_count(); $i++) { $fo = "ore" . $i . "c"; if ($max_ores[$i] == 0) { $tmp = 0; } else { $tmp = $cur_ores[$i] / $max_ores[$i] * 100; } ${$fo} = "white"; if ($tmp > 50) { ${$fo} = "yellow"; } if ($tmp > 75) { ${$fo} = "orange"; } if ($tmp > 99) { ${$fo} = "red"; } } # Only show a table if we have rows in it... if ($first_row) { $first_row = false; print_remark("Sector table"); echo "<table align=center border=0>\n"; echo " <tr class=wb><td colspan=" . (ore_get_ore_count() + 2) . "><b><i>Sector " . $sector['sector'] . ": " . $sector['name'] . "</i></b></td></tr>\n"; echo " <tr class=bl><th>Name</th>"; for ($i = 0; $i != ore_get_ore_count(); $i++) { echo "<th>" . ore_get_ore_name($i) . "</th>"; } echo "</tr>\n"; } if (!planet_is_minable($planet['id'])) { echo " <tr class=bl>"; echo "<td> Planet " . $planet['name'] . " </td>"; echo "<th colspan=" . ore_get_ore_count() . ">No mining possible</th>"; echo "</tr>\n"; } else { echo " <tr class=bl>"; echo "<td> <a href=\"anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']) . "\">Planet " . $planet['name'] . "</a> </td>"; for ($i = 0; $i != ore_get_ore_count(); $i++) { $fo = "ore" . $i . "c"; echo "<td><font color=" . ${$fo} . ">" . $cur_ores[$i] . "</font></td>"; } echo "</tr>\n"; } } // while if ($first_row == false) { echo "</table>\n"; // Close last sector echo "<br><br>\n"; } }