function get_minimap_values($colors = true, $scanrange = true, $fleets = true) { global $uid; $user_alliance = get_alliance($uid); if (!$colors) { $scanrange = false; } $sth = mysql_query("select id, uid from planets where sid=" . $this->id . " and uid != 0"); if (!$sth) { return 0; } while ($its_planets = mysql_fetch_array($sth)) { $its_uid = $its_planets["uid"]; $its_id = $its_planets["id"]; // minimap_colors if ($colors) { if ($its_uid == $uid) { $this->minimap_colors[] = "lime"; $this->scan = true; // scanrange if ($scanrange) { $its_scanradius = get_max_scan_range_by_pid($its_id); } } elseif (is_allied($its_uid, $uid)) { $this->minimap_colors[] = "yellow"; $this->scan = true; // scanrange if ($scanrange) { $its_scanradius = get_max_scan_range_by_pid($its_id); } } else { $planet_alliance = get_alliance($its_uid); if ($user_alliance && $planet_alliance && is_friendly($user_alliance, $planet_alliance)) { $this->minimap_colors[] = "orange"; } elseif ($user_alliance && $planet_alliance && is_enemy($user_alliance, $planet_alliance)) { $this->minimap_colors[] = "red"; } else { $this->minimap_colors[] = "blue"; } } } // max scanrange ermitteln if ($its_scanradius && $this->scanradius < $its_scanradius) { $this->scanradius = $its_scanradius; } } // minimap_fleets if ($fleets) { $sth = mysql_query("select distinct(uid) as unique_uid from fleet_info where sid=" . $this->id); if (!$sth || !mysql_num_rows($sth)) { return 0; } while ($its_fleets = mysql_fetch_array($sth)) { $its_uid = $its_fleets["unique_uid"]; if ($its_uid == $uid) { $this->minimap_fleets[] = "lime"; $this->scan = true; // scanrange der Flotten if ($scanrange) { $fleet_scanradius = get_max_fleet_scanrange_by_sid($this->id); } } elseif (is_allied($its_uid, $uid)) { $this->minimap_fleets[] = "yellow"; $this->scan = true; // scanrange der Flotten if ($scanrange) { $fleet_scanradius = get_max_fleet_scanrange_by_sid($this->id); } } else { $fleet_alliance = get_alliance($its_uid); if ($user_alliance && $fleet_alliance && is_friendly($user_alliance, $fleet_alliance)) { $this->minimap_fleets[] = "orange"; } elseif ($user_alliance && $fleet_alliance && is_enemy($user_alliance, $fleet_alliance)) { $this->minimap_fleets[] = "red"; } else { $this->minimap_fleets[] = "blue"; } } if ($fleet_scanradius && $this->scanradius < $fleet_scanradius) { $this->scanradius = $fleet_scanradius; } } // Scanrange if ($scanrange) { // Systeme in Scanrange $visible_systems = get_systems_in_scanrange($this->id, $this->scanradius); if (is_array($visible_systems)) { for ($j = 0; $j < sizeof($visible_systems); $j++) { $this->systems_in_scanrange[] = new MINIMAP_SYSTEM($visible_systems[$j]); } } for ($j = 0; $j < sizeof($this->systems_in_scanrange); $j++) { $this->systems_in_scanrange[$j]->get_minimap_values(true, false, true); $this->systems_in_scanrange[$j]->make_visible(); } } } // ende WHILE if (isset($this->minimap_colors[0])) { $this->minimap_colors = array_unique($this->minimap_colors); } if (isset($this->minimap_fleets[0])) { $this->minimap_fleets = array_unique($this->minimap_fleets); } }
function is_in_scanrange($uid, $sid) { global $uid; // erstmal check ob eine eigene bzw. allieerte flotte im system ist $is_in_range = false; if (is_a_fleet_in_system($uid, $sid)) { $is_in_range = true; } else { // flotten von alliierten im system? $allied = get_allied_ids($uid); for ($i = 0; $i < sizeof($allied); $i++) { if (is_a_fleet_in_system($allied[$i], $sid)) { $is_in_range = true; break; } } // ist es denn wenigstens in irgendeinem scanradius des users oder eines allierten? if (!$is_in_range) { $sth = mysql_query("select max(radius) from scanradius"); if (!$sth || mysql_num_rows($sth) == 0) { return 0; } $max_scanrange = mysql_fetch_row($sth); $systems = get_systems_in_scanrange($sid, $max_scanrange[0]); for ($i = 0; $i < sizeof($systems); $i++) { $own_star = is_own_star($systems[$i]); // auch ob er alliiert ist if ($own_star) { // nen gebäude mit ner aussreichenden scanrange? $sth = mysql_query("select p.uid,p.id,s.x,s.y from planets as p, systems as s where p.sid='{$systems[$i]}' and s.id='{$systems[$i]}'"); if (!$sth) { return 0; } while ($planets = mysql_fetch_array($sth)) { if ($planets["uid"] == $uid || is_allied($uid, $planets["uid"])) { $planets_scan_range = get_max_scan_range_by_pid($planets["id"]); if ($planets_scan_range) { $system_coords = get_system_coords($sid); $system_x = substr($system_coords, 0, strpos($system_coords, ":")); $system_y = substr($system_coords, strpos($system_coords, ":") + 1); $entfernung = calculate_distance($planets["x"], $planets["y"], $system_x, $system_y); if ($entfernung <= $planets_scan_range) { $is_in_range = true; } } } } } // end if // oder vielleicht ne flotte? if (!$is_in_range) { // $sth = mysql_query("select s.radius,fi.uid,sy.x,sy.y from scanradius as s,systems as sy, fleet as f, fleetinfo as fi where f.prod_id = s.prod_id and f.fid = fi.fid and fi.sid='$systems[$i]' and and sy.id='$systems[$i]'"); $sth = mysql_query("select fid, uid, sid from fleet_info where sid=" . $systems[$i] . ""); if (!$sth) { return 0; } if (mysql_num_rows($sth) != 0) { while ($flotten = mysql_fetch_array($sth)) { if ($flotten["uid"] == $uid || is_allied($uid, $flotten["uid"])) { $sth2 = mysql_query("select max(s.radius) from scanradius as s, fleet as f where f.fid=" . $flotten["fid"] . " and f.prod_id=s.prod_id"); $fleet_scan_range = mysql_fetch_row($sth2); if ($fleet_scan_range) { $system_coords = get_system_coords($sid); $system_x = substr($system_coords, 0, strpos($system_coords, ":")); $system_y = substr($system_coords, strpos($system_coords, ":") + 1); $fleet_coords = get_system_coords($flotten["{$sid}"]); $fleet_x = substr($fleet_coords, 0, strpos($fleet_coords, ":")); $fleet_y = substr($fleet_coords, strpos($fleet_coords, ":") + 1); $entfernung = calculate_distance($fleet_x, $fleet_y, $system_x, $system_y); if ($entfernung <= $fleet_scan_range) { $is_in_range = true; } } } } } //if (!$sth) //return 0; } } // end for } } return $is_in_range; }