@@ -1,5 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | +/** |
|
| 4 | + * @param double $planet_sectors |
|
| 5 | + */ |
|
| 3 | 6 | function uni_create_planet_get_density($position_data, $user_row, $planet_sectors) { |
| 4 | 7 | $density_list = sn_get_groups('planet_density'); |
| 5 | 8 | $density_min = reset($density_list); |
@@ -7,12 +7,12 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | $possible_cores = array(); |
| 9 | 9 | $probability = 0; |
| 10 | - foreach($density_list as $possible_core_id => $core_data) { |
|
| 11 | - if(!$core_data[UNIT_PLANET_DENSITY_RARITY]) { |
|
| 10 | + foreach ($density_list as $possible_core_id => $core_data) { |
|
| 11 | + if (!$core_data[UNIT_PLANET_DENSITY_RARITY]) { |
|
| 12 | 12 | continue; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - if( |
|
| 15 | + if ( |
|
| 16 | 16 | // Core type exists |
| 17 | 17 | in_array($possible_core_id, $position_data['core_types']) |
| 18 | 18 | // Limit core type with planet sector count |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | $random = mt_rand(1, $probability); |
| 35 | 35 | $selected_core = null; |
| 36 | - foreach($possible_cores as $core_type => $core_info) { |
|
| 37 | - if($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) { |
|
| 36 | + foreach ($possible_cores as $core_type => $core_info) { |
|
| 37 | + if ($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) { |
|
| 38 | 38 | $selected_core = $core_info; |
| 39 | 39 | break; |
| 40 | 40 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | function uni_create_planet($Galaxy, $System, $Position, $PlanetOwnerID, $planet_name_unsafe = '', $HomeWorld = false, $options = array()) { |
| 58 | 58 | $Position = intval($Position); |
| 59 | 59 | |
| 60 | - if(!isset($options['skip_check']) && db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
| 60 | + if (!isset($options['skip_check']) && db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
| 61 | 61 | return false; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | $planet_generator = sn_get_groups('planet_generator'); |
| 68 | 68 | |
| 69 | - if($HomeWorld) { |
|
| 69 | + if ($HomeWorld) { |
|
| 70 | 70 | $position_data = $planet_generator[0]; |
| 71 | 71 | } else { |
| 72 | 72 | $position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position]; |
| 73 | - if($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
| 73 | + if ($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
| 74 | 74 | // Корректируем температуру для планеты-странника |
| 75 | 75 | $position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START); |
| 76 | 76 | } |
@@ -170,15 +170,15 @@ discard block |
||
| 170 | 170 | $moon_name = ''; |
| 171 | 171 | $moon_row = array(); |
| 172 | 172 | $moon = db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_MOON, false, 'id'); |
| 173 | - if(!$moon['id']) { |
|
| 173 | + if (!$moon['id']) { |
|
| 174 | 174 | $moon_planet = db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_PLANET, true, '`id`, `temp_min`, `temp_max`, `name`, `debris_metal`, `debris_crystal`'); |
| 175 | 175 | |
| 176 | - if($moon_planet['id']) { |
|
| 176 | + if ($moon_planet['id']) { |
|
| 177 | 177 | $base_storage_size = BASE_STORAGE_SIZE; |
| 178 | 178 | |
| 179 | - if(!$moon_chance) { |
|
| 179 | + if (!$moon_chance) { |
|
| 180 | 180 | $size = mt_rand(1100, 8999); |
| 181 | - } elseif($moon_chance <= 100) { |
|
| 181 | + } elseif ($moon_chance <= 100) { |
|
| 182 | 182 | $size = mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999); |
| 183 | 183 | } else { |
| 184 | 184 | $size = $moon_chance; |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | $field_max = ceil($size / 1000); |
| 196 | 196 | |
| 197 | - if(isset($options['image']) && $options['image']) { |
|
| 197 | + if (isset($options['image']) && $options['image']) { |
|
| 198 | 198 | $moon_image = $options['image']; |
| 199 | 199 | } else { |
| 200 | 200 | $moon_image = 'mond'; |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | `deuterium` = '0', `deuterium_perhour` = '0', `deuterium_max` = '{$base_storage_size}'" |
| 210 | 210 | ); |
| 211 | 211 | |
| 212 | - if($update_debris) { |
|
| 212 | + if ($update_debris) { |
|
| 213 | 213 | $debris_spent = $moon_chance * 1000000; |
| 214 | 214 | $metal_spent = round(min($moon_planet['debris_metal'], $debris_spent * mt_rand(50, 75) / 100)); |
| 215 | 215 | $crystal_spent = min($moon_planet['debris_crystal'], $debris_spent - $metal_spent); |
@@ -244,21 +244,21 @@ discard block |
||
| 244 | 244 | $planet_row['id'] = $user['current_planet']; |
| 245 | 245 | |
| 246 | 246 | // Пытаемся переключить на новую планету |
| 247 | - if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) { |
|
| 247 | + if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) { |
|
| 248 | 248 | $planet_row = db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id'); |
| 249 | 249 | } else { |
| 250 | 250 | $planet_row = db_planet_by_id($planet_row['id']); |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
| 254 | - if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
| 254 | + if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
| 255 | 255 | { |
| 256 | 256 | $planet_row = db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
| 257 | 257 | // Если текущей планеты не существует - выставляем Столицу |
| 258 | - if(!isset($planet_row['id'])) { |
|
| 258 | + if (!isset($planet_row['id'])) { |
|
| 259 | 259 | $planet_row = db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id'); |
| 260 | 260 | // Если и столицы не существует - значит что-то очень не так с записью пользователя |
| 261 | - if(!isset($planet_row['id'])) { |
|
| 261 | + if (!isset($planet_row['id'])) { |
|
| 262 | 262 | global $debug; |
| 263 | 263 | $debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502); |
| 264 | 264 | } |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | // Если производилось переключение планеты - делаем запись в юзере |
| 269 | - if($user['current_planet'] != $planet_row['id']) { |
|
| 269 | + if ($user['current_planet'] != $planet_row['id']) { |
|
| 270 | 270 | db_user_set_by_id($user['id'], "`current_planet` = '{$planet_row['id']}'"); |
| 271 | 271 | $user['current_planet'] = $planet_row['id']; |
| 272 | 272 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) { |
| 287 | - if(!$from['id']) { |
|
| 287 | + if (!$from['id']) { |
|
| 288 | 288 | $result = classLocale::$lang['sys_planet_expedition']; |
| 289 | 289 | } else { |
| 290 | 290 | $from_planet_id = $include_id ? ( |
@@ -334,30 +334,30 @@ discard block |
||
| 334 | 334 | $coordinates["{$prefix}planet"] = intval($coordinates["{$prefix}planet"]); |
| 335 | 335 | |
| 336 | 336 | return |
| 337 | - isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies&& |
|
| 338 | - isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems&& |
|
| 337 | + isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies && |
|
| 338 | + isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems && |
|
| 339 | 339 | isset($coordinates["{$prefix}planet"]) && $coordinates["{$prefix}planet"] > 0 && $coordinates["{$prefix}planet"] <= Vector::$knownPlanets; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | function uni_planet_teleport_check($user, $planetrow, $new_coordinates = null) { |
| 343 | 343 | try { |
| 344 | - if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
| 344 | + if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
| 345 | 345 | throw new exception(classLocale::$lang['ov_teleport_err_cooldown'], ERR_ERROR); |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) { |
|
| 348 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) { |
|
| 349 | 349 | throw new exception(classLocale::$lang['ov_teleport_err_no_dark_matter'], ERR_ERROR); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | // TODO: Replace quick-check with using gathered flying fleet data |
| 353 | - if(FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
| 353 | + if (FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
| 354 | 354 | throw new exception(classLocale::$lang['ov_teleport_err_fleet'], ERR_ERROR); |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - if(is_array($new_coordinates)) { |
|
| 357 | + if (is_array($new_coordinates)) { |
|
| 358 | 358 | $new_coordinates['planet_type'] = PT_PLANET; |
| 359 | 359 | $incoming = db_planet_by_vector($new_coordinates, '', true, 'id'); |
| 360 | - if($incoming['id']) { |
|
| 360 | + if ($incoming['id']) { |
|
| 361 | 361 | throw new exception(classLocale::$lang['ov_teleport_err_destination_busy'], ERR_ERROR); |
| 362 | 362 | } |
| 363 | 363 | } |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | 'result' => ERR_NONE, |
| 367 | 367 | 'message' => '', |
| 368 | 368 | ); |
| 369 | - } catch(exception $e) { |
|
| 369 | + } catch (exception $e) { |
|
| 370 | 370 | $response = array( |
| 371 | 371 | 'result' => $e->getCode(), |
| 372 | 372 | 'message' => $e->getMessage(), |
@@ -841,6 +841,9 @@ discard block |
||
| 841 | 841 | return max(0, $this->shipsGetCapacity() - $this->resourcesGetTotal()); |
| 842 | 842 | } |
| 843 | 843 | |
| 844 | + /** |
|
| 845 | + * @param integer $ship_id |
|
| 846 | + */ |
|
| 844 | 847 | public function shipsGetTotalById($ship_id) { |
| 845 | 848 | return $this->unitList->unitsCountById($ship_id); |
| 846 | 849 | } |
@@ -955,7 +958,7 @@ discard block |
||
| 955 | 958 | /** |
| 956 | 959 | * Set current resource list from array of units |
| 957 | 960 | * |
| 958 | - * @param array $resource_list |
|
| 961 | + * @param integer[] $resource_list |
|
| 959 | 962 | */ |
| 960 | 963 | public function resourcesSet($resource_list) { |
| 961 | 964 | if(!empty($this->propertiesAdjusted['resource_list'])) { |
@@ -1000,7 +1003,7 @@ discard block |
||
| 1000 | 1003 | } |
| 1001 | 1004 | |
| 1002 | 1005 | /** |
| 1003 | - * @param array $rate |
|
| 1006 | + * @param integer[] $rate |
|
| 1004 | 1007 | * |
| 1005 | 1008 | * @return float |
| 1006 | 1009 | */ |
@@ -1031,7 +1034,6 @@ discard block |
||
| 1031 | 1034 | * Restores fleet or resources to planet |
| 1032 | 1035 | * |
| 1033 | 1036 | * @param bool $start |
| 1034 | - * @param bool $only_resources |
|
| 1035 | 1037 | * @param int $result |
| 1036 | 1038 | * |
| 1037 | 1039 | * @return int |
@@ -1347,6 +1349,9 @@ discard block |
||
| 1347 | 1349 | } |
| 1348 | 1350 | } |
| 1349 | 1351 | |
| 1352 | + /** |
|
| 1353 | + * @param integer $errorCode |
|
| 1354 | + */ |
|
| 1350 | 1355 | public function restrictToPlanet($errorCode) { |
| 1351 | 1356 | if($this->targetVector->type != PT_PLANET) { |
| 1352 | 1357 | throw new Exception($errorCode, $errorCode); |
@@ -1361,6 +1366,9 @@ discard block |
||
| 1361 | 1366 | } |
| 1362 | 1367 | } |
| 1363 | 1368 | |
| 1369 | + /** |
|
| 1370 | + * @param integer $missilesAttack |
|
| 1371 | + */ |
|
| 1364 | 1372 | public function restrictToAttackMissiles($missilesAttack) { |
| 1365 | 1373 | if($missilesAttack != $this->shipsGetTotal()) { |
| 1366 | 1374 | throw new Exception('FLIGHT_SHIPS_ONLY_MISSILES', FLIGHT_SHIPS_ONLY_MISSILES); |
@@ -307,9 +307,9 @@ discard block |
||
| 307 | 307 | public function tplRenderAvailableShips($playerRow, $planetRow) { |
| 308 | 308 | $record_index = 0; |
| 309 | 309 | $ship_list = array(); |
| 310 | - foreach(sn_get_groups('fleet') as $n => $unit_id) { |
|
| 310 | + foreach (sn_get_groups('fleet') as $n => $unit_id) { |
|
| 311 | 311 | $unit_level = mrc_get_level($playerRow, $planetRow, $unit_id, false, true); |
| 312 | - if($unit_level <= 0) { |
|
| 312 | + if ($unit_level <= 0) { |
|
| 313 | 313 | continue; |
| 314 | 314 | } |
| 315 | 315 | $ship_data = get_ship_data($unit_id, $playerRow); |
@@ -337,8 +337,8 @@ discard block |
||
| 337 | 337 | public function tplSortShipList(&$ship_list) { |
| 338 | 338 | $fleet_ship_sort = classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT]; |
| 339 | 339 | $fleet_ship_sort_inverse = classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE]; |
| 340 | - if($fleet_ship_sort || $fleet_ship_sort_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
| 341 | - switch($fleet_ship_sort) { |
|
| 340 | + if ($fleet_ship_sort || $fleet_ship_sort_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
| 341 | + switch ($fleet_ship_sort) { |
|
| 342 | 342 | case PLAYER_OPTION_SORT_NAME: |
| 343 | 343 | $fleet_ship_sort_field = 'NAME'; |
| 344 | 344 | break; |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | break; |
| 357 | 357 | } |
| 358 | 358 | $fleet_ship_sort_inverse_a = $fleet_ship_sort_inverse ? -1 : 1; |
| 359 | - usort($ship_list, function ($a, $b) use ($fleet_ship_sort_field, $fleet_ship_sort_inverse_a) { |
|
| 359 | + usort($ship_list, function($a, $b) use ($fleet_ship_sort_field, $fleet_ship_sort_inverse_a) { |
|
| 360 | 360 | return $a[$fleet_ship_sort_field] < $b[$fleet_ship_sort_field] ? -1 * $fleet_ship_sort_inverse_a : ( |
| 361 | 361 | $a[$fleet_ship_sort_field] > $b[$fleet_ship_sort_field] ? 1 * $fleet_ship_sort_inverse_a : 0 |
| 362 | 362 | ); |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | public function dbInsert() { |
| 379 | 379 | // WARNING! MISSION TIMES MUST BE SET WITH set_times() method! |
| 380 | 380 | // TODO - more checks! |
| 381 | - if(empty($this->_time_launch)) { |
|
| 381 | + if (empty($this->_time_launch)) { |
|
| 382 | 382 | die('Fleet time not set!'); |
| 383 | 383 | } |
| 384 | 384 | |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | // Записываем изменения в БД |
| 588 | 588 | $this->dbSave(); |
| 589 | 589 | |
| 590 | - if($this->_group_id) { |
|
| 590 | + if ($this->_group_id) { |
|
| 591 | 591 | // TODO: Make here to delete only one AKS - by adding aks_fleet_count to AKS table |
| 592 | 592 | db_fleet_aks_purge(); |
| 593 | 593 | } |
@@ -654,18 +654,18 @@ discard block |
||
| 654 | 654 | */ |
| 655 | 655 | // TODO - separate shipList and unitList |
| 656 | 656 | public function unitsSetFromArray($unit_array) { |
| 657 | - if(empty($unit_array) || !is_array($unit_array)) { |
|
| 657 | + if (empty($unit_array) || !is_array($unit_array)) { |
|
| 658 | 658 | return; |
| 659 | 659 | } |
| 660 | - foreach($unit_array as $unit_id => $unit_count) { |
|
| 660 | + foreach ($unit_array as $unit_id => $unit_count) { |
|
| 661 | 661 | $unit_count = floatval($unit_count); |
| 662 | - if(!$unit_count) { |
|
| 662 | + if (!$unit_count) { |
|
| 663 | 663 | continue; |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | - if($this->isShip($unit_id)) { |
|
| 666 | + if ($this->isShip($unit_id)) { |
|
| 667 | 667 | $this->unitList->unitSetCount($unit_id, $unit_count); |
| 668 | - } elseif($this->isResource($unit_id)) { |
|
| 668 | + } elseif ($this->isResource($unit_id)) { |
|
| 669 | 669 | $this->resource_list[$unit_id] = $unit_count; |
| 670 | 670 | } else { |
| 671 | 671 | throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), ERR_ERROR); |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | public function parse_missile_db_row($missile_db_row) { |
| 695 | 695 | // $this->_reset(); |
| 696 | 696 | |
| 697 | - if(empty($missile_db_row) || !is_array($missile_db_row)) { |
|
| 697 | + if (empty($missile_db_row) || !is_array($missile_db_row)) { |
|
| 698 | 698 | return; |
| 699 | 699 | } |
| 700 | 700 | |
@@ -857,7 +857,7 @@ discard block |
||
| 857 | 857 | public function shipsGetCapacityRecyclers(array $recycler_info) { |
| 858 | 858 | $recyclers_incoming_capacity = 0; |
| 859 | 859 | $fleet_data = $this->shipsGetArray(); |
| 860 | - foreach($recycler_info as $recycler_id => $recycler_data) { |
|
| 860 | + foreach ($recycler_info as $recycler_id => $recycler_data) { |
|
| 861 | 861 | $recyclers_incoming_capacity += $fleet_data[$recycler_id] * $recycler_data['capacity']; |
| 862 | 862 | } |
| 863 | 863 | |
@@ -877,7 +877,7 @@ discard block |
||
| 877 | 877 | sn_db_transaction_check(true); |
| 878 | 878 | |
| 879 | 879 | // Если флот уже обработан - не существует или возращается - тогда ничего не делаем |
| 880 | - if($this->isEmpty()) { |
|
| 880 | + if ($this->isEmpty()) { |
|
| 881 | 881 | return $result; |
| 882 | 882 | } |
| 883 | 883 | |
@@ -899,18 +899,18 @@ discard block |
||
| 899 | 899 | // TODO - Проверка, что планета всё еще существует на указанных координатах, а не телепортировалась, не удалена хозяином, не уничтожена врагом |
| 900 | 900 | // Флот, который возвращается на захваченную планету, пропадает |
| 901 | 901 | // Ship landing is possible only to fleet owner's planet |
| 902 | - if($this->getPlayerOwnerId() == $planet_arrival['id_owner']) { |
|
| 902 | + if ($this->getPlayerOwnerId() == $planet_arrival['id_owner']) { |
|
| 903 | 903 | $db_changeset = array(); |
| 904 | 904 | |
| 905 | 905 | $fleet_array = $this->shipsGetArray(); |
| 906 | - foreach($fleet_array as $ship_id => $ship_count) { |
|
| 907 | - if($ship_count) { |
|
| 906 | + foreach ($fleet_array as $ship_id => $ship_count) { |
|
| 907 | + if ($ship_count) { |
|
| 908 | 908 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($ship_id, $ship_count, $user, $planet_arrival['id']); |
| 909 | 909 | } |
| 910 | 910 | } |
| 911 | 911 | |
| 912 | 912 | // Adjusting ship amount on planet |
| 913 | - if(!empty($db_changeset)) { |
|
| 913 | + if (!empty($db_changeset)) { |
|
| 914 | 914 | db_changeset_apply($db_changeset); |
| 915 | 915 | } |
| 916 | 916 | |
@@ -958,7 +958,7 @@ discard block |
||
| 958 | 958 | * @param array $resource_list |
| 959 | 959 | */ |
| 960 | 960 | public function resourcesSet($resource_list) { |
| 961 | - if(!empty($this->propertiesAdjusted['resource_list'])) { |
|
| 961 | + if (!empty($this->propertiesAdjusted['resource_list'])) { |
|
| 962 | 962 | throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR); |
| 963 | 963 | } |
| 964 | 964 | $this->resourcesAdjust($resource_list, true); |
@@ -972,13 +972,13 @@ discard block |
||
| 972 | 972 | public function resourcesAdjust($resource_delta_list, $replace_value = false) { |
| 973 | 973 | !is_array($resource_delta_list) ? $resource_delta_list = array() : false; |
| 974 | 974 | |
| 975 | - foreach($resource_delta_list as $resource_id => $unit_delta) { |
|
| 976 | - if(!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) { |
|
| 975 | + foreach ($resource_delta_list as $resource_id => $unit_delta) { |
|
| 976 | + if (!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) { |
|
| 977 | 977 | // Not a resource or no resources - continuing |
| 978 | 978 | continue; |
| 979 | 979 | } |
| 980 | 980 | |
| 981 | - if($replace_value) { |
|
| 981 | + if ($replace_value) { |
|
| 982 | 982 | $this->resource_list[$resource_id] = $unit_delta; |
| 983 | 983 | } else { |
| 984 | 984 | $this->resource_list[$resource_id] += $unit_delta; |
@@ -988,7 +988,7 @@ discard block |
||
| 988 | 988 | } |
| 989 | 989 | |
| 990 | 990 | // Check for negative unit value |
| 991 | - if($this->resource_list[$resource_id] < 0) { |
|
| 991 | + if ($this->resource_list[$resource_id] < 0) { |
|
| 992 | 992 | // TODO |
| 993 | 993 | throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR); |
| 994 | 994 | } |
@@ -1040,7 +1040,7 @@ discard block |
||
| 1040 | 1040 | sn_db_transaction_check(true); |
| 1041 | 1041 | |
| 1042 | 1042 | // Если флот уже обработан - не существует или возращается - тогда ничего не делаем |
| 1043 | - if(!$this->resourcesGetTotal()) { |
|
| 1043 | + if (!$this->resourcesGetTotal()) { |
|
| 1044 | 1044 | return $result; |
| 1045 | 1045 | } |
| 1046 | 1046 | |
@@ -1060,7 +1060,7 @@ discard block |
||
| 1060 | 1060 | // TODO - Проверка, что планета всё еще существует на указанных координатах, а не телепортировалась, не удалена хозяином, не уничтожена врагом |
| 1061 | 1061 | |
| 1062 | 1062 | // Restoring resources to planet |
| 1063 | - if($this->resourcesGetTotal()) { |
|
| 1063 | + if ($this->resourcesGetTotal()) { |
|
| 1064 | 1064 | $fleet_resources = $this->resourcesGetList(); |
| 1065 | 1065 | db_planet_set_by_id($planet_arrival['id'], |
| 1066 | 1066 | "`metal` = `metal` + '{$fleet_resources[RES_METAL]}', `crystal` = `crystal` + '{$fleet_resources[RES_CRYSTAL]}', `deuterium` = `deuterium` + '{$fleet_resources[RES_DEUTERIUM]}'"); |
@@ -1112,12 +1112,12 @@ discard block |
||
| 1112 | 1112 | |
| 1113 | 1113 | protected function populateTargetPlanet() { |
| 1114 | 1114 | $targetPlanetCoords = $this->targetVector; |
| 1115 | - if($this->mission_type != MT_NONE) { |
|
| 1115 | + if ($this->mission_type != MT_NONE) { |
|
| 1116 | 1116 | $this->restrictTargetTypeByMission(); |
| 1117 | 1117 | |
| 1118 | 1118 | // TODO - Нельзя тут просто менять тип планеты или координат! |
| 1119 | 1119 | // If current planet type is not allowed on mission - switch planet type |
| 1120 | - if(empty($this->allowed_planet_types[$this->targetVector->type])) { |
|
| 1120 | + if (empty($this->allowed_planet_types[$this->targetVector->type])) { |
|
| 1121 | 1121 | $targetPlanetCoords->type = reset($this->allowed_planet_types); |
| 1122 | 1122 | } |
| 1123 | 1123 | } |
@@ -1126,14 +1126,14 @@ discard block |
||
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | 1128 | protected function restrictTargetTypeByMission() { |
| 1129 | - if($this->_mission_type == MT_MISSILE) { |
|
| 1129 | + if ($this->_mission_type == MT_MISSILE) { |
|
| 1130 | 1130 | $this->allowed_planet_types = array(PT_PLANET => PT_PLANET); |
| 1131 | - } elseif($this->_mission_type == MT_COLONIZE || $this->_mission_type == MT_EXPLORE) { |
|
| 1131 | + } elseif ($this->_mission_type == MT_COLONIZE || $this->_mission_type == MT_EXPLORE) { |
|
| 1132 | 1132 | // TODO - PT_NONE |
| 1133 | 1133 | $this->allowed_planet_types = array(PT_PLANET => PT_PLANET); |
| 1134 | - } elseif($this->_mission_type == MT_RECYCLE) { |
|
| 1134 | + } elseif ($this->_mission_type == MT_RECYCLE) { |
|
| 1135 | 1135 | $this->allowed_planet_types = array(PT_DEBRIS => PT_DEBRIS); |
| 1136 | - } elseif($this->_mission_type == MT_DESTROY) { |
|
| 1136 | + } elseif ($this->_mission_type == MT_DESTROY) { |
|
| 1137 | 1137 | $this->allowed_planet_types = array(PT_MOON => PT_MOON); |
| 1138 | 1138 | } else { |
| 1139 | 1139 | $this->allowed_planet_types = array(PT_PLANET => PT_PLANET, PT_MOON => PT_MOON); |
@@ -1170,7 +1170,7 @@ discard block |
||
| 1170 | 1170 | |
| 1171 | 1171 | lng_include('overview'); |
| 1172 | 1172 | |
| 1173 | - if(empty($this->dbSourcePlanetRow)) { |
|
| 1173 | + if (empty($this->dbSourcePlanetRow)) { |
|
| 1174 | 1174 | message(classLocale::$lang['fl_noplanetrow'], classLocale::$lang['fl_error']); |
| 1175 | 1175 | } |
| 1176 | 1176 | |
@@ -1179,11 +1179,11 @@ discard block |
||
| 1179 | 1179 | $ship_list = $this->tplRenderAvailableShips($this->dbOwnerRow, $this->dbSourcePlanetRow); |
| 1180 | 1180 | $this->tplSortShipList($ship_list); |
| 1181 | 1181 | |
| 1182 | - foreach($ship_list as $ship_data) { |
|
| 1182 | + foreach ($ship_list as $ship_data) { |
|
| 1183 | 1183 | $template->assign_block_vars('ships', $ship_data); |
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | - foreach(classLocale::$lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) { |
|
| 1186 | + foreach (classLocale::$lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) { |
|
| 1187 | 1187 | $template->assign_block_vars('ship_sort_list', array( |
| 1188 | 1188 | 'VALUE' => $sort_id, |
| 1189 | 1189 | 'TEXT' => $sort_text, |
@@ -1239,7 +1239,7 @@ discard block |
||
| 1239 | 1239 | $template = gettemplate('fleet1', true); |
| 1240 | 1240 | |
| 1241 | 1241 | |
| 1242 | - foreach($this->allowed_planet_types as $possible_planet_type_id) { |
|
| 1242 | + foreach ($this->allowed_planet_types as $possible_planet_type_id) { |
|
| 1243 | 1243 | $template->assign_block_vars('possible_planet_type_id', array( |
| 1244 | 1244 | 'ID' => $possible_planet_type_id, |
| 1245 | 1245 | 'NAME' => classLocale::$lang['sys_planet_type'][$possible_planet_type_id], |
@@ -1252,7 +1252,7 @@ discard block |
||
| 1252 | 1252 | 'START_COORDS' => uni_render_coordinates($this->dbSourcePlanetRow), |
| 1253 | 1253 | 'START_NAME' => $this->dbSourcePlanetRow['name'], |
| 1254 | 1254 | ); |
| 1255 | - if(!empty($this->dbTargetRow)) { |
|
| 1255 | + if (!empty($this->dbTargetRow)) { |
|
| 1256 | 1256 | $template_route += array( |
| 1257 | 1257 | 'END_TYPE_TEXT_SH' => classLocale::$lang['sys_planet_type_sh'][$this->dbTargetRow['planet_type']], |
| 1258 | 1258 | 'END_COORDS' => uni_render_coordinates($this->dbTargetRow), |
@@ -1265,13 +1265,13 @@ discard block |
||
| 1265 | 1265 | $fleet = array(); |
| 1266 | 1266 | $this->unitList->unitsRender($page, $fleet, $template); |
| 1267 | 1267 | |
| 1268 | - if(empty($fleet['fleetarray'])) { |
|
| 1268 | + if (empty($fleet['fleetarray'])) { |
|
| 1269 | 1269 | message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5); |
| 1270 | 1270 | } |
| 1271 | 1271 | |
| 1272 | 1272 | // Building list of shortcuts |
| 1273 | 1273 | $query = db_note_list_select_by_owner_and_planet($this->dbOwnerRow); |
| 1274 | - while($shortcut = db_fetch($query)) { |
|
| 1274 | + while ($shortcut = db_fetch($query)) { |
|
| 1275 | 1275 | $template->assign_block_vars('shortcut', array( |
| 1276 | 1276 | 'NAME' => $shortcut['title'], |
| 1277 | 1277 | 'GALAXY' => $shortcut['galaxy'], |
@@ -1286,9 +1286,9 @@ discard block |
||
| 1286 | 1286 | |
| 1287 | 1287 | // Building list of own planets & moons |
| 1288 | 1288 | $colonies = db_planet_list_sorted($this->dbOwnerRow); |
| 1289 | - if(count($colonies) > 1) { |
|
| 1290 | - foreach($colonies as $row) { |
|
| 1291 | - if($row['id'] == $this->dbSourcePlanetRow['id']) { |
|
| 1289 | + if (count($colonies) > 1) { |
|
| 1290 | + foreach ($colonies as $row) { |
|
| 1291 | + if ($row['id'] == $this->dbSourcePlanetRow['id']) { |
|
| 1292 | 1292 | continue; |
| 1293 | 1293 | } |
| 1294 | 1294 | |
@@ -1304,10 +1304,10 @@ discard block |
||
| 1304 | 1304 | } |
| 1305 | 1305 | |
| 1306 | 1306 | $aks_madnessred = db_acs_get_list(); |
| 1307 | - while($row = db_fetch($aks_madnessred)) { |
|
| 1307 | + while ($row = db_fetch($aks_madnessred)) { |
|
| 1308 | 1308 | $members = explode(',', $row['eingeladen']); |
| 1309 | - foreach($members as $a => $b) { |
|
| 1310 | - if($b == $this->dbOwnerRow['id']) { |
|
| 1309 | + foreach ($members as $a => $b) { |
|
| 1310 | + if ($b == $this->dbOwnerRow['id']) { |
|
| 1311 | 1311 | $template->assign_block_vars('acss', array( |
| 1312 | 1312 | 'ID' => $row['id'], |
| 1313 | 1313 | 'NAME' => $row['name'], |
@@ -1342,13 +1342,13 @@ discard block |
||
| 1342 | 1342 | } |
| 1343 | 1343 | |
| 1344 | 1344 | public function restrictToKnownSpace() { |
| 1345 | - if(!$this->targetVector->isInKnownSpace()) { |
|
| 1345 | + if (!$this->targetVector->isInKnownSpace()) { |
|
| 1346 | 1346 | throw new Exception('FLIGHT_VECTOR_BEYOND_SYSTEM', FLIGHT_VECTOR_BEYOND_SYSTEM); |
| 1347 | 1347 | } |
| 1348 | 1348 | } |
| 1349 | 1349 | |
| 1350 | 1350 | public function restrictToPlanet($errorCode) { |
| 1351 | - if($this->targetVector->type != PT_PLANET) { |
|
| 1351 | + if ($this->targetVector->type != PT_PLANET) { |
|
| 1352 | 1352 | throw new Exception($errorCode, $errorCode); |
| 1353 | 1353 | } |
| 1354 | 1354 | } |
@@ -1356,31 +1356,31 @@ discard block |
||
| 1356 | 1356 | public function restrictToNoMissiles() { |
| 1357 | 1357 | $missilesAttack = $this->unitList->unitsCountById(UNIT_DEF_MISSILE_INTERPLANET); |
| 1358 | 1358 | $missilesDefense = $this->unitList->unitsCountById(UNIT_DEF_MISSILE_INTERCEPTOR); |
| 1359 | - if($missilesAttack + $missilesDefense == $this->shipsGetTotal()) { |
|
| 1359 | + if ($missilesAttack + $missilesDefense == $this->shipsGetTotal()) { |
|
| 1360 | 1360 | throw new Exception('FLIGHT_SHIPS_NO_MISSILES', FLIGHT_SHIPS_NO_MISSILES); |
| 1361 | 1361 | } |
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | 1364 | public function restrictToAttackMissiles($missilesAttack) { |
| 1365 | - if($missilesAttack != $this->shipsGetTotal()) { |
|
| 1365 | + if ($missilesAttack != $this->shipsGetTotal()) { |
|
| 1366 | 1366 | throw new Exception('FLIGHT_SHIPS_ONLY_MISSILES', FLIGHT_SHIPS_ONLY_MISSILES); |
| 1367 | 1367 | } |
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | 1370 | public function restrictToSelf() { |
| 1371 | - if($this->dbTargetRow['id'] != $this->getPlayerOwnerId()) { |
|
| 1371 | + if ($this->dbTargetRow['id'] != $this->getPlayerOwnerId()) { |
|
| 1372 | 1372 | throw new Exception('FLIGHT_VECTOR_ONLY_OWN', FLIGHT_VECTOR_ONLY_OWN); |
| 1373 | 1373 | } |
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | 1376 | public function restrictToOther() { |
| 1377 | - if($this->dbTargetRow['id'] == $this->getPlayerOwnerId()) { |
|
| 1377 | + if ($this->dbTargetRow['id'] == $this->getPlayerOwnerId()) { |
|
| 1378 | 1378 | throw new Exception('FLIGHT_VECTOR_ONLY_OTHER', FLIGHT_VECTOR_ONLY_OTHER); |
| 1379 | 1379 | } |
| 1380 | 1380 | } |
| 1381 | 1381 | |
| 1382 | 1382 | public function restrictToNotOnlySpies() { |
| 1383 | - if($this->unitList->unitsCountById(SHIP_SPY) == $this->shipsGetTotal()) { |
|
| 1383 | + if ($this->unitList->unitsCountById(SHIP_SPY) == $this->shipsGetTotal()) { |
|
| 1384 | 1384 | throw new Exception('FLIGHT_SHIPS_NOT_ONLY_SPIES', FLIGHT_SHIPS_NOT_ONLY_SPIES); |
| 1385 | 1385 | } |
| 1386 | 1386 | } |
@@ -1388,7 +1388,7 @@ discard block |
||
| 1388 | 1388 | public function restrictMissionMissile() { |
| 1389 | 1389 | $missilesAttack = $this->unitList->unitsCountById(UNIT_DEF_MISSILE_INTERPLANET); |
| 1390 | 1390 | $missilesDefense = $this->unitList->unitsCountById(UNIT_DEF_MISSILE_INTERCEPTOR); |
| 1391 | - if($this->_mission_type == MT_MISSILE) { |
|
| 1391 | + if ($this->_mission_type == MT_MISSILE) { |
|
| 1392 | 1392 | $this->restrictToAttackMissiles($missilesAttack); |
| 1393 | 1393 | $this->restrictToKnownSpace(); |
| 1394 | 1394 | $this->restrictToOther(); |
@@ -1399,7 +1399,7 @@ discard block |
||
| 1399 | 1399 | throw new Exception('FLIGHT_ALLOWED', FLIGHT_ALLOWED); |
| 1400 | 1400 | } |
| 1401 | 1401 | |
| 1402 | - if($missilesAttack + $missilesDefense > 0) { |
|
| 1402 | + if ($missilesAttack + $missilesDefense > 0) { |
|
| 1403 | 1403 | throw new Exception('FLIGHT_SHIPS_NO_MISSILES', FLIGHT_SHIPS_NO_MISSILES); |
| 1404 | 1404 | } |
| 1405 | 1405 | |
@@ -1409,7 +1409,7 @@ discard block |
||
| 1409 | 1409 | |
| 1410 | 1410 | protected function restrictMissionExplore() { |
| 1411 | 1411 | // Is it exploration - fleet sent beyond of system? |
| 1412 | - if(!$this->targetVector->isInKnownSpace()) { |
|
| 1412 | + if (!$this->targetVector->isInKnownSpace()) { |
|
| 1413 | 1413 | $this->restrictToNotOnlySpies(); |
| 1414 | 1414 | $this->restrictToNoMissiles(); |
| 1415 | 1415 | |
@@ -1424,14 +1424,14 @@ discard block |
||
| 1424 | 1424 | |
| 1425 | 1425 | protected function restrictToColonizer() { |
| 1426 | 1426 | // Colonization fleet should have at least one colonizer |
| 1427 | - if(!$this->unitList->unitsCountById(SHIP_COLONIZER) <= 0) { |
|
| 1427 | + if (!$this->unitList->unitsCountById(SHIP_COLONIZER) <= 0) { |
|
| 1428 | 1428 | throw new Exception('FLIGHT_SHIPS_NO_COLONIZER', FLIGHT_SHIPS_NO_COLONIZER); |
| 1429 | 1429 | } |
| 1430 | 1430 | } |
| 1431 | 1431 | |
| 1432 | 1432 | protected function restrictMissionColonize() { |
| 1433 | 1433 | // Is it colonization - fleet sent to empty place? |
| 1434 | - if(empty($this->dbTargetRow)) { |
|
| 1434 | + if (empty($this->dbTargetRow)) { |
|
| 1435 | 1435 | // Only planet can be destination for colonization |
| 1436 | 1436 | $this->restrictToPlanet(FLIGHT_MISSION_COLONIZE_NOT_EMPTY); |
| 1437 | 1437 | $this->restrictToColonizer(); |
@@ -1449,25 +1449,25 @@ discard block |
||
| 1449 | 1449 | } |
| 1450 | 1450 | |
| 1451 | 1451 | protected function restrictToMovable() { |
| 1452 | - if(!$this->unitList->unitsIsAllMovable($this->dbOwnerRow)) { |
|
| 1452 | + if (!$this->unitList->unitsIsAllMovable($this->dbOwnerRow)) { |
|
| 1453 | 1453 | throw new Exception('FLIGHT_SHIPS_UNMOVABLE', FLIGHT_SHIPS_UNMOVABLE); |
| 1454 | 1454 | } |
| 1455 | 1455 | } |
| 1456 | 1456 | |
| 1457 | 1457 | protected function restrictToFleetUnits() { |
| 1458 | - if(!$this->unitList->unitsInGroup(sn_get_groups(array('fleet', 'missile')))) { |
|
| 1458 | + if (!$this->unitList->unitsInGroup(sn_get_groups(array('fleet', 'missile')))) { |
|
| 1459 | 1459 | throw new Exception('FLIGHT_SHIPS_UNIT_WRONG', FLIGHT_SHIPS_UNIT_WRONG); |
| 1460 | 1460 | } |
| 1461 | 1461 | } |
| 1462 | 1462 | |
| 1463 | - public function restrictMissionRecycle(){ |
|
| 1464 | - if($this->targetVector->type == PT_DEBRIS) { |
|
| 1463 | + public function restrictMissionRecycle() { |
|
| 1464 | + if ($this->targetVector->type == PT_DEBRIS) { |
|
| 1465 | 1465 | $recyclers = 0; |
| 1466 | - foreach(sn_get_groups('flt_recyclers') as $recycler_id) { |
|
| 1466 | + foreach (sn_get_groups('flt_recyclers') as $recycler_id) { |
|
| 1467 | 1467 | $recyclers += $this->unitList->unitsCountById($recycler_id); |
| 1468 | 1468 | } |
| 1469 | 1469 | |
| 1470 | - if($recyclers <= 0) { |
|
| 1470 | + if ($recyclers <= 0) { |
|
| 1471 | 1471 | throw new Exception('FLIGHT_SHIPS_NO_RECYCLERS', FLIGHT_SHIPS_NO_RECYCLERS); |
| 1472 | 1472 | } |
| 1473 | 1473 | |
@@ -1481,7 +1481,7 @@ discard block |
||
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | 1483 | public function restrictMission() { |
| 1484 | - if($this->targetVector->isEqualToPlanet($this->dbSourcePlanetRow)) { |
|
| 1484 | + if ($this->targetVector->isEqualToPlanet($this->dbSourcePlanetRow)) { |
|
| 1485 | 1485 | throw new Exception('FLIGHT_VECTOR_SAME_SOURCE', FLIGHT_VECTOR_SAME_SOURCE); |
| 1486 | 1486 | } |
| 1487 | 1487 | |
@@ -1512,12 +1512,12 @@ discard block |
||
| 1512 | 1512 | // TODO - later then |
| 1513 | 1513 | |
| 1514 | 1514 | // If no ACS group is shown - then it can't be an ACS attack |
| 1515 | - if(empty($this->_group_id)) { |
|
| 1515 | + if (empty($this->_group_id)) { |
|
| 1516 | 1516 | unset($this->allowed_missions[MT_ACS]); |
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | 1519 | // Checking target owner |
| 1520 | - if($this->dbTargetRow['id'] != $this->getPlayerOwnerId()) { |
|
| 1520 | + if ($this->dbTargetRow['id'] != $this->getPlayerOwnerId()) { |
|
| 1521 | 1521 | // Relocate can be done only on owner's planet/moon |
| 1522 | 1522 | unset($this->allowed_missions[MT_RELOCATE]); |
| 1523 | 1523 | } else { |
@@ -1532,7 +1532,7 @@ discard block |
||
| 1532 | 1532 | } |
| 1533 | 1533 | |
| 1534 | 1534 | // If no Reapers (i.e. Death Star) in fleet - then mission Moon Destroy is unaccessible |
| 1535 | - if($this->targetVector->type == PT_MOON && $this->unitList->unitsCountById(SHIP_HUGE_DEATH_STAR) <= 0) { |
|
| 1535 | + if ($this->targetVector->type == PT_MOON && $this->unitList->unitsCountById(SHIP_HUGE_DEATH_STAR) <= 0) { |
|
| 1536 | 1536 | unset($this->allowed_missions[MT_DESTROY]); |
| 1537 | 1537 | } |
| 1538 | 1538 | } |
@@ -1542,13 +1542,13 @@ discard block |
||
| 1542 | 1542 | |
| 1543 | 1543 | try { |
| 1544 | 1544 | $this->restrictMission(); |
| 1545 | - } catch(Exception $e) { |
|
| 1545 | + } catch (Exception $e) { |
|
| 1546 | 1546 | // TODO - MESSAGE BOX |
| 1547 | 1547 | pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]); |
| 1548 | 1548 | } |
| 1549 | 1549 | |
| 1550 | 1550 | // If mission is not set - setting first mission from allowed |
| 1551 | - if(!$this->_mission_type && is_array($this->allowed_missions)) { |
|
| 1551 | + if (!$this->_mission_type && is_array($this->allowed_missions)) { |
|
| 1552 | 1552 | $this->_mission_type = reset($this->allowed_missions); |
| 1553 | 1553 | } |
| 1554 | 1554 | |
@@ -1558,7 +1558,7 @@ discard block |
||
| 1558 | 1558 | |
| 1559 | 1559 | $template = gettemplate('fleet2', true); |
| 1560 | 1560 | |
| 1561 | - foreach($this->allowed_missions as $key => $value) { |
|
| 1561 | + foreach ($this->allowed_missions as $key => $value) { |
|
| 1562 | 1562 | $template->assign_block_vars('missions', array( |
| 1563 | 1563 | 'ID' => $key, |
| 1564 | 1564 | 'NAME' => classLocale::$lang['type_mission'][$key], |
@@ -1573,7 +1573,7 @@ discard block |
||
| 1573 | 1573 | 'START_NAME' => $planetrow['name'], |
| 1574 | 1574 | ); |
| 1575 | 1575 | |
| 1576 | - if(!empty($TargetPlanet)) { |
|
| 1576 | + if (!empty($TargetPlanet)) { |
|
| 1577 | 1577 | $template_route += array( |
| 1578 | 1578 | 'END_TYPE_TEXT_SH' => classLocale::$lang['sys_planet_type_sh'][$TargetPlanet['planet_type']], |
| 1579 | 1579 | 'END_COORDS' => uni_render_coordinates($TargetPlanet), |
@@ -1584,8 +1584,8 @@ discard block |
||
| 1584 | 1584 | $template->assign_block_vars('fleets', $template_route); |
| 1585 | 1585 | |
| 1586 | 1586 | $sn_groups_fleet = sn_get_groups('fleet'); |
| 1587 | - foreach($fleetarray as $ship_id => $ship_count) { |
|
| 1588 | - if(in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
| 1587 | + foreach ($fleetarray as $ship_id => $ship_count) { |
|
| 1588 | + if (in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
| 1589 | 1589 | // $ship_base_data = get_ship_data($ship_id, $user); |
| 1590 | 1590 | $template->assign_block_vars('fleets.ships', array( |
| 1591 | 1591 | 'ID' => $ship_id, |
@@ -1599,15 +1599,14 @@ discard block |
||
| 1599 | 1599 | } |
| 1600 | 1600 | |
| 1601 | 1601 | $fleet_capacity = 0; |
| 1602 | - foreach($fleetarray as $Ship => $Count) { |
|
| 1602 | + foreach ($fleetarray as $Ship => $Count) { |
|
| 1603 | 1603 | $fleet_capacity += get_unit_param($Ship, P_CAPACITY) * $Count; |
| 1604 | 1604 | } |
| 1605 | 1605 | |
| 1606 | - $max_duration = $this->_mission_type == MT_EXPLORE ? get_player_max_expedition_duration($user) : |
|
| 1607 | - (isset($missiontype[MT_HOLD]) ? 12 : 0); |
|
| 1608 | - if($max_duration) { |
|
| 1606 | + $max_duration = $this->_mission_type == MT_EXPLORE ? get_player_max_expedition_duration($user) : (isset($missiontype[MT_HOLD]) ? 12 : 0); |
|
| 1607 | + if ($max_duration) { |
|
| 1609 | 1608 | $config_game_speed_expedition = ($this->_mission_type == MT_EXPLORE && classSupernova::$config->game_speed_expedition ? classSupernova::$config->game_speed_expedition : 1); |
| 1610 | - for($i = 1; $i <= $max_duration; $i++) { |
|
| 1609 | + for ($i = 1; $i <= $max_duration; $i++) { |
|
| 1611 | 1610 | $template->assign_block_vars('duration', array( |
| 1612 | 1611 | 'ID' => $i, |
| 1613 | 1612 | 'TIME' => pretty_time(ceil($i * 3600 / $config_game_speed_expedition)), |
@@ -1616,7 +1615,7 @@ discard block |
||
| 1616 | 1615 | } |
| 1617 | 1616 | |
| 1618 | 1617 | $sn_group_resources = sn_get_groups('resources'); |
| 1619 | - for($i = 0; $i < 3; $i++) { |
|
| 1618 | + for ($i = 0; $i < 3; $i++) { |
|
| 1620 | 1619 | $amount = $planetrow[$sn_group_resources[$i]] - ($i == 2 ? $travel_data['consumption'] : 0); |
| 1621 | 1620 | $template->assign_block_vars('resources', array( |
| 1622 | 1621 | 'ID' => $i, |
@@ -1626,7 +1625,7 @@ discard block |
||
| 1626 | 1625 | )); |
| 1627 | 1626 | } |
| 1628 | 1627 | |
| 1629 | - if(sn_module::$sn_module['unit_captain']->manifest['active'] && ($captain = sn_module::$sn_module['unit_captain']->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) { |
|
| 1628 | + if (sn_module::$sn_module['unit_captain']->manifest['active'] && ($captain = sn_module::$sn_module['unit_captain']->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) { |
|
| 1630 | 1629 | $template->assign_vars(array( |
| 1631 | 1630 | 'CAPTAIN_ID' => $captain['unit_id'], |
| 1632 | 1631 | 'CAPTAIN_LEVEL' => $captain['captain_level'], |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** |
| 284 | - * @param $page |
|
| 284 | + * @param string $page |
|
| 285 | 285 | * @param $fleet |
| 286 | 286 | * @param template $template |
| 287 | 287 | * |
@@ -332,6 +332,10 @@ discard block |
||
| 332 | 332 | * @return int|mixed |
| 333 | 333 | */ |
| 334 | 334 | // TODO - REDO!!!! |
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * @return double |
|
| 338 | + */ |
|
| 335 | 339 | function flt_fleet_speed($user) { |
| 336 | 340 | $speeds = array(); |
| 337 | 341 | if(!empty($this->mapUnitIdToDb)) { |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @param Unit $value |
| 89 | 89 | */ |
| 90 | 90 | public function offsetSet($offset, $value) { |
| 91 | - if(isset($this->mapUnitIdToDb[$value->unitId])) { |
|
| 91 | + if (isset($this->mapUnitIdToDb[$value->unitId])) { |
|
| 92 | 92 | classSupernova::$debug->error('UnitList::offsetSet: Unit with UnitId ' . $value->unitId . ' already exists'); |
| 93 | 93 | } |
| 94 | 94 | $this->mapUnitIdToDb[$value->unitId] = $value; |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | public function offsetUnset($offset) { |
| 99 | - if(!empty($this[$offset]->unitId)) { |
|
| 99 | + if (!empty($this[$offset]->unitId)) { |
|
| 100 | 100 | // $unit_id = $this[$offset]->unitId; |
| 101 | 101 | // $this->mapUnitIdToDb[$unit_id] = null; |
| 102 | 102 | // unset($this->mapUnitIdToDb[$unit_id]); |
@@ -117,20 +117,20 @@ discard block |
||
| 117 | 117 | public function dbLoad($dbId, $lockSkip = false) { |
| 118 | 118 | // $this->_reset(); |
| 119 | 119 | |
| 120 | - if($dbId <= 0) { |
|
| 120 | + if ($dbId <= 0) { |
|
| 121 | 121 | return; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if(!is_object($this->locatedAt)) { |
|
| 124 | + if (!is_object($this->locatedAt)) { |
|
| 125 | 125 | classSupernova::$debug->error('UnitList::dbLoad have no locatedAt field set'); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | $unit_array = classSupernova::db_get_unit_list_by_location(0, $this->getLocationType(), $this->getLocationDbId()); |
| 129 | - if(!is_array($unit_array)) { |
|
| 129 | + if (!is_array($unit_array)) { |
|
| 130 | 130 | return; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - foreach($unit_array as $unit_db_row) { |
|
| 133 | + foreach ($unit_array as $unit_db_row) { |
|
| 134 | 134 | $unit = $this->_createElement(); |
| 135 | 135 | $unit->dbRowParse($unit_db_row); |
| 136 | 136 | |
@@ -145,25 +145,25 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | public function dbSave() { |
| 148 | - if(!is_object($this->locatedAt)) { |
|
| 148 | + if (!is_object($this->locatedAt)) { |
|
| 149 | 149 | classSupernova::$debug->error('UnitList::dbSave have no locatedAt field set'); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - foreach($this->mapUnitIdToDb as $unit) { |
|
| 152 | + foreach ($this->mapUnitIdToDb as $unit) { |
|
| 153 | 153 | $unit_db_id = $unit->dbId; |
| 154 | 154 | $unit->dbSave(); |
| 155 | 155 | |
| 156 | - if($unit->isEmpty()) { |
|
| 156 | + if ($unit->isEmpty()) { |
|
| 157 | 157 | // Removing unit object |
| 158 | 158 | // TODO - change when there will be common bus for all objects |
| 159 | 159 | // ...or should I? If COUNT is empty - it means that object does not exists in DB. So it should be deleted from PHP memory and cache too |
| 160 | 160 | unset($this[$unit_db_id]); |
| 161 | 161 | } else { |
| 162 | - if($unit->dbId <= 0) { |
|
| 162 | + if ($unit->dbId <= 0) { |
|
| 163 | 163 | classSupernova::$debug->error('Error writing unit to DB'); |
| 164 | 164 | } |
| 165 | 165 | // If unit is new then putting unit object to container |
| 166 | - if(empty($this->_container[$unit->dbId])) { |
|
| 166 | + if (empty($this->_container[$unit->dbId])) { |
|
| 167 | 167 | $this->_container[$unit->dbId] = $unit; |
| 168 | 168 | } |
| 169 | 169 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | public function unitGetCount($unit_id) { |
| 204 | - if(empty($this->mapUnitIdToDb[$unit_id])) { |
|
| 204 | + if (empty($this->mapUnitIdToDb[$unit_id])) { |
|
| 205 | 205 | throw new Exception('Unit [' . $unit_id . '] is not exists in UnitList'); |
| 206 | 206 | } |
| 207 | 207 | return $this->mapUnitIdToDb[$unit_id]->count; |
@@ -216,14 +216,14 @@ discard block |
||
| 216 | 216 | * @param bool $replace_value |
| 217 | 217 | */ |
| 218 | 218 | public function unitAdjustCount($unit_id, $unit_count = 0, $replace_value = false) { |
| 219 | - if(empty($this->mapUnitIdToDb[$unit_id])) { |
|
| 219 | + if (empty($this->mapUnitIdToDb[$unit_id])) { |
|
| 220 | 220 | // If unit not exists - creating one and setting all attributes |
| 221 | 221 | $this->mapUnitIdToDb[$unit_id] = $this->_createElement(); |
| 222 | 222 | $this->mapUnitIdToDb[$unit_id]->setUnitId($unit_id); |
| 223 | 223 | $this->mapUnitIdToDb[$unit_id]->setLocatedAt($this); |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - if($replace_value) { |
|
| 226 | + if ($replace_value) { |
|
| 227 | 227 | $this->mapUnitIdToDb[$unit_id]->count = $unit_count; |
| 228 | 228 | } else { |
| 229 | 229 | $this->mapUnitIdToDb[$unit_id]->adjustCount($unit_count); |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | public function unitsGetArray() { |
| 239 | 239 | $result = array(); |
| 240 | - foreach($this->mapUnitIdToDb as $unit) { |
|
| 240 | + foreach ($this->mapUnitIdToDb as $unit) { |
|
| 241 | 241 | $result[$unit->unitId] = $unit->count; |
| 242 | 242 | } |
| 243 | 243 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | public function unitsCountApplyLossMultiplier($ships_lost_multiplier) { |
| 248 | - foreach($this->mapUnitIdToDb as $unit_id => $unit) { |
|
| 248 | + foreach ($this->mapUnitIdToDb as $unit_id => $unit) { |
|
| 249 | 249 | $unit->count = floor($unit->count * $ships_lost_multiplier); |
| 250 | 250 | } |
| 251 | 251 | } |
@@ -271,8 +271,8 @@ discard block |
||
| 271 | 271 | |
| 272 | 272 | public function unitsPropertySumById($unit_id = 0, $propertyName = 'count') { |
| 273 | 273 | $result = 0; |
| 274 | - foreach($this->mapUnitIdToDb as $unit) { |
|
| 275 | - if(!$unit_id || $unit->unitId == $unit_id) { |
|
| 274 | + foreach ($this->mapUnitIdToDb as $unit) { |
|
| 275 | + if (!$unit_id || $unit->unitId == $unit_id) { |
|
| 276 | 276 | $result += $unit->$propertyName; |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -292,18 +292,18 @@ discard block |
||
| 292 | 292 | * @var Fleet $objFleet |
| 293 | 293 | */ |
| 294 | 294 | $objFleet = $this->getLocatedAt(); |
| 295 | - if(empty($objFleet)) { |
|
| 295 | + if (empty($objFleet)) { |
|
| 296 | 296 | throw new Exception('No fleet owner on UnitList::unitsRender() in ' . __FILE__ . '@' . __LINE__); |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - foreach($this->mapUnitIdToDb as $unit) { |
|
| 299 | + foreach ($this->mapUnitIdToDb as $unit) { |
|
| 300 | 300 | $ship_id = $unit->unitId; |
| 301 | 301 | $ship_count = $unit->count; |
| 302 | - if(!UnitShip::is_in_group($ship_id) || $ship_count <= 0) { |
|
| 302 | + if (!UnitShip::is_in_group($ship_id) || $ship_count <= 0) { |
|
| 303 | 303 | continue; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - if($ship_count > mrc_get_level($objFleet->dbOwnerRow, $objFleet->dbSourcePlanetRow, $ship_id, false, true)) { |
|
| 306 | + if ($ship_count > mrc_get_level($objFleet->dbOwnerRow, $objFleet->dbSourcePlanetRow, $ship_id, false, true)) { |
|
| 307 | 307 | $page .= classLocale::$lang['fl_noenought']; |
| 308 | 308 | } else { |
| 309 | 309 | $fleet['fleetarray'][$ship_id] = $ship_count; |
@@ -334,9 +334,9 @@ discard block |
||
| 334 | 334 | // TODO - REDO!!!! |
| 335 | 335 | function flt_fleet_speed($user) { |
| 336 | 336 | $speeds = array(); |
| 337 | - if(!empty($this->mapUnitIdToDb)) { |
|
| 338 | - foreach($this->mapUnitIdToDb as $ship_id => $unit) { |
|
| 339 | - if($unit->getCount() > 0 && in_array($unit->unitId, sn_get_groups(array('fleet', 'missile')))) { |
|
| 337 | + if (!empty($this->mapUnitIdToDb)) { |
|
| 338 | + foreach ($this->mapUnitIdToDb as $ship_id => $unit) { |
|
| 339 | + if ($unit->getCount() > 0 && in_array($unit->unitId, sn_get_groups(array('fleet', 'missile')))) { |
|
| 340 | 340 | $single_ship_data = get_ship_data($unit->unitId, $user); |
| 341 | 341 | $speeds[] = $single_ship_data['speed']; |
| 342 | 342 | } |
@@ -357,11 +357,11 @@ discard block |
||
| 357 | 357 | $fleet_speed = $this->flt_fleet_speed($dbOwnerRow); |
| 358 | 358 | $real_speed = $speed_percent * sqrt($fleet_speed); |
| 359 | 359 | |
| 360 | - if($fleet_speed && $game_fleet_speed) { |
|
| 360 | + if ($fleet_speed && $game_fleet_speed) { |
|
| 361 | 361 | $duration = max(1, round((35000 / $speed_percent * sqrt($distance * 10 / $fleet_speed) + 10) / $game_fleet_speed)); |
| 362 | 362 | |
| 363 | - foreach($this->mapUnitIdToDb as $ship_id => $unit) { |
|
| 364 | - if(!$unit->unitId || $unit->getCount() <= 0) { |
|
| 363 | + foreach ($this->mapUnitIdToDb as $ship_id => $unit) { |
|
| 364 | + if (!$unit->unitId || $unit->getCount() <= 0) { |
|
| 365 | 365 | continue; |
| 366 | 366 | } |
| 367 | 367 | |
@@ -392,8 +392,8 @@ discard block |
||
| 392 | 392 | * @return bool |
| 393 | 393 | */ |
| 394 | 394 | public function unitsInGroup($group) { |
| 395 | - foreach($this->mapUnitIdToDb as $unitId => $unit) { |
|
| 396 | - if(!in_array($unitId, $group)) { |
|
| 395 | + foreach ($this->mapUnitIdToDb as $unitId => $unit) { |
|
| 396 | + if (!in_array($unitId, $group)) { |
|
| 397 | 397 | return false; |
| 398 | 398 | } |
| 399 | 399 | } |
@@ -402,9 +402,9 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | public function unitsIsAllMovable($dbOwnerRow) { |
| 405 | - foreach($this->mapUnitIdToDb as $unitId => $unit) { |
|
| 405 | + foreach ($this->mapUnitIdToDb as $unitId => $unit) { |
|
| 406 | 406 | $single_ship_data = get_ship_data($unit->unitId, $dbOwnerRow); |
| 407 | - if($single_ship_data['speed'] <= 0) { |
|
| 407 | + if ($single_ship_data['speed'] <= 0) { |
|
| 408 | 408 | return false; |
| 409 | 409 | } |
| 410 | 410 | } |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | |
| 484 | 484 | print('</tr>'); |
| 485 | 485 | |
| 486 | - foreach($this->mapUnitIdToDb as $unit) { |
|
| 486 | + foreach ($this->mapUnitIdToDb as $unit) { |
|
| 487 | 487 | print('<tr>'); |
| 488 | 488 | |
| 489 | 489 | print('<td>'); |
@@ -534,14 +534,14 @@ discard block |
||
| 534 | 534 | |
| 535 | 535 | |
| 536 | 536 | public function unitZeroDbId() { |
| 537 | - foreach($this->mapUnitIdToDb as $unit) { |
|
| 537 | + foreach ($this->mapUnitIdToDb as $unit) { |
|
| 538 | 538 | $unit->zeroDbId(); |
| 539 | 539 | } |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | |
| 543 | 543 | public function unitZeroCount() { |
| 544 | - foreach($this->mapUnitIdToDb as $unit) { |
|
| 544 | + foreach ($this->mapUnitIdToDb as $unit) { |
|
| 545 | 545 | $unit->count = 0; |
| 546 | 546 | } |
| 547 | 547 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | $uni_system = sys_get_param_int('system', $planetrow['system']); |
| 17 | 17 | $planet = sys_get_param_int('planet', $planetrow['planet']); |
| 18 | 18 | |
| 19 | -if($mode == 'name') { |
|
| 19 | +if ($mode == 'name') { |
|
| 20 | 20 | require_once('includes/includes/uni_rename.php'); |
| 21 | 21 | } |
| 22 | 22 | |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $flying_fleet_count = FleetList::fleet_count_flying($user['id']); |
| 39 | 39 | |
| 40 | -if($mode == 1) { |
|
| 41 | -} elseif($mode == 2 || $mode == 3) { |
|
| 40 | +if ($mode == 1) { |
|
| 41 | +} elseif ($mode == 2 || $mode == 3) { |
|
| 42 | 42 | $planet = $planetrow['planet']; |
| 43 | 43 | } else { |
| 44 | 44 | $uni_galaxy = $planetrow['galaxy']; |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $planet = $planetrow['planet']; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | -$uni_galaxy = $uni_galaxy < 1 ? 1 : ($uni_galaxy > Vector::$knownGalaxies? Vector::$knownGalaxies: $uni_galaxy); |
|
| 49 | +$uni_galaxy = $uni_galaxy < 1 ? 1 : ($uni_galaxy > Vector::$knownGalaxies ? Vector::$knownGalaxies : $uni_galaxy); |
|
| 50 | 50 | $uni_system = $uni_system < 1 ? 1 : ($uni_system > Vector::$knownSystems ? Vector::$knownSystems : $uni_system); |
| 51 | 51 | $planet = $planet < 1 ? 1 : ($planet > Vector::$knownPlanets + 1 ? Vector::$knownPlanets + 1 : $planet); |
| 52 | 52 | |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | $PhalanxRange = GetPhalanxRange($HavePhalanx); |
| 65 | 65 | |
| 66 | 66 | $planet_precache_query = db_planet_list_in_system($uni_galaxy, $uni_system); |
| 67 | -if(!empty($planet_precache_query)) { |
|
| 68 | - foreach($planet_precache_query as $planet_row) { |
|
| 67 | +if (!empty($planet_precache_query)) { |
|
| 68 | + foreach ($planet_precache_query as $planet_row) { |
|
| 69 | 69 | $planet_list[$planet_row['planet']][$planet_row['planet_type']] = $planet_row; |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | * @var Fleet[][][] $fleet_list |
| 84 | 84 | */ |
| 85 | 85 | $fleet_list = array(); |
| 86 | -foreach($system_fleet_list->_container as $objFleetSystem) { |
|
| 87 | - if(!$objFleetSystem->isReturning()) { |
|
| 86 | +foreach ($system_fleet_list->_container as $objFleetSystem) { |
|
| 87 | + if (!$objFleetSystem->isReturning()) { |
|
| 88 | 88 | $fleet_planet = $objFleetSystem->fleet_end_planet; |
| 89 | 89 | $fleet_type = $objFleetSystem->fleet_end_type; |
| 90 | 90 | } else { |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | $recycler_info = array(); |
| 100 | 100 | $planet_recyclers_orbiting = 0; |
| 101 | 101 | $recyclers_fleet = array(); |
| 102 | -foreach(sn_get_groups('flt_recyclers') as $recycler_id) { |
|
| 102 | +foreach (sn_get_groups('flt_recyclers') as $recycler_id) { |
|
| 103 | 103 | $recycler_info[$recycler_id] = get_ship_data($recycler_id, $user); |
| 104 | 104 | $recyclers_fleet[$recycler_id] = mrc_get_level($user, $planetrow, $recycler_id); |
| 105 | 105 | $planet_recyclers_orbiting += $recyclers_fleet[$recycler_id]; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $fleet_id = 1; |
| 110 | 110 | $fleets = array(); |
| 111 | 111 | $config_game_max_planet = Vector::$knownPlanets + 1; |
| 112 | -for($Planet = 1; $Planet < $config_game_max_planet; $Planet++) { |
|
| 112 | +for ($Planet = 1; $Planet < $config_game_max_planet; $Planet++) { |
|
| 113 | 113 | unset($uni_galaxyRowPlanet); |
| 114 | 114 | unset($uni_galaxyRowMoon); |
| 115 | 115 | unset($uni_galaxyRowUser); |
@@ -119,27 +119,27 @@ discard block |
||
| 119 | 119 | $uni_galaxyRowPlanet = $planet_list[$Planet][PT_PLANET]; |
| 120 | 120 | |
| 121 | 121 | $planet_fleet_id = 0; |
| 122 | - if($uni_galaxyRowPlanet['destruyed']) { |
|
| 122 | + if ($uni_galaxyRowPlanet['destruyed']) { |
|
| 123 | 123 | CheckAbandonPlanetState($uni_galaxyRowPlanet); |
| 124 | - } elseif($uni_galaxyRowPlanet['id']) { |
|
| 125 | - if($cached['users'][$uni_galaxyRowPlanet['id_owner']]) { |
|
| 124 | + } elseif ($uni_galaxyRowPlanet['id']) { |
|
| 125 | + if ($cached['users'][$uni_galaxyRowPlanet['id_owner']]) { |
|
| 126 | 126 | $uni_galaxyRowUser = $cached['users'][$uni_galaxyRowPlanet['id_owner']]; |
| 127 | 127 | } else { |
| 128 | 128 | $uni_galaxyRowUser = db_user_by_id($uni_galaxyRowPlanet['id_owner']); |
| 129 | 129 | $cached['users'][$uni_galaxyRowUser['id']] = $uni_galaxyRowUser; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if(!$uni_galaxyRowUser['id']) { |
|
| 132 | + if (!$uni_galaxyRowUser['id']) { |
|
| 133 | 133 | $debug->warning("Planet '{$uni_galaxyRowPlanet['name']}' [{$uni_galaxy}:{$uni_system}:{$Planet}] has no owner!", 'Userless planet', 503); |
| 134 | 134 | $uni_galaxyRowPlanet['destruyed'] = SN_TIME_NOW + 60 * 60 * 24; |
| 135 | 135 | $uni_galaxyRowPlanet['id_owner'] = 0; |
| 136 | 136 | db_planet_set_by_id($uni_galaxyRowPlanet['id'], "id_owner = 0, destruyed = {$uni_galaxyRowPlanet['destruyed']}"); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - if($uni_galaxyRowUser['id']) { |
|
| 139 | + if ($uni_galaxyRowUser['id']) { |
|
| 140 | 140 | $planetcount++; |
| 141 | - if($uni_galaxyRowUser['ally_id']) { |
|
| 142 | - if($cached['allies'][$uni_galaxyRowUser['ally_id']]) { |
|
| 141 | + if ($uni_galaxyRowUser['ally_id']) { |
|
| 142 | + if ($cached['allies'][$uni_galaxyRowUser['ally_id']]) { |
|
| 143 | 143 | $allyquery = $cached['allies'][$uni_galaxyRowUser['ally_id']]; |
| 144 | 144 | } else { |
| 145 | 145 | $allyquery = db_ally_get_by_id($uni_galaxyRowUser['ally_id']); |
@@ -148,19 +148,19 @@ discard block |
||
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_PLANET]); |
| 151 | - if(!empty($fleets_to_planet['own']['count'])) { |
|
| 151 | + if (!empty($fleets_to_planet['own']['count'])) { |
|
| 152 | 152 | $planet_fleet_id = $fleet_id; |
| 153 | 153 | $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id); |
| 154 | 154 | $fleet_id++; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | $uni_galaxyRowMoon = $planet_list[$Planet][PT_MOON]; |
| 158 | - if($uni_galaxyRowMoon['destruyed']) { |
|
| 158 | + if ($uni_galaxyRowMoon['destruyed']) { |
|
| 159 | 159 | CheckAbandonPlanetState($uni_galaxyRowMoon); |
| 160 | 160 | } else { |
| 161 | 161 | $moon_fleet_id = 0; |
| 162 | 162 | $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_MOON]); |
| 163 | - if(!empty($fleets_to_planet['own']['count'])) { |
|
| 163 | + if (!empty($fleets_to_planet['own']['count'])) { |
|
| 164 | 164 | $moon_fleet_id = $fleet_id; |
| 165 | 165 | $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id); |
| 166 | 166 | $fleet_id++; |
@@ -171,10 +171,10 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | $recyclers_incoming_capacity = 0; |
| 173 | 173 | $uni_galaxyRowPlanet['debris'] = $uni_galaxyRowPlanet['debris_metal'] + $uni_galaxyRowPlanet['debris_crystal']; |
| 174 | - if($uni_galaxyRowPlanet['debris']) { |
|
| 175 | - if(!empty($fleet_list[$Planet][PT_DEBRIS])) { |
|
| 176 | - foreach($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) { |
|
| 177 | - if($objFleetToDebris->playerOwnerId == $user['id']) { |
|
| 174 | + if ($uni_galaxyRowPlanet['debris']) { |
|
| 175 | + if (!empty($fleet_list[$Planet][PT_DEBRIS])) { |
|
| 176 | + foreach ($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) { |
|
| 177 | + if ($objFleetToDebris->playerOwnerId == $user['id']) { |
|
| 178 | 178 | $recyclers_incoming_capacity += $objFleetToDebris->shipsGetCapacityRecyclers($recycler_info); |
| 179 | 179 | } |
| 180 | 180 | } |
@@ -251,21 +251,21 @@ discard block |
||
| 251 | 251 | |
| 252 | 252 | tpl_assign_fleet($template, $fleets); |
| 253 | 253 | |
| 254 | -foreach(sn_get_groups('defense_active') as $unit_id) { |
|
| 254 | +foreach (sn_get_groups('defense_active') as $unit_id) { |
|
| 255 | 255 | $template->assign_block_vars('defense_active', array( |
| 256 | 256 | 'ID' => $unit_id, |
| 257 | 257 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
| 258 | 258 | )); |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | -foreach($cached['users'] as $PlanetUser) { |
|
| 262 | - if(!$PlanetUser) { |
|
| 261 | +foreach ($cached['users'] as $PlanetUser) { |
|
| 262 | + if (!$PlanetUser) { |
|
| 263 | 263 | continue; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | $user_ally = $cached['allies'][$PlanetUser['ally_id']]; |
| 267 | - if(isset($user_ally)) { |
|
| 268 | - if($PlanetUser['id'] == $user_ally['ally_owner']) { |
|
| 267 | + if (isset($user_ally)) { |
|
| 268 | + if ($PlanetUser['id'] == $user_ally['ally_owner']) { |
|
| 269 | 269 | $user_rank_title = $user_ally['ally_owner_range']; |
| 270 | 270 | } else { |
| 271 | 271 | $ally_ranks = explode(';', $user_ally['ranklist']); |
@@ -288,8 +288,8 @@ discard block |
||
| 288 | 288 | )); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | -foreach($cached['allies'] as $PlanetAlly) { |
|
| 292 | - if($PlanetAlly) { |
|
| 291 | +foreach ($cached['allies'] as $PlanetAlly) { |
|
| 292 | + if ($PlanetAlly) { |
|
| 293 | 293 | $template->assign_block_vars('alliances', array( |
| 294 | 294 | 'ID' => $PlanetAlly['id'], |
| 295 | 295 | 'NAME_JS' => js_safe_string($PlanetAlly['ally_name']), |
@@ -11,12 +11,12 @@ discard block |
||
| 11 | 11 | $uni_galaxy = sys_get_param_int('galaxy', $planetrow['galaxy']); |
| 12 | 12 | $uni_system = sys_get_param_int('system'); |
| 13 | 13 | |
| 14 | - if($uni_galaxy < 1 || $uni_galaxy > Vector::$knownGalaxies) |
|
| 14 | + if ($uni_galaxy < 1 || $uni_galaxy > Vector::$knownGalaxies) |
|
| 15 | 15 | { |
| 16 | 16 | throw new exception(classLocale::$lang['uni_msg_error_wrong_galaxy'], ERR_ERROR); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - if($uni_system < 0 || $uni_system > Vector::$knownSystems) |
|
| 19 | + if ($uni_system < 0 || $uni_system > Vector::$knownSystems) |
|
| 20 | 20 | { |
| 21 | 21 | throw new exception(classLocale::$lang['uni_msg_error_wrong_system'], ERR_ERROR); |
| 22 | 22 | } |
@@ -25,12 +25,12 @@ discard block |
||
| 25 | 25 | $uni_row['universe_price'] += $uni_system ? classSupernova::$config->uni_price_system : classSupernova::$config->uni_price_galaxy; |
| 26 | 26 | $uni_row['universe_name'] = strip_tags($uni_row['universe_name'] ? $uni_row['universe_name'] : ($uni_system ? "{$classLocale['sys_system']} [{$uni_galaxy}:{$uni_system}]" : "{$classLocale['sys_galaxy']} {$uni_galaxy}")); |
| 27 | 27 | |
| 28 | - if(sys_get_param_str('uni_name_submit')) |
|
| 28 | + if (sys_get_param_str('uni_name_submit')) |
|
| 29 | 29 | { |
| 30 | 30 | $uni_row['universe_name'] = strip_tags(sys_get_param_str('uni_name')); |
| 31 | 31 | |
| 32 | 32 | $uni_price = sys_get_param_float('uni_price'); |
| 33 | - if($uni_price < $uni_row['universe_price']) |
|
| 33 | + if ($uni_price < $uni_row['universe_price']) |
|
| 34 | 34 | { |
| 35 | 35 | throw new exception(classLocale::$lang['uni_msg_error_low_price'], ERR_ERROR); |
| 36 | 36 | } |
@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | sn_db_transaction_start(); |
| 40 | 40 | $user = db_user_by_id($user['id'], true); |
| 41 | 41 | // if($user[get_unit_param(RES_DARK_MATTER, P_NAME)] < $uni_price) |
| 42 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $uni_price) |
|
| 42 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $uni_price) |
|
| 43 | 43 | { |
| 44 | 44 | throw new exception(classLocale::$lang['uni_msg_error_no_dm'], ERR_ERROR); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if(!rpg_points_change($user['id'], RPG_RENAME, -$uni_price, "Renaming [{$uni_galaxy}:{$uni_system}] to " . sys_get_param_str_unsafe('uni_name'))) |
|
| 47 | + if (!rpg_points_change($user['id'], RPG_RENAME, -$uni_price, "Renaming [{$uni_galaxy}:{$uni_system}] to " . sys_get_param_str_unsafe('uni_name'))) |
|
| 48 | 48 | { |
| 49 | 49 | throw new exception(classLocale::$lang['sys_msg_err_update_dm'], ERR_ERROR); |
| 50 | 50 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | // @version 1.0 |
| 4 | 4 | // @copyright 2008 by Chlorel for XNova |
| 5 | 5 | |
| 6 | -if(SN_IN_FLEET !== true) { |
|
| 6 | +if (SN_IN_FLEET !== true) { |
|
| 7 | 7 | $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
| 8 | 8 | } |
| 9 | 9 | |
@@ -20,25 +20,25 @@ discard block |
||
| 20 | 20 | $errorlist .= !is_array($fleetarray) ? classLocale::$lang['fl_no_fleetarray'] : ''; |
| 21 | 21 | |
| 22 | 22 | $errorlist = ''; |
| 23 | - if(!$galaxy || $galaxy > Vector::$knownGalaxies|| $galaxy < 1) { |
|
| 23 | + if (!$galaxy || $galaxy > Vector::$knownGalaxies || $galaxy < 1) { |
|
| 24 | 24 | $errorlist .= classLocale::$lang['fl_limit_galaxy']; |
| 25 | 25 | } |
| 26 | - if(!$system || $system > Vector::$knownSystems|| $system < 1) { |
|
| 26 | + if (!$system || $system > Vector::$knownSystems || $system < 1) { |
|
| 27 | 27 | $errorlist .= classLocale::$lang['fl_limit_system']; |
| 28 | 28 | } |
| 29 | - if(!$planet || $planet < 1 || ($planet > Vector::$knownPlanets&& $target_mission != MT_EXPLORE)) { |
|
| 29 | + if (!$planet || $planet < 1 || ($planet > Vector::$knownPlanets && $target_mission != MT_EXPLORE)) { |
|
| 30 | 30 | $errorlist .= classLocale::$lang['fl_limit_planet']; |
| 31 | 31 | } |
| 32 | - if($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) { |
|
| 32 | + if ($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) { |
|
| 33 | 33 | $errorlist .= classLocale::$lang['fl_ownpl_err']; |
| 34 | 34 | } |
| 35 | - if(!$planet_type) { |
|
| 35 | + if (!$planet_type) { |
|
| 36 | 36 | $errorlist .= classLocale::$lang['fl_no_planettype']; |
| 37 | 37 | } |
| 38 | - if($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) { |
|
| 38 | + if ($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) { |
|
| 39 | 39 | $errorlist .= classLocale::$lang['fl_fleet_err_pl']; |
| 40 | 40 | } |
| 41 | - if(empty($missiontype[$target_mission])) { |
|
| 41 | + if (empty($missiontype[$target_mission])) { |
|
| 42 | 42 | $errorlist .= classLocale::$lang['fl_bad_mission']; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $TransDeuterium = max(0, sys_get_param_float('resource2')); |
| 48 | 48 | $StorageNeeded = $TransMetal + $TransCrystal + $TransDeuterium; |
| 49 | 49 | |
| 50 | - if(!$StorageNeeded && $target_mission == MT_TRANSPORT) { |
|
| 50 | + if (!$StorageNeeded && $target_mission == MT_TRANSPORT) { |
|
| 51 | 51 | $errorlist .= classLocale::$lang['fl_noenoughtgoods']; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -56,41 +56,41 @@ discard block |
||
| 56 | 56 | $user = db_user_by_id($user['id'], true); |
| 57 | 57 | $planetrow = db_planet_by_id($planetrow['id'], true); |
| 58 | 58 | |
| 59 | - if($target_mission == MT_EXPLORE) { |
|
| 60 | - if($MaxExpeditions == 0) { |
|
| 59 | + if ($target_mission == MT_EXPLORE) { |
|
| 60 | + if ($MaxExpeditions == 0) { |
|
| 61 | 61 | $errorlist .= classLocale::$lang['fl_expe_notech']; |
| 62 | - } elseif($FlyingExpeditions >= $MaxExpeditions) { |
|
| 62 | + } elseif ($FlyingExpeditions >= $MaxExpeditions) { |
|
| 63 | 63 | $errorlist .= classLocale::$lang['fl_expe_max']; |
| 64 | 64 | } |
| 65 | 65 | } else { |
| 66 | - if($TargetPlanet['id_owner']) { |
|
| 67 | - if($target_mission == MT_COLONIZE) { |
|
| 66 | + if ($TargetPlanet['id_owner']) { |
|
| 67 | + if ($target_mission == MT_COLONIZE) { |
|
| 68 | 68 | $errorlist .= classLocale::$lang['fl_colonized']; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if($TargetPlanet['id_owner'] == $planetrow['id_owner']) { |
|
| 72 | - if($target_mission == MT_ATTACK) { |
|
| 71 | + if ($TargetPlanet['id_owner'] == $planetrow['id_owner']) { |
|
| 72 | + if ($target_mission == MT_ATTACK) { |
|
| 73 | 73 | $errorlist .= classLocale::$lang['fl_no_self_attack']; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if($target_mission == MT_SPY) { |
|
| 76 | + if ($target_mission == MT_SPY) { |
|
| 77 | 77 | $errorlist .= classLocale::$lang['fl_no_self_spy']; |
| 78 | 78 | } |
| 79 | 79 | } else { |
| 80 | - if($target_mission == MT_RELOCATE) { |
|
| 80 | + if ($target_mission == MT_RELOCATE) { |
|
| 81 | 81 | $errorlist .= classLocale::$lang['fl_only_stay_at_home']; |
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | } else { |
| 85 | - if($target_mission < MT_COLONIZE) { |
|
| 85 | + if ($target_mission < MT_COLONIZE) { |
|
| 86 | 86 | $errorlist .= classLocale::$lang['fl_unknow_target']; |
| 87 | 87 | } else { |
| 88 | - if($target_mission == MT_DESTROY) { |
|
| 88 | + if ($target_mission == MT_DESTROY) { |
|
| 89 | 89 | $errorlist .= classLocale::$lang['fl_nomoon']; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if($target_mission == MT_RECYCLE) { |
|
| 93 | - if($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) { |
|
| 92 | + if ($target_mission == MT_RECYCLE) { |
|
| 93 | + if ($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) { |
|
| 94 | 94 | $errorlist .= classLocale::$lang['fl_nodebris']; |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -99,13 +99,13 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | |
| 102 | - if(sn_module::$sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) { |
|
| 102 | + if (sn_module::$sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) { |
|
| 103 | 103 | $captain = sn_module::$sn_module['unit_captain']->unit_captain_get($planetrow['id']); |
| 104 | 104 | // mrc_get_level($user, $planetrow, UNIT_CAPTAIN, true); |
| 105 | - if(!$captain) { |
|
| 105 | + if (!$captain) { |
|
| 106 | 106 | $errorlist .= classLocale::$lang['module_unit_captain_error_no_captain']; |
| 107 | - } elseif($captain['unit_location_type'] == LOC_PLANET) { |
|
| 108 | - if($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) { |
|
| 107 | + } elseif ($captain['unit_location_type'] == LOC_PLANET) { |
|
| 108 | + if ($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) { |
|
| 109 | 109 | $errorlist .= classLocale::$lang['module_unit_captain_error_captain_already_bound']; |
| 110 | 110 | } |
| 111 | 111 | } else { |
@@ -113,14 +113,14 @@ discard block |
||
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - if($errorlist) { |
|
| 116 | + if ($errorlist) { |
|
| 117 | 117 | sn_db_transaction_rollback(); |
| 118 | 118 | message("<span class='error'><ul>{$errorlist}</ul></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, false); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | // On verifie s'il y a assez de vaisseaux sur la planete ! |
| 122 | - foreach($fleetarray as $Ship => $Count) { |
|
| 123 | - if($Count > mrc_get_level($user, $planetrow, $Ship)) { |
|
| 122 | + foreach ($fleetarray as $Ship => $Count) { |
|
| 123 | + if ($Count > mrc_get_level($user, $planetrow, $Ship)) { |
|
| 124 | 124 | message("<span class='error'><b>{$classLocale['fl_fleet_err']}</b></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -131,10 +131,10 @@ discard block |
||
| 131 | 131 | //But is it acs?? |
| 132 | 132 | //Well all acs fleets must have a fleet code. |
| 133 | 133 | //The co-ords must be the same as where the acs fleet is going. |
| 134 | - if($fleet_group && sys_get_param_str('acs_target_mr') == "g{$galaxy}s{$system}p{$planet}t{$planet_type}") { |
|
| 134 | + if ($fleet_group && sys_get_param_str('acs_target_mr') == "g{$galaxy}s{$system}p{$planet}t{$planet_type}") { |
|
| 135 | 135 | //ACS attack must exist (if acs fleet has arrived this will also return false (2 checks in 1!!!) |
| 136 | 136 | $aks = db_acs_get_by_group_id($fleet_group); |
| 137 | - if(!$aks) { |
|
| 137 | + if (!$aks) { |
|
| 138 | 138 | $fleet_group = 0; |
| 139 | 139 | } else { |
| 140 | 140 | //Also it must be mission type 2 |
@@ -145,31 +145,31 @@ discard block |
||
| 145 | 145 | $planet = $aks['planet']; |
| 146 | 146 | $planet_type = $aks['planet_type']; |
| 147 | 147 | } |
| 148 | - } elseif($target_mission == MT_ACS) { |
|
| 148 | + } elseif ($target_mission == MT_ACS) { |
|
| 149 | 149 | //Check that a failed acs attack isn't being sent, if it is, make it an attack fleet. |
| 150 | 150 | $target_mission = MT_ATTACK; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - if($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { |
|
| 153 | + if ($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { |
|
| 154 | 154 | $TargetPlanet = array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet, 'id_owner' => 0); |
| 155 | 155 | } |
| 156 | 156 | $options = array('fleet_speed_percent' => $speed_percent, 'fleet_group' => $fleet_group, 'resources' => $StorageNeeded); |
| 157 | 157 | $cant_attack = flt_can_attack($planetrow, $TargetPlanet, $fleetarray, $target_mission, $options); |
| 158 | 158 | |
| 159 | - if($cant_attack !== FLIGHT_ALLOWED) { |
|
| 159 | + if ($cant_attack !== FLIGHT_ALLOWED) { |
|
| 160 | 160 | message("<span class='error'><b>{$classLocale['fl_attack_error'][$cant_attack]}</b></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 99); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1); |
| 164 | - if(!in_array($speed_percent, $speed_possible)) { |
|
| 164 | + if (!in_array($speed_percent, $speed_possible)) { |
|
| 165 | 165 | message("<span class='error'><b>" . classLocale::$lang['fl_cheat_speed'] . "</b></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $mission_time_in_seconds = 0; |
| 169 | 169 | $arrival_time = SN_TIME_NOW + $time_to_travel; |
| 170 | - if($target_mission == MT_ACS && $aks) { |
|
| 170 | + if ($target_mission == MT_ACS && $aks) { |
|
| 171 | 171 | // if($fleet_start_time > $aks['ankunft']) { |
| 172 | - if($arrival_time > $aks['ankunft']) { |
|
| 172 | + if ($arrival_time > $aks['ankunft']) { |
|
| 173 | 173 | message(classLocale::$lang['fl_aks_too_slow'] . 'Fleet arrival: ' . date(FMT_DATE_TIME, $arrival_time) . " AKS arrival: " . date(FMT_DATE_TIME, $aks['ankunft']), classLocale::$lang['fl_error']); |
| 174 | 174 | } |
| 175 | 175 | $group_sync_delta_time = $aks['ankunft'] - $arrival_time; |
@@ -178,11 +178,11 @@ discard block |
||
| 178 | 178 | // Set return time to ACS return time + fleet's time to travel |
| 179 | 179 | $return_time = $aks['ankunft'] + $time_to_travel; |
| 180 | 180 | } else { |
| 181 | - if($target_mission == MT_EXPLORE || $target_mission == MT_HOLD) { |
|
| 181 | + if ($target_mission == MT_EXPLORE || $target_mission == MT_HOLD) { |
|
| 182 | 182 | $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : ($target_mission == MT_HOLD ? 12 : 0); |
| 183 | - if($max_duration) { |
|
| 183 | + if ($max_duration) { |
|
| 184 | 184 | $mission_time_in_hours = sys_get_param_id('missiontime'); |
| 185 | - if($mission_time_in_hours > $max_duration || $mission_time_in_hours < 1) { |
|
| 185 | + if ($mission_time_in_hours > $max_duration || $mission_time_in_hours < 1) { |
|
| 186 | 186 | $debug->warning('Supplying wrong mission time', 'Hack attempt', 302, array('base_dump' => true)); |
| 187 | 187 | die(); |
| 188 | 188 | } |
@@ -196,19 +196,19 @@ discard block |
||
| 196 | 196 | $FleetStorage = 0; |
| 197 | 197 | |
| 198 | 198 | $db_changeset = array(); |
| 199 | - foreach($fleetarray as $Ship => $Count) { |
|
| 199 | + foreach ($fleetarray as $Ship => $Count) { |
|
| 200 | 200 | $FleetStorage += get_unit_param($Ship, P_CAPACITY) * $Count; |
| 201 | 201 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($Ship, -$Count, $user, $planetrow['id']); |
| 202 | 202 | } |
| 203 | 203 | $FleetStorage -= $consumption; |
| 204 | 204 | |
| 205 | - if($StorageNeeded > $FleetStorage) { |
|
| 205 | + if ($StorageNeeded > $FleetStorage) { |
|
| 206 | 206 | message("<span class='error'><b>" . classLocale::$lang['fl_nostoragespa'] . pretty_number($StorageNeeded - $FleetStorage) . "</b></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
| 207 | 207 | } |
| 208 | - if($planetrow['deuterium'] < $TransDeuterium + $consumption) { |
|
| 208 | + if ($planetrow['deuterium'] < $TransDeuterium + $consumption) { |
|
| 209 | 209 | message("<font color=\"red\"><b>" . classLocale::$lang['fl_no_deuterium'] . pretty_number($TransDeuterium + $consumption - $planetrow['deuterium']) . "</b></font>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
| 210 | 210 | } |
| 211 | - if(($planetrow['metal'] < $TransMetal) || ($planetrow['crystal'] < $TransCrystal)) { |
|
| 211 | + if (($planetrow['metal'] < $TransMetal) || ($planetrow['crystal'] < $TransCrystal)) { |
|
| 212 | 212 | message("<font color=\"red\"><b>" . classLocale::$lang['fl_no_resources'] . "</b></font>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | $template = gettemplate('fleet3', true); |
| 240 | 240 | |
| 241 | - if(is_array($captain)) { |
|
| 241 | + if (is_array($captain)) { |
|
| 242 | 242 | db_unit_set_by_id($captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$objFleet->dbId}"); |
| 243 | 243 | } |
| 244 | 244 | |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | 'START_LEFT' => floor($return_time + 1 - SN_TIME_NOW), |
| 252 | 252 | ); |
| 253 | 253 | |
| 254 | - if(!empty($TargetPlanet)) { |
|
| 254 | + if (!empty($TargetPlanet)) { |
|
| 255 | 255 | $template_route += array( |
| 256 | 256 | 'END_TYPE_TEXT_SH' => classLocale::$lang['sys_planet_type_sh'][$TargetPlanet['planet_type']], |
| 257 | 257 | 'END_COORDS' => uni_render_coordinates($TargetPlanet), |
@@ -264,8 +264,8 @@ discard block |
||
| 264 | 264 | $template->assign_block_vars('fleets', $template_route); |
| 265 | 265 | |
| 266 | 266 | $sn_groups_fleet = sn_get_groups('fleet'); |
| 267 | - foreach($fleetarray as $ship_id => $ship_count) { |
|
| 268 | - if(in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
| 267 | + foreach ($fleetarray as $ship_id => $ship_count) { |
|
| 268 | + if (in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
| 269 | 269 | // $ship_base_data = get_ship_data($ship_id, $user); |
| 270 | 270 | $template->assign_block_vars('fleets.ships', array( |
| 271 | 271 | 'ID' => $ship_id, |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | * |
| 13 | 13 | **/ |
| 14 | 14 | |
| 15 | -if(SN_IN_FLEET !== true) { |
|
| 15 | +if (SN_IN_FLEET !== true) { |
|
| 16 | 16 | $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
| 17 | 17 | } |
| 18 | 18 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | $planet_list = array(); |
| 27 | 27 | |
| 28 | - if(is_array($resources_taken)) |
|
| 28 | + if (is_array($resources_taken)) |
|
| 29 | 29 | { |
| 30 | 30 | $query = implode(',', array_keys($resources_taken)); |
| 31 | 31 | $query = " AND `destruyed` = 0 AND `id` IN ({$query})"; |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | $query = ''; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - foreach(sn_get_groups('flt_transports') as $transport_id) { |
|
| 36 | + foreach (sn_get_groups('flt_transports') as $transport_id) { |
|
| 37 | 37 | $transports[$transport_id] = get_unit_param($transport_id, P_CAPACITY); |
| 38 | 38 | } |
| 39 | 39 | arsort($transports); |
| 40 | 40 | |
| 41 | 41 | $planets_db_list = db_planet_list_sorted($user, $planetrow['id'], '*', $query); |
| 42 | 42 | !is_array($planets_db_list) ? $planets_db_list = array() : false; |
| 43 | - foreach($planets_db_list as $planet_db_data) { |
|
| 43 | + foreach ($planets_db_list as $planet_db_data) { |
|
| 44 | 44 | // begin planet loop |
| 45 | - if(!$query) { |
|
| 45 | + if (!$query) { |
|
| 46 | 46 | $resources_taken[$planet_db_data['id']] = 1; |
| 47 | 47 | } |
| 48 | 48 | sn_db_transaction_start(); |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | $planet_id = $planet_db_data['id']; |
| 55 | 55 | |
| 56 | 56 | $planet_resources = 0; |
| 57 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
| 58 | - if($resources_taken[$planet_id] == 1 || $resources_taken[$planet_id][$resource_id]) { |
|
| 57 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
| 58 | + if ($resources_taken[$planet_id] == 1 || $resources_taken[$planet_id][$resource_id]) { |
|
| 59 | 59 | $planet_resources += floor(mrc_get_level($user, $planet_db_data, $resource_id, true, true)); // $planet_db_data[get_unit_param($resource_id, P_NAME)]); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | $fleet_capacity = 0; |
| 87 | 87 | $ship_loadout = array(); |
| 88 | 88 | $fleet = array(); |
| 89 | - foreach($transports as $ship_id => $ship_capacity) { |
|
| 90 | - if($ship_count = mrc_get_level($user, $planet_db_data, $ship_id, true, true)) { |
|
| 89 | + foreach ($transports as $ship_id => $ship_capacity) { |
|
| 90 | + if ($ship_count = mrc_get_level($user, $planet_db_data, $ship_id, true, true)) { |
|
| 91 | 91 | $ship_loadout[$ship_id]['capacity'] = $ship_count * $ship_capacity; |
| 92 | 92 | $ship_loadout[$ship_id]['taken'] = 0; |
| 93 | 93 | $fleet_capacity += $ship_loadout[$ship_id]['capacity']; |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $will_take = min($planet_resources, $fleet_capacity); |
| 100 | 100 | |
| 101 | - foreach($ship_loadout as $ship_id => &$planet_ship) { |
|
| 101 | + foreach ($ship_loadout as $ship_id => &$planet_ship) { |
|
| 102 | 102 | $can_take = min($will_take, $planet_ship['capacity']); |
| 103 | - if($can_take <= 0) { |
|
| 103 | + if ($can_take <= 0) { |
|
| 104 | 104 | continue; |
| 105 | 105 | } |
| 106 | 106 | $planet_ship['capacity'] -= $can_take; |
@@ -108,23 +108,23 @@ discard block |
||
| 108 | 108 | $fleet[$ship_id] = ceil($planet_ship['taken'] / $transports[$ship_id]); |
| 109 | 109 | |
| 110 | 110 | $will_take -= $can_take; |
| 111 | - if($will_take <= 0) { |
|
| 111 | + if ($will_take <= 0) { |
|
| 112 | 112 | break; |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - if(!empty($fleet)) { |
|
| 116 | + if (!empty($fleet)) { |
|
| 117 | 117 | $travel_data = flt_travel_data($user, $planetrow, $planet_db_data, $fleet, 10); |
| 118 | 118 | $planet_data['FLEET_SPEED'] = $travel_data['fleet_speed']; |
| 119 | 119 | $planet_data['DISTANCE'] = $travel_data['distance']; |
| 120 | 120 | $planet_data['DURATION'] = $travel_data['duration']; |
| 121 | 121 | $planet_data['CONSUMPTION'] = $travel_data['consumption']; |
| 122 | 122 | |
| 123 | - if(floor(mrc_get_level($user, $planet_db_data, RES_DEUTERIUM, true)) >= $planet_data['CONSUMPTION']) { |
|
| 123 | + if (floor(mrc_get_level($user, $planet_db_data, RES_DEUTERIUM, true)) >= $planet_data['CONSUMPTION']) { |
|
| 124 | 124 | $will_take = min($planet_resources, $fleet_capacity) - $planet_data['CONSUMPTION']; |
| 125 | 125 | |
| 126 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
| 127 | - if($resources_taken[$planet_id] != 1 && !$resources_taken[$planet_id][$resource_id]) { |
|
| 126 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
| 127 | + if ($resources_taken[$planet_id] != 1 && !$resources_taken[$planet_id][$resource_id]) { |
|
| 128 | 128 | continue; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $fleet[$resource_id] = min($will_take, $resource_amount); |
| 134 | 134 | $will_take -= $resource_amount; |
| 135 | 135 | |
| 136 | - if($will_take <= 0) { |
|
| 136 | + if ($will_take <= 0) { |
|
| 137 | 137 | break; |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -157,19 +157,19 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | $resources_taken = sys_get_param('resources'); |
| 159 | 159 | |
| 160 | -if(!empty($resources_taken)) { // begin processing parameters |
|
| 160 | +if (!empty($resources_taken)) { // begin processing parameters |
|
| 161 | 161 | $planet_list = flt_build_gathering($resources_taken); |
| 162 | 162 | |
| 163 | - foreach($planet_list as $planet_id => $planet_data) { |
|
| 164 | - if($planet_data['RESULT'] == FLIGHT_ALLOWED) { |
|
| 163 | + foreach ($planet_list as $planet_id => $planet_data) { |
|
| 164 | + if ($planet_data['RESULT'] == FLIGHT_ALLOWED) { |
|
| 165 | 165 | $planet_data['RESULT'] = flt_t_send_fleet($user, $planet_data['PLANET_DB_DATA'], $planetrow, $planet_data['FLEET'], MT_TRANSPORT); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $planet_data['MESSAGE'] = classLocale::$lang['fl_attack_error'][$planet_data['RESULT']]; |
| 169 | 169 | |
| 170 | 170 | $template->assign_block_vars('results', $planet_data); |
| 171 | - if(!empty($planet_data['FLEET']) && $planet_data['RESULT'] == FLIGHT_ALLOWED) { |
|
| 172 | - foreach($planet_data['FLEET'] as $unit_id => $amount) { |
|
| 171 | + if (!empty($planet_data['FLEET']) && $planet_data['RESULT'] == FLIGHT_ALLOWED) { |
|
| 172 | + foreach ($planet_data['FLEET'] as $unit_id => $amount) { |
|
| 173 | 173 | $template->assign_block_vars('results.units', array( |
| 174 | 174 | 'ID' => $unit_id, |
| 175 | 175 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | // Building list of own planets & moons |
| 184 | 184 | $planet_list = flt_build_gathering(); |
| 185 | -foreach($planet_list as $planet_data) { |
|
| 185 | +foreach ($planet_list as $planet_data) { |
|
| 186 | 186 | $planet_data['DURATION'] = $planet_data['DURATION'] ? pretty_time($planet_data['DURATION']) : classLocale::$lang['flt_no_fuel']; |
| 187 | 187 | $template->assign_block_vars('colonies', $planet_data); |
| 188 | 188 | } |
@@ -1,14 +1,14 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | function flt_fleet_speed($user, $fleet) { |
| 4 | - if(!is_array($fleet)) { |
|
| 4 | + if (!is_array($fleet)) { |
|
| 5 | 5 | $fleet = array($fleet => 1); |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | $speeds = array(); |
| 9 | - if(!empty($fleet)) { |
|
| 10 | - foreach($fleet as $ship_id => $amount) { |
|
| 11 | - if($amount && in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { |
|
| 9 | + if (!empty($fleet)) { |
|
| 10 | + foreach ($fleet as $ship_id => $amount) { |
|
| 11 | + if ($amount && in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { |
|
| 12 | 12 | $single_ship_data = get_ship_data($ship_id, $user); |
| 13 | 13 | $speeds[] = $single_ship_data['speed']; |
| 14 | 14 | } |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | $game_fleet_speed = flt_server_flight_speed_multiplier(); |
| 53 | 53 | $fleet_speed = flt_fleet_speed($user_row, $fleet_array); |
| 54 | - if(!empty($fleet_array) && $fleet_speed && $game_fleet_speed) { |
|
| 54 | + if (!empty($fleet_array) && $fleet_speed && $game_fleet_speed) { |
|
| 55 | 55 | $speed_percent = $speed_percent ? max(min($speed_percent, 10), 1) : 10; |
| 56 | 56 | $real_speed = $speed_percent * sqrt($fleet_speed); |
| 57 | 57 | |
| 58 | 58 | $duration = max(1, round((35000 / $speed_percent * sqrt($distance * 10 / $fleet_speed) + 10) / $game_fleet_speed)); |
| 59 | 59 | |
| 60 | - foreach($fleet_array as $ship_id => $ship_count) { |
|
| 61 | - if(!$ship_id || !$ship_count) { |
|
| 60 | + foreach ($fleet_array as $ship_id => $ship_count) { |
|
| 61 | + if (!$ship_id || !$ship_count) { |
|
| 62 | 62 | continue; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -86,19 +86,19 @@ discard block |
||
| 86 | 86 | function flt_bashing_check($user, $enemy, $planet_dst, $mission, $flight_duration, $fleet_group = 0) { |
| 87 | 87 | $config_bashing_attacks = classSupernova::$config->fleet_bashing_attacks; |
| 88 | 88 | $config_bashing_interval = classSupernova::$config->fleet_bashing_interval; |
| 89 | - if(!$config_bashing_attacks) { |
|
| 89 | + if (!$config_bashing_attacks) { |
|
| 90 | 90 | // Bashing allowed - protection disabled |
| 91 | 91 | return FLIGHT_ALLOWED; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | $bashing_result = FLIGHT_MISSION_ATTACK_BASHING; |
| 95 | - if($user['ally_id'] && $enemy['ally_id']) { |
|
| 95 | + if ($user['ally_id'] && $enemy['ally_id']) { |
|
| 96 | 96 | $relations = ali_relations($user['ally_id'], $enemy['ally_id']); |
| 97 | - if(!empty($relations)) { |
|
| 97 | + if (!empty($relations)) { |
|
| 98 | 98 | $relations = $relations[$enemy['ally_id']]; |
| 99 | - switch($relations['alliance_diplomacy_relation']) { |
|
| 99 | + switch ($relations['alliance_diplomacy_relation']) { |
|
| 100 | 100 | case ALLY_DIPLOMACY_WAR: |
| 101 | - if(SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) { |
|
| 101 | + if (SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) { |
|
| 102 | 102 | $bashing_result = FLIGHT_MISSION_ATTACK_BASHING_WAR_DELAY; |
| 103 | 103 | } else { |
| 104 | 104 | return FLIGHT_ALLOWED; |
@@ -120,9 +120,9 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | // Retrieving flying fleets |
| 122 | 122 | $objFleetsBashing = FleetList::dbGetFleetListBashing($user['id'], $planet_dst); |
| 123 | - foreach($objFleetsBashing->_container as $fleetBashing) { |
|
| 123 | + foreach ($objFleetsBashing->_container as $fleetBashing) { |
|
| 124 | 124 | // Checking for ACS - each ACS count only once |
| 125 | - if($fleetBashing->group_id) { |
|
| 125 | + if ($fleetBashing->group_id) { |
|
| 126 | 126 | $bashing_list["{$user['id']}_{$fleetBashing->group_id}"] = $fleetBashing->time_arrive_to_target; |
| 127 | 127 | } else { |
| 128 | 128 | $bashing_list[] = $fleetBashing->time_arrive_to_target; |
@@ -130,12 +130,12 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | // Check for joining to ACS - if there are already fleets in ACS no checks should be done |
| 133 | - if($mission == MT_ACS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
| 133 | + if ($mission == MT_ACS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
| 134 | 134 | return FLIGHT_ALLOWED; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | $query = db_bashing_list_get($user, $planet_dst, $time_limit); |
| 138 | - while($bashing_row = db_fetch($query)) { |
|
| 138 | + while ($bashing_row = db_fetch($query)) { |
|
| 139 | 139 | $bashing_list[] = $bashing_row['bashing_time']; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -144,9 +144,9 @@ discard block |
||
| 144 | 144 | $last_attack = 0; |
| 145 | 145 | $wave = 0; |
| 146 | 146 | $attack = 1; |
| 147 | - foreach($bashing_list as &$bash_time) { |
|
| 147 | + foreach ($bashing_list as &$bash_time) { |
|
| 148 | 148 | $attack++; |
| 149 | - if($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
| 149 | + if ($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
| 150 | 150 | $attack = 1; |
| 151 | 151 | $wave++; |
| 152 | 152 | } |
@@ -163,16 +163,16 @@ discard block |
||
| 163 | 163 | //TODO: try..catch |
| 164 | 164 | global $user; |
| 165 | 165 | |
| 166 | - if($user['vacation']) { |
|
| 166 | + if ($user['vacation']) { |
|
| 167 | 167 | return $result = FLIGHT_PLAYER_VACATION_OWN; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if(empty($fleet) || !is_array($fleet)) { |
|
| 170 | + if (empty($fleet) || !is_array($fleet)) { |
|
| 171 | 171 | return $result = FLIGHT_SHIPS_NO_SHIPS; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | $sn_groups_mission = sn_get_groups('missions'); |
| 175 | - if(!isset($sn_groups_mission[$mission])) { |
|
| 175 | + if (!isset($sn_groups_mission[$mission])) { |
|
| 176 | 176 | return $result = FLIGHT_MISSION_UNKNOWN; |
| 177 | 177 | } |
| 178 | 178 | $sn_data_mission = $sn_groups_mission[$mission]; |
@@ -191,32 +191,32 @@ discard block |
||
| 191 | 191 | $resources = 0; |
| 192 | 192 | $ship_ids = sn_get_groups('fleet'); |
| 193 | 193 | $resource_ids = sn_get_groups('resources_loot'); |
| 194 | - foreach($fleet as $ship_id => $ship_count) { |
|
| 194 | + foreach ($fleet as $ship_id => $ship_count) { |
|
| 195 | 195 | $is_ship = in_array($ship_id, $ship_ids); |
| 196 | 196 | $is_resource = in_array($ship_id, $resource_ids); |
| 197 | - if(!$is_ship && !$is_resource) { |
|
| 197 | + if (!$is_ship && !$is_resource) { |
|
| 198 | 198 | // TODO Спецобработчик для Капитана и модулей |
| 199 | 199 | // return FLIGHT_SHIPS_UNIT_WRONG; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - if($ship_count < 0) { |
|
| 202 | + if ($ship_count < 0) { |
|
| 203 | 203 | return $result = $is_ship ? FLIGHT_SHIPS_NEGATIVE : FLIGHT_RESOURCES_NEGATIVE; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - if($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
| 206 | + if ($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
| 207 | 207 | // TODO FLIGHT_MISSION_MISSILE_NO_MISSILES |
| 208 | 208 | return $result = $is_ship ? FLIGHT_SHIPS_NOT_ENOUGH_OR_RESOURCES : FLIGHT_RESOURCES_NOT_ENOUGH; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - if($is_ship) { |
|
| 211 | + if ($is_ship) { |
|
| 212 | 212 | $single_ship_data = get_ship_data($ship_id, $user); |
| 213 | - if($single_ship_data[P_SPEED] <= 0) { |
|
| 213 | + if ($single_ship_data[P_SPEED] <= 0) { |
|
| 214 | 214 | return $result = FLIGHT_SHIPS_UNMOVABLE; |
| 215 | 215 | } |
| 216 | 216 | $ships += $ship_count; |
| 217 | 217 | $recyclers += in_array($ship_id, sn_get_groups('flt_recyclers')) ? $ship_count : 0; |
| 218 | 218 | $spies += $ship_id == SHIP_SPY ? $ship_count : 0; |
| 219 | - } elseif($is_resource) { |
|
| 219 | + } elseif ($is_resource) { |
|
| 220 | 220 | $resources += $ship_count; |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | */ |
| 229 | 229 | |
| 230 | - if(isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
| 230 | + if (isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
| 231 | 231 | return $result = FLIGHT_RESOURCES_FORBIDDEN; |
| 232 | 232 | } |
| 233 | 233 | |
@@ -239,78 +239,78 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | |
| 241 | 241 | $speed = $options['fleet_speed_percent']; |
| 242 | - if($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
| 242 | + if ($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
| 243 | 243 | return $result = FLIGHT_FLEET_SPEED_WRONG; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | $travel_data = flt_travel_data($user, $planet_src, $planet_dst, $fleet, $options['fleet_speed_percent']); |
| 247 | 247 | |
| 248 | 248 | |
| 249 | - if(mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
| 249 | + if (mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
| 250 | 250 | return $result = FLIGHT_RESOURCES_FUEL_NOT_ENOUGH; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - if($travel_data['consumption'] > $travel_data['capacity']) { |
|
| 253 | + if ($travel_data['consumption'] > $travel_data['capacity']) { |
|
| 254 | 254 | return $result = FLIGHT_FLEET_TOO_FAR; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - if($travel_data['hold'] < $resources) { |
|
| 257 | + if ($travel_data['hold'] < $resources) { |
|
| 258 | 258 | return $result = FLIGHT_FLEET_OVERLOAD; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | $fleet_start_time = SN_TIME_NOW + $travel_data['duration']; |
| 262 | 262 | |
| 263 | 263 | $fleet_group = $options['fleet_group']; |
| 264 | - if($fleet_group) { |
|
| 265 | - if($mission != MT_ACS) { |
|
| 264 | + if ($fleet_group) { |
|
| 265 | + if ($mission != MT_ACS) { |
|
| 266 | 266 | return $result = FLIGHT_MISSION_IMPOSSIBLE; |
| 267 | 267 | }; |
| 268 | 268 | |
| 269 | 269 | $acs = db_acs_get_by_group_id($fleet_group); |
| 270 | - if(!$acs['id']) { |
|
| 270 | + if (!$acs['id']) { |
|
| 271 | 271 | return $result = FLIGHT_MISSION_ACS_NOT_EXISTS; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) { |
|
| 274 | + if ($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) { |
|
| 275 | 275 | return $result = FLIGHT_MISSION_ACS_WRONG_TARGET; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - if($fleet_start_time > $acs['ankunft']) { |
|
| 278 | + if ($fleet_start_time > $acs['ankunft']) { |
|
| 279 | 279 | return $result = FLIGHT_MISSION_ACS_TOO_LATE; |
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | $flying_fleets = $options['flying_fleets']; |
| 284 | - if(!$flying_fleets) { |
|
| 284 | + if (!$flying_fleets) { |
|
| 285 | 285 | $flying_fleets = FleetList::fleet_count_flying($user['id']); |
| 286 | 286 | } |
| 287 | - if(GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
| 287 | + if (GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
| 288 | 288 | return $result = FLIGHT_FLEET_NO_SLOTS; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | // В одиночку шпионские зонды могут летать только в миссии Шпионаж, Передислокация и Транспорт |
| 292 | - if($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
| 292 | + if ($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
| 293 | 293 | return $result = FLIGHT_SHIPS_NOT_ONLY_SPIES; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // Checking for no planet |
| 297 | - if(!$planet_dst['id_owner']) { |
|
| 298 | - if($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
| 297 | + if (!$planet_dst['id_owner']) { |
|
| 298 | + if ($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
| 299 | 299 | return $result = FLIGHT_SHIPS_NO_COLONIZER; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - if($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
| 302 | + if ($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
| 303 | 303 | return $result = FLIGHT_ALLOWED; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | return $result = FLIGHT_VECTOR_NO_TARGET; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - if($mission == MT_RECYCLE) { |
|
| 310 | - if($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
| 309 | + if ($mission == MT_RECYCLE) { |
|
| 310 | + if ($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
| 311 | 311 | return $result = FLIGHT_MISSION_RECYCLE_NO_DEBRIS; |
| 312 | 312 | } |
| 313 | - if($recyclers <= 0) { |
|
| 313 | + if ($recyclers <= 0) { |
|
| 314 | 314 | return $result = FLIGHT_SHIPS_NO_RECYCLERS; |
| 315 | 315 | } |
| 316 | 316 | |
@@ -318,8 +318,8 @@ discard block |
||
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | // Got planet. Checking if it is ours |
| 321 | - if($planet_dst['id_owner'] == $user['id']) { |
|
| 322 | - if($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
| 321 | + if ($planet_dst['id_owner'] == $user['id']) { |
|
| 322 | + if ($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
| 323 | 323 | return $result = FLIGHT_ALLOWED; |
| 324 | 324 | } |
| 325 | 325 | |
@@ -327,19 +327,19 @@ discard block |
||
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | // No, planet not ours. Cutting mission that can't be send to not-ours planet |
| 330 | - if($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
| 330 | + if ($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
| 331 | 331 | return $result = FLIGHT_MISSION_IMPOSSIBLE; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | $enemy = db_user_by_id($planet_dst['id_owner']); |
| 335 | 335 | // We cannot attack or send resource to users in VACATION mode |
| 336 | - if($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
| 336 | + if ($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
| 337 | 337 | return $result = FLIGHT_PLAYER_VACATION; |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | // Multi IP protection |
| 341 | 341 | // TODO: Here we need a procedure to check proxies |
| 342 | - if(sys_is_multiaccount($user, $enemy)) { |
|
| 342 | + if (sys_is_multiaccount($user, $enemy)) { |
|
| 343 | 343 | return $result = FLIGHT_PLAYER_SAME_IP; |
| 344 | 344 | } |
| 345 | 345 | |
@@ -347,8 +347,8 @@ discard block |
||
| 347 | 347 | $enemy_points = $enemy['total_points']; |
| 348 | 348 | |
| 349 | 349 | // Is it transport? If yes - checking for buffing to prevent mega-alliance destroyer |
| 350 | - if($mission == MT_TRANSPORT) { |
|
| 351 | - if($user_points >= $enemy_points || classSupernova::$config->allow_buffing) { |
|
| 350 | + if ($mission == MT_TRANSPORT) { |
|
| 351 | + if ($user_points >= $enemy_points || classSupernova::$config->allow_buffing) { |
|
| 352 | 352 | return $result = FLIGHT_ALLOWED; |
| 353 | 353 | } else { |
| 354 | 354 | return $result = FLIGHT_PLAYER_BUFFING; |
@@ -358,66 +358,66 @@ discard block |
||
| 358 | 358 | // Only aggresive missions passed to this point. HOLD counts as passive but aggresive |
| 359 | 359 | |
| 360 | 360 | // Is it admin with planet protection? |
| 361 | - if($planet_dst['id_level'] > $user['authlevel']) { |
|
| 361 | + if ($planet_dst['id_level'] > $user['authlevel']) { |
|
| 362 | 362 | return $result = FLIGHT_PLAYER_ADMIN; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | // Okay. Now skipping protection checks for inactive longer then 1 week |
| 366 | - if(!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { |
|
| 367 | - if( |
|
| 366 | + if (!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { |
|
| 367 | + if ( |
|
| 368 | 368 | ($enemy_points <= classSupernova::$config->game_noob_points && $user_points > classSupernova::$config->game_noob_points) |
| 369 | 369 | || |
| 370 | 370 | (classSupernova::$config->game_noob_factor && $user_points > $enemy_points * classSupernova::$config->game_noob_factor) |
| 371 | 371 | ) { |
| 372 | - if($mission != MT_HOLD) { |
|
| 372 | + if ($mission != MT_HOLD) { |
|
| 373 | 373 | return $result = FLIGHT_PLAYER_NOOB; |
| 374 | 374 | } |
| 375 | - if($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) { |
|
| 375 | + if ($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) { |
|
| 376 | 376 | return $result = FLIGHT_PLAYER_NOOB; |
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | // Is it HOLD mission? If yes - there should be ally deposit |
| 382 | - if($mission == MT_HOLD) { |
|
| 383 | - if(mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
| 382 | + if ($mission == MT_HOLD) { |
|
| 383 | + if (mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
| 384 | 384 | return $result = FLIGHT_ALLOWED; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | return $result = FLIGHT_MISSION_HOLD_NO_ALLY_DEPOSIT; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - if($mission == MT_SPY) { |
|
| 390 | + if ($mission == MT_SPY) { |
|
| 391 | 391 | return $result = $spies >= 1 ? FLIGHT_ALLOWED : FLIGHT_MISSION_SPY_NO_SPIES; |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | // Is it MISSILE mission? |
| 395 | - if($mission == MT_MISSILE) { |
|
| 395 | + if ($mission == MT_MISSILE) { |
|
| 396 | 396 | $sn_data_mip = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET); |
| 397 | - if(mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
| 397 | + if (mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
| 398 | 398 | return $result = FLIGHT_MISSION_MISSILE_NO_SILO; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - if(!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
| 401 | + if (!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
| 402 | 402 | return $result = FLIGHT_MISSION_MISSILE_NO_MISSILES; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | $distance = abs($planet_dst['system'] - $planet_src['system']); |
| 406 | 406 | $mip_range = flt_get_missile_range($user); |
| 407 | - if($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
| 407 | + if ($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
| 408 | 408 | return $result = FLIGHT_MISSION_MISSILE_TOO_FAR; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - if(isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
| 411 | + if (isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
| 412 | 412 | return $result = FLIGHT_MISSION_MISSILE_WRONG_STRUCTURE; |
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - if($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
| 416 | + if ($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
| 417 | 417 | return $result = FLIGHT_MISSION_IMPOSSIBLE; |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | - if($mission == MT_ATTACK || $mission == MT_ACS || $mission == MT_DESTROY) { |
|
| 420 | + if ($mission == MT_ATTACK || $mission == MT_ACS || $mission == MT_DESTROY) { |
|
| 421 | 421 | return $result = flt_bashing_check($user, $enemy, $planet_dst, $mission, $travel_data['duration'], $fleet_group); |
| 422 | 422 | } |
| 423 | 423 | |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | $from = $from['planet']; |
| 445 | 445 | |
| 446 | 446 | $can_attack = flt_can_attack($from, $to, $fleet_REAL_array, $mission, $options); |
| 447 | - if($can_attack != FLIGHT_ALLOWED) { |
|
| 447 | + if ($can_attack != FLIGHT_ALLOWED) { |
|
| 448 | 448 | $internal_transaction ? sn_db_transaction_rollback() : false; |
| 449 | 449 | |
| 450 | 450 | return $can_attack; |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | $travel_data = flt_travel_data($user, $from, $to, $fleet_REAL_array, $options['fleet_speed_percent']); |
| 456 | 456 | |
| 457 | 457 | $time_on_mission = 0; |
| 458 | - if($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
| 458 | + if ($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
| 459 | 459 | // TODO - include some checks about maximum and minumum stay_duration |
| 460 | 460 | $time_on_mission = $options['stay_time'] * 3600; |
| 461 | 461 | } |
@@ -478,14 +478,14 @@ discard block |
||
| 478 | 478 | $sn_group_resources_loot = sn_get_groups('resources_loot'); |
| 479 | 479 | $db_changeset = array(); |
| 480 | 480 | $planet_row_changed_fields = array(); |
| 481 | - foreach($fleet_REAL_array as $unit_id => $amount) { |
|
| 482 | - if(!$amount || !$unit_id) { |
|
| 481 | + foreach ($fleet_REAL_array as $unit_id => $amount) { |
|
| 482 | + if (!$amount || !$unit_id) { |
|
| 483 | 483 | continue; |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | - if(in_array($unit_id, $sn_group_fleet)) { |
|
| 486 | + if (in_array($unit_id, $sn_group_fleet)) { |
|
| 487 | 487 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, -$amount, $user, $from['id']); |
| 488 | - } elseif(in_array($unit_id, $sn_group_resources_loot)) { |
|
| 488 | + } elseif (in_array($unit_id, $sn_group_resources_loot)) { |
|
| 489 | 489 | $planet_row_changed_fields[pname_resource_name($unit_id)]['delta'] -= $amount; |
| 490 | 490 | } |
| 491 | 491 | } |
@@ -524,16 +524,16 @@ discard block |
||
| 524 | 524 | |
| 525 | 525 | $ship_data = array(); |
| 526 | 526 | $fleet_array = array(); |
| 527 | - foreach($ship_list as $transport_id => $cork) { |
|
| 527 | + foreach ($ship_list as $transport_id => $cork) { |
|
| 528 | 528 | $ship_data[$transport_id] = flt_travel_data($user, $from, $to, array($transport_id => 1), 10); |
| 529 | 529 | } |
| 530 | 530 | uasort($ship_data, 'flt_calculate_ship_to_transport_sort'); |
| 531 | 531 | |
| 532 | 532 | $fleet_capacity = 0; |
| 533 | 533 | $fuel_total = $fuel_left = mrc_get_level($user, $from, RES_DEUTERIUM); |
| 534 | - foreach($ship_data as $transport_id => &$ship_info) { |
|
| 534 | + foreach ($ship_data as $transport_id => &$ship_info) { |
|
| 535 | 535 | $ship_loaded = min($ship_list[$transport_id], ceil($resource_amount / $ship_info['hold']), floor($fuel_left / $ship_info['consumption'])); |
| 536 | - if($ship_loaded) { |
|
| 536 | + if ($ship_loaded) { |
|
| 537 | 537 | $fleet_array[$transport_id] = $ship_loaded; |
| 538 | 538 | $resource_amount -= min($resource_amount, $ship_info['hold'] * $ship_loaded); |
| 539 | 539 | $fuel_left -= $ship_info['consumption'] * $ship_loaded; |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | // Compare function to sort fleet in time order |
| 4 | 4 | function tpl_assign_fleet_compare($a, $b) { |
| 5 | - if($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) { |
|
| 6 | - if($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) { |
|
| 5 | + if ($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) { |
|
| 6 | + if ($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) { |
|
| 7 | 7 | return 0; |
| 8 | 8 | } |
| 9 | 9 | |
@@ -19,17 +19,17 @@ discard block |
||
| 19 | 19 | * @param string $js_name |
| 20 | 20 | */ |
| 21 | 21 | function tpl_assign_fleet(&$template, $fleets, $js_name = 'fleets') { |
| 22 | - if(!$fleets) { |
|
| 22 | + if (!$fleets) { |
|
| 23 | 23 | return; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | usort($fleets, 'tpl_assign_fleet_compare'); |
| 27 | 27 | |
| 28 | - foreach($fleets as $fleet_data) { |
|
| 28 | + foreach ($fleets as $fleet_data) { |
|
| 29 | 29 | $template->assign_block_vars($js_name, $fleet_data['fleet']); |
| 30 | 30 | |
| 31 | - if($fleet_data['ships']) { |
|
| 32 | - foreach($fleet_data['ships'] as $ship_data) { |
|
| 31 | + if ($fleet_data['ships']) { |
|
| 32 | + foreach ($fleet_data['ships'] as $ship_data) { |
|
| 33 | 33 | $template->assign_block_vars("{$js_name}.ships", $ship_data); |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | 'DEUTERIUM' => $fleet[RES_DEUTERIUM], |
| 51 | 51 | ); |
| 52 | 52 | |
| 53 | - foreach($fleet as $ship_id => $ship_amount) { |
|
| 54 | - if(in_array($ship_id, sn_get_groups('fleet'))) { |
|
| 53 | + foreach ($fleet as $ship_id => $ship_amount) { |
|
| 54 | + if (in_array($ship_id, sn_get_groups('fleet'))) { |
|
| 55 | 55 | $single_ship_data = get_ship_data($ship_id, $user_data); |
| 56 | 56 | $return['ships'][$ship_id] = array( |
| 57 | 57 | 'ID' => $ship_id, |
@@ -90,11 +90,11 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | $result = array(); |
| 92 | 92 | |
| 93 | - if(!$user_data) { |
|
| 93 | + if (!$user_data) { |
|
| 94 | 94 | $user_data = $user; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if(!$objFleet->isReturning() && $objFleet->mission_type == MT_ACS) { |
|
| 97 | + if (!$objFleet->isReturning() && $objFleet->mission_type == MT_ACS) { |
|
| 98 | 98 | $aks = db_acs_get_by_group_id($objFleet->group_id); |
| 99 | 99 | } |
| 100 | 100 | |
@@ -135,14 +135,14 @@ discard block |
||
| 135 | 135 | 'STAY_LEFT' => floor($objFleet->time_mission_job_complete + 1 - SN_TIME_NOW), |
| 136 | 136 | ); |
| 137 | 137 | |
| 138 | - if(property_exists($objFleet, 'fleet_start_name')) { |
|
| 138 | + if (property_exists($objFleet, 'fleet_start_name')) { |
|
| 139 | 139 | $result['START_NAME'] = $objFleet->fleet_start_name; |
| 140 | 140 | } |
| 141 | - if(property_exists($objFleet, 'fleet_end_name')) { |
|
| 141 | + if (property_exists($objFleet, 'fleet_end_name')) { |
|
| 142 | 142 | $result['END_NAME'] = $objFleet->fleet_end_name; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - if(property_exists($objFleet, 'event_time')) { |
|
| 145 | + if (property_exists($objFleet, 'event_time')) { |
|
| 146 | 146 | $result['fleet'] = array_merge($result['fleet'], array( |
| 147 | 147 | 'OV_LABEL' => $objFleet->ov_label, |
| 148 | 148 | 'EVENT_TIME_TEXT' => property_exists($objFleet, 'event_time') ? date(FMT_DATE_TIME, $objFleet->event_time + SN_CLIENT_TIME_DIFF) : '', |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | $ship_id = 0; |
| 157 | 157 | $result['ships'] = array(); |
| 158 | - if($spy_level >= 6) { |
|
| 159 | - foreach($ship_list_fully_parsed as $ship_sn_id => $ship_amount) { |
|
| 160 | - if($spy_level >= 10) { |
|
| 158 | + if ($spy_level >= 6) { |
|
| 159 | + foreach ($ship_list_fully_parsed as $ship_sn_id => $ship_amount) { |
|
| 160 | + if ($spy_level >= 10) { |
|
| 161 | 161 | $single_ship_data = get_ship_data($ship_sn_id, $user_data); |
| 162 | 162 | $result['ships'][$ship_sn_id] = array( |
| 163 | 163 | 'ID' => $ship_sn_id, |
@@ -190,8 +190,8 @@ discard block |
||
| 190 | 190 | function tpl_parse_planet_que($que, $planet, $que_id) { |
| 191 | 191 | $hangar_que = array(); |
| 192 | 192 | $que_hangar = $que['ques'][$que_id][$planet['id_owner']][$planet['id']]; |
| 193 | - if(!empty($que_hangar)) { |
|
| 194 | - foreach($que_hangar as $que_item) { |
|
| 193 | + if (!empty($que_hangar)) { |
|
| 194 | + foreach ($que_hangar as $que_item) { |
|
| 195 | 195 | $hangar_que['que'][] = array('id' => $que_item['que_unit_id'], 'count' => $que_item['que_unit_amount']); |
| 196 | 196 | $hangar_que[$que_item['que_unit_id']] += $que_item['que_unit_amount']; |
| 197 | 197 | } |
@@ -251,10 +251,10 @@ discard block |
||
| 251 | 251 | 'PLANET_GOVERNOR_LEVEL_MAX' => get_unit_param($planet['PLANET_GOVERNOR_ID'], P_MAX_STACK), |
| 252 | 252 | ); |
| 253 | 253 | |
| 254 | - if(!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) { |
|
| 254 | + if (!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) { |
|
| 255 | 255 | $result['building_que'] = array(); |
| 256 | 256 | $building_que = &$que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']]; |
| 257 | - foreach($building_que as $que_element) { |
|
| 257 | + foreach ($building_que as $que_element) { |
|
| 258 | 258 | $result['building_que'][] = que_tpl_parse_element($que_element); |
| 259 | 259 | } |
| 260 | 260 | } |
@@ -270,19 +270,19 @@ discard block |
||
| 270 | 270 | function flt_get_fleets_to_planet_by_array_of_Fleet($array_of_Fleet) { |
| 271 | 271 | global $user; |
| 272 | 272 | |
| 273 | - if(empty($array_of_Fleet)) { |
|
| 273 | + if (empty($array_of_Fleet)) { |
|
| 274 | 274 | return false; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | $fleet_list = array(); |
| 278 | - foreach($array_of_Fleet as $fleet) { |
|
| 279 | - if($fleet->playerOwnerId == $user['id']) { |
|
| 280 | - if($fleet->mission_type == MT_MISSILE) { |
|
| 278 | + foreach ($array_of_Fleet as $fleet) { |
|
| 279 | + if ($fleet->playerOwnerId == $user['id']) { |
|
| 280 | + if ($fleet->mission_type == MT_MISSILE) { |
|
| 281 | 281 | continue; |
| 282 | 282 | } |
| 283 | 283 | $fleet_ownage = 'own'; |
| 284 | 284 | } else { |
| 285 | - switch($fleet->mission_type) { |
|
| 285 | + switch ($fleet->mission_type) { |
|
| 286 | 286 | case MT_ATTACK: |
| 287 | 287 | case MT_ACS: |
| 288 | 288 | case MT_DESTROY: |
@@ -299,10 +299,10 @@ discard block |
||
| 299 | 299 | |
| 300 | 300 | $fleet_list[$fleet_ownage]['fleets'][$fleet->dbId] = $fleet; |
| 301 | 301 | |
| 302 | - if($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) { |
|
| 302 | + if ($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) { |
|
| 303 | 303 | $fleet_sn = $fleet->shipsGetArray(); |
| 304 | - foreach($fleet_sn as $ship_id => $ship_amount) { |
|
| 305 | - if(in_array($ship_id, sn_get_groups('fleet'))) { |
|
| 304 | + foreach ($fleet_sn as $ship_id => $ship_amount) { |
|
| 305 | + if (in_array($ship_id, sn_get_groups('fleet'))) { |
|
| 306 | 306 | $fleet_list[$fleet_ownage]['total'][$ship_id] += $ship_amount; |
| 307 | 307 | } |
| 308 | 308 | } |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | return $fleet_list; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | -function tpl_set_resource_info(template &$template, $planet_row, $fleets_to_planet = array(), $round = 0) { |
|
| 322 | +function tpl_set_resource_info(template & $template, $planet_row, $fleets_to_planet = array(), $round = 0) { |
|
| 323 | 323 | $template->assign_vars(array( |
| 324 | 324 | 'RESOURCE_ROUNDING' => $round, |
| 325 | 325 | |