function get_max_fleet_scanrange_by_sid($sid, $user_id = 0) { global $uid; if (!$user_id) { $user_id = $uid; } $sth = mysql_query("select fid from fleet_info where sid=" . $sid); if (!$sth || !mysql_num_rows($sth)) { return 0; } while ($its_fleets = mysql_fetch_array($sth)) { $its_user = get_uid_by_fid($its_fleets["fid"]); if ($its_user == $user_id || is_allied($its_user, $user_id)) { $scanrange[] = get_max_scanrange_by_fid($its_fleets["fid"]); } } if (is_array($scanrange)) { rsort($scanrange); $max_scanrange = $scanrange[0]; } else { $max_scanrange = 0; } return $max_scanrange; }
function proc_assign() { global $uid; if (get_admiral_owner($_REQUEST["aid"]) != $uid) { show_error("FUFUFUFUFUFFU"); return false; } if (get_uid_by_fid($_REQUEST["fid"]) != $uid) { show_error("NANANANANANAN"); return false; } set_admiral($_REQUEST["aid"], $_REQUEST["fid"]); }
function draw_fleet($fids, $pid) { global $uid; for ($i = 0; $i < sizeof($fids); $i++) { $its_uid = get_uid_by_fid($fids[$i]); $relation = get_uids_relation($uid, $its_uid); switch ($relation) { case "same": $same++; break; case "allie": $allie++; break; case "friend": $friend++; break; case "enemy": $enemy++; break; case "neutral": $neutral++; break; } } $root_x = 10; $root_y = 20; if ($same) { $x = $root_x * -1; $y = $root_y * -1; // $fleets .= "<g onclick=\"showUnits('".$pid."',95);\" class=\"fleetsOwn\">"; $fleets .= "<g class=\"fleetsOwn\">"; $fleets .= "<use xlink:href=\"#sShip\" x=\"" . $x . "\" y=\"" . $y . "\"/>"; $x = $x - 3; $y = $y + 9; for ($i = 0; $i < $same; $i++) { $y -= 3; if ($i >= 4) { $x += -3; $y = $root_y * -1 + 9; } $fleets .= "<rect x=\"" . $x . "\" y=\"" . $y . "\" width=\"2\" height=\"1\"/>"; } $fleets .= "</g>"; } if ($allie) { $x = ($root_x + 10) * -1; $y = $root_y * 0 - 5; // $fleets .= "<g onclick=\"showUnits('".$pid."',96);\" class=\"fleetsAllied\">"; $fleets .= "<g class=\"fleetsAllied\">"; $fleets .= "<use xlink:href=\"#sShip\" x=\"" . $x . "\" y=\"" . $y . "\"/>"; $x = $x - 3; $y = $y + 9; for ($i = 0; $i < $allie; $i++) { $y -= 3; if ($i >= 4) { $x += -3; $y = $root_y * 0 + 9; } $fleets .= "<rect x=\"" . $x . "\" y=\"" . $y . "\" width=\"2\" height=\"1\"/>"; } $fleets .= "</g>"; } if ($friend) { $x = $root_x * -1; $y = $root_y - 10; //$fleets .= "<g onclick=\"showUnits('".$pid."',97);\" class=\"fleetsFriend\">"; $fleets .= "<g class=\"fleetsFriend\">"; $fleets .= "<use xlink:href=\"#sShip\" x=\"" . $x . "\" y=\"" . $y . "\"/>"; $x = $x - 3; $y = $y + 9; for ($i = 0; $i < $friend; $i++) { $y -= 3; if ($i >= 4) { $x += -3; $y = $root_y * -1 + 9; } $fleets .= "<rect x=\"" . $x . "\" y=\"" . $y . "\" width=\"2\" height=\"1\"/>"; } $fleets .= "</g>"; } if ($neutral) { $x = $root_x - 5; $y = $root_y - 10; //$fleets .= "<g onclick=\"showUnits('".$pid."',98);\" class=\"fleetsNeutral\">"; $fleets .= "<g class=\"fleetsNeutral\">"; $fleets .= "<use xlink:href=\"#sShip\" x=\"" . $x . "\" y=\"" . $y . "\"/>"; $x = $x + 10; $y = $y + 9; for ($i = 0; $i < $neutral; $i++) { $y -= 3; if ($i >= 4) { $x += 3; $y = $root_y + 9; } $fleets .= "<rect x=\"" . $x . "\" y=\"" . $y . "\" width=\"2\" height=\"1\"/>"; } $fleets .= "</g>"; } if ($enemy) { $x = $root_x; $y = $root_y * 0 - 5; //$fleets .= "<g onclick=\"showUnits('".$pid."',99);\" class=\"fleetsEnemy\">"; $fleets .= "<g class=\"fleetsEnemy\">"; $fleets .= "<use xlink:href=\"#sShip\" x=\"" . $x . "\" y=\"" . $y . "\"/>"; $x = $x + 10; $y = $y + 9; for ($i = 0; $i < $enemy; $i++) { $y -= 3; if ($i >= 4) { $x += 3; $y = $root_y + 9; } $fleets .= "<rect x=\"" . $x . "\" y=\"" . $y . "\" width=\"2\" height=\"1\"/>"; } $fleets .= "</g>"; } // hack, custom element, das anzeigt was für flotten bei dem planeten vertreten sind $fleets .= "<SR_FLEET_AT_PLANET enemy=\"" . $enemy . "\" allied=\"" . $allied . "\" own=\"" . $same . "\" friendly=\"" . $friend . "\" neutral=\"" . $neutral . "\"/>"; return $fleets; }
function is_own_fleet($fid, $type = 0) { global $uid; $fleet_uid = get_uid_by_fid($fid); if ($type == 0) { if ($uid == $fleet_uid) { return true; } else { return false; } } else { if ($uid == $fleet_uid || is_allied($uid, $fleet_uid)) { return true; } else { return false; } } }