function jump($fid, $sid) { global $uid; $pid = get_pid_of_jumpgate($sid); if (!$pid) { echo "no"; return 0; } $start_sid = get_sid_by_fid($fid); $start_pid = get_pid_of_jumpgate($start_sid); if (!$start_pid) { echo "no"; return 0; } $sth = mysql_query("select jv.tonnage,j.used_tonnage from jumpgates as j,jumpgatevalues as jv where j.sid={$sid} and j.pid={$pid} and jv.prod_id=j.prod_id"); if (!$sth || mysql_num_rows($sth) == 0) { echo "bug"; return 0; } $targetj = mysql_fetch_array($sth); $sth = mysql_query("select f.fid from fleet_info as f,jumpgates as j where f.sid=j.sid and j.sid!={$sid} and j.sid={$start_sid} and f.fid={$fid}"); if (!$sth) { echo "bug"; return 0; } if (mysql_num_rows($sth) == 0) { echo "same"; return 0; } $sth = mysql_query("select fi.name as fname ,fi.sid,p.name,p.typ,fi.fid,s.tonnage,f.count from fleet_info as fi,production as p,shipvalues as s left join fleet as f on fi.fid=f.fid where p.prod_id=f.prod_id and f.fid=" . $fid . " and s.prod_id=f.prod_id and s.prod_id=p.prod_id and f.fid is not null"); if (!$sth) { echo "bug"; return 0; } while ($fleet = mysql_fetch_array($sth)) { if (!$max_tonnage) { if (!$sid_fleet) { $sid_fleet = $fleet["sid"]; } $sth1 = mysql_query("select jv.tonnage,j.used_tonnage from jumpgates as j,jumpgatevalues as jv where j.sid=" . $fleet["sid"] . " and jv.prod_id=j.prod_id"); if (!$sth1) { echo "bug"; return 0; } $home = mysql_fetch_array($sth1); $home_avail = $home["tonnage"] - $home["used_tonnage"]; $target_avail = $targetj["tonnage"] - $targetj["used_tonnage"]; if ($home_avail < $target_avail) { $max_tonnage = $home_avail; } else { $max_tonnage = $target_avail; } } $fleet_tonnage = $fleet_tonnage + $fleet["tonnage"] * $fleet["count"]; } if ($fleet_tonnage > $max_tonnage) { echo "max_tonnage"; return 0; } $sth = mysql_query("select j.password,p.uid from jumpgates as j,planets as p,orbital as o where p.sid=j.sid and j.sid={$sid} and o.pid=p.id and o.prod_id=j.prod_id and j.pid=p.id"); if (!$sth) { echo "bug"; return 0; } $target_pass = mysql_fetch_array($sth); $sth = mysql_query("select j.password,p.uid from jumpgates as j,planets as p,orbital as o where p.sid=j.sid and j.sid=" . $sid_fleet . " and o.pid=p.id and o.prod_id=j.prod_id and j.pid=p.id"); if (!$sth) { echo "bug"; return 0; } $start_pass = mysql_fetch_array($sth); if ($start_pass["uid"] != $uid || $target_pass["uid"] != $uid) { echo "not_yours"; return 0; } else { $sth = mysql_query("update fleet_info set sid={$sid},pid=0,tsid=0,tpid=0,mission=0 where fid={$fid}"); if (!$sth) { echo "bug"; return 0; } $sth = mysql_query("update jumpgates set used_tonnage=used_tonnage+{$fleet_tonnage} where (sid={$sid}) or (sid={$start_sid})"); echo "success"; } }
function fleet_is_examinable($fid, $sid = 0) { global $uid; $examinable = false; if ($sid == 0) { $sid = get_sid_by_fid($fid); } $allies = get_allied_ids($uid); if (is_array($allies)) { array_push($allies, $uid); } else { $allies[] = $uid; } for ($m = 0; $m < sizeof($allies); $m++) { if (is_a_fleet_in_system($allies[$m], $sid)) { $examinable = true; break; } if (has_a_planet_in_system($allies[$m], $sid) == "true") { $examinable = true; break; } } return $examinable; }