} */ if (($_POST['planettype'] == 3 || $_POST['planettype'] == 1) && $fleet_group_mr > 0 && $UsedPlanet) { $missiontype[2] = $lang['type_mission'][2]; } if ($_POST['planettype'] == 3 && ($_POST['ship214'] >= 1 || $_POST['ship218']) >= 1 && !$YourPlanet && $UsedPlanet) { $missiontype[9] = $lang['type_mission'][9]; } $fleetarray = unserialize(base64_decode(str_rot13($_POST["usedfleet"]))); $mission = $_POST['target_mission']; $SpeedFactor = $_POST['speedfactor']; $AllFleetSpeed = GetFleetMaxSpeed($fleetarray, 0, $user); $GenFleetSpeed = $_POST['speed']; $MaxFleetSpeed = min($AllFleetSpeed); $distance = GetTargetDistance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']); $duration = GetMissionDuration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor); $consumption = GetFleetConsumption($fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $user); $MissionSelector = ""; if (count($missiontype) > 0) { if ($planet == 16) { $MissionSelector .= "<tr height=\"20\">"; $MissionSelector .= "<th>"; $MissionSelector .= "<input type=\"radio\" name=\"mission\" value=\"15\" checked=\"checked\">" . $lang['type_mission'][15] . "<br /><br />"; $MissionSelector .= "<font color=\"red\">" . $lang['fl_expe_warning'] . "</font>"; $MissionSelector .= "</th>"; $MissionSelector .= "</tr>"; } else { $i = 0; foreach ($missiontype as $a => $b) { $MissionSelector .= "<tr height=\"20\">"; $MissionSelector .= "<th>";
$DebrisSize = $TargetGalaxy['metal'] + $TargetGalaxy['crystal']; $RecyclerNeeded = floor($DebrisSize / $pricelist[209]['capacity']) + 1; $RecyclerSpeed = $pricelist[209]['speed'] + $pricelist[209]['speed'] * $user['combustion_tech'] * 0.1; $RecyclerCount = $planetrow[$resource[209]]; if ($RecyclerCount > $RecyclerNeeded) { $FleetCount = $RecyclerNeeded; } else { $FleetCount = $RecyclerCount; } $FleetArray[209] = $FleetCount; } $distance = GetTargetDistance($planetrow['galaxy'], $Galaxy, $planetrow['system'], $System, $planetrow['planet'], $Planet); $SpeedFactor = $game_config['fleet_speed']; $GenFleetSpeed = 10; // a 100% $duration = GetMissionDuration($GenFleetSpeed, $RecyclerSpeed, $distance, $SpeedFactor); $page .= "<br /><br />"; $page .= "<center>"; $page .= "<table width=\"519\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">"; $page .= "<tr height=\"20\">"; $page .= "<td class=\"c\" colspan=\"2\">"; $page .= "<span class=\"success\">" . $lang['fl_fleet_send'] . "</span>"; $page .= "</td>"; $page .= "</tr>"; $page .= "<tr height=\"20\">"; $page .= "<th>" . $lang['fl_mission'] . "</th>"; $page .= "<th>" . $missiontype[$Mode] . "</th>"; $page .= "</tr>"; $page .= "<tr height=\"20\">"; $page .= "<th>" . $lang['fl_dist'] . "</th>"; $page .= "<th>" . $distance . "</th>";
if ($TargetRow['id_owner'] == '' and $_POST['mission'] != 8) { $ResultMessage = "601;" . $lang['gs_c601'] . "|" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserMissiles; die($ResultMessage); } if ($TargetRow["id_owner"] == $planetrow["id_owner"] and $_POST["mission"] == 6) { $ResultMessage = "618;" . $lang['gs_c618'] . "|" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserMissiles; die($ResultMessage); } if ($_POST['thisgalaxy'] != $planetrow['galaxy'] | $_POST['thissystem'] != $planetrow['system'] | $_POST['thisplanet'] != $planetrow['planet'] | $_POST['thisplanettype'] != $planetrow['planet_type']) { $ResultMessage = "618;" . $lang['gs_c618'] . "|" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserMissiles; die($ResultMessage); } $Distance = GetTargetDistance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']); $speedall = GetFleetMaxSpeed($FleetArray, 0, $user); $SpeedAllMin = min($speedall); $Duration = GetMissionDuration(10, $SpeedAllMin, $Distance, GetGameSpeedFactor()); $fleet['fly_time'] = $Duration; $fleet['start_time'] = $Duration + time(); $fleet['end_time'] = $Duration * 2 + time(); $FleetShipCount = 0; $FleetDBArray = ""; $FleetSubQRY = ""; $consumption = 0; $SpeedFactor = GetGameSpeedFactor(); foreach ($FleetArray as $Ship => $Count) { $ShipSpeed = $pricelist[$Ship]["speed"]; $spd = 35000 / ($Duration * $SpeedFactor - 10) * sqrt($Distance * 10 / $ShipSpeed); $basicConsumption = $pricelist[$Ship]["consumption"] * $Count; $consumption += $basicConsumption * $Distance / 35000 * ($spd / 10 + 1) * ($spd / 10 + 1); $FleetShipCount += $Count; $FleetDBArray .= $Ship . "," . $Count . ";";
function flt_t_send_fleet($user, &$from, $to, $fleet, $mission, $options = array()) { //ini_set('error_reporting', E_ALL); //doquery('SET autocommit = 0;'); //doquery('LOCK TABLES {{users}} READ, {{planets}} WRITE, {{fleet}} WRITE, {{aks}} WRITE, {{statpoints}} READ;'); doquery('START TRANSACTION;'); $from = sys_o_get_updated($user, $from['id'], $GLOBALS['time_now']); $from = $from['planet']; $speed_factor = get_fleet_speed(); $distance = GetTargetDistance($from['galaxy'], $to['galaxy'], $from['system'], $to['system'], $from['planet'], $to['planet']); $fleet_speed = min(GetFleetMaxSpeed($fleet, 0, $user)); $duration = GetMissionDuration(10, $fleet_speed, $distance, $speed_factor); $consumption = GetFleetConsumption($fleet, $speed_factor, $duration, $distance, $fleet_speed, $user); //!! $fleet_group = 0; //!! $options = array(); $can_attack = flt_can_attack($from, $to, $fleet, $mission, $options); if ($can_attack != ATTACK_ALLOWED) { doquery('ROLLBACK'); return $can_attack; } global $time_now, $sn_data; $fleet_start_time = $time_now + $duration; if ($mission == MT_EXPLORE or $mission == MT_HOLD) { $stay_duration = $options['stay_time'] * 3600; $stay_time = $fleet_start_time + $stay_duration; } else { $stay_duration = 0; $stay_time = 0; } $fleet_end_time = $fleet_start_time + $duration + $stay_duration; $fleet_ship_count = 0; $fleet_string = ''; $planet_sub_query = ''; foreach ($fleet as $unit_id => $amount) { if (!$amount || !$unit_id) { continue; } if (in_array($unit_id, $sn_data['groups']['fleet'])) { $fleet_ship_count += $amount; $fleet_string .= "{$unit_id},{$amount};"; } $planet_sub_query .= "`{$sn_data[$unit_id]['name']}` = `{$sn_data[$unit_id]['name']}` - {$amount},"; } $to['id_owner'] = intval($to['id_owner']); $QryInsertFleet = "INSERT INTO {{fleets}} SET "; $QryInsertFleet .= "`fleet_owner` = '{$user['id']}', "; $QryInsertFleet .= "`fleet_mission` = '{$mission}', "; $QryInsertFleet .= "`fleet_amount` = '{$fleet_ship_count}', "; $QryInsertFleet .= "`fleet_array` = '{$fleet_string}', "; $QryInsertFleet .= "`fleet_start_time` = '{$fleet_start_time}', "; $QryInsertFleet .= "`fleet_start_galaxy` = '{$from['galaxy']}', "; $QryInsertFleet .= "`fleet_start_system` = '{$from['system']}', "; $QryInsertFleet .= "`fleet_start_planet` = '{$from['planet']}', "; $QryInsertFleet .= "`fleet_start_type` = '{$from['planet_type']}', "; $QryInsertFleet .= "`fleet_end_time` = '{$fleet_end_time}', "; $QryInsertFleet .= "`fleet_end_stay` = '{$stay_time}', "; $QryInsertFleet .= "`fleet_end_galaxy` = '{$to['galaxy']}', "; $QryInsertFleet .= "`fleet_end_system` = '{$to['system']}', "; $QryInsertFleet .= "`fleet_end_planet` = '{$to['planet']}', "; $QryInsertFleet .= "`fleet_end_type` = '{$to['planet_type']}', "; $QryInsertFleet .= "`fleet_resource_metal` = '{$fleet[RES_METAL]}', "; $QryInsertFleet .= "`fleet_resource_crystal` = '{$fleet[RES_CRYSTAL]}', "; $QryInsertFleet .= "`fleet_resource_deuterium` = '{$fleet[RES_DEUTERIUM]}', "; $QryInsertFleet .= "`fleet_target_owner` = '{$to['id_owner']}', "; $QryInsertFleet .= "`fleet_group` = '{$fleet_group}', "; $QryInsertFleet .= "`start_time` = '{$time_now}';"; doquery($QryInsertFleet); $QryUpdatePlanet = "UPDATE {{planets}} SET {$planet_sub_query} `deuterium` = `deuterium` - '{$consumption}' WHERE `id` = '{$from['id']}' LIMIT 1;"; doquery($QryUpdatePlanet); if (BE_DEBUG) { debug($QryInsertFleet); debug($QryUpdatePlanet); } doquery("COMMIT;"); // doquery('SET autocommit = 1;'); $from = doquery("SELECT * FROM {{planets}} WHERE `id` = '{$from['id']}' LIMIT 1;", '', true); return ATTACK_ALLOWED; //ini_set('error_reporting', E_ALL ^ E_NOTICE); }
function ShowFleet2Page($CurrentUser, $CurrentPlanet) { global $resource, $pricelist, $reslist, $phpEx, $lang, $db, $displays; //$parse = $lang; $displays->assignContent('fleet/fleet2_table'); $galaxy = intval($_POST['galaxy']); $system = intval($_POST['system']); $planet = intval($_POST['planet']); $planettype = intval($_POST['planettype']); $fleet_group_mr = intval($_POST['fleet_group']); //print_r($_POST); $YourPlanet = false; $UsedPlanet = false; $select = $db->query("SELECT `id_owner`,`galaxy`,`system`,`planet`,`planet_type` FROM `{{table}}`", "planets"); while ($row = mysql_fetch_array($select)) { if ($galaxy == $row['galaxy'] && $system == $row['system'] && $planet == $row['planet'] && $planettype == $row['planet_type']) { if ($row['id_owner'] == $CurrentUser['id']) { $YourPlanet = true; $UsedPlanet = true; } else { $UsedPlanet = true; } break; } } if ($_POST['planettype'] == 2) { if ($_POST['ship209'] >= 1) { $missiontype = array(8 => $lang['type_mission'][8]); } else { $missiontype = array(); } } elseif ($_POST['planettype'] == 1 or $_POST['planettype'] == 3) { if ($_POST['ship208'] >= 1 && !$UsedPlanet) { $missiontype = array(7 => $lang['type_mission'][7]); } elseif ($_POST['ship210'] >= 1 && !$YourPlanet) { $missiontype = array(6 => $lang['type_mission'][6]); } if ($_POST['ship202'] >= 1 || $_POST['ship203'] >= 1 || $_POST['ship204'] >= 1 || $_POST['ship205'] >= 1 || $_POST['ship206'] >= 1 || $_POST['ship207'] >= 1 || $_POST['ship210'] >= 1 || $_POST['ship211'] >= 1 || $_POST['ship213'] >= 1 || $_POST['ship214'] >= 1 || $_POST['ship215'] >= 1 || $_POST['ship216'] >= 1 || $_POST['ship217'] >= 1 || $_POST['ship218'] >= 1 || $_POST['ship219'] >= 1 || $_POST['ship220'] >= 1 || $_POST['ship221'] >= 1 || $_POST['ship222'] >= 1 || $_POST['ship223'] >= 1 || $_POST['ship224'] >= 1 || $_POST['ship225'] >= 1 || $_POST['ship226'] >= 1) { if (!$YourPlanet) { $missiontype[1] = $lang['type_mission'][1]; } $missiontype[3] = $lang['type_mission'][3]; $missiontype[5] = $lang['type_mission'][5]; } } elseif ($_POST['ship209'] >= 1 || $_POST['ship208']) { $missiontype[3] = $lang['type_mission'][3]; } if ($YourPlanet) { $missiontype[4] = $lang['type_mission'][4]; } if (($_POST['planettype'] == 3 || $_POST['planettype'] == 1) && $fleet_group_mr > 0 && $UsedPlanet) { $missiontype[2] = $lang['type_mission'][2]; } if ($_POST['planettype'] == 3 && $_POST['ship214'] >= 1 && !$YourPlanet && $UsedPlanet && $CurrentUser['rpg_empereur'] == 1) { $missiontype[9] = $lang['type_mission'][9]; } $fleetarray = unserialize(base64_decode(str_rot13($_POST["usedfleet"]))); $mission = $_POST['target_mission']; $SpeedFactor = $_POST['speedfactor']; $AllFleetSpeed = GetFleetMaxSpeed($fleetarray, 0, $CurrentUser); $GenFleetSpeed = $_POST['speed']; $MaxFleetSpeed = min($AllFleetSpeed); $distance = GetTargetDistance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']); $duration = GetMissionDuration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor); $consumption = GetFleetConsumption($fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $CurrentUser); $MissionSelector = ""; if (count($missiontype) > 0) { if ($planet == 16) { $MissionSelector .= "<tr height=\"20\">"; $MissionSelector .= "<th>"; $MissionSelector .= "<input type=\"radio\" name=\"mission\" value=\"15\" checked=\"checked\">" . $lang['type_mission'][15] . "<br /><br />"; $MissionSelector .= "<font color=\"red\">" . $lang['fl_expedition_alert_message'] . "</font>"; $MissionSelector .= "</th>"; $MissionSelector .= "</tr>"; } else { $i = 0; foreach ($missiontype as $a => $b) { $MissionSelector .= "<tr height=\"20\">"; $MissionSelector .= "<th>"; $MissionSelector .= "<input id=\"inpuT_" . $i . "\" type=\"radio\" name=\"mission\" value=\"" . $a . "\"" . ($mission == $a ? " checked=\"checked\"" : "") . ">"; $MissionSelector .= "<label for=\"inpuT_" . $i . "\">" . $b . "</label><br>"; $MissionSelector .= "</th>"; $MissionSelector .= "</tr>"; $i++; } } } else { header("location:game.php?page=fleet"); } if ($_POST['thisplanettype'] == 1) { $parse['title'] = "" . $_POST['thisgalaxy'] . ":" . $_POST['thissystem'] . ":" . $_POST['thisplanet'] . " - " . $lang['fl_planet'] . ""; } elseif ($_POST['thisplanettype'] == 3) { $parse['title'] = "" . $_POST['thisgalaxy'] . ":" . $_POST['thissystem'] . ":" . $_POST['thisplanet'] . " - " . $lang['fl_moon'] . ""; } $parse['metal_fleet'] = floor($CurrentPlanet["metal"]); $parse['crystal_fleet'] = floor($CurrentPlanet["crystal"]); $parse['deuterium_fleet'] = floor($CurrentPlanet["deuterium"]); $parse['consumption'] = $consumption; $parse['distance'] = $distance; $parse['speedfactor_fleet'] = $_POST['speedfactor']; $parse['thisgalaxy_fleet'] = $_POST["thisgalaxy"]; $parse['thissystem_fleet'] = $_POST["thissystem"]; $parse['thisplanet_fleet'] = $_POST["thisplanet"]; $parse['galaxy_fleet'] = $_POST["galaxy"]; $parse['system_fleet'] = $_POST["system"]; $parse['planet_fleet'] = $_POST["planet"]; $parse['thisplanettype_fleet'] = $_POST["thisplanettype"]; $parse['planettype_fleet'] = $_POST["planettype"]; $parse['speedallsmin_fleet'] = $_POST["speedallsmin"]; $parse['speed_fleet'] = $_POST['speed']; $parse['speedfactor_fleet'] = $_POST["speedfactor"]; $parse['usedfleet_fleet'] = $_POST["usedfleet"]; $parse['maxepedition_fleet'] = $_POST['maxepedition']; $parse['curepedition_fleet'] = $_POST['curepedition']; $parse['fleet_group_fleet'] = $_POST['fleet_group']; $parse['acs_target_mr_fleet'] = $_POST['acs_target_mr']; foreach ($fleetarray as $Ship => $Count) { $input_extra .= "<input type=\"hidden\" name=\"ship" . $Ship . "\" value=\"" . $Count . "\" />\n"; $input_extra .= "<input type=\"hidden\" name=\"capacity" . $Ship . "\" value=\"" . $pricelist[$Ship]['capacity'] . "\" />\n"; $input_extra .= "<input type=\"hidden\" name=\"consumption" . $Ship . "\" value=\"" . GetShipConsumption($Ship, $CurrentUser) . "\" />\n"; $input_extra .= "<input type=\"hidden\" name=\"speed" . $Ship . "\" value=\"" . GetFleetMaxSpeed("", $Ship, $CurrentUser) . "\" />\n"; } $parse['input_extra'] = $input_extra; $parse['missionselector'] = $MissionSelector; if ($planet == 16) { $StayBlock .= "<tr height=\"20\">"; $StayBlock .= "<td class=\"c\" colspan=\"3\">" . $lang['fl_hold_time'] . "</td>"; $StayBlock .= "</tr>"; $StayBlock .= "<tr height=\"20\">"; $StayBlock .= "<th colspan=\"3\">"; $StayBlock .= "<select name=\"expeditiontime\" >"; $StayBlock .= "<option value=\"1\">1</option>"; $StayBlock .= "<option value=\"2\">2</option>"; $StayBlock .= "</select>"; $StayBlock .= "hora(s)"; $StayBlock .= "</th>"; $StayBlock .= "</tr>"; } elseif ($missiontype[5] != '') { $StayBlock .= "<tr height=\"20\">"; $StayBlock .= "<td class=\"c\" colspan=\"3\">" . $lang['fl_hold_time'] . "</td>"; $StayBlock .= "</tr>"; $StayBlock .= "<tr height=\"20\">"; $StayBlock .= "<th colspan=\"3\">"; $StayBlock .= "<select name=\"holdingtime\" >"; $StayBlock .= "<option value=\"0\">0</option>"; $StayBlock .= "<option value=\"1\">1</option>"; $StayBlock .= "<option value=\"2\">2</option>"; $StayBlock .= "<option value=\"4\">4</option>"; $StayBlock .= "<option value=\"8\">8</option>"; $StayBlock .= "<option value=\"16\">16</option>"; $StayBlock .= "<option value=\"32\">32</option>"; $StayBlock .= "</select>"; $StayBlock .= "hora(s)"; $StayBlock .= "</th>"; $StayBlock .= "</tr>"; } $parse['stayblock'] = $StayBlock; foreach ($parse as $key => $value) { $displays->assign($key, $value); } $displays->display(); }
function flt_can_attack($planet_src, $planet_dst, $fleet = array(), $mission, $options = false) { global $config, $sn_data, $user, $time_now; if ($user['vacation']) { return ATTACK_OWN_VACATION; } if (empty($fleet) || !is_array($fleet)) { return ATTACK_NO_FLEET; } foreach ($fleet as $ship_id => $ship_count) { if ($ship_count > $planet_src[$sn_data[$ship_id]['name']]) { return ATTACK_NO_SHIPS; } } $speed = $options['speed']; if ($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { return ATTACK_WRONG_SPEED; } $speed_factor = get_fleet_speed(); $distance = GetTargetDistance($planet_src['galaxy'], $planet_dst['galaxy'], $planet_src['system'], $planet_dst['system'], $planet_src['planet'], $planet_dst['planet']); $fleet_speed = min(GetFleetMaxSpeed($fleet, 0, $user)); $fleet_speed_percent = $options['fleet_speed_percent'] ? $options['fleet_speed_percent'] : 10; $duration = GetMissionDuration($fleet_speed_percent, $fleet_speed, $distance, $speed_factor); $consumption = GetFleetConsumption($fleet, $speed_factor, $duration, $distance, $fleet_speed, $user, $fleet_speed_percent); if ($planet_src[$sn_data[RES_DEUTERIUM]['name']] < $fleet[RES_DEUTERIUM] + $consumption) { return ATTACK_NO_FUEL; } $fleet_start_time = $time_now + $duration; $fleet_group = $options['fleet_group']; if ($fleet_group) { if ($mission != MT_AKS) { return ATTACK_WRONG_MISSION; } $acs = doquery("SELECT * FROM {{aks}} WHERE id = '{$fleet_group}' LIMIT 1;", '', true); if (!$acs['id']) { return ATTACK_NO_ACS; } if ($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) { return ATTACK_ACS_WRONG_TARGET; } if ($fleet_start_time > $acs['ankunft']) { return ATTACK_ACS_TOO_LATE; } } $flying_fleets = $options['flying_fleets']; if (!$flying_fleets) { $flying_fleets = doquery("SELECT COUNT(fleet_id) AS `flying_fleets` FROM {{fleets}} WHERE `fleet_owner` = '{$user['id']}';", '', true); $flying_fleets = $flying_fleets['flying_fleets']; } if (GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { return ATTACK_NO_SLOTS; } // Checking for no planet if (!$planet_dst['id_owner']) { if ($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { return ATTACK_NO_COLONIZER; } if ($mission == MT_EXPLORE || $mission == MT_COLONIZE) { return ATTACK_ALLOWED; } return ATTACK_NO_TARGET; } if ($mission == MT_RECYCLE) { if ($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { return ATTACK_NO_DEBRIS; } if ($fleet[SHIP_RECYCLER] <= 0) { return ATTACK_NO_RECYCLERS; } return ATTACK_ALLOWED; } // Got planet. Checking if it is ours if ($planet_dst['id_owner'] == $user['id']) { if ($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { return ATTACK_ALLOWED; } return ATTACK_OWN; } // No, planet not ours. Cutting mission that can't be send to not-ours planet if ($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { return ATTACK_WRONG_MISSION; } $enemy = doquery("SELECT * FROM {{users}} WHERE `id` = '{$planet_dst['id_owner']}' LIMIT 1;", '', true); // We cannot attack or send resource to users in VACATION mode if ($enemy['vacation'] && $target_mission != MT_RECYCLE) { return ATTACK_VACATION; } // Multi IP protection. Here we need a procedure to check proxies if (sys_is_multiaccount($user, $enemy)) { return ATTACK_SAME_IP; } $user_points = doquery("SELECT total_points FROM {{statpoints}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '{$user['id']}';", '', true); $user_points = $user_points['total_points']; $enemy_points = doquery("SELECT total_points FROM {{statpoints}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '{$enemy['id']}';", '', true); $enemy_points = $enemy_points['total_points']; // Is it transport? If yes - checking for buffing to prevent mega-alliance destroyer if ($mission == MT_TRANSPORT) { if ($user_points >= $enemy_points || $config->allow_buffing) { return ATTACK_ALLOWED; } else { return ATTACK_BUFFING; } } // Only aggresive missions passed to this point. HOLD counts as passive but aggresive // Is it admin with planet protection? if ($planet_dst['id_level'] > $user['authlevel']) { return ATTACK_ADMIN; } // Okay. Now skipping protection checks for inactive longer then 1 week if (!$enemy['onlinetime'] || $enemy['onlinetime'] >= $time_now - 60 * 60 * 24 * 7) { if ($enemy_points <= $config->game_noob_points && $user_points > $config->game_noob_points || $config->game_noob_factor && $user_points > $enemy_points * $config->game_noob_factor) { if ($mission != MT_HOLD) { return ATTACK_NOOB; } if ($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && $config->ally_help_weak)) { return ATTACK_NOOB; } } } // Is it HOLD mission? If yes - there should be ally deposit if ($mission == MT_HOLD) { if ($planet_dst[$sn_data[34]['name']]) { return ATTACK_ALLOWED; } return ATTACK_NO_ALLY_DEPOSIT; } if ($mission == MT_SPY) { if ($fleet[SHIP_SPY] >= 1) { return ATTACK_ALLOWED; } return ATTACK_NO_SPIES; } // Is it MISSILE mission? if ($mission == MT_MISSILE) { if ($planet_src[$sn_data[44]['name']] < $sn_data[503]['require'][44]) { return ATTACK_NO_SILO; } if (!$fleet[503]) { return ATTACK_NO_MISSILE; } $distance = abs($planet_dst['system'] - $planet_src['system']); $mip_range = get_missile_range(); if ($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { return ATTACK_MISSILE_TOO_FAR; } } if ($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { return ATTACK_WRONG_MISSION; } if ($mission == MT_ATTACK || $mission == MT_AKS || $mission == MT_DESTROY) { return flt_bashing_check($user, $enemy, $planet_dst, $mission, $duration, $fleet_group); } return ATTACK_ALLOWED; }
function ShowFleet3Page($CurrentUser, $CurrentPlanet) { global $resource, $pricelist, $reslist, $phpEx, $lang, $xgp_root, $game_config; include_once $xgp_root . 'includes/functions/IsVacationMode.' . $phpEx; $parse = $lang; if (IsVacationMode($CurrentUser)) { die(message($lang['fl_vacation_mode_active'], "game.php?page=overview", 2)); } $fleet_group_mr = 0; if ($_POST['fleet_group'] > 0) { if ($_POST['mission'] == 2) { $target = "g" . intval($_POST["galaxy"]) . "s" . intval($_POST["system"]) . "p" . intval($_POST["planet"]) . "t" . intval($_POST["planettype"]); if ($_POST['acs_target_mr'] == $target) { $aks_count_mr = doquery("SELECT * FROM {{table}} WHERE id = '" . intval($_POST['fleet_group']) . "'", 'aks'); if (mysql_num_rows($aks_count_mr) > 0) { $fleet_group_mr = $_POST['fleet_group']; } } } } if ($_POST['fleet_group'] == 0 && $_POST['mission'] == 2) { $_POST['mission'] = 1; } $TargetPlanet = doquery("SELECT `id_owner`,`id_level`,`destruyed`,`ally_deposit` FROM {{table}} WHERE `galaxy` = '" . intval($_POST['galaxy']) . "' AND `system` = '" . intval($_POST['system']) . "' AND `planet` = '" . intval($_POST['planet']) . "' AND `planet_type` = '" . intval($_POST['planettype']) . "';", 'planets', true); $MyDBRec = doquery("SELECT `id`,`onlinetime`,`ally_id`,`urlaubs_modus` FROM {{table}} WHERE `id` = '" . intval($CurrentUser['id']) . "';", 'users', true); $IsHereWormHole = doquery("SELECT * FROM {{table}} WHERE (`start_galaxy` = '" . $_POST['galaxy'] . "' AND `start_system` = '" . $_POST['system'] . "' AND `start_planet` = '" . $_POST['planet'] . "') OR (`end_galaxy` = '" . $_POST['galaxy'] . "' AND `end_system` = '" . $_POST['system'] . "' AND `end_planet` = '" . $_POST['planet'] . "');", 'wormholes', true); $protection = $game_config['noobprotection']; $protectiontime = $game_config['noobprotectiontime']; $protectionmulti = $game_config['noobprotectionmulti']; if ($protectiontime < 1) { $protectiontime = 9999999999999999; } $fleetarray = unserialize(base64_decode(str_rot13($_POST["usedfleet"]))); if ($TargetPlanet["destruyed"] != 0) { die(header("Location: game.php?page=fleet")); } if (!is_array($fleetarray)) { die(header("Location: game.php?page=fleet")); } foreach ($fleetarray as $Ship => $Count) { if ($Count > $CurrentPlanet[$resource[$Ship]]) { die(header("Location: game." . $phpEx . "?page=fleet")); } } $error = 0; $galaxy = intval($_POST['galaxy']); $system = intval($_POST['system']); $planet = intval($_POST['planet']); $planettype = intval($_POST['planettype']); $fleetmission = intval($_POST['mission']); if ($planettype != 1 && $planettype != 2 && $planettype != 3) { exit(header("Location: game." . $phpEx . "?page=fleet")); } if ($fleetmission == 8) { $YourPlanet = false; $UsedPlanet = false; $select = doquery("SELECT * FROM {{table}} WHERE galaxy = '" . $galaxy . "' AND system = '" . $system . "' AND planet = '" . $planet . "'", "planets"); } else { $YourPlanet = false; $UsedPlanet = false; $select = doquery("SELECT * FROM {{table}} WHERE galaxy = '" . $galaxy . "' AND system = '" . $system . "' AND planet = '" . $planet . "' AND planet_type = '" . $planettype . "'", "planets"); } if ($CurrentPlanet['galaxy'] == $galaxy && $CurrentPlanet['system'] == $system && $CurrentPlanet['planet'] == $planet && $CurrentPlanet['planet_type'] == $planettype) { exit(header("Location: game." . $phpEx . "?page=fleet")); } if ($_POST['mission'] != 15) { if (mysql_num_rows($select) < 1 && $fleetmission != 7) { exit(header("Location: game." . $phpEx . "?page=fleet")); } elseif ($fleetmission == 9 && mysql_num_rows($select) < 1) { exit(header("Location: game." . $phpEx . "?page=fleet")); } } else { $MaxExpedition = $CurrentUser[$resource[124]]; if ($MaxExpedition >= 1) { $maxexpde = doquery("SELECT COUNT(fleet_owner) AS `expedi` FROM {{table}} WHERE `fleet_owner` = '" . intval($CurrentUser['id']) . "' AND `fleet_mission` = '15';", 'fleets', true); $ExpeditionEnCours = $maxexpde['expedi']; $EnvoiMaxExpedition = 1 + floor($MaxExpedition / 3); } else { $ExpeditionEnCours = 0; $EnvoiMaxExpedition = 0; } if ($EnvoiMaxExpedition == 0) { message("<font color=\"red\"><b>" . $lang['fl_expedition_tech_required'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } elseif ($ExpeditionEnCours >= $EnvoiMaxExpedition) { message("<font color=\"red\"><b>" . $lang['fl_expedition_fleets_limit'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } } $select = mysql_fetch_array($select); if ($select['id_owner'] == $CurrentUser['id']) { $YourPlanet = true; $UsedPlanet = true; } elseif (!empty($select['id_owner'])) { $YourPlanet = false; $UsedPlanet = true; } else { $YourPlanet = false; $UsedPlanet = false; } if (empty($fleetmission)) { exit(header("Location: game." . $phpEx . "?page=fleet")); } if ($TargetPlanet['id_owner'] == '') { $HeDBRec = $MyDBRec; } elseif ($TargetPlanet['id_owner'] != '') { $HeDBRec = doquery("SELECT `id`,`onlinetime`,`ally_id`,`urlaubs_modus` FROM {{table}} WHERE `id` = '" . intval($TargetPlanet['id_owner']) . "';", 'users', true); } $UserPoints = doquery("SELECT `total_points` FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . intval($MyDBRec['id']) . "';", 'statpoints', true); $User2Points = doquery("SELECT `total_points` FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . intval($HeDBRec['id']) . "';", 'statpoints', true); $MyGameLevel = $UserPoints['total_points']; $HeGameLevel = $User2Points['total_points']; if ($HeDBRec['onlinetime'] >= time() - 60 * 60 * 24 * 7) { if ($MyGameLevel > $HeGameLevel * $protectionmulti && $TargetPlanet['id_owner'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 6 or $_POST['mission'] == 9) && $protection == 1 && $HeGameLevel < $protectiontime * 1000) { message("<font color=\"lime\"><b>" . $lang['fl_week_player'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } if ($MyGameLevel * $protectionmulti < $HeGameLevel && $TargetPlanet['id_owner'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 5 or $_POST['mission'] == 6 or $_POST['mission'] == 9) && $protection == 1 && $MyGameLevel < $protectiontime * 1000) { message("<font color=\"red\"><b>" . $lang['fl_strong_player'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } } if ($HeDBRec['urlaubs_modus'] && $_POST['mission'] != 8) { message("<font color=\"lime\"><b>" . $lang['fl_in_vacation_player'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } $FlyingFleets = mysql_fetch_assoc(doquery("SELECT COUNT(fleet_id) as Number FROM {{table}} WHERE `fleet_owner`='" . intval($CurrentUser['id']) . "'", 'fleets')); $ActualFleets = $FlyingFleets["Number"]; if (1 + $CurrentUser[$resource[108]] + $CurrentUser['rpg_commandant'] * COMMANDANT <= $ActualFleets) { message($lang['fl_no_slots'], "game." . $phpEx . "?page=fleet", 1); } if ($_POST['resource1'] + $_POST['resource2'] + $_POST['resource3'] + $_POST['resource4'] < 1 && $_POST['mission'] == 3) { message("<font color=\"lime\"><b>" . $lang['fl_empty_transport'] . "</b></font>", "game." . $phpEx . "?page=fleet", 1); } if ($_POST['mission'] != 15) { if ($TargetPlanet['id_owner'] == '' && $_POST['mission'] < 7) { exit(header("Location: game." . $phpEx . "?page=fleet")); } if ($TargetPlanet['id_owner'] != '' && $_POST['mission'] == 7) { message("<font color=\"red\"><b>" . $lang['fl_planet_populed'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } if ($IsHereWormHole) { message("<font color=\"red\"><b>Hay un agujero de gusano en esa posicion</b></font>", "fleet." . $phpEx, 2); } if ($HeDBRec['ally_id'] != $MyDBRec['ally_id'] && $_POST['mission'] == 4) { message("<font color=\"red\"><b>" . $lang['fl_stay_not_on_enemy'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } if ($TargetPlanet['ally_deposit'] < 1 && $HeDBRec != $MyDBRec && $_POST['mission'] == 5) { message("<font color=\"red\"><b>" . $lang['fl_not_ally_deposit'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } if ($TargetPlanet["id_owner"] == $CurrentPlanet["id_owner"] && ($_POST["mission"] == 1 or $_POST["mission"] == 6)) { exit(header("Location: game." . $phpEx . "?page=fleet")); } if ($TargetPlanet["id_owner"] != $CurrentPlanet["id_owner"] && $_POST["mission"] == 4) { message("<font color=\"red\"><b>" . $lang['fl_deploy_only_your_planets'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } } $missiontype = array(1 => $lang['type_mission'][1], 2 => $lang['type_mission'][2], 3 => $lang['type_mission'][3], 4 => $lang['type_mission'][4], 5 => $lang['type_mission'][5], 6 => $lang['type_mission'][6], 7 => $lang['type_mission'][7], 8 => $lang['type_mission'][8], 9 => $lang['type_mission'][9], 15 => $lang['type_mission'][15]); $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1); $AllFleetSpeed = GetFleetMaxSpeed($fleetarray, 0, $CurrentUser); $GenFleetSpeed = $_POST['speed']; $SpeedFactor = $game_config['fleet_speed'] / 2500; $MaxFleetSpeed = min($AllFleetSpeed); if (!in_array($GenFleetSpeed, $speed_possible)) { exit(header("Location: game." . $phpEx . "?page=fleet")); } if ($MaxFleetSpeed != $_POST['speedallsmin']) { exit(header("Location: game." . $phpEx . "?page=fleet")); } if (!$_POST['planettype']) { exit(header("Location: game." . $phpEx . "?page=fleet")); } if (!$_POST['galaxy'] || !is_numeric($_POST['galaxy']) || $_POST['galaxy'] > MAX_GALAXY_IN_WORLD || $_POST['galaxy'] < 1) { exit(header("Location: game." . $phpEx . "?page=fleet")); } if (!$_POST['system'] || !is_numeric($_POST['system']) || $_POST['system'] > MAX_SYSTEM_IN_GALAXY || $_POST['system'] < 1) { exit(header("Location: game." . $phpEx . "?page=fleet")); } if (!$_POST['planet'] || !is_numeric($_POST['planet']) || $_POST['planet'] > MAX_PLANET_IN_SYSTEM + 1 || $_POST['planet'] < 1) { exit(header("Location: game." . $phpEx . "?page=fleet")); } if ($_POST['thisgalaxy'] != $CurrentPlanet['galaxy'] | $_POST['thissystem'] != $CurrentPlanet['system'] | $_POST['thisplanet'] != $CurrentPlanet['planet'] | $_POST['thisplanettype'] != $CurrentPlanet['planet_type']) { exit(header("Location: game." . $phpEx . "?page=fleet")); } if (!isset($fleetarray)) { exit(header("Location: game." . $phpEx . "?page=fleet")); } if ($_POST['wormhole'] == 'on') { $WormHole = doquery("SELECT * FROM {{table}} WHERE (`start_galaxy` = '" . $_POST['wormhole_galaxy'] . "' AND `start_system` = '" . $_POST['wormhole_system'] . "' AND `start_planet` = '" . $_POST['wormhole_planet'] . "') OR (`end_galaxy` = '" . $_POST['wormhole_galaxy'] . "' AND `end_system` = '" . $_POST['wormhole_system'] . "' AND `end_planet` = '" . $_POST['wormhole_planet'] . "');", 'wormholes', true); if ($WormHole) { if ($WormHole['state'] == 0) { message('El Agujero de gusano esta inestable', "game." . $phpEx . "?page=fleet"); } if ($WormHole['time'] < time() and $WormHole['state'] == 1) { message('El Agujero de gusano esta inestable', "game." . $phpEx . "?page=fleet"); } if ($fleetarray[210] >= 1) { message('Las Sondas de espionaje no pueden atravesar los Agujeros de gusano', "game." . $phpEx . "?page=fleet"); } if ($WormHole['start_galaxy'] == $_POST['wormhole_galaxy'] and $WormHole['start_system'] == $_POST['wormhole_system'] and $WormHole['start_planet'] == $_POST['wormhole_planet']) { $Orientation = 'end'; } else { $Orientation = 'start'; } $distance1 = GetTargetDistance($_POST['thisgalaxy'], $_POST['wormhole_galaxy'], $_POST['thissystem'], $_POST['wormhole_system'], $_POST['thisplanet'], $_POST['wormhole_planet']); $distance2 = GetTargetDistance($WormHole[$Orientation . '_galaxy'], $_POST['galaxy'], $WormHole[$Orientation . '_system'], $_POST['system'], $WormHole[$Orientation . '_planet'], $_POST['planet']); $distance = $distance1 + $distance2; $wormhole_id = $WormHole['id'] . ',' . $Orientation; } else { message('El Agujero de gusano no existe', "game." . $phpEx . "?page=fleet"); } } else { $wormhole_id = 0; $distance = GetTargetDistance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']); } $duration = GetMissionDuration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor); $consumption = GetFleetConsumption($fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $CurrentUser); $fleet['start_time'] = $duration + time(); if ($_POST['mission'] == 15) { $StayDuration = $_POST['expeditiontime'] * 3600; $StayTime = $fleet['start_time'] + $_POST['expeditiontime'] * 3600; } elseif ($_POST['mission'] == 5) { $StayDuration = $_POST['holdingtime'] * 3600; $StayTime = $fleet['start_time'] + $_POST['holdingtime'] * 3600; } else { $StayDuration = 0; $StayTime = 0; } $fleet['end_time'] = $StayDuration + 2 * $duration + time(); $FleetStorage = 0; $FleetShipCount = 0; $fleet_array = ""; $FleetSubQRY = ""; foreach ($fleetarray as $Ship => $Count) { $FleetStorage += $pricelist[$Ship]["capacity"] * $Count; $FleetShipCount += $Count; $fleet_array .= $Ship . "," . $Count . ";"; $FleetSubQRY .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - " . $Count . ", "; } $FleetStorage -= $consumption; $StorageNeeded = 0; $_POST['resource1'] = max(0, (int) trim($_POST['resource1'])); $_POST['resource2'] = max(0, (int) trim($_POST['resource2'])); $_POST['resource3'] = max(0, (int) trim($_POST['resource3'])); $_POST['resource4'] = max(0, (int) trim($_POST['resource4'])); if ($_POST['resource1'] < 1) { $TransMetal = 0; } else { $TransMetal = $_POST['resource1']; $StorageNeeded += $TransMetal; } if ($_POST['resource2'] < 1) { $TransCrystal = 0; } else { $TransCrystal = $_POST['resource2']; $StorageNeeded += $TransCrystal; } if ($_POST['resource3'] < 1) { $TransDeuterium = 0; } else { $TransDeuterium = $_POST['resource3']; $StorageNeeded += $TransDeuterium; } if ($_POST['resource4'] < 1) { $TransTritium = 0; } else { $TransTritium = $_POST['resource4']; $StorageNeeded += $TransTritium; } $StockMetal = $CurrentPlanet['metal']; $StockCrystal = $CurrentPlanet['crystal']; $StockDeuterium = $CurrentPlanet['deuterium']; $StockTritium = $CurrentPlanet['tritium']; $StockDeuterium -= $consumption; $StockOk = false; if ($StockMetal >= $TransMetal) { if ($StockCrystal >= $TransCrystal) { if ($StockDeuterium >= $TransDeuterium) { if ($StockTritium >= $TransTritium) { $StockOk = true; } } } } if (!$StockOk) { message("<font color=\"red\"><b>" . $lang['fl_no_enought_deuterium'] . pretty_number($consumption) . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } if ($StorageNeeded > $FleetStorage) { message("<font color=\"red\"><b>" . $lang['fl_no_enought_cargo_capacity'] . pretty_number($StorageNeeded - $FleetStorage) . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } if ($TargetPlanet['id_level'] > $CurrentUser['authlevel'] && $game_config['adm_attack'] == 0) { message($lang['fl_admins_cannot_be_attacked'], "game." . $phpEx . "?page=fleet", 2); } if ($fleet_group_mr != 0) { $AksStartTime = doquery("SELECT MAX(`fleet_start_time`) AS Start FROM {{table}} WHERE `fleet_group` = '" . $fleet_group_mr . "';", "fleets", true); if ($AksStartTime['Start'] >= $fleet['start_time']) { $fleet['end_time'] += $AksStartTime['Start'] - $fleet['start_time']; $fleet['start_time'] = $AksStartTime['Start']; } else { $QryUpdateFleets = "UPDATE {{table}} SET "; $QryUpdateFleets .= "`fleet_start_time` = '" . $fleet['start_time'] . "', "; $QryUpdateFleets .= "`fleet_end_time` = fleet_end_time + '" . ($fleet['start_time'] - $AksStartTime['Start']) . "' "; $QryUpdateFleets .= "WHERE "; $QryUpdateFleets .= "`fleet_group` = '" . $fleet_group_mr . "';"; doquery($QryUpdateFleets, 'fleets'); $fleet['end_time'] += $fleet['start_time'] - $AksStartTime['Start']; } } $QryInsertFleet = "INSERT INTO {{table}} SET "; $QryInsertFleet .= "`fleet_owner` = '" . intval($CurrentUser['id']) . "', "; $QryInsertFleet .= "`fleet_mission` = '" . intval($_POST['mission']) . "', "; $QryInsertFleet .= "`fleet_amount` = '" . intval($FleetShipCount) . "', "; $QryInsertFleet .= "`fleet_array` = '" . $fleet_array . "', "; $QryInsertFleet .= "`fleet_start_time` = '" . $fleet['start_time'] . "', "; $QryInsertFleet .= "`fleet_start_galaxy` = '" . intval($_POST['thisgalaxy']) . "', "; $QryInsertFleet .= "`fleet_start_system` = '" . intval($_POST['thissystem']) . "', "; $QryInsertFleet .= "`fleet_start_planet` = '" . intval($_POST['thisplanet']) . "', "; $QryInsertFleet .= "`fleet_start_type` = '" . intval($_POST['thisplanettype']) . "', "; $QryInsertFleet .= "`fleet_end_time` = '" . intval($fleet['end_time']) . "', "; $QryInsertFleet .= "`fleet_end_stay` = '" . intval($StayTime) . "', "; $QryInsertFleet .= "`fleet_end_galaxy` = '" . intval($_POST['galaxy']) . "', "; $QryInsertFleet .= "`fleet_end_system` = '" . intval($_POST['system']) . "', "; $QryInsertFleet .= "`fleet_end_planet` = '" . intval($_POST['planet']) . "', "; $QryInsertFleet .= "`fleet_end_type` = '" . intval($_POST['planettype']) . "', "; $QryInsertFleet .= "`fleet_resource_metal` = '" . $TransMetal . "', "; $QryInsertFleet .= "`fleet_resource_crystal` = '" . $TransCrystal . "', "; $QryInsertFleet .= "`fleet_resource_deuterium` = '" . $TransDeuterium . "', "; $QryInsertFleet .= "`fleet_resource_tritium` = '" . $TransTritium . "', "; $QryInsertFleet .= "`fleet_target_owner` = '" . intval($TargetPlanet['id_owner']) . "', "; $QryInsertFleet .= "`fleet_wormhole` = '" . $wormhole_id . "', "; $QryInsertFleet .= "`fleet_group` = '" . intval($fleet_group_mr) . "', "; $QryInsertFleet .= "`start_time` = '" . time() . "';"; doquery($QryInsertFleet, 'fleets'); $QryUpdatePlanet = "UPDATE `{{table}}` SET "; $QryUpdatePlanet .= $FleetSubQRY; $QryUpdatePlanet .= "`metal` = `metal` - " . $TransMetal . ", "; $QryUpdatePlanet .= "`crystal` = `crystal` - " . $TransCrystal . ", "; $QryUpdatePlanet .= "`deuterium` = `deuterium` - " . ($TransDeuterium + $consumption) . ", "; $QryUpdatePlanet .= "`tritium` = `tritium` - " . $TransTritium . " "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = " . intval($CurrentPlanet['id']) . " LIMIT 1;"; doquery($QryUpdatePlanet, "planets"); $parse['mission'] = $missiontype[$_POST['mission']]; $parse['distance'] = pretty_number($distance); $parse['speedallsmin'] = pretty_number($_POST['speedallsmin']); $parse['consumption'] = pretty_number($consumption); $parse['from'] = $_POST['thisgalaxy'] . ":" . $_POST['thissystem'] . ":" . $_POST['thisplanet']; $parse['destination'] = $_POST['galaxy'] . ":" . $_POST['system'] . ":" . $_POST['planet']; $parse['start_time'] = date("M D d H:i:s", $fleet['start_time']); $parse['end_time'] = date("M D d H:i:s", $fleet['end_time']); foreach ($fleetarray as $Ship => $Count) { $fleet_list .= "</tr><tr height=\"20\">"; $fleet_list .= "<th>" . $lang['tech'][$Ship] . "</th>"; $fleet_list .= "<th>" . pretty_number($Count) . "</th>"; } $parse['fleet_list'] = $fleet_list; display(parsetemplate(gettemplate('fleet/fleet3_table'), $parse), false); }
protected function GetFleet() { global $resource, $reslist, $pricelist; $planet = $this->player['planet']; $system = $this->player['system']; $galaxy = $this->player['galaxy']; $fleetarray = array(); $totalships = 0; foreach ($reslist['fleet'] as $Element) { if ($this->CurrentPlanet[$resource[$Element]] > 0 and $Element != 212) { $fleetarray[$Element] = $this->CurrentPlanet[$resource[$Element]]; $totalships += $this->CurrentPlanet[$resource[$Element]]; } } if ($this->CurrentPlanet[$resource[21]] <= 5 and $totalships > 150 or $totalships > 5000) { $AllFleetSpeed = GetFleetMaxSpeed($fleetarray, 0, $this->player); $MaxFleetSpeed = min($AllFleetSpeed); $distance = GetTargetDistance($this->CurrentPlanet['galaxy'], $galaxy, $this->CurrentPlanet['system'], $system, $this->CurrentPlanet['planet'], $planet); $duration = GetMissionDuration(10, $MaxFleetSpeed, $distance, GetGameSpeedFactor()); $consumption = GetFleetConsumption($fleetarray, GetGameSpeedFactor(), $duration, $distance, $MaxFleetSpeed, $this->player); $StayDuration = 0; $StayTime = 0; $fleet['start_time'] = $duration + time(); $fleet['end_time'] = $StayDuration + 2 * $duration + time(); $FleetStorage = 0; $fleet_array2 = ''; $FleetShipCount = 0; $FleetSubQRY = ""; $Mining = array(); foreach ($fleetarray as $Ship => $Count) { $FleetStorage += $pricelist[$Ship]["capacity"] * $Count; $FleetShipCount += $Count; $fleet_array2 .= $Ship . "," . $Count . ";"; $FleetSubQRY .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - " . $Count . " , "; } $FleetStorage -= $consumption; if ($this->CurrentPlanet['metal'] > $FleetStorage / 3) { $Mining['metal'] = $FleetStorage / 3; $FleetStorage = $FleetStorage - $Mining['metal']; } else { $Mining['metal'] = $this->CurrentPlanet['metal']; $FleetStorage = $FleetStorage - $Mining['metal']; } if ($this->CurrentPlanet['crystal'] > $FleetStorage / 2) { $Mining['crystal'] = $FleetStorage / 2; $FleetStorage = $FleetStorage - $Mining['crystal']; } else { $Mining['crystal'] = $this->CurrentPlanet['crystal']; $FleetStorage = $FleetStorage - $Mining['crystal']; } if ($this->CurrentPlanet['deuterium'] > $FleetStorage) { $Mining['deuterium'] = $FleetStorage; $FleetStorage = $FleetStorage - $Mining['deuterium']; } else { $Mining['deuterium'] = $this->CurrentPlanet['deuterium']; $FleetStorage = $FleetStorage - $Mining['deuterium']; } $QryInsertFleet = "INSERT INTO {{table}} SET "; $QryInsertFleet .= "`fleet_owner` = '" . $this->player['id'] . "', "; $QryInsertFleet .= "`fleet_mission` = '4', "; $QryInsertFleet .= "`fleet_amount` = '" . $FleetShipCount . "', "; $QryInsertFleet .= "`fleet_array` = '" . $fleet_array2 . "', "; $QryInsertFleet .= "`fleet_start_time` = '" . $fleet['start_time'] . "', "; $QryInsertFleet .= "`fleet_start_galaxy` = '" . $this->CurrentPlanet['galaxy'] . "', "; $QryInsertFleet .= "`fleet_start_system` = '" . $this->CurrentPlanet['system'] . "', "; $QryInsertFleet .= "`fleet_start_planet` = '" . $this->CurrentPlanet['planet'] . "', "; $QryInsertFleet .= "`fleet_start_type` = '" . $this->CurrentPlanet['planet_type'] . "', "; $QryInsertFleet .= "`fleet_end_time` = '" . $fleet['end_time'] . "', "; $QryInsertFleet .= "`fleet_end_stay` = '" . $StayTime . "', "; $QryInsertFleet .= "`fleet_end_galaxy` = '" . $galaxy . "', "; $QryInsertFleet .= "`fleet_end_system` = '" . $system . "', "; $QryInsertFleet .= "`fleet_end_planet` = '" . $planet . "', "; $QryInsertFleet .= "`fleet_end_type` = '1', "; $QryInsertFleet .= "`fleet_resource_metal` = '" . $Mining['metal'] . "', "; $QryInsertFleet .= "`fleet_resource_crystal` = '" . $Mining['crystal'] . "', "; $QryInsertFleet .= "`fleet_resource_deuterium` = '" . $Mining['deuterium'] . "', "; $QryInsertFleet .= "`fleet_target_owner` = '0', "; $QryInsertFleet .= "`fleet_group` = '0', "; $QryInsertFleet .= "`start_time` = '" . time() . "';"; doquery($QryInsertFleet, 'fleets'); $QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet .= $FleetSubQRY; $QryUpdatePlanet .= "`id` = '" . $this->CurrentPlanet['id'] . "' "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '" . $this->CurrentPlanet['id'] . "'"; doquery($QryUpdatePlanet, "planets"); $this->CurrentPlanet["metal"] -= $Mining['metal']; $this->CurrentPlanet["crystal"] -= $Mining['crystal']; $this->CurrentPlanet["deuterium"] -= $consumption + $Mining['deuterium']; } }
function ShowFleet3Page($CurrentUser, &$CurrentPlanet) { global $resource, $pricelist, $reslist, $phpEx, $lang, $svn_root, $db, $displays; include_once $svn_root . 'includes/functions/IsVacationMode.' . $phpEx; //$parse = $lang; if (IsVacationMode($CurrentUser)) { exit($displays->message($lang['fl_vacation_mode_active'], "game.php?page=overview", 2)); } $displays->assignContent('fleet/fleet3_table'); $fleet_group_mr = 0; if ($_POST['fleet_group'] != 0) { if ($_POST['mission'] == 2) { $aks_count_mr = $db->query("SELECT * FROM {{table}} WHERE id = '" . $_POST['fleet_group'] . "'", 'sac'); if (mysql_num_rows($aks_count_mr) > 0) { $fleet_group_mr = $_POST['fleet_group']; } } } if ($_POST['fleet_group'] == 0 && $_POST['mission'] == 2) { $_POST['mission'] = 1; } $TargetPlanet = $db->query("SELECT `id_owner`,`id_level`,`destruyed`,`ally_deposit` FROM {{table}} WHERE `galaxy` = '" . $_POST['galaxy'] . "' AND `system` = '" . $_POST['system'] . "' AND `planet` = '" . $_POST['planet'] . "' AND `planet_type` = '" . $_POST['planettype'] . "';", 'planets', true); $MyDBRec = $db->query("SELECT `id`,`onlinetime`,`ally_id`,`urlaubs_modus` FROM {{table}} WHERE `id` = '" . $CurrentUser['id'] . "';", 'users', true); $protection = $db->game_config['noobprotection']; $protectiontime = $db->game_config['noobprotectiontime']; $protectionmulti = $db->game_config['noobprotectionmulti']; if ($protectiontime < 1) { $protectiontime = 9999999999999999; } $fleetarray = unserialize(base64_decode(str_rot13($_POST["usedfleet"]))); if ($TargetPlanet["destruyed"] != 0) { exit(header("Location: game." . $phpEx . "?page=fleet")); } if (!is_array($fleetarray)) { exit(header("Location: game." . $phpEx . "?page=fleet")); } foreach ($fleetarray as $Ship => $Count) { if ($Count > $CurrentPlanet[$resource[$Ship]]) { exit(header("location:game." . $phpEx . "?page=fleet")); } } $error = 0; $galaxy = intval($_POST['galaxy']); $system = intval($_POST['system']); $planet = intval($_POST['planet']); $planettype = intval($_POST['planettype']); $fleetmission = $_POST['mission']; if ($planettype != 1 && $planettype != 2 && $planettype != 3) { exit(header("location:game." . $phpEx . "?page=fleet")); } if ($fleetmission == 8) { $YourPlanet = false; $UsedPlanet = false; $select = $db->query("SELECT * FROM {{table}} WHERE galaxy = '" . $galaxy . "' AND system = '" . $system . "' AND planet = '" . $planet . "'", "planets"); } else { $YourPlanet = false; $UsedPlanet = false; $select = $db->query("SELECT * FROM {{table}} WHERE galaxy = '" . $galaxy . "' AND system = '" . $system . "' AND planet = '" . $planet . "' AND planet_type = '" . $planettype . "'", "planets"); } if ($CurrentPlanet['galaxy'] == $galaxy && $CurrentPlanet['system'] == $system && $CurrentPlanet['planet'] == $planet && $CurrentPlanet['planet_type'] == $planettype) { exit(header("location:game." . $phpEx . "?page=fleet")); } if ($_POST['mission'] != 15) { if (mysql_num_rows($select) < 1 && $fleetmission != 7) { exit(header("location:game." . $phpEx . "?page=fleet")); } elseif ($fleetmission == 9 && mysql_num_rows($select) < 1) { exit(header("location:game." . $phpEx . "?page=fleet")); } } else { $MaxExpedition = $CurrentUser[$resource[124]]; if ($MaxExpedition >= 1) { $maxexpde = $db->query("SELECT COUNT(fleet_owner) AS `expedi` FROM {{table}} WHERE `fleet_owner` = '" . $CurrentUser['id'] . "' AND `fleet_mission` = '15';", 'fleets', true); $ExpeditionEnCours = $maxexpde['expedi']; $EnvoiMaxExpedition = 1 + floor($MaxExpedition / 3); } else { $ExpeditionEnCours = 0; $EnvoiMaxExpedition = 0; } if ($EnvoiMaxExpedition == 0) { $displays->message("<font color=\"red\"><b>" . $lang['fl_expedition_tech_required'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } elseif ($ExpeditionEnCours >= $EnvoiMaxExpedition) { $displays->message("<font color=\"red\"><b>" . $lang['fl_expedition_fleets_limit'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } } $select = mysql_fetch_array($select); if ($select['id_owner'] == $CurrentUser['id']) { $YourPlanet = true; $UsedPlanet = true; } elseif (!empty($select['id_owner'])) { $YourPlanet = false; $UsedPlanet = true; } else { $YourPlanet = false; $UsedPlanet = false; } if (empty($fleetmission)) { exit(header("location:game." . $phpEx . "?page=fleet")); } if ($TargetPlanet['id_owner'] == '') { $HeDBRec = $MyDBRec; } elseif ($TargetPlanet['id_owner'] != '') { $HeDBRec = $db->query("SELECT `id`,`onlinetime`,`ally_id`,`urlaubs_modus` FROM {{table}} WHERE `id` = '" . $TargetPlanet['id_owner'] . "';", 'users', true); } $UserPoints = $db->query("SELECT `total_points` FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $MyDBRec['id'] . "';", 'statpoints', true); $User2Points = $db->query("SELECT `total_points` FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $HeDBRec['id'] . "';", 'statpoints', true); $MyGameLevel = $UserPoints['total_points']; $HeGameLevel = $User2Points['total_points']; //PROTECCION include_once "./includes/functions/classes/class.noobs.php"; $noobs = new proteccion_noob(); $noobs->prin = $MyGameLevel; $noobs->mission = $_POST['mission']; $noobs->seco = $HeGameLevel; $noobs->vacation = $HeDBRec['urlaubs_modus']; $noobs_users = $noobs->check(); if ($noobs_users['status']) { $span = explode("_", $noobs_users['lang_g']); $array = array("s" => "red", "w" => "lime", "v" => "lime"); //$ResultMessage = "{$array[$span[1]]}; ".$lang[$noobs_users['lang_f']]." |".$CurrentFlyingFleets." ".$UserSpyProbes." ".$UserRecycles." ".$UserMissiles; //die ( $ResultMessage ); $displays->message("<font color=\"{$array[$span[1]]}\"><b>" . $lang[$noobs_users['lang_f']] . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } /* if($HeDBRec['onlinetime'] >= (time()-60 * 60 * 24 * 7)) { if ($MyGameLevel > ($HeGameLevel * $protectionmulti) && $TargetPlanet['id_owner'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 6 or $_POST['mission'] == 9) && $protection == 1 && $HeGameLevel < ($protectiontime * 1000)) $displays->message("<font color=\"lime\"><b>".$lang['fl_week_player']."</b></font>", "game." . $phpEx . "?page=fleet", 2); if (($MyGameLevel * $protectionmulti) < $HeGameLevel && $TargetPlanet['id_owner'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 5 or $_POST['mission'] == 6 or $_POST['mission'] == 9) && $protection == 1 && $MyGameLevel < ($protectiontime * 1000)) $displays->message("<font color=\"red\"><b>".$lang['fl_strong_player']."</b></font>", "game." . $phpEx . "?page=fleet", 2); } if ($HeDBRec['urlaubs_modus'] && $_POST['mission'] != 8) $displays->message("<font color=\"lime\"><b>".$lang['fl_in_vacation_player']."</b></font>", "game." . $phpEx . "?page=fleet", 2); */ //FIN DE PROTECCION $FlyingFleets = mysql_fetch_assoc($db->query("SELECT COUNT(fleet_id) as Number FROM {{table}} WHERE `fleet_owner`='{$CurrentUser['id']}'", 'fleets')); $ActualFleets = $FlyingFleets["Number"]; if (1 + $CurrentUser[$resource[108]] + $CurrentUser['rpg_commandant'] * 3 <= $ActualFleets) { $displays->message($lang['fl_no_slots'], "game." . $phpEx . "?page=fleet", 1); } if ($_POST['resource1'] + $_POST['resource2'] + $_POST['resource3'] < 1 && $_POST['mission'] == 3) { $displays->message("<font color=\"lime\"><b>" . $lang['fl_empty_transport'] . "</b></font>", "game." . $phpEx . "?page=fleet", 1); } if ($_POST['mission'] != 15) { if ($TargetPlanet['id_owner'] == '' && $_POST['mission'] < 7) { exit(header("location:game." . $phpEx . "?page=fleet")); } if ($TargetPlanet['id_owner'] != '' && $_POST['mission'] == 7) { $displays->message("<font color=\"red\"><b>" . $lang['fl_planet_populed'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } if ($HeDBRec['ally_id'] != $MyDBRec['ally_id'] && $_POST['mission'] == 4) { $displays->message("<font color=\"red\"><b>" . $lang['fl_stay_not_on_enemy'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } if ($TargetPlanet['ally_deposit'] < 1 && $HeDBRec != $MyDBRec && $_POST['mission'] == 5) { $displays->message("<font color=\"red\"><b>" . $lang['fl_not_ally_deposit'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } if ($TargetPlanet["id_owner"] == $CurrentPlanet["id_owner"] && ($_POST["mission"] == 1 or $_POST["mission"] == 6)) { exit(header("location:game." . $phpEx . "?page=fleet")); } if ($TargetPlanet["id_owner"] != $CurrentPlanet["id_owner"] && $_POST["mission"] == 4) { $displays->message("<font color=\"red\"><b>" . $lang['fl_deploy_only_your_planets'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } } $missiontype = array(1 => $lang['type_mission'][1], 2 => $lang['type_mission'][2], 3 => $lang['type_mission'][3], 4 => $lang['type_mission'][4], 5 => $lang['type_mission'][5], 6 => $lang['type_mission'][6], 7 => $lang['type_mission'][7], 8 => $lang['type_mission'][8], 9 => $lang['type_mission'][9], 15 => $lang['type_mission'][15]); $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1); $AllFleetSpeed = GetFleetMaxSpeed($fleetarray, 0, $CurrentUser); $GenFleetSpeed = $_POST['speed']; $SpeedFactor = $_POST['speedfactor']; $MaxFleetSpeed = min($AllFleetSpeed); if (!in_array($GenFleetSpeed, $speed_possible)) { exit(header("location:game." . $phpEx . "?page=fleet")); } if ($MaxFleetSpeed != $_POST['speedallsmin']) { exit(header("location:game." . $phpEx . "?page=fleet")); } if (!$_POST['planettype']) { exit(header("location:game." . $phpEx . "?page=fleet")); } if (!$_POST['galaxy'] || !is_numeric($_POST['galaxy']) || $_POST['galaxy'] > MAX_GALAXY_IN_WORLD || $_POST['galaxy'] < 1) { exit(header("location:game." . $phpEx . "?page=fleet")); } if (!$_POST['system'] || !is_numeric($_POST['system']) || $_POST['system'] > MAX_SYSTEM_IN_GALAXY || $_POST['system'] < 1) { exit(header("location:game." . $phpEx . "?page=fleet")); } if (!$_POST['planet'] || !is_numeric($_POST['planet']) || $_POST['planet'] > MAX_PLANET_IN_SYSTEM + 1 || $_POST['planet'] < 1) { exit(header("location:game." . $phpEx . "?page=fleet")); } if ($_POST['thisgalaxy'] != $CurrentPlanet['galaxy'] | $_POST['thissystem'] != $CurrentPlanet['system'] | $_POST['thisplanet'] != $CurrentPlanet['planet'] | $_POST['thisplanettype'] != $CurrentPlanet['planet_type']) { exit(header("location:game." . $phpEx . "?page=fleet")); } if (!isset($fleetarray)) { exit(header("location:game." . $phpEx . "?page=fleet")); } $distance = GetTargetDistance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']); $duration = GetMissionDuration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor); $consumption = GetFleetConsumption($fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $CurrentUser); $fleet['start_time'] = $duration + time(); if ($_POST['mission'] == 15) { $StayDuration = $_POST['expeditiontime'] * 3600; $StayTime = $fleet['start_time'] + $_POST['expeditiontime'] * 3600; } elseif ($_POST['mission'] == 5) { $StayDuration = $_POST['holdingtime'] * 3600; $StayTime = $fleet['start_time'] + $_POST['holdingtime'] * 3600; } else { $StayDuration = 0; $StayTime = 0; } $StorageNeeded = 0; $_POST['resource1'] = max(0, (int) trim($_POST['resource1'])); $_POST['resource2'] = max(0, (int) trim($_POST['resource2'])); $_POST['resource3'] = max(0, (int) trim($_POST['resource3'])); if ($_POST['resource1'] < 1) { $TransMetal = 0; } else { $TransMetal = $_POST['resource1']; $StorageNeeded += $TransMetal; } if ($_POST['resource2'] < 1) { $TransCrystal = 0; } else { $TransCrystal = $_POST['resource2']; $StorageNeeded += $TransCrystal; } if ($_POST['resource3'] < 1) { $TransDeuterium = 0; } else { $TransDeuterium = $_POST['resource3']; $StorageNeeded += $TransDeuterium; } $FleetShipCount = 0; $FleetStorage = 0; $fleet_array = ""; foreach ($fleetarray as $Ship => $Count) { $fleet_array .= $Ship . "," . $Count . ";"; $FleetStorage += $pricelist[$Ship]["capacity"] * $Count; $FleetShipCount += $Count; $CurrentPlanet[$resource[$Ship]] = $CurrentPlanet[$resource[$Ship]] - $Count; } $StockMetal = $CurrentPlanet['metal']; $StockCrystal = $CurrentPlanet['crystal']; $StockDeuterium = $CurrentPlanet['deuterium']; $StockDeuterium -= $consumption; $StockOk = false; if ($StockMetal >= $TransMetal) { if ($StockCrystal >= $TransCrystal) { if ($StockDeuterium >= $TransDeuterium) { $StockOk = true; } } } if (!$StockOk) { $displays->message("<font color=\"red\"><b>" . $lang['fl_no_enought_deuterium'] . pretty_number($consumption) . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } if ($StorageNeeded > $FleetStorage) { $displays->message("<font color=\"red\"><b>" . $lang['fl_no_enought_cargo_capacity'] . pretty_number($StorageNeeded - $FleetStorage) . "</b></font>", "game." . $phpEx . "?page=fleet", 2); } if ($TargetPlanet['id_level'] > $CurrentUser['authlevel'] && $db->game_config['adm_attack'] == 0) { $displays->message($lang['fl_admins_cannot_be_attacked'], "game." . $phpEx . "?page=fleet", 2); } $fleet['end_time'] = $StayDuration + 2 * $duration + time(); if ($fleet_group_mr != 0) { $AksStartTime = mysql_fetch_array($db->query("SELECT MAX(`fleet_start_time`) AS Start, MAX(`fleet_end_time`) AS End FROM {{table}} WHERE `fleet_group` = '" . $fleet_group_mr . "';", 'fleets')); if ($AksStartTime['Start'] > $fleet['start_time']) { $fleet['start_time'] = $AksStartTime['Start'] + 1; $fleet['end_time'] = $AksStartTime['End'] + 1; } else { $AksTime = mysql_fetch_array($db->query("SELECT fleet_start_time, fleet_end_time FROM {{table}} WHERE `fleet_group` = '" . $fleet_group_mr . "' AND `fleet_mission` = '1';", 'fleets')); if ($AksTime['fleet_start_time'] < $fleet['start_time']) { $QryUpdateFleets = "UPDATE {{table}} SET "; $QryUpdateFleets .= "`fleet_start_time` = '" . $fleet['start_time'] . "', "; $QryUpdateFleets .= "`fleet_end_time` = '" . $fleet['end_time'] . "' "; $QryUpdateFleets .= "WHERE "; $QryUpdateFleets .= "`fleet_group` = '" . $fleet_group_mr . "' AND "; $QryUpdateFleets .= "`fleet_mission` = '1';"; $db->query($QryUpdateFleets, "fleets"); $SelectFleets = $db->query("SELECT * FROM {{table}} WHERE `fleet_group` = '" . $fleet_group_mr . "' AND `fleet_mission` = '2' ORDER BY `fleet_id` ASC ;", 'fleets'); $nb = mysql_num_rows($SelectFleets); $i = 0; if ($nb > 0) { while ($row = mysql_fetch_array($SelectFleets)) { $i++; $row['fleet_start_time'] = $fleet['start_time'] + $i; $row['fleet_end_time'] = $fleet['end_time'] + $i; $QryUpdateFleets = "UPDATE {{table}} SET "; $QryUpdateFleets .= "`fleet_start_time` = '" . $row['fleet_start_time'] . "', "; $QryUpdateFleets .= "`fleet_end_time` = '" . $row['fleet_end_time'] . "' "; $QryUpdateFleets .= "WHERE "; $QryUpdateFleets .= "`fleet_id` = '" . $row['fleet_id'] . "';"; $db->query($QryUpdateFleets, "fleets"); } } $fleet['start_time'] = $fleet['start_time'] + $nb + 1; $fleet['end_time'] = $fleet['end_time'] + $nb + 1; } } } $CurrentPlanet["fleet"] = $fleetarray; $FleetStorage -= $consumption; $CurrentPlanet["metal"] -= $TransMetal; $CurrentPlanet["crystal"] -= $TransCrystal; $CurrentPlanet["deuterium"] -= $TransDeuterium + $consumption; $QryInsertFleet = "INSERT INTO {{table}} SET "; $QryInsertFleet .= "`fleet_owner` = '" . $CurrentUser['id'] . "', "; $QryInsertFleet .= "`fleet_mission` = '" . $_POST['mission'] . "', "; $QryInsertFleet .= "`fleet_amount` = '" . $FleetShipCount . "', "; $QryInsertFleet .= "`fleet_array` = '" . $fleet_array . "', "; $QryInsertFleet .= "`fleet_start_time` = '" . $fleet['start_time'] . "', "; $QryInsertFleet .= "`fleet_start_galaxy` = '" . intval($_POST['thisgalaxy']) . "', "; $QryInsertFleet .= "`fleet_start_system` = '" . intval($_POST['thissystem']) . "', "; $QryInsertFleet .= "`fleet_start_planet` = '" . intval($_POST['thisplanet']) . "', "; $QryInsertFleet .= "`fleet_start_type` = '" . intval($_POST['thisplanettype']) . "', "; $QryInsertFleet .= "`fleet_end_time` = '" . $fleet['end_time'] . "', "; $QryInsertFleet .= "`fleet_end_stay` = '" . $StayTime . "', "; $QryInsertFleet .= "`fleet_end_galaxy` = '" . intval($_POST['galaxy']) . "', "; $QryInsertFleet .= "`fleet_end_system` = '" . intval($_POST['system']) . "', "; $QryInsertFleet .= "`fleet_end_planet` = '" . intval($_POST['planet']) . "', "; $QryInsertFleet .= "`fleet_end_type` = '" . intval($_POST['planettype']) . "', "; $QryInsertFleet .= "`fleet_resource_metal` = '" . $TransMetal . "', "; $QryInsertFleet .= "`fleet_resource_crystal` = '" . $TransCrystal . "', "; $QryInsertFleet .= "`fleet_resource_deuterium` = '" . $TransDeuterium . "', "; $QryInsertFleet .= "`fleet_target_owner` = '" . $TargetPlanet['id_owner'] . "', "; $QryInsertFleet .= "`fleet_group` = '" . $fleet_group_mr . "', "; $QryInsertFleet .= "`start_time` = '" . time() . "';"; $db->query($QryInsertFleet, 'fleets'); $parse['mission'] = $missiontype[$_POST['mission']]; $parse['distance'] = pretty_number($distance); $parse['speedallsmin'] = pretty_number($_POST['speedallsmin']); $parse['consumption'] = pretty_number($consumption); $parse['from'] = $_POST['thisgalaxy'] . ":" . $_POST['thissystem'] . ":" . $_POST['thisplanet']; $parse['destination'] = $_POST['galaxy'] . ":" . $_POST['system'] . ":" . $_POST['planet']; $parse['start_time'] = date("M D d H:i:s", $fleet['start_time']); $parse['end_time'] = date("M D d H:i:s", $fleet['end_time']); foreach ($fleetarray as $Ship => $Count) { $fleet_list .= "</tr><tr height=\"20\">"; $fleet_list .= "<th>" . $lang['tech'][$Ship] . "</th>"; $fleet_list .= "<th>" . pretty_number($Count) . "</th>"; } $parse['fleet_list'] = $fleet_list; foreach ($parse as $key => $value) { $displays->assign($key, $value); } $displays->display(); }
$cant_attack = ATTACK_WRONG_STRUCTURE; die("{$cant_attack}|{$lang['fl_attack_error'][$cant_attack]}|{$CurrentFlyingFleets}|{$UserSpyProbes}|{$UserRecycles}|{$UserMissiles}"); } $mips_sent = $fleet_array[503]; $distance = abs($target_system - $planetrow['system']); $mipRange = $user['impulse_motor_tech'] * 5 - 1; $arrival = $time_now + round((30 + 60 * $distance) / get_fleet_speed()); doquery("INSERT INTO `{{iraks}}` SET\r\n `zielid` = '{$TargetRow['id_owner']}', `galaxy` = '{$target_galaxy}', `system` = '{$target_system}', `planet` = '{$target_planet}',\r\n `owner` = '{$user['id']}', `galaxy_angreifer` = '{$planetrow['galaxy']}', `system_angreifer` = '{$planetrow['system']}', `planet_angreifer` = '{$planetrow['planet']}',\r\n `zeit` = '{$arrival}', `anzahl` = '{$mips_sent}', `primaer` = '{$target_structure}';"); $FleetSubQRY = "`{$sn_data[503]['name']}` = `{$sn_data[503]['name']}` - '{$mips_sent}', "; $Ship = 503; //doquery("UPDATE `{{planets}}` SET WHERE `id` = '{$user['current_planet']}' LIMIT 1;"); } else { $Distance = GetTargetDistance($planetrow['galaxy'], $target_galaxy, $planetrow['system'], $target_system, $planetrow['planet'], $target_planet); $speedall = GetFleetMaxSpeed($fleet_array, 0, $user); $SpeedAllMin = min($speedall); $Duration = GetMissionDuration(10, $SpeedAllMin, $Distance, get_fleet_speed()); $fleet_start_time = $Duration + time(); $fleet_end_time = $Duration * 2 + time(); $consumption = 0; $SpeedFactor = get_fleet_speed(); foreach ($fleet_array as $Ship => $Count) { $ShipSpeed = $sn_data[$Ship]["speed"]; $spd = 35000 / ($Duration * $SpeedFactor - 10) * sqrt($Distance * 10 / $ShipSpeed); $basicConsumption = $sn_data[$Ship]["consumption"] * $Count; $consumption += $basicConsumption * $Distance / 35000 * ($spd / 10 + 1) * ($spd / 10 + 1); } $consumption = round($consumption) + 1; if ($UserDeuterium < $consumption) { $ResultMessage = "13|{$lang['gs_c13']}|{$CurrentFlyingFleets}|{$UserSpyProbes}|{$UserRecycles}|{$UserMissiles}"; die($ResultMessage); }
$missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY]; } } } } } } } if (!$target_mission && is_array($missiontype)) { $target_mission = MT_ATTACK; } ksort($missiontype); $speed_percent = intval($_POST['speed']); $fleet_speed = min(GetFleetMaxSpeed($fleetarray, 0, $user)); $distance = GetTargetDistance($planetrow['galaxy'], $galaxy, $planetrow['system'], $system, $planetrow['planet'], $planet); $duration = GetMissionDuration($speed_percent, $fleet_speed, $distance, $SpeedFactor); $consumption = GetFleetConsumption($fleetarray, $SpeedFactor, $duration, $distance, $fleet_speed, $user, $speed_percent); // No Break // No Break case 1: case 0: $parse['thisgalaxy'] = $planetrow['galaxy']; $parse['thissystem'] = $planetrow['system']; $parse['thisplanet'] = $planetrow['planet']; $parse['thisplanet_type'] = $planetrow['planet_type']; // no break } $parse['galaxy'] = $galaxy; $parse['system'] = $system; $parse['planet'] = $planet; $parse['planet_type'] = $planet_type;
$speeds[$id] = GetShipSpeed($id); //Cargo space $capacity += $pricelist[$id]['capacity'] * $fleetarray[$id]; //Fuel use if ($pricelist[$id]['upgrade'] > 0 && $user[$resource[$pricelist[$id]['drive2']]] > $pricelist[$id]['upgrade']) { $fuel += $pricelist[$id]['consumption2'] * $fleetarray[$id]; } else { $fuel += $pricelist[$id]['consumption'] * $fleetarray[$id]; } } } //Find the minimum speed. $speed = min($speeds); //How Far? $distance = GetTargetDistance($planetrow['galaxy'], $galaxy, $planetrow['system'], $system, $planetrow['planet'], $planet); $duration = GetMissionDuration(GetGameSpeedFactor(), $speed, $distance, $fleetspeed); //$fuelused = GetFleetFuelReq($fleetarray,$speeds,$speed,$fleetspeed,$fuel,$distance); $fuelused = GetFleetFuelReq($fleetspeed, $fuel, $distance); //Holding the fleet if ($fleetmission == 15) { $stay = $_GET['expeditiontime'] * 3600; } elseif ($fleetmission == 5) { $stay = $_GET['holdingtime'] * 3600; } else { $stay = 0; } //Remove fuel from capacity. $capacity -= $consumption; //Currently need no storage... ...but add metal crystal and deut. $StorageNeeded = 0; if ($_GET['resource1'] <= 0) {