function get_fleet_items($id, $sql_foreign_key) { global $uid; global $map_info; $sth = mysql_query("SELECT * FROM fleet_info WHERE " . $sql_foreign_key . "=" . $id . " order by uid"); if (!$sth || !mysql_num_rows($sth)) { return false; } $i = 0; $ships = array(); while ($fleets = mysql_fetch_assoc($sth)) { $ships[$i] = array(); $its_fleet = new fleet($fleets["fid"]); $its_fid = $fleets["fid"]; // get fleets userdata // ALLIANZ $sth2 = mysql_query("select u.name, u.imperium, a.name as alliance_name, a.color, a.symbol, a.milminister from users u left outer join alliance a on a.id=u.alliance where u.id=" . $fleets["uid"]); if (!$sth2 || !mysql_num_rows($sth2)) { return 0; } $fleets_user_info = mysql_fetch_array($sth2); if ($fleets_user_info["alliance_name"]) { $return_array[$i]["allianceName"] = htmlspecialchars($fleets_user_info["alliance_name"]); $return_array[$i]["allianceColor"] = $fleets_user_info["color"]; if ($fleets_user_info["symbol"]) { $return_array[$i]["allianceSymbol"] = $fleets_user_info["symbol"]; } else { $return_array[$i]["allianceSymbol"] = 0; } } else { $return_array[$i]["allianceName"] = 0; $return_array[$i]["allianceColor"] = 0; $return_array[$i]["allianceSymbol"] = 0; } // all items same data $return_array[$i]["picture"] = get_fleet_pic($its_fid); $return_array[$i]["topic"] = htmlspecialchars($fleets["name"]); $return_array[$i]["description"] = htmlspecialchars($fleets["name"]); $return_array[$i]["oid"] = $fleets["fid"]; $return_array[$i]["sid"] = $fleets["sid"]; $return_array[$i]["pid"] = $fleets["pid"]; $return_array[$i]["tsid"] = $fleets["tsid"]; $return_array[$i]["tpid"] = $fleets["tpid"]; $return_array[$i]["relationClass"] = get_uids_relation($uid, $fleets["uid"], 1); $return_array[$i]["footer"] = false; $is_commanded_by_mod = $its_fleet->milminister == 1 && $fleets_user_info["milminister"] == $uid; if ($uid == $its_fleet->uid || $is_commanded_by_mod) { $its_mission = get_mission_by_mission_id($fleets["mission"]); $its_target = get_fleets_target($its_fid); // full fleet item, own or borrowed units $return_array[$i]["itemType"] = "FULL_FLEET_ITEM"; $return_array[$i]["type"] = "fleet"; // sounds // okay, suboptimal weil gleiche funkiion schon bei get_fleet_pic aufgerufen wird :S, bin jetzt aba faul $strongest_ship = get_strongest_ship_by_fid($its_fid); // ggf noch sounds von admirälen einfügen $sound_array = get_sound_by_prod_id($strongest_ship); $return_array[$i]["soundReport"] = $sound_array["report"]; $return_array[$i]["soundConfirm"] = $sound_array["confirm"]; // Target if ($its_target["planet"]["tid"] || $its_target["system"]["tid"]) { // ETA berechnen $return_array[$i]["eta"] = get_true_ETA_by_fid($its_fid); if ($its_target["planet"]["tid"]) { $return_array[$i]["target"] = get_planetname($its_target["planet"]["tid"]); } else { $return_array[$i]["target"] = get_systemname($its_target["system"]["tid"]); } } // Mission $return_array[$i]["missionSymbol"] = $its_mission[2]; $return_array[$i]["missionName"] = $its_mission[0]; $return_array[$i]["mission"] = $fleets["mission"]; // Tactics $return_array[$i]["tactic"] = $fleets["tactic"]; $return_array[$i]["tacticSymbol"] = 0; $return_array[$i]["tacticName"] = get_tactic_by_tacticflag($fleets["tactic"]); // Reloading? $return_array[$i]["reloadSymbol"] = get_reload($its_fid); // Infantry aboard? $return_array[$i]["infantrySymbol"] = get_infantrycount_by_fid($its_fid); // Minister of Defence $return_array[$i]["modSymbol"] = $fleets["milminister"]; // FLEET CONTROL //manage fleet if (!$is_commanded_by_mod) { $return_array[$i]["fleet_control"] .= "<SR_FLEET_CONTROL type=\"SR_SIMPLE_ACTION\" face=\"control_button_manage_fleet.svgz\" controlName=\"manage fleet\" description=\"manage fleet\"/>"; } $planet_uid = get_uid_by_pid($its_fleet->pid); // transfer infantry if ($its_fleet->get_total_transporter_capacity() > 0 && ($planet_uid == $its_fleet->uid || is_allied($planet_uid, $its_fleet->uid)) || has_infantry_on_planet($its_fleet->pid, $its_fleet->uid)) { $return_array[$i]["fleet_control"] .= "<SR_FLEET_CONTROL type=\"SR_SIMPLE_ACTION\" face=\"control_button_inf_transfer.svgz\" controlName=\"transfer infantry\" description=\"transfer infantry\"/>"; } } else { // bäh, mir fällt kein anständiges query ein $light = 0; $medium = 0; $heavy = 0; $sth3 = mysql_query("select sum(count), typ as shipcount from fleet join production using(prod_id) where fid='" . $its_fid . "' group by typ"); if (!$sth3 || !mysql_num_rows($sth3)) { return 0; } while (list($shipcount, $typ) = mysql_fetch_row($sth3)) { switch ($typ) { case "L": $light = $shipcount; break; case "M": $medium = $shipcount; break; case "H": $heavy = $shipcount; break; } } $return_array[$i]["footer"] = $heavy . " " . $medium . " " . $light; $return_array[$i]["type"] = "fleet"; $return_array[$i]["text1"] = htmlspecialchars($fleets_user_info["name"]); $return_array[$i]["text2"] = htmlspecialchars($fleets_user_info["imperium"]); if ($return_array[$i]["relationClass"] == "colorAllied") { $return_array[$i]["itemType"] = "ADVANCED_FLEET_ITEM"; $return_array[$i]["fleet_control"] .= "<SR_FLEET_CONTROL type=\"SR_SIMPLE_ACTION\" face=\"control_button_examine_fleet.svgz\" controlName=\"examine fleet\" description=\"view fleet details\"/>"; } else { $return_array[$i]["itemType"] = "FLEET_ITEM"; // fleet control buttons, keine Attribute sondern childs, nur nach den Attributen im $return_array auflisten! // special actions $special_actions = get_special_fleet_actions($its_fid, "fleet"); if (is_array($special_actions)) { for ($j = 0; $j < sizeof($special_actions); $j++) { $return_array[$i]["fleet_control"] .= "<SR_FLEET_CONTROL type=\"SR_SPECIAL_ACTION\" face=\"" . $special_actions[$j]["picture"] . "\" controlName=\"" . $special_actions[$j]["name"] . "\" description=\"" . $special_actions[$j]["description"] . "\" controlId=\"" . $special_actions[$j]["action_id"] . "\""; $return_array[$i]["fleet_control"] .= " metal=\"" . $special_actions[$j]["metal"] . "\" energy=\"" . $special_actions[$j]["energy"] . "\" mopgas=\"" . $special_actions[$j]["mopgas"] . "\" erkunum=\"" . $special_actions[$j]["erkunum"] . "\" gortium=\"" . $special_actions[$j]["gortium"] . "\" susebloom=\"" . $special_actions[$j]["susebloom"] . "\"/>"; } } // fleet control EXAMINE FLEET falls die flotte sich in unmittelbarer Nähe zu dem user und seinen alliierten befindet if (fleet_is_examinable($its_fid, $its_fleet->sid) == "true") { $return_array[$i]["fleet_control"] .= "<SR_FLEET_CONTROL type=\"SR_SIMPLE_ACTION\" face=\"control_button_examine_fleet.svgz\" controlName=\"examine fleet\" description=\"view fleet details\"/>"; if (has_noscan_ships_and_constructions($its_fid)) { $return_array[$i]["picture"] = "animationRauschen"; $return_array[$i]["footer"] = "0 0 0"; } } else { // wenn in scanrange, aber nicht wirklih sichbar, picture zu p_unknown.jpg ändern $return_array[$i]["picture"] = PIC_ROOT . "p_unknown.png"; if (has_noscan_ships_and_constructions($its_fid)) { $return_array[$i]["footer"] = "0 0 0"; } } } } if ($uid == $its_fleet->uid || $map_info->is_allied($its_fleet->uid) || fleet_is_examinable($its_fid)) { // mop: alle schiffsnamen $prod_ids = array_keys($its_fleet->ships); $sth2 = mysql_query("select prod_id,name,typ from production where prod_id in (" . implode(",", $prod_ids) . ")"); while (list($prod_id, $name, $typ) = mysql_fetch_row($sth2)) { $ship_data = $its_fleet->ships[$prod_id]; $ship_data[] = $name; $ship_data[] = $typ; $ships[$i][$prod_id] = $ship_data; // mop: enthält dann array aus count und reload } } $i++; } return array($return_array, $ships); }
function execute_examinefleet() { global $uid; $its_fleet = new fleet($_GET["fid"]); $can_see = false; if ($its_fleet->uid == $uid) { show_svg_message("There should be no button that would allow you doing this. :S"); return false; } $allies = get_allied_ids($uid); if (is_array($allies)) { array_push($allies, $uid); } else { $allies[] = $uid; } $allied_fleet = in_array($its_fleet->uid, $allies); // check ob eigene oder alleierte planeten im system sind $sth = mysql_query("select 1 from planets where sid=" . $its_fleet->sid . " and uid in (" . implode(",", $allies) . ") LIMIT 1"); if (!$sth) { show_svg_message("There was an Database error #mcontrol:exec_exam_fleet:1"); return false; } if (mysql_num_rows($sth) > 0) { $can_see = true; } // check ob eigene oder alleierte flotten im system sind if (!$can_see) { $sth = mysql_query("select 1 from fleet_info where sid=" . $its_fleet->sid . " and uid in (" . implode(",", $allies) . ") LIMIT 1"); if (!$sth) { show_svg_message("There was an Database error #mcontrol:exec_exam_fleet:2"); return false; } if (mysql_num_rows($sth) > 0) { $can_see = true; } } if (can_see) { $doc = domxml_new_doc("1.0"); $rootElem = $doc->create_element("SR_REQUEST"); $rootElem->set_attribute("type", "examine_fleet"); $rootElem->set_attribute("fid", $its_fleet->fid); $rootElem->set_attribute("owner", $its_fleet->uid); $missionElem = $doc->create_element("SR_FLEET_MISSION"); $no_scan = false; // mission if ($allied_fleet) { // alleierte Flotte, wir sehen die mission // mission kann sich unterscheiden wenn das ziel feindlich ist. $no_target = false; $target_relation = false; if ($its_fleet->tsid > 0 && $its_fleet->tpid > 0) { $sth = mysql_query("SELECT s.name as s_name, p.name, p.uid, p.type, p.id FROM systems s LEFT JOIN planets p on s.id = p.sid WHERE s.id = " . $its_fleet->tsid . " and p.id=" . $its_fleet->tpid); } elseif ($its_fleet->tsid > 0) { $sth = mysql_query("SELECT name as s_name from systems where id = " . $its_fleet->tsid); } else { $no_target = true; } if (!$no_target) { if (!$sth || mysql_num_rows($sth) == 0) { show_svg_message("ERR::Can not get Target"); return false; } $target_info = mysql_fetch_assoc($sth); if ($target_info["s_name"]) { $missionElem->set_attribute("tsys_name", htmlspecialchars($target_info["s_name"])); } if ($target_info["name"]) { if ($target_info["name"] == "Unnamed") { $target_info["name"] = get_planetname($target_info["id"]); } $missionElem->set_attribute("tpla_name", htmlspecialchars($target_info["name"])); $missionElem->set_attribute("tpla_type", $target_info["type"]); if ($target_info["uid"] > 0) { $target_relation = get_uids_relation($its_fleet->uid, $target_info["uid"]); } } $eta = get_true_ETA_by_fid($its_fleet->fid); $rootElem->set_attribute("eta", $eta); } switch ($its_fleet->mission) { case M_MOVE: if ($target_relation == "enemy") { $missionElem->set_attribute("mission", "fleet_mission_attack.svgz"); $missionElem->set_attribute("missionText", "Attacking"); } elseif ($target_relation == "allie" || $target_relation == "same" || $its_fleet->tsid == 0) { $missionElem->set_attribute("mission", "fleet_mission_defend.svgz"); $missionElem->set_attribute("missionText", "Defending"); } else { $missionElem->set_attribute("mission", "fleet_mission_move.svgz"); $missionElem->set_attribute("missionText", "Moving"); } break; case M_INVADE: $missionElem->set_attribute("mission", "fleet_mission_invade.svgz"); $missionElem->set_attribute("missionText", "Invading"); break; case M_BOMB: $missionElem->set_attribute("mission", "fleet_mission_bomb.svgz"); $missionElem->set_attribute("missionText", "Bombarding"); break; case M_COLONIZE: $missionElem->set_attribute("mission", "fleet_mission_colonize.svgz"); $missionElem->set_attribute("missionText", "Colonizing"); break; } $missionElem->set_attribute("tactic", $its_fleet->tactic); } else { $missionElem->set_attribute("mission", "fleet_mission_unknown.svgz"); $missionElem->set_attribute("missionText", "unknown mission"); $missionElem->set_attribute("tactic", "-1"); // gucken ob wir no-scan schiffe haben (special 'N' in shipvalues) $sth = mysql_query("SELECT s.prod_id FROM fleet f, shipvalues s WHERE s.special = 'N' AND s.prod_id = f.prod_id AND f.fid = " . $its_fleet->fid); if (!$sth) { show_svg_message("ERROR::Getting NOSCAN ships"); return false; } if (mysql_num_rows($sth) > 0) { $no_scan = true; } // gucken ob der planet vielleicht so nen gebäude hat?? if (!$no_scan && $its_fleet->pid > 0) { // alleierte der flotte $fleet_allies = get_allied_ids($its_fleet->uid); if (is_array($fleet_allies)) { array_push($fleet_allies, $its_fleet->uid); } else { $fleet_allies[] = $its_fleet->uid; } $sth = mysql_query("SELECT s.prod_id FROM planets p, constructions c join shipvalues s using(prod_id) where s.special='N' and c.pid = p.id and p.id = " . $its_fleet->pid . " and p.uid in (" . implode(",", $fleet_allies) . ")"); if (!$sth) { show_svg_message("ERROR::Getting NOSCAN buildings"); return false; } if (mysql_num_rows($sth) > 0) { $no_scan = true; } } } $rootElem->append_child($missionElem); // ships if (!$no_scan) { foreach ($its_fleet->ships as $prod_id => $values) { $shipElem = $doc->create_element("SR_SHIP"); $shipElem->set_attribute("prod_id", $prod_id); $shipElem->set_attribute("count", $values[0]); if ($allied_fleet) { $shipElem->set_attribute("reload", $values[1]); } else { $shipElem->set_attribute("reload", -1); } $rootElem->append_child($shipElem); } } // admiral $sth = mysql_query("SELECT a.pic, a.name, a.id, a.fid from admirals a join fleet_info f using(fid) having a.fid=" . $its_fleet->fid . ""); if (!$sth) { show_svg_message("There was an Database error #mcontrol:exec_exam_fleet:3"); return false; } if (mysql_num_rows($sth) > 0) { list($a_pic, $a_name, $a_id) = mysql_fetch_row($sth); $admiralElem = $doc->create_element("SR_ADMIRAL"); $admiralElem->set_attribute("name", $a_name); $admiralElem->set_attribute("pic", $a_pic); $admiralElem->set_attribute("level", get_admiral_level($a_id)); $rootElem->append_child($admiralElem); $rootElem->set_attribute("pic", "ADMIRAL"); } else { if (!$no_scan) { $rootElem->set_attribute("pic", get_strongest_ship_by_fid($its_fleet->fid)); } else { $rootElem->set_attribute("pic", 0); } } $doc->append_child($rootElem); echo $doc->dump_mem(); } else { show_svg_message("Either this is a bug or you're a h4xx0r. :S"); } }
function get_fleet_pic($fid) { if ($admiral = get_admiral($fid)) { $its_pic = ADMIRAL_ROOT . get_admiral_pic($admiral); } else { $strongest_ship = get_strongest_ship_by_fid($fid); $its_pic = PIC_ROOT . get_pic($strongest_ship); } return $its_pic; }