function covertops() { $sth = mysql_query("select * from covertops as c,covertopsmissions as cm where c.time=1 and c.cid=cm.id"); if (!$sth) { echo "Dtaabaser failure!"; } while ($covertops = mysql_fetch_array($sth)) { $success = false; $sth1 = mysql_query("select sum(c.value) from covertopsupgrades as c,constructions as b,planets as p where p.id=b.pid and b.prod_id=c.prod_id and p.uid=" . $covertops["uid"]); if (!$sth1) { echo "Dast FDS!"; } $f_co_upgrades = mysql_fetch_row($sth1); $sth1 = mysql_query("select count(id) from planets where uid=" . $covertops["uid"]); if (!$sth1) { echo "Datasbe failure!"; } $f_planets = mysql_fetch_row($sth1); $f_rate = $f_co_upgrades[0] / $f_planets[0]; // echo("Friendly Rate: ".$f_rate."\n"); if ($covertops["targettype"] == "I") { $imperium = $covertops["target"]; } else { $sth1 = mysql_query("select uid from planets where id=" . $covertops["target"]); if (!$sth1) { echo "Datasbe failuer!"; } $uid = mysql_fetch_array($sth1); $imperium = $uid["uid"]; } $sth1 = mysql_query("select sum(population)/10000 from planets where uid=" . $imperium); if (!$sth1) { echo "Datasber faileur!"; } $spies = mysql_fetch_row($sth1); $sth1 = mysql_query("select sum(count) from covertops where uid=" . $imperium); if (!$sth1) { echo "Database failuer!"; } $used_spies = mysql_fetch_row($sth1); if ($used_spies[0] == NULL) { $rate = 100; } else { $rate = ($spies[0] - $used_spies[0]) / $spies[0] * 100; } // echo("Grundrate: $rate\n"); $sth1 = mysql_query("select sum(c.value) from covertopsupgrades as c,constructions as b,planets as p where p.id=b.pid and b.prod_id=c.prod_id and p.uid={$imperium}"); if (!$sth1) { echo "Dtasabr failuer!"; } $co_upgrades = mysql_fetch_row($sth1); $sth1 = mysql_query("select count(id) from planets where uid={$imperium}"); if (!$sth1) { echo "Datasbe failure!"; } $planets = mysql_fetch_row($sth1); $rate = $rate + $co_upgrades[0] / $planets[0]; // echo("Rate mit Upgrades: $rate\n"); if ($rate <= 0) { $success = true; } else { mt_srand((double) microtime() * 1000000); $random = mt_rand(0, $rate - $f_rate); // echo("Berechnung: Rate->$rate Frindly Rate->$f_rate Zufall->$random Chance->".$covertops["chance"]."\n"); if ($random <= $covertops["chance"]) { $success = true; } } // if ($success) // echo("Success!\n"); // DEBUG! // $success=true; if ($success) { switch ($covertops["missiontype"]) { case "S": define("MAX_STEAL", 25); $sth1 = mysql_query("select f.prod_id,f.fid,f.count,p.typ, p.name, f.reload from fleet as f,production as p left join fleet_info as fi on fi.fid=f.fid where fi.uid={$imperium} and fi.mission=0 and fi.tpid=0 and fi.tsid=0 and fi.pid!=0 and f.prod_id=p.prod_id order by rand() limit 1"); if (!$sth1) { echo "Datsbe faileur!"; } if (mysql_num_rows($sth1) > 0) { $fleet = mysql_fetch_array($sth1); $sth2 = mysql_query("select p.id,p.sid from planets as p,users as u where p.id=u.homeworld and u.id=" . $covertops["uid"]); if (!$sth2) { echo "Dtabaser faileur!"; } $home = mysql_fetch_array($sth2); switch ($fleet["typ"]) { case "L": $multiplikator = 1; break; case "M": $multiplikator = 5; break; case "H": $multiplikator = 10; break; } if ($multiplikator * $fleet["count"] > MAX_STEAL) { $fleet["count"] = floor(MAX_STEAL / $multiplikator); } $new_fleet = new fleet(); $new_fleet->add_ships_arr(array($fleet["prod_id"] => array($fleet["count"], $fleet["reload"]))); $new_fleet->uid = $covertops["uid"]; $new_fleet->pid = $home["id"]; $new_fleet->sid = $home["sid"]; $new_fleet->create_fleet(); $sth2 = mysql_query("update fleet set count=count-" . $fleet["count"] . " where fid=" . $fleet["fid"] . " and prod_id=" . $fleet["prod_id"]); delete_empty_fleets(); ticker($covertops["uid"], "You have stolen " . $fleet["count"] . " " . $fleet["name"], "s"); ticker($imperium, $fleet["count"] . " " . $fleet["name"] . " vanished from your radar!", "s"); } else { ticker($covertops["uid"], "Your spies didn't find any ships. The target imperium doesn't have any!", "s"); } break; case "B": $sth1 = mysql_query("select b.prod_id,b.pid,pl.name,p.name as pname from planets as pl,production as p,constructions as b where b.prod_id=p.prod_id and b.pid=pl.id and pl.uid={$imperium} order by rand()"); if (!$sth1) { echo "Database failoer!"; } if (mysql_num_rows($sth1) > 0) { $building = mysql_fetch_array($sth1); $sth1 = mysql_query("delete from constructions where prod_id=" . $building["prod_id"] . " and pid=" . $building["pid"]); if (!$sth1) { echo "DDFatabf failur!"; } if ($building["name"] == "Unnamed") { $building["name"] = get_planetname("pid"); } ticker($covertops["uid"], "Your spies destroyed the " . $building["pname"] . " on planet " . $building["name"] . "!", "s"); ticker($imperium, "The " . $building["pname"] . " on planet " . $building["name"] . " was destroyed misteriously!", "s"); } break; case "F": $sth1 = mysql_query("select f.prod_id,f.fid from fleet as f,fleet_info as fi where fi.uid={$imperium} and fi.fid=f.fid"); if (!$sth1) { echo "Datsbe faileur!"; } if (mysql_num_rows($sth1) > 0) { if (mysql_num_rows($sth1) == 1) { $random = 0; } else { mt_srand((double) microtime() * 1000000); $random = mt_rand(0, mysql_num_rows($sth1) - 1); } for ($i = 0; $i <= $random; $i++) { $fleet = mysql_fetch_array($sth1); } $sth2 = mysql_query("delete from fleet where fid=" . $fleet["fid"] . " and prod_id=" . $fleet["prod_id"]); delete_empty_fleets(); ticker($covertops["uid"], "You spies destroyed some ships!", "s"); ticker($imperium, "Enemy spies destroyed some of your ships!", "s"); } else { ticker($covertops["uid"], "Your spies didn't find any ships. The target imperium doesn't have any!", "s"); } break; case "N": $sth1 = mysql_query("select * from ticker where uid={$imperium}"); if (!$sth1) { echo "Database failure!"; } while ($ticker = mysql_fetch_array($sth1)) { if ($end = strrpos($ticker["text"], "*")) { $text = substr($ticker["text"], $end + 1); } else { $text = $ticker["text"]; } $mail = $mail . "\n" . $text; } if (mysql_num_rows($sth1) == 0) { $mail = "This Imperium doesn't have any news at the moment!"; } $sth1 = mysql_query("select imperium from users where id=" . $imperium); if (!$sth1) { echo "Datsabe failure!"; } $imp_name = mysql_fetch_array($sth1); mail_to_uid($covertops["uid"], "News of " . $imp_name["imperium"], $mail); ticker($covertops["uid"], "Your spies have successfully hacked a news network. Check Mails.", "s"); break; case "M": $mail = ""; $sth1 = mysql_query("select fi.*,f.prod_id,f.count,f.reload,p.name,s.x,s.y from fleet as f,production as p,systems as s left join fleet_info as fi on fi.fid=f.fid and fi.uid={$imperium} where p.prod_id=f.prod_id and s.id=fi.sid order by fid"); if (mysql_num_rows($sth1) == 0) { $mail = "Target imperium doesn't have any fleets"; } else { while ($part_fleet = mysql_fetch_array($sth1)) { if ($part_fleet["fid"] != $fid_old) { $fid_old = $part_fleet["fid"]; $counter++; } $fleet[$counter][] = $part_fleet; } $counter = 1; for ($i = 1; $i <= sizeof($fleet); $i++) { $mail = $mail . "Fleet " . $counter++ . "<br>"; $mail = $mail . "<table>"; $head_array = ""; $text_arr = ""; $prod_arr = ""; for ($j = 0; $j < sizeof($fleet[$i]); $j++) { $head_array[$j] = $fleet[$i][$j]["name"]; $text_arr[$j] = $fleet[$i][$j]["count"]; } switch ($fleet[$i][0]["mission"]) { case "0": $mission_text["a"] = "Defending"; $mission_text["b"] = "defend"; break; case "1": $mission_text["a"] = "Attacking"; $mission_text["b"] = "attack"; break; case "4": $mission_text["a"] = ""; $mission_text["b"] = "colonize"; break; } if ($fleet[$i][0]["pid"] != 0 and $fleet[$i][0]["tsid"] == 0 and $fleet[$i][0]["tpid"] == 0) { $planetname = get_planetname($fleet[$i][0]["pid"]); $mission = $mission_text["a"] . " planet " . $planetname; } if ($fleet[$i][0]["pid"] == 0 and $fleet[$i][0]["tsid"] == 0 and $fleet[$i][0]["tpid"] == 0) { $systemname = get_systemname($fleet[$i][0]["sid"]); $mission = $mission_text["a"] . " system " . $systemname; } if ($fleet[$i][0]["tsid"] != 0 and $fleet[$i][0]["tpid"] == 0) { $systemname = get_systemname($fleet[$i][0]["tsid"]); $mission = "On its way to " . $mission_text["b"] . " system " . $systemname; } if ($fleet[$i][0]["tsid"] != 0 and $fleet[$i][0]["tpid"] != 0) { $planetname = get_planetname($fleet[$i][0]["tpid"]); $mission = "On its way to " . $mission_text["b"] . " planet " . $planetname; } $text_arr[] = $mission; $head_array[] = "Mission"; reset($head_array); $mail = $mail . "<tr>"; while (list($key, $dummy) = each($head_array)) { //echo($dummy."\n"); $mail = $mail . "<th>{$dummy}</th>"; } $mail = $mail . "</tr>"; reset($text_arr); $mail = $mail . "<tr>"; while (list($key, $dummy) = each($text_arr)) { echo $key . " - " . $dummy . "\n"; $mail = $mail . "<td>{$dummy}</td>"; } $mail = $mail . "</tr>"; $mail = $mail . "</table>"; } } $sth1 = mysql_query("select imperium from users where id=" . $imperium); if (!$sth1) { echo "Datsabe failure!"; } $imp_name = mysql_fetch_array($sth1); mail_to_uid($covertops["uid"], "Military overview of " . $imp_name["imperium"], $mail); ticker($covertops["uid"], "Your spies have successfully hacked a military network. Check Mails.", "s"); break; case "I": $mail = ""; $sth1 = mysql_query("select c.target,cm.descr,cm.targettype from covertops as c,covertopsmissions as cm where uid={$imperium} and cm.id=c.cid"); if (!$sth1) { echo "Databasdf faileru!"; } while ($missions = mysql_fetch_array($sth1)) { if ($missions["targettype"] == "I") { $sth2 = mysql_query("select imperium from users where id=" . $missions["target"]); if (!$sth2) { echo "Datasbae failuer!"; } $imp_tname = mysql_fetch_array($sth2); $target = "Imperium " . $imp_tname["imperium"]; } else { $planetname = get_planetname($missions["target"]); $target = "Planet " . $planetname; } $mail = $mail . "\n" . $missions["descr"] . " Target :" . $target; } $sth1 = mysql_query("select imperium from users where id=" . $imperium); if (!$sth1) { echo "Datsabe failure!"; } $imp_name = mysql_fetch_array($sth1); mail_to_uid($covertops["uid"], "CovertOps overview of " . $imp_name["imperium"], $mail); break; case "C": $sth1 = mysql_query("select population from planets where id=" . $covertops["target"]); if (!$sth1) { echo "Datasb faileur!"; } $pop = mysql_fetch_array($sth1); if ($pop["population"] > 10000000) { mt_srand((double) microtime() * 1000000); $killed = mt_rand(5000000, 8000000); } else { mt_srand((double) microtime() * 1000000); $killed = round($pop["population"] * (mt_rand(30, 80) / 100)); } $planetname = get_planetname($covertops["target"]); $sth1 = mysql_query("update planets set population=population-{$killed} where id=" . $covertops["target"]); if (!$sth1) { echo "udFH failuewr!"; } ticker($covertops["uid"], "Your spies launched a nuclear assault on Planet " . $planetname . " {$killed} were killed!", "s"); $sth1 = mysql_query("select uid from planets where id=" . $covertops["target"]); if (!$sth1) { echo "Database dfasi!"; } $uid_target = mysql_fetch_array($sth1); ticker($uid_target["uid"], "Enemy spies launched a deadly nuclear attack agaonst Planet " . $planetname . " {$killed} were killed!", "s"); break; case "V": $sth1 = mysql_query("select population from planets where id=" . $covertops["target"]); if (!$sth1) { echo "Datasb faileur!"; } $pop = mysql_fetch_array($sth1); mt_srand((double) microtime() * 1000000); $killed = round($pop["population"] * (mt_rand(30, 80) / 100)); $planetname = get_planetname($covertops["target"]); $sth1 = mysql_query("update planets set population=population-{$killed} where id=" . $covertops["target"]); if (!$sth1) { echo "udFH failuewr!"; } ticker($covertops["uid"], "Your spies deployed a deadly virus on Planet " . $planetname . " {$killed} were killed!", "s"); $sth1 = mysql_query("select uid from planets where id=" . $covertops["target"]); if (!$sth1) { echo "Database dfasi!"; } $uid_target = mysql_fetch_array($sth1); ticker($uid_target["uid"], "Enemy spies deployed a deadly virus on Planet " . $planetname . " {$killed} were killed!", "s"); break; case "A": $sth1 = mysql_query("select imperium from users where id={$imperium}"); if (!$sth1) { echo "Databsae faileru!"; } $imp_name = mysql_fetch_array($sth1); $sth1 = mysql_query("select id,name,value from admirals where uid={$imperium} order by rand()"); if (!$sth1) { echo "Dtzasa faielru!"; } if (mysql_num_rows($sth1) == 0) { ticker($covertops["uid"], "Your spies didn't find an admiral of Imperium " . $imp_name["imperium"] . "!", "s"); return 0; } $admiral = mysql_fetch_array($sth1); $sth1 = mysql_query("delete from admirals where id=" . $admiral["id"]); if (!$sth1) { echo "Dzasakhbd faileur!"; } ticker($covertops["uid"], "Your spies killed Admiral " . $admiral["name"] . " of Imperium " . $imp_name["imperium"] . "!", "s"); ticker($imperium, "Admiral " . $admiral["name"] . " was assasinated!", "w"); break; case "T": $sth1 = mysql_query("select imperium from users where id={$imperium}"); if (!$sth1) { echo "Databsae faileru!"; } $imp_name = mysql_fetch_array($sth1); $sth1 = mysql_query("select sid from tradestations where uid={$imperium}"); if (!$sth1) { echo "Dtasgha faij!"; } if (mysql_num_rows($sth1) == 0) { ticker($covertops["uid"], $imp_name["imperium"] . " doesn't have a tradestation. Mission aborted.", "w"); } list($stationid) = mysql_fetch_row($sth1); $sth1 = mysql_query("update tradestations set fail_chance=fail_chance+(rand()*10+1) where sid={$stationid}"); if (!$sth1) { echo "Datsbae fauO!"; } ticker($covertops["uid"], "Your spies have successfully sabotaged " . $imp_name["imperium"] . "'s tradestation", "w"); break; } } else { mt_srand((double) microtime() * 10000000); $random = mt_rand(0, 100); if ($random <= 50) { if ($random <= 20) { $sth1 = mysql_query("select name,imperium from users where id=" . $covertops["uid"]); if (!$sth1) { echo "Dtas afa!"; } $att_name = mysql_fetch_array($sth1); ticker($imperium, "Your spies intercepted some enemy spies. Their leader is " . $att_name["name"] . " (" . $att_name["imperium"] . ")!", "s"); } else { ticker($imperium, "Your spies intercepted some enemy spies!", "s"); } } } } $sth = mysql_query("delete from covertops where time<=1"); if (!$sth) { echo "Dtabas faislru!"; } $sth = mysql_query("update covertops set time=time-'1'"); if (!$sth) { echo "Dtasbwer failure!"; } }
function combat_report($pid, $sid) { global $combat; if (COMBAT_VERBOSE) { start_timer(1); echo "Erstelle Kampfbericht..."; } $combat_smarty = new Smarty(); global $__base_inc_dir; $combat_smarty->template_dir = $__base_inc_dir . "battle/templates/"; $combat_smarty->compile_dir = $__base_inc_dir . "battle/templates_c"; $combat_smarty->config_dir = $__base_inc_dir . "battle/configs/"; $combat_smarty->cache_dir = $__base_inc_dir . "battle/cache/"; $puid = get_uid_by_pid($pid); if ($pid) { if ($puid) { $puname = get_name_by_uid($puid); } else { $puname = "no owner"; } if ($pid == -1) { $combat_smarty->assign("location", "SimOrbit"); } else { $combat_smarty->assign("location", get_planetname($pid) . " ({$puname})"); } } else { $combat_smarty->assign("location", get_systemname($sid)); } $invader_id = combat_get_conqueror($pid); if (!$invader_id) { $combat_smarty->assign("invasion", ""); } else { $combat["shots_fired"]++; if ($invader_id < 0 && $invader_id > -100) { $combat_smarty->assign("invasion", "Planet1 has been invaded by Side2"); } elseif ($invader_id == -100) { $combat_smarty->assign("invasion", "Planetary combat, production was delayed."); } else { $combat_smarty->assign("invasion", get_planetname($pid) . " has been invaded by " . get_name_by_uid($invader_id)); } } // Admiraele berichten $query = $GLOBALS["db"]->query("SELECT SUM(c1.challenge) AS xp_earned, c2.admiral_id AS admiral_id, c2.uid \nAS uid FROM combat c1 INNER JOIN combat c2 ON (c1.killed_by=c2.id) WHERE c2.admiral_id <> 0 \nGROUP BY c2.admiral_id") or die("Admiral-XP: " . $GLOBALS["db"]->error); while ($result = $query->fetch_assoc()) { if (!is_array($results[$result["uid"]]["admirals"])) { $aidx = 0; } else { $aidx = sizeof($results[$result["uid"]]["admirals"]); } $results[$result["uid"]]["admirals"][$aidx]["name"] = dlookup("name", "admirals", "id=" . $result["admiral_id"]); if (is_null(dlookup("killed_by", "combat", "admiral_carried=" . $result["admiral_id"]))) { $results[$result["uid"]]["admirals"][$aidx]["xp"] = dlookup("value", "admirals", "id=" . $result["admiral_id"]); $results[$result["uid"]]["admirals"][$aidx]["newxp"] = dlookup("value", "admirals", "id=" . $result["admiral_id"]) + $result["xp_earned"]; $results[$result["uid"]]["admirals"][$aidx]["lvlup"] = calculate_admiral_level(dlookup("value", "admirals", "id=" . $result["admiral_id"]) + $result["xp_earned"]) != calculate_admiral_level(dlookup("value", "admirals", "id=" . $result["admiral_id"])); } } $users_query = $GLOBALS["db"]->query("SELECT DISTINCT uid, aid FROM combat") or die($GLOBALS["db"]->error); if (!$users_query) { return false; } while ($users_result = $users_query->fetch_assoc()) { // Feinde $results_query = $GLOBALS["db"]->query("SELECT alliance2 FROM diplomacy dp WHERE status=0 AND \nalliance1=" . $users_result["aid"]) or die($GLOBALS["db"]->error); if (!$results_query) { return false; } while (list($results[$users_result["uid"]]["enemies"][]) = $results_query->fetch_row()) { } // Schiffe gesamt $namefield = "CONCAT(p.name, ' ', IF(c.position='L','[unloaded]',\nIF(c.position='T','[on transport]',IF(c.position='U','[landed]',IF(IFNULL(c.killed_special,'')='E',\n'[disabled]',IF(IFNULL(c.killed_special,'')='R', '[captured]', ''))))))"; $results_query = $GLOBALS["db"]->query("SELECT {$namefield} AS name, \nSUM(c.count_max) AS count FROM combat c INNER JOIN production p \nUSING (prod_id) WHERE uid=" . $users_result["uid"] . " GROUP BY p.name, c.position, c.killed_special") or die($GLOBALS["db"]->error); if (!$results_query) { return false; } while ($unit = $results_query->fetch_assoc()) { $results[$users_result["uid"]]["ships"][$unit["name"]] = $unit["count"]; } // Schiffe zerstört $results_query = $GLOBALS["db"]->query("SELECT {$namefield} AS name, SUM(c.count_max-c.count) AS count,\nIFNULL(c.killed_special,'') AS killed_special FROM combat c INNER JOIN production p \nUSING (prod_id) WHERE uid=" . $users_result["uid"] . " GROUP BY p.name, c.position, c.killed_special") or die($GLOBALS["db"]->error); if (!$results_query) { return false; } while ($unit = $results_query->fetch_assoc()) { if ($unit["killed_special"] != "E" && $unit["killed_special"] != "R") { $results[$users_result["uid"]]["destroyed_ships"][$unit["name"]] = $unit["count"]; } } // Schiffe lebendig $results_query = $GLOBALS["db"]->query("SELECT {$namefield} AS name, SUM(c.count) AS count,\nIFNULL(c.killed_special,'') AS killed_special FROM combat c INNER JOIN production p \nUSING (prod_id) WHERE c.killed_by IS NULL AND uid=" . $users_result["uid"] . " GROUP BY p.name, c.position, \nc.killed_special") or die($GLOBALS["db"]->error); if (!$results_query) { return false; } while ($unit = $results_query->fetch_assoc()) { if ($unit["killed_special"] != "E" && $unit["killed_special"] != "R") { $results[$users_result["uid"]]["remaining_ships"][$unit["name"]] = $unit["count"]; } } } // Planetare Schilde berichten $query = $GLOBALS["db"]->query("SELECT 'Planetary shields' AS name, SUM(c.shield) AS shieldsum, \nSUM(c.shield_max) AS maxsum FROM combat c INNER JOIN production p USING (prod_id) WHERE c.special \nLIKE 'H%'") or die($GLOBALS["db"]->error); while ($result = $query->fetch_assoc()) { if ($result["maxsum"] > 0) { $results[$puid]["ships"][$result["name"]] = $result["maxsum"]; $results[$puid]["destroyed_ships"][$result["name"]] = $result["maxsum"] - $result["shieldsum"]; $results[$puid]["remaining_ships"][$result["name"]] = $result["shieldsum"]; } } $combat_smarty->assign("results", $results); $users_query = $GLOBALS["db"]->query("SELECT DISTINCT uid FROM combat") or die($GLOBALS["db"]->error); if (!$users_query) { return false; } while ($users_result = $users_query->fetch_assoc()) { if ($users_result["uid"] < 0) { $users[$users_result["uid"]] = "BattleSim Side " . $users_result["uid"] * -1; } else { $users[$users_result["uid"]] = get_name_by_uid($users_result["uid"]); } } $combat_smarty->assign("users", $users); ob_start(); $combat_smarty->display("battlereport.tpl"); $report = ob_get_contents(); ob_end_clean(); $combat_smarty->clear_all_assign(); // Report abspeichern if (BATTLE_DESTROY && $combat["shots_fired"] > 0) { $week = dlookup("week", "timeinfo"); $sth = $GLOBALS["db"]->query("INSERT INTO battlereports SET pid={$pid}, sid={$sid}, \nreport='" . addslashes($report) . "', week={$week}") or die($GLOBALS["db"]->error); $report_id = $GLOBALS["db"]->insert_id; $query = $GLOBALS["db"]->query("SELECT DISTINCT uid FROM combat") or die($GLOBALS["db"]->error); while (list($id) = $query->fetch_row()) { $sth = $GLOBALS["db"]->query("INSERT INTO battlereports_user (uid, rid) VALUES ({$id}, {$report_id})") or die($GLOBALS["db"]->error); } $query = $GLOBALS["db"]->query("SELECT DISTINCT aid FROM combat") or die($GLOBALS["db"]->error); while (list($id) = $query->fetch_row()) { $sth = $GLOBALS["db"]->query("INSERT INTO battlereports_alliance (aid, rid) VALUES ({$id}, {$report_id})") or die($GLOBALS["db"]->error); } } if (COMBAT_VERBOSE) { echo "OK! (" . round(read_timer(1), 4) . "s)" . COMBAT_NEWLINE . COMBAT_NEWLINE; } if (!BATTLE_DESTROY) { echo "{$report}" . COMBAT_NEWLINE . COMBAT_NEWLINE; } }
function get_name() { $location = get_systemname($this->sid); if ($this->pid) { $location .= " (Orbit of " . get_planetname($this->pid) . ")"; } return $location; }
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 move_fleet($mission) { global $uid; $fid = $_GET["fid"]; $targetId = $_GET["targetId"]; $targetType = $_GET["targetType"]; // planet || system $fleet = new fleet($fid); // validation if ($uid != $fleet->uid) { if ($fleet->milminister == 1) { $sth = mysql_query("select a.milminister from users u left join alliance a on u.alliance = a.id where u.id = " . $uid); if (!$sth) { show_svg_message("ERR::GET MoD"); return false; } list($its_mod) = mysql_fetch_row($sth); if ($its_mod != $uid) { show_svg_message("You can not command that fleet"); return false; } } else { show_svg_message("You can not command that fleet"); return false; } } if ($targetType == "system") { $destination_system = $targetId; $destination_planet = 0; $destination_name = get_systemname($targetId); } else { $sth = mysql_query("select sid, name, uid from planets where id = '{$targetId}'"); if (!$sth || !mysql_num_rows($sth)) { return 0; } $dest_data = mysql_fetch_row($sth); $destination_system = $dest_data[0]; $destination_name = $dest_data[1]; $destination_planet = $targetId; $destination_planet_uid = $dest_data[2]; } $max_warp = get_max_warp($uid); $route = move_to($fleet->sid, $destination_system, $max_warp); if (is_array($route)) { $fleet_mode = "defensive"; // gucken ob der zielplanet ein feindlicher ist if ($destination_planet != 0 && $destination_planet_uid != 0) { if (get_uids_relation($uid, $destination_planet_uid) == "enemy") { $fleet_mode = "aggressive"; } } set_mission($fid, $mission, $destination_system, $destination_planet); $its_mission = get_mission_by_mission_id($mission, $fleet_mode); set_route($route, $fid); $true_eta = get_true_ETA_by_fid($fid); $request .= "<SR_REQUEST oid=\"" . $fid . "\" type=\"FLEET_ROUTE\">"; $request .= "<SR_ROUTE_INFO eta=\"" . $true_eta . "\" targetName=\"" . $destination_name . "\" sid=\"" . $fleet->sid . "\" mission=\"" . $mission . "\" missionName=\"" . $its_mission[0] . "\" missionSymbol=\"" . $its_mission[2] . "\" />"; // general info if ($fleet->sid == $destination_system) { if ($destination_planet == 0 || $fleet->pid == 0) { if ($destination_planet == 0) { $target_planet = $fleet->pid; $target_system = $destination_system; } else { $target_planet = $destination_planet; $target_system = $fleet->sid; } $request .= "<SR_ROUTE_SYSTEM_TO_PLANET jumpNumber=\"0\" pid=\"" . $target_planet . "\" sid=\"" . $target_system . "\"/>"; } else { $request .= "<SR_ROUTE_PLANET_TO_PLANET jumpNumber=\"0\" pid1=\"" . $fleet->pid . "\" pid2=\"" . $destination_planet . "\" sid=\"" . $fleet->sid . "\"/>"; } } else { // wenn die flotte nicht schon überm stern hängt, muss sie erst dahin fliegen um das system zu verlassen $a = 0; if ($fleet->pid != 0) { $request .= "<SR_ROUTE_SYSTEM_TO_PLANET jumpNumber=\"" . $a++ . "\" pid=\"" . $fleet->pid . "\" sid=\"" . $fleet->sid . "\"/>"; } for ($i = 0; $i < sizeof($route); $i++) { $request .= "<SR_ROUTE_SYSTEM jumpNumber=\"" . ($i + $a) . "\" sid=\"" . $route[$i] . "\"/>"; } // wenn die flotte nicht zum einem anderen stern fliegt, sondern zu einem planeten, kommt noch ein inter-planetärer flug hinzu if ($destination_planet != 0) { $request .= "<SR_ROUTE_SYSTEM_TO_PLANET jumpNumber=\"" . ++$i . "\" pid=\"" . $destination_planet . "\" sid=\"" . $destination_system . "\"/>"; } } $request .= "</SR_REQUEST>"; echo $request; return true; } else { show_svg_message("Sir! Our fleet '" . get_fleet_name($_GET["fid"]) . "' can't carry out your command. The targets destination has an insuperable gap that exceeds our warp technolgy of " . $max_warp . " parsec."); return false; } }
function show_info() { global $uid; global $pid; $sth = mysql_query("select * from planets p,popgain g where p.id={$pid} and p.uid={$uid} and p.id=g.pid"); if (!$sth || mysql_num_rows($sth) == 0) { show_error("Jailhouse rock!"); return 0; } center_headline("Information Screen"); $planet = mysql_fetch_assoc($sth); table_border_start("center", "", "#302859", "#100666", "#D2CCF9"); echo "<tr>\n"; echo " <td rowspan=\"14\">\n"; echo " <img src=\"arts/" . $planet["type"] . ".jpg\">\n"; echo " <td>\n"; echo "</tr>\n"; table_head_text(array("Information"), "2"); table_text_open(); table_text_design("Owner", "", "center", "1", "head"); $sth = mysql_query("select u.name,ifnull(a.name,'none') as aname from users u left join alliance a on a.id=u.alliance where u.id=" . $planet["uid"]); if (!$sth || mysql_num_rows($sth) == 0) { show_error("Database failure!"); return 0; } $owner = mysql_fetch_assoc($sth); table_text_design($owner["name"], "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("System", "", "center", "1", "head"); table_text_design(get_systemname($planet["sid"]), "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("Alliance", "", "center", "1", "head"); table_text_design($owner["aname"], "", "center", "1", "text"); table_text_close(); if ($planet["gain"] > 0) { $gain = "<span style=\"color: lime\">+" . $planet["gain"] * 100 . "%</span>"; } else { $gain = "+/-0%"; } table_text_open(); table_text_design("Population", "", "center", "1", "head"); table_text_design(get_poplevel_by_pop($planet["population"]) . " " . $gain . " (" . $planet["max_poplevel"] . ")", "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("Planettype", "", "center", "1", "head"); switch ($planet["type"]) { case "O": $type = "Origin Class"; break; case "M": $type = "Mars Class"; break; case "A": $type = "Ancient Class"; break; case "D": $type = "Desert Class"; break; case "E": $type = "Eden Class"; break; case "G": $type = "Gas Giant Class"; break; case "H": $type = "Heavy Grav Class"; break; case "I": $type = "Ice Class"; break; case "R": $type = "Rock Class"; break; case "T": $type = "Toxic Class"; break; } define("planet_raw_metal", "8.5"); define("planet_raw_energy", "8.5"); define("planet_raw_mopgas", "8.5"); define("planet_raw_erkunum", "8.5"); define("planet_raw_gortium", "8.5"); define("planet_raw_susebloom", "8.5"); define("planet_no_upgrade_factor", "1"); $sth = mysql_query("select * from planets where id={$pid}"); $population_factor = log10($planet["population"] / 1000) + 3; $sth = mysql_query("select * from final_prod_factors where pid=" . $pid); if (!$sth) { show_error("ERR::GET PROD_FACTORS"); return false; } if (mysql_num_rows($sth) == 1) { $factors = mysql_fetch_assoc($sth); } else { $factors = false; } $metal_plus = round($factors["metal"] * ($planet["metal"] / 100) * (planet_raw_metal * $population_factor)); $energy_plus = round($factors["energy"] * ($planet["energy"] / 100) * planet_raw_energy * $population_factor); $mopgas_plus = round($factors["mopgas"] * ($planet["mopgas"] / 100) * planet_raw_mopgas * $population_factor); $erkunum_plus = round($factors["erkunum"] * ($planet["erkunum"] / 100) * planet_raw_erkunum * $population_factor); $gortium_plus = round($factors["gortium"] * ($planet["gortium"] / 100) * planet_raw_gortium * $population_factor); $susebloom_plus = round($factors["susebloom"] * ($planet["susebloom"] / 100) * planet_raw_susebloom * $population_factor); table_text_design($type, "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("Production factor", "", "center", "1", "head"); table_text_design($planet["production_factor"] * 100 . "%", "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("<img src='arts/metal.gif' title='Metal' alt='Metal'>", "", "center", "1", "head"); table_text_design($metal_plus, "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("<img src='arts/energy.gif' title='Energy' alt='Energy'>", "", "center", "1", "head"); table_text_design($energy_plus, "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("<img src='arts/mopgas.gif' title='Mopgas' alt='Mopgas'>", "", "center", "1", "head"); table_text_design($mopgas_plus, "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("<img src='arts/erkunum.gif' title='Erkunum' alt='Erkunum'>", "", "center", "1", "head"); table_text_design($erkunum_plus, "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("<img src='arts/gortium.gif' title='Gortium' alt='Gortium'>", "", "center", "1", "head"); table_text_design($gortium_plus, "", "center", "1", "text"); table_text_close(); table_text_open(); table_text_design("<img src='arts/susebloom.gif' title='Susebloom' alt='Susebloom'>", "", "center", "1", "head"); table_text_design($susebloom_plus, "", "center", "1", "text"); table_text_close(); table_end(); echo "<br><br>\n"; echo "<center>\n"; // echo("<a href=\"planet.php?pid=".$planet["id"]."\" target=\"anzeige_frame\">fleet orders</a>\n"); echo "</center>\n"; echo "<br>\n"; $query = mysql_query("SELECT ps.*, p.pic, p.description, p.name FROM planetary_shields ps \nINNER JOIN production p USING (prod_id) WHERE pid={$pid}") or die(mysql_error()); if (mysql_num_rows($query) > 0) { table_start("center", "500"); table_head_text(array("Shield generators installed on {$planet['name']}"), "5"); table_text_open("head"); table_text_design(" ", "50px", "", "", "head"); table_text_design("Building", "300", "", "", "head"); table_text_design("Max", "50", "center", "", "head"); table_text_design("Power", "50", "center", "", "head"); table_text_design("Load", "50", "center", "", "head"); while ($result = mysql_fetch_assoc($query)) { table_text_open("text", "center"); table_text_design("<a href='" . $_SERVER["PHP_SELF"] . "?act=print_building_info&prod_id=" . $result["prod_id"] . "'><img src='arts/" . $result["pic"] . "' alt='" . $result["description"] . "' border='0' width=\"50px\" height=\"50px\" /></a>", "50px", "", "", "text", "2"); table_text_design($result["name"], "300", "", "", "text", "2"); table_text_design($result["max_value"], "50", "", "", "text", "2"); table_text_design($result["value"], "50", "", "", "text", "2"); table_text_design($result["regeneration"] + $result["regeneration_bonus"], "50", "", "", "text", "2"); table_text_close(); } table_end(); } echo "<br>\n"; table_start("center", "500"); table_head_text(array("Units stationed on " . $planet["name"]), "5"); table_text(array(" ", " ", " ", " ", " "), "center", "100", "", "text"); table_text_open("head"); table_text_design("Infantry", "200", "center", "2", "head"); table_text_design(" ", "100", "", "", "head"); table_text_design("Fleet", "200", "center", "2", "head"); table_text_close(); $sth = mysql_query("select sum(count) from infantery as i,production as p where i.pid=" . $pid . " and i.prod_id=p.prod_id\n and p.typ='I'"); if (!$sth) { show_error("Database failure!"); return 0; } $inf = mysql_fetch_row($sth); if ($inf[0] == "") { $inf[0] = "No troops"; } table_text_open("text", "center"); table_text_design("Infantry", "", "", "", "text"); table_text_design($inf[0], "", "", "", "text"); table_text_design(" ", "100", "", "", "none"); table_text_design("Europa Class", "", "", "", "text"); table_text_design(get_fcount_by_type($uid, "L", $pid), "", "", "", "text"); table_text_close(); $sth = mysql_query("select sum(count) from infantery as i,production as p where i.pid=" . $pid . " and i.prod_id=p.prod_id and p.typ='T'"); if (!$sth) { show_error("Database failure!"); return 0; } $inf = mysql_fetch_row($sth); if ($inf[0] == "") { $inf[0] = "No Vehicles"; } table_text_open("text", "center"); table_text_design("Vehicles", "", "", "", "text"); table_text_design($inf[0], "", "", "", "text"); table_text_design(" ", "100", "", "", "none"); table_text_design("Zeus Class", "", "", "", "text"); table_text_design(get_fcount_by_type($uid, "M", $pid), "", "", "", "text"); table_text_close(); table_text_open("text", "center"); table_text_design(" "); table_text_design(" "); table_text_design(" ", "100", "", "", "none"); table_text_design("Olymp Class", "", "", "", "text"); table_text_design(get_fcount_by_type($uid, "H", $pid), "", "", "", "text"); table_text_close(); table_end(); }
function get_fleets_target($fid) { $sth = mysql_query("select tpid, tsid, pid, sid from fleet_info where fid={$fid}"); if (!$sth || !mysql_num_rows($sth)) { return false; } $target_id = mysql_fetch_array($sth); $fleet_target["planet"]["tid"] = $target_id["tpid"]; $fleet_target["system"]["tid"] = $target_id["tsid"]; $fleet_target["planet"]["id"] = $target_id["pid"]; $fleet_target["system"]["id"] = $target_id["sid"]; if ($target_id["tpid"]) { $fleet_target["planet"]["name"] = get_planetname($target_id[0]); } if ($target_id["tsid"]) { $fleet_target["system"]["name"] = get_systemname($target_id[0]); } return $fleet_target; }
function show_available_fleets() { global $uid; global $pid; global $bewohnbar; global $PHP_SELF; table_start("center", "500"); table_text(array("<a href=\"" . $PHP_SELF . "?act=show_fleets&pid=" . $pid . "&bewohnbar=" . $bewohnbar . "\">Show your own fleets</a>", "<a href=\"" . $PHP_SELF . "?act=show_available_fleets&pid=" . $pid . "&bewohnbar=" . $bewohnbar . "\">Show fleets assigned to you</a>")); table_end(); $sth = mysql_query("select a.milminister,a.id,u.alliance from alliance as a, users as u where a.milminister='{$uid}' and u.alliance = a.id"); if (!$sth) { show_message("Database Failure 1"); return 0; } if ($sth == 0) { show_message("Not working! Fool >:o"); return 0; } $sth = mysql_query("select f.*,p.typ,p.special from fleet as f,production as p where f.milminister='{$uid}' and p.prod_id=f.prod_id order by f.fid"); if (!$sth) { show_error("Database failure! 2"); return 0; } if (mysql_num_rows($sth) == 0) { center_headline("No allied fleets under your command"); return 0; } table_start("center", "80%"); table_head_text(array("Allied Fleets under your command"), "9"); table_text(array(" "), "", "", "9", "text"); table_text(array("Fleet number", "Light Ships", "Medium Ships", "Heavy Ships", "Current Mission", "New Mission", "Behaviour", "ETA", " "), "center", "", "", "head"); while ($part_fleet = mysql_fetch_array($sth)) { if ($part_fleet["fid"] != $fid_old) { $fid_old = $part_fleet["fid"]; $counter++; } $fleet[$counter][] = $part_fleet; } for ($i = 1; $i <= sizeof($fleet); $i++) { $light = ""; $medium = ""; $heavy = ""; for ($j = 0; $j < sizeof($fleet[$i]); $j++) { if ($fleet[$i][$j]["typ"] == "L") { $light += $fleet[$i][$j]["count"]; } if ($fleet[$i][$j]["typ"] == "M") { $medium += $fleet[$i][$j]["count"]; } if ($fleet[$i][$j]["typ"] == "H") { $heavy += $fleet[$i][$j]["count"]; } if ($fleet[$i][$j]["special"] == "O") { $fleet[$i][0]["orbital_colony"] = "O"; } } switch ($fleet[$i][0]["mission"]) { case "0": $mission_text["a"] = "Defending"; $mission_text["b"] = "defend"; break; case "1": $mission_text["a"] = "Attacking"; $mission_text["b"] = "attack"; break; case "4": $mission_text["a"] = "Colonizing"; $mission_text["b"] = "colonize"; break; case "5": $mission_text["a"] = "Invading"; $mission_text["b"] = "invade"; } if ($fleet[$i][0]["pid"] != 0 and $fleet[$i][0]["tsid"] == 0 and $fleet[$i][0]["tpid"] == 0) { $planetname = get_planetname($fleet[$i][0]["pid"]); $mission = $mission_text["a"] . " planet " . $planetname; } if ($fleet[$i][0]["pid"] == 0 and $fleet[$i][0]["tsid"] == 0 and $fleet[$i][0]["tpid"] == 0) { $systemname = get_systemname($fleet[$i][0]["sid"]); $mission = $mission_text["a"] . " system " . $systemname; } if ($fleet[$i][0]["tsid"] != 0 and $fleet[$i][0]["tpid"] == 0) { $systemname = get_systemname($fleet[$i][0]["tsid"]); $mission = "On its way to " . $mission_text["b"] . " system " . $systemname; } if ($fleet[$i][0]["tsid"] != 0 and $fleet[$i][0]["tpid"] != 0) { $planetname = get_planetname($fleet[$i][0]["tpid"]); $mission = "On its way to " . $mission_text["b"] . " planet " . $planetname; } $sth = mysql_query("select x,y,id from systems where id=" . $fleet[$i][0]["sid"]); $system = mysql_fetch_array($sth); $sth = mysql_query("select s.x,s.y,s.id from systems as s,planets as p where s.id=p.sid and p.id={$pid}"); $targetsystem = mysql_fetch_array($sth); if ($targetsystem["id"] == $system["id"]) { $eta = "Already here!"; } else { $sth1 = mysql_query("select max(w.range) from warp as w,research as r where w.tid=r.t_id and r.uid=" . $uid); $range = mysql_fetch_row($sth1); if ($range[0] == NULL) { global $no_warp_tech; $range[0] = $no_warp_tech; } $eta = eta_to_planet($system["x"], $system["y"], $targetsystem["x"], $targetsystem["y"], $range[0], $old); if (!$eta) { $eta = "No route to system"; } else { $eta = $eta[0]; } } $sth = mysql_query("select uid from planets where id={$pid} and uid!=0 and uid!={$uid}"); if (mysql_num_rows($sth) != 0) { $invade = "<option value=\"5\"> Invade Planet"; } if ($fleet[$i][0]["pid"] == $pid) { $sth = mysql_query("select f.fid from inf_transporters as i,fleet as f where i.prod_id=f.prod_id and f.fid=" . $fleet[$i][0]["fid"]); if (mysql_num_rows($sth) != 0) { $transport = "<option value=\"9\"> Transfer Infantery"; } } $new_mission = "<select name=\"newmission\">\n"; $new_mission = $new_mission . "<option value=\"0\">Defend this planet<option value=\"1\">Attack this planet" . $transport . $invade . "</select>"; $behaviour = "<select name=\"behaviour\">\n"; if ($fleet[$i][0]["behaviour"] == 0) { $behaviour = $behaviour . "<option selected value=\"0\">Evasive"; $behaviour = $behaviour . "<option value=\"1\">Aggressive"; } else { $behaviour = $behaviour . "<option value=\"0\">Evasive"; $behaviour = $behaviour . "<option selected value=\"1\">Aggressive"; } $behaviour = $behaviour . "</select>"; if ($light == "") { $light = "0"; } if ($medium == "") { $medium = "0"; } if ($heavy == "") { $heavy = "0"; } echo "<form action=\"" . $PHP_SELF . "\" method=post>"; table_text(array(($k += 1) . "<input type=hidden name=\"fid\" value=\"" . $fleet[$i][0]["fid"] . "\"", $light, $medium, $heavy, $mission, $new_mission, $behaviour, $eta, "<input type=hidden name=\"act\" value=\"newmission\"><input type=hidden name=\"pid\" value=\"" . $pid . "\"><input type=submit value=\"Execute\""), "center", "", "", "text"); echo "</form>"; } table_end(); }
function transfer() { global $uid; global $fleet; global $PHP_SELF; global $HTTP_REFFERRER; if (!is_array($fleet)) { show_error("You have to select a fleet and some ships in order to transfer!"); return 0; } $i = 0; while (list($key, $value) = each($fleet)) { if ($value == "Y") { $fleets[$i] = new fleet($key); if (!$fleets[$i]->uid == $uid) { show_error("Hello! I'm your friend...Why are you trying such nasty things?"); return 0; } if (!$pid) { $pid = $fleets[$i]->pid; $sid = $fleets[$i]->sid; } else { if ($fleets[$i]->pid != $pid || $fleets[$i]->sid != $sid) { show_error("You may only select fleets which are at the same planet and system!"); return 0; } } } $i++; } $new_fleet = new fleet(); echo "<form action=\"" . $PHP_SELF . "\" method=post>"; for ($i = 0; $i < sizeof($fleets); $i++) { $temp_var = "fleet_" . $fleets[$i]->fid; global ${$temp_var}; foreach ((array) ${$temp_var} as $key => $value) { // Überprüfen ob die werte ok sind (key=>prod_id, value=>count) if ($fleets[$i]->ships[$key] && $fleets[$i]->ships[$key][0] >= $value && (int) $value > 0) { // Das wird nachher ausgelesen um die flotten auch um den wert zu reduzieren $fleets[$i]->ships[$key][0] -= $value; $aff_fleets[] = $fleets[$i]->fid; $new_fleet->add_ships_arr(array($key => array($value, $fleets[$i]->ships[$key][1]))); } elseif ($value == 0) { continue; } else { show_error("You entered a wrong shipcount for fleet " . $fleets[$i]->name . "!"); return 0; } form_hidden("fleet_" . $fleets[$i]->fid . "[" . $key . "]", $value); } } $fids = get_fids_by_pid($pid, $uid, $sid); for ($i = 0; $i < sizeof($fleets); $i++) { // mop: was für nen toller hack if (in_array($fleets[$i]->fid, $fids)) { // mop: umdrehen, damit wir das unsetten können ohne das array komplett durchsuchen zu müssen $fids_tmp = array_flip($fids); unset($fids_tmp[$fleets[$i]->fid]); // mop: und wieder zurück $fids = array_flip($fids_tmp); } form_hidden("fid[" . $i . "]", $fleets[$i]->fid); } // mop: wenn fertig fidsarray neubauen $fids = array_values($fids); // mop: jetzt die ausgewählten flotten abwählen for ($i = 0; $i < sizeof($fids); $i++) { $trans_fleets[$i] = new fleet($fids[$i]); } if (sizeof($trans_fleets) == 0) { center_headline("You have no fleets you could transfer these ships to:)"); go_back($_SERVER["PHP_SELF"]); } else { for ($i = 0; $i < sizeof($trans_fleets); $i++) { $head_array = ""; $text_arr = ""; $prod_arr = ""; table_start("center", "80%"); table_head_text(array("Fleet " . $trans_fleets[$i]->name), "20"); $head_array[0] = " "; $prod_arr[0] = ""; $text_arr[0] = "<input type=radio name=\"fleet\" value=\"" . $trans_fleets[$i]->fid . "\">"; reset($trans_fleets[$i]); while (list($prod_id, $ship_arr) = each($trans_fleets[$i]->ships)) { $head_array[] = get_name_by_prod_id($prod_id); $text_arr[] = $ship_arr[0]; } $mission = $trans_fleets[$i]->get_mission(); list($type, $location) = $trans_fleets[$i]->get_location(); if ($type == 0) { $mission_text = $mission[0] . " "; } else { $mission_text = "On its way to " . $mission[1] . " "; } list($location_id, $location_type) = $location; if ($location_type == 0) { $mission_text .= "planet " . get_planetname($trans_fleets[$i]->pid); $location_text = "Planet " . get_planetname($trans_fleets[$i]->pid) . "(" . get_systemname($trans_fleets[$i]->sid) . ")"; } else { $mission_text .= "system " . get_system_coords($trans_fleets[$i]->sid); $location_text = "System " . get_systemname($trans_fleets[$i]->sid); } table_text(array(" "), "", "", "20", "head"); table_text_open(); table_text_design("Mission:", "50", "", "", "smallhead"); table_text_design($mission_text, "", "", "19", "text"); table_text_close(); table_text($head_array, "", "", "", "smallhead"); table_text($text_arr, "", "", "", "text"); table_end(); echo "<br><br>\n"; } form_hidden("act", "transferab"); echo "<center>\n"; echo "<input type=submit value=\"Transfer\">"; echo "</center>\n"; echo "</form>"; } }