@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | $result = []; |
| 291 | 291 | |
| 292 | 292 | foreach ($this->getShipListArray() as $unit_id => $unit_amount) { |
| 293 | - $shipsLost = ceil($unit_amount * $multiplier); |
|
| 293 | + $shipsLost = ceil($unit_amount * $multiplier); |
|
| 294 | 294 | $result[$unit_id] += $shipsLost; |
| 295 | 295 | } |
| 296 | 296 | |
@@ -436,8 +436,8 @@ discard block |
||
| 436 | 436 | protected function getTravelData() { |
| 437 | 437 | $travel_data = flt_travel_data( |
| 438 | 438 | $this->getFleetOwnerRecord(), |
| 439 | - ['galaxy' => $this->fleet_start_galaxy, 'system' => $this->fleet_start_system, 'planet' => $this->fleet_start_planet,], |
|
| 440 | - ['galaxy' => $this->fleet_end_galaxy, 'system' => $this->fleet_end_system, 'planet' => $this->fleet_end_planet,], |
|
| 439 | + ['galaxy' => $this->fleet_start_galaxy, 'system' => $this->fleet_start_system, 'planet' => $this->fleet_start_planet, ], |
|
| 440 | + ['galaxy' => $this->fleet_end_galaxy, 'system' => $this->fleet_end_system, 'planet' => $this->fleet_end_planet, ], |
|
| 441 | 441 | $this->getShipListArray(), |
| 442 | 442 | $this->speedPercentTenth |
| 443 | 443 | ); |
@@ -14,24 +14,24 @@ discard block |
||
| 14 | 14 | global $debug, $template_result, $user, $lang, $planetrow; |
| 15 | 15 | |
| 16 | 16 | // Напоминание для Администрации, что игра отключена |
| 17 | -if($template_result[F_GAME_DISABLE]) { |
|
| 17 | +if ($template_result[F_GAME_DISABLE]) { |
|
| 18 | 18 | echo '<div class="global_admin_warning">', $template_result[F_GAME_DISABLE_REASON], '</div>'; |
| 19 | 19 | } |
| 20 | 20 | unset($disable_reason); |
| 21 | 21 | |
| 22 | 22 | |
| 23 | -if(defined('IN_ADMIN') && IN_ADMIN === true) { |
|
| 23 | +if (defined('IN_ADMIN') && IN_ADMIN === true) { |
|
| 24 | 24 | lng_include('admin'); |
| 25 | -} elseif(SN::$sys_user_logged_in) { |
|
| 25 | +} elseif (SN::$sys_user_logged_in) { |
|
| 26 | 26 | sys_user_vacation($user); |
| 27 | 27 | |
| 28 | 28 | $planet_id = SetSelectedPlanet($user); |
| 29 | 29 | |
| 30 | 30 | // TODO НЕ НУЖНО АЛЬЯНС КАЖДЫЙ РАЗ ОБНОВЛЯТЬ!!! |
| 31 | - if($user['ally_id']) { |
|
| 31 | + if ($user['ally_id']) { |
|
| 32 | 32 | db_mysql::db_transaction_start(); |
| 33 | 33 | \Alliance\Alliance::sn_ali_fill_user_ally($user); |
| 34 | - if(!$user['ally']['player']['id']) { |
|
| 34 | + if (!$user['ally']['player']['id']) { |
|
| 35 | 35 | // sn_sys_logout(false, true); |
| 36 | 36 | // core_auth::logout(false); |
| 37 | 37 | SN::$auth->logout(false); |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | db_mysql::db_transaction_commit(); |
| 51 | 51 | |
| 52 | 52 | $planetrow = $global_data['planet']; |
| 53 | - if(!($planetrow && isset($planetrow['id']) && $planetrow['id'])) { |
|
| 53 | + if (!($planetrow && isset($planetrow['id']) && $planetrow['id'])) { |
|
| 54 | 54 | // sn_sys_logout(false, true); |
| 55 | 55 | // core_auth::logout(false); |
| 56 | 56 | SN::$auth->logout(false); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | sys_user_options_unpack($user); |
| 66 | 66 | |
| 67 | 67 | global $sn_page_name, $sn_mvc; |
| 68 | -if(!empty($sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_EARLY_HEADER])) { |
|
| 68 | +if (!empty($sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_EARLY_HEADER])) { |
|
| 69 | 69 | $title = !empty($sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_TITLE]) ? $sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_TITLE] : ''; |
| 70 | 70 | SnTemplate::renderHeader($page, $title, $template_result, false, $user, SN::$config, $lang, $planetrow); |
| 71 | 71 | } |
@@ -17,34 +17,34 @@ discard block |
||
| 17 | 17 | $template = SnTemplate::gettemplate('notes', true); |
| 18 | 18 | |
| 19 | 19 | $result = array(); |
| 20 | -if(($result_message = sys_get_param_str('MESSAGE')) && isset($lang[$result_message])) { |
|
| 20 | +if (($result_message = sys_get_param_str('MESSAGE')) && isset($lang[$result_message])) { |
|
| 21 | 21 | $result[] = array('STATUS' => sys_get_param_int('STATUS'), 'MESSAGE' => $lang[$result_message]); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | $note_id_edit = sys_get_param_id('note_id_edit'); |
| 25 | -if(sys_get_param('note_delete')) { |
|
| 25 | +if (sys_get_param('note_delete')) { |
|
| 26 | 26 | try { |
| 27 | 27 | $not = ''; |
| 28 | 28 | $query_where = ''; |
| 29 | - switch(sys_get_param_str('note_delete_range')) { |
|
| 29 | + switch (sys_get_param_str('note_delete_range')) { |
|
| 30 | 30 | case 'all': |
| 31 | 31 | break; |
| 32 | 32 | |
| 33 | 33 | case 'marked_not': |
| 34 | 34 | $not = 'NOT'; |
| 35 | 35 | case 'marked': |
| 36 | - if(!is_array($notes_marked = sys_get_param('note'))) { |
|
| 36 | + if (!is_array($notes_marked = sys_get_param('note'))) { |
|
| 37 | 37 | throw new exception('note_err_none_selected', ERR_WARNING); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | $notes_marked_filtered = array(); |
| 41 | - foreach($notes_marked as $note_id => $note_select) { |
|
| 42 | - if($note_select == 'on' && $note_id = idval($note_id)) { |
|
| 41 | + foreach ($notes_marked as $note_id => $note_select) { |
|
| 42 | + if ($note_select == 'on' && $note_id = idval($note_id)) { |
|
| 43 | 43 | $notes_marked_filtered[] = $note_id; |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if(empty($notes_marked_filtered)) { |
|
| 47 | + if (empty($notes_marked_filtered)) { |
|
| 48 | 48 | throw new exception('note_err_none_selected', ERR_WARNING); |
| 49 | 49 | } |
| 50 | 50 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | doquery("DELETE FROM {{notes}} WHERE `owner` = {$user['id']} {$query_where};"); |
| 62 | 62 | db_mysql::db_transaction_commit(); |
| 63 | 63 | throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE); |
| 64 | - } catch(exception $e) { |
|
| 64 | + } catch (exception $e) { |
|
| 65 | 65 | $note_id_edit = 0; |
| 66 | 66 | db_mysql::db_transaction_rollback(); |
| 67 | 67 | $result[] = array( |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | 'MESSAGE' => $lang[$e->getMessage()], |
| 70 | 70 | ); |
| 71 | 71 | } |
| 72 | -} elseif(($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) { |
|
| 72 | +} elseif (($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) { |
|
| 73 | 73 | $note_title == SN::$db->db_escape($lang['note_new_title']) ? $note_title = '' : false; |
| 74 | 74 | ($note_text = sys_get_param_str('note_text')) == SN::$db->db_escape($lang['note_new_text']) ? $note_text = '' : false; |
| 75 | 75 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $note_system = max(0, min(sys_get_param_id('note_system'), SN::$config->game_maxSystem)); |
| 79 | 79 | $note_planet = max(0, min(sys_get_param_id('note_planet'), SN::$config->game_maxPlanet + 1)); |
| 80 | 80 | |
| 81 | - if(!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) { |
|
| 81 | + if (!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) { |
|
| 82 | 82 | throw new exception('note_err_note_empty', ERR_WARNING); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -87,15 +87,15 @@ discard block |
||
| 87 | 87 | $note_sticky = intval(sys_get_param_id('note_sticky')) ? 1 : 0; |
| 88 | 88 | |
| 89 | 89 | db_mysql::db_transaction_start(); |
| 90 | - if($note_id_edit) { |
|
| 90 | + if ($note_id_edit) { |
|
| 91 | 91 | $check_note_id = doquery("SELECT `id`, `owner` FROM {{notes}} WHERE `id` = {$note_id_edit} LIMIT 1 FOR UPDATE", true); |
| 92 | - if(!$check_note_id) { |
|
| 92 | + if (!$check_note_id) { |
|
| 93 | 93 | throw new exception('note_err_note_not_found', ERR_ERROR); |
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if($note_id_edit) { |
|
| 98 | - if($check_note_id['owner'] != $user['id']) { |
|
| 97 | + if ($note_id_edit) { |
|
| 98 | + if ($check_note_id['owner'] != $user['id']) { |
|
| 99 | 99 | throw new exception('note_err_owner_wrong', ERR_ERROR); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | db_mysql::db_transaction_commit(); |
| 111 | 111 | sys_redirect('notes.php?STATUS=' . ERR_NONE . '&MESSAGE=' . ($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added')); |
| 112 | 112 | // throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE); |
| 113 | - } catch(exception $e) { |
|
| 113 | + } catch (exception $e) { |
|
| 114 | 114 | $note_id_edit = 0; |
| 115 | 115 | db_mysql::db_transaction_rollback(); |
| 116 | 116 | $result[] = array( |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | -if(!$note_id_edit) { |
|
| 123 | +if (!$note_id_edit) { |
|
| 124 | 124 | \Note\Note::note_assign($template, array( |
| 125 | 125 | 'id' => 0, |
| 126 | 126 | 'time' => SN_TIME_NOW, |
@@ -133,13 +133,13 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | $note_exist = false; |
| 135 | 135 | $notes_query = doquery("SELECT * FROM {{notes}} WHERE owner={$user['id']} ORDER BY priority DESC, galaxy ASC, system ASC, planet ASC, planet_type ASC, `time` DESC"); |
| 136 | -while($note_row = db_fetch($notes_query)) { |
|
| 136 | +while ($note_row = db_fetch($notes_query)) { |
|
| 137 | 137 | \Note\Note::note_assign($template, $note_row); |
| 138 | 138 | $note_exist = $note_exist || $note_row['id'] == $note_id_edit; |
| 139 | 139 | } |
| 140 | 140 | $note_id_edit = $note_exist ? $note_id_edit : 0; |
| 141 | 141 | |
| 142 | -foreach($note_priority_classes as $note_priority_id => $note_priority_class) { |
|
| 142 | +foreach ($note_priority_classes as $note_priority_id => $note_priority_class) { |
|
| 143 | 143 | $template->assign_block_vars('note_priority', array( |
| 144 | 144 | 'ID' => $note_priority_id, |
| 145 | 145 | 'CLASS' => $note_priority_classes[$note_priority_id], |
@@ -147,14 +147,14 @@ discard block |
||
| 147 | 147 | )); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | -foreach($lang['sys_planet_type'] as $planet_type_id => $planet_type_string) { |
|
| 150 | +foreach ($lang['sys_planet_type'] as $planet_type_id => $planet_type_string) { |
|
| 151 | 151 | $template->assign_block_vars('planet_type', array( |
| 152 | 152 | 'ID' => $planet_type_id, |
| 153 | 153 | 'TEXT' => $planet_type_string, |
| 154 | 154 | )); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | -foreach($result as $result_data) { |
|
| 157 | +foreach ($result as $result_data) { |
|
| 158 | 158 | $template->assign_block_vars('result', $result_data); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -73,29 +73,29 @@ discard block |
||
| 73 | 73 | Constants::K_OUTCOME => Constants::EXPEDITION_OUTCOME_FOUND_FLEET, |
| 74 | 74 | Constants::K_OUTCOME_TYPE => Constants::OUTCOME_TYPE_GOOD, |
| 75 | 75 | P_CHANCE => 200, |
| 76 | - 'percent' => [0 => 0.1, 1 => 0.02, 2 => 0.01,], |
|
| 76 | + 'percent' => [0 => 0.1, 1 => 0.02, 2 => 0.01, ], |
|
| 77 | 77 | Constants::K_OUTCOME_SECONDARY => [ |
| 78 | - [P_CHANCE => 90, P_MULTIPLIER => 0.01, P_MESSAGE_ID => 2,], |
|
| 79 | - [P_CHANCE => 9, P_MULTIPLIER => 0.02, P_MESSAGE_ID => 1,], |
|
| 80 | - [P_CHANCE => 1, P_MULTIPLIER => 0.10, P_MESSAGE_ID => 0,], |
|
| 78 | + [P_CHANCE => 90, P_MULTIPLIER => 0.01, P_MESSAGE_ID => 2, ], |
|
| 79 | + [P_CHANCE => 9, P_MULTIPLIER => 0.02, P_MESSAGE_ID => 1, ], |
|
| 80 | + [P_CHANCE => 1, P_MULTIPLIER => 0.10, P_MESSAGE_ID => 0, ], |
|
| 81 | 81 | ], |
| 82 | 82 | ], |
| 83 | 83 | Constants::EXPEDITION_OUTCOME_FOUND_RESOURCES => [ |
| 84 | 84 | Constants::K_OUTCOME => Constants::EXPEDITION_OUTCOME_FOUND_RESOURCES, |
| 85 | 85 | Constants::K_OUTCOME_TYPE => Constants::OUTCOME_TYPE_GOOD, |
| 86 | 86 | P_CHANCE => 300, |
| 87 | - 'percent' => [0 => 0.1, 1 => 0.050, 2 => 0.025,], |
|
| 87 | + 'percent' => [0 => 0.1, 1 => 0.050, 2 => 0.025, ], |
|
| 88 | 88 | Constants::K_OUTCOME_SECONDARY => [ |
| 89 | - [P_CHANCE => 90, P_MULTIPLIER => 0.025, P_MESSAGE_ID => 2,], |
|
| 90 | - [P_CHANCE => 9, P_MULTIPLIER => 0.050, P_MESSAGE_ID => 1,], |
|
| 91 | - [P_CHANCE => 1, P_MULTIPLIER => 0.100, P_MESSAGE_ID => 0,], |
|
| 89 | + [P_CHANCE => 90, P_MULTIPLIER => 0.025, P_MESSAGE_ID => 2, ], |
|
| 90 | + [P_CHANCE => 9, P_MULTIPLIER => 0.050, P_MESSAGE_ID => 1, ], |
|
| 91 | + [P_CHANCE => 1, P_MULTIPLIER => 0.100, P_MESSAGE_ID => 0, ], |
|
| 92 | 92 | ], |
| 93 | 93 | ], |
| 94 | 94 | Constants::EXPEDITION_OUTCOME_FOUND_DM => [ |
| 95 | 95 | Constants::K_OUTCOME => Constants::EXPEDITION_OUTCOME_FOUND_DM, |
| 96 | 96 | Constants::K_OUTCOME_TYPE => Constants::OUTCOME_TYPE_GOOD, |
| 97 | 97 | P_CHANCE => 100, |
| 98 | - 'percent' => [0 => 0.0100, 1 => 0.0040, 2 => 0.0010,], |
|
| 98 | + 'percent' => [0 => 0.0100, 1 => 0.0040, 2 => 0.0010, ], |
|
| 99 | 99 | Constants::K_OUTCOME_SECONDARY => [ |
| 100 | 100 | [P_CHANCE => 90, P_MULTIPLIER => 0.0010, /*P_MESSAGE_ID => 2,*/], |
| 101 | 101 | [P_CHANCE => 9, P_MULTIPLIER => 0.0040, /*P_MESSAGE_ID => 1,*/], |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | if (!$config[P_CHANCE]) { |
| 155 | 155 | continue; |
| 156 | 156 | } |
| 157 | - $this->outcome = $key1; |
|
| 157 | + $this->outcome = $key1; |
|
| 158 | 158 | if ($this->valueRolled <= $config [self::K_ROLL_VALUE]) { |
| 159 | 159 | break; |
| 160 | 160 | } |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | if ($found_ship_cost > $found_in_metal) { |
| 625 | 625 | unset($can_be_found[$found_ship_id]); |
| 626 | 626 | } else { |
| 627 | - $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost)); |
|
| 627 | + $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost)); |
|
| 628 | 628 | $this->shipsFound[$found_ship_id] += $found_ship_count; |
| 629 | 629 | $found_in_metal -= $found_ship_count * $found_ship_cost; |
| 630 | 630 | } |
@@ -46,17 +46,17 @@ discard block |
||
| 46 | 46 | public static $processedIPR = -1; |
| 47 | 47 | |
| 48 | 48 | public static $MISSIONS = [ |
| 49 | - MT_ATTACK => [self::IS_TRANSPORT => false, self::IS_ATTACK => true,], |
|
| 50 | - MT_AKS => [self::IS_TRANSPORT => false, self::IS_ATTACK => true,], |
|
| 51 | - MT_DESTROY => [self::IS_TRANSPORT => false, self::IS_ATTACK => true,], |
|
| 52 | - MT_HOLD => [self::IS_TRANSPORT => false,], |
|
| 53 | - MT_SPY => [self::IS_TRANSPORT => false, self::IS_LOCK_SOURCE => true, 'AJAX' => true,], |
|
| 54 | - MT_TRANSPORT => [self::IS_TRANSPORT => true, self::IS_LOCK_SOURCE => true,], |
|
| 55 | - MT_RELOCATE => [self::IS_TRANSPORT => true, self::IS_LOCK_SOURCE => true,], |
|
| 56 | - MT_RECYCLE => [self::IS_TRANSPORT => false, 'AJAX' => true,], |
|
| 57 | - MT_EXPLORE => [self::IS_TRANSPORT => false,], |
|
| 58 | - MT_COLONIZE => [self::IS_TRANSPORT => true,], |
|
| 59 | - MT_MISSILE => [self::IS_TRANSPORT => false, 'AJAX' => true,], |
|
| 49 | + MT_ATTACK => [self::IS_TRANSPORT => false, self::IS_ATTACK => true, ], |
|
| 50 | + MT_AKS => [self::IS_TRANSPORT => false, self::IS_ATTACK => true, ], |
|
| 51 | + MT_DESTROY => [self::IS_TRANSPORT => false, self::IS_ATTACK => true, ], |
|
| 52 | + MT_HOLD => [self::IS_TRANSPORT => false, ], |
|
| 53 | + MT_SPY => [self::IS_TRANSPORT => false, self::IS_LOCK_SOURCE => true, 'AJAX' => true, ], |
|
| 54 | + MT_TRANSPORT => [self::IS_TRANSPORT => true, self::IS_LOCK_SOURCE => true, ], |
|
| 55 | + MT_RELOCATE => [self::IS_TRANSPORT => true, self::IS_LOCK_SOURCE => true, ], |
|
| 56 | + MT_RECYCLE => [self::IS_TRANSPORT => false, 'AJAX' => true, ], |
|
| 57 | + MT_EXPLORE => [self::IS_TRANSPORT => false, ], |
|
| 58 | + MT_COLONIZE => [self::IS_TRANSPORT => true, ], |
|
| 59 | + MT_MISSILE => [self::IS_TRANSPORT => false, 'AJAX' => true, ], |
|
| 60 | 60 | ]; |
| 61 | 61 | |
| 62 | 62 | public function __construct($fleetRow, $eventType) { |
@@ -71,19 +71,18 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | $this->fleetOwnerId = $fleetRow[self::F_FLEET_OWNER_ID]; |
| 73 | 73 | |
| 74 | - $this->missionId = (int)$this->fleet[FleetDispatcher::F_FLEET_MISSION]; |
|
| 74 | + $this->missionId = (int) $this->fleet[FleetDispatcher::F_FLEET_MISSION]; |
|
| 75 | 75 | $this->missionInfoNew = self::$MISSIONS[$this->missionId]; |
| 76 | 76 | |
| 77 | - $this->eventTimeStamp = (int)$this->fleet[$this->event === EVENT_FLT_ARRIVE ? 'fleet_start_time' : |
|
| 78 | - ($this->event === EVENT_FLT_ACCOMPLISH ? 'fleet_end_stay' : /* EVENT_FLT_RETURN */ |
|
| 77 | + $this->eventTimeStamp = (int) $this->fleet[$this->event === EVENT_FLT_ARRIVE ? 'fleet_start_time' : ($this->event === EVENT_FLT_ACCOMPLISH ? 'fleet_end_stay' : /* EVENT_FLT_RETURN */ |
|
| 79 | 78 | 'fleet_end_time')]; |
| 80 | 79 | |
| 81 | 80 | /** @var Fleet $fleetObject */ |
| 82 | - $fleetObject = (object)$this->fleet; |
|
| 81 | + $fleetObject = (object) $this->fleet; |
|
| 83 | 82 | |
| 84 | 83 | // Always locking flying fleet and fleet owner |
| 85 | - $this->userIdsToLock = [(int)$fleetObject->fleet_owner ?: 0 => true,]; |
|
| 86 | - $this->fleetIdsToLock = [(int)$fleetObject->fleet_id => true,]; |
|
| 84 | + $this->userIdsToLock = [(int) $fleetObject->fleet_owner ?: 0 => true, ]; |
|
| 85 | + $this->fleetIdsToLock = [(int) $fleetObject->fleet_id => true, ]; |
|
| 87 | 86 | $this->planetIdsToLock = []; |
| 88 | 87 | |
| 89 | 88 | // Some locks make sense only on specific event types |
@@ -103,10 +102,10 @@ discard block |
||
| 103 | 102 | // If the fleet is a part of existing fleet group - locking also fleets in group and their respected owners |
| 104 | 103 | // Only doing it for EVENT_FLT_ARRIVE - currently no other event types does trigger fleet group actions |
| 105 | 104 | if (!empty($fleetObject->fleet_group) && $this->event === EVENT_FLT_ARRIVE) { |
| 106 | - $fleetGroupId = (int)$fleetObject->fleet_group; |
|
| 105 | + $fleetGroupId = (int) $fleetObject->fleet_group; |
|
| 107 | 106 | foreach (DbFleetStatic::db_fleet_list("`fleet_group` = {$fleetGroupId}") as $fleetInGroup) { |
| 108 | - $this->userIdsToLock[(int)$fleetInGroup[self::F_FLEET_OWNER_ID] ?: 0] = true; |
|
| 109 | - $this->fleetIdsToLock[(int)$fleetInGroup[self::F_FLEET_ID] ?: 0] = true; |
|
| 107 | + $this->userIdsToLock[(int) $fleetInGroup[self::F_FLEET_OWNER_ID] ?: 0] = true; |
|
| 108 | + $this->fleetIdsToLock[(int) $fleetInGroup[self::F_FLEET_ID] ?: 0] = true; |
|
| 110 | 109 | } |
| 111 | 110 | } |
| 112 | 111 | |
@@ -129,8 +128,8 @@ discard block |
||
| 129 | 128 | $this->eventTimeStamp |
| 130 | 129 | ); |
| 131 | 130 | foreach ($fleetsOnHold as $aFleet) { |
| 132 | - $this->userIdsToLock[(int)$aFleet[self::F_FLEET_OWNER_ID] ?: 0] = true; |
|
| 133 | - $this->fleetIdsToLock[(int)$aFleet[self::F_FLEET_ID] ?: 0] = true; |
|
| 131 | + $this->userIdsToLock[(int) $aFleet[self::F_FLEET_OWNER_ID] ?: 0] = true; |
|
| 132 | + $this->fleetIdsToLock[(int) $aFleet[self::F_FLEET_ID] ?: 0] = true; |
|
| 134 | 133 | } |
| 135 | 134 | } |
| 136 | 135 | |
@@ -164,18 +163,14 @@ discard block |
||
| 164 | 163 | } |
| 165 | 164 | |
| 166 | 165 | public static function sortEvents(&$eventList) { |
| 167 | - uasort($eventList, function (FleetDispatchEvent $a, FleetDispatchEvent $b) { |
|
| 166 | + uasort($eventList, function(FleetDispatchEvent $a, FleetDispatchEvent $b) { |
|
| 168 | 167 | return |
| 169 | 168 | // Сравниваем время флотов - кто раньше, тот и первый обрабатывается |
| 170 | - $a->eventTimeStamp > $b->eventTimeStamp ? 1 : ($a->eventTimeStamp < $b->eventTimeStamp ? -1 : |
|
| 171 | - // Если время - одинаковое, сравниваем события флотов |
|
| 169 | + $a->eventTimeStamp > $b->eventTimeStamp ? 1 : ($a->eventTimeStamp < $b->eventTimeStamp ? -1 : // Если время - одинаковое, сравниваем события флотов |
|
| 172 | 170 | // Если события - одинаковые, то флоты равны |
| 173 | - ($a->event == $b->event ? 0 : |
|
| 174 | - // Если события разные - первыми считаем прибывающие флоты |
|
| 175 | - ($a->event == EVENT_FLT_ARRIVE ? 1 : ($b->event == EVENT_FLT_ARRIVE ? -1 : |
|
| 176 | - // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
| 177 | - ($a->event == EVENT_FLT_ACCOMPLISH ? 1 : ($b->event == EVENT_FLT_ACCOMPLISH ? -1 : |
|
| 178 | - // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
| 171 | + ($a->event == $b->event ? 0 : // Если события разные - первыми считаем прибывающие флоты |
|
| 172 | + ($a->event == EVENT_FLT_ARRIVE ? 1 : ($b->event == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
| 173 | + ($a->event == EVENT_FLT_ACCOMPLISH ? 1 : ($b->event == EVENT_FLT_ACCOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
| 179 | 174 | // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска |
| 180 | 175 | ( |
| 181 | 176 | 0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий |
@@ -228,10 +223,10 @@ discard block |
||
| 228 | 223 | // $this->srcPlanetRow = is_array($srcPlanetRow) ? $srcPlanetRow : DBStaticPlanet::db_planet_by_vector($this->fleet, 'fleet_start_'); |
| 229 | 224 | $this->srcPlanetRow = $srcPlanetRow; |
| 230 | 225 | |
| 231 | - $this->srcPlanetId = !empty($this->srcPlanetRow[self::F_PLANET_ID]) ? (int)$this->srcPlanetRow[self::F_PLANET_ID] : 0; |
|
| 226 | + $this->srcPlanetId = !empty($this->srcPlanetRow[self::F_PLANET_ID]) ? (int) $this->srcPlanetRow[self::F_PLANET_ID] : 0; |
|
| 232 | 227 | // Starting planet can change owner while fleet mission - and even change planet ID |
| 233 | 228 | // It can happen due to teleport shenanigans or because of planet capturing (in certain game modes) |
| 234 | - $this->fleetOwnerId = !empty($this->srcPlanetRow[self::F_PLANET_OWNER_ID]) ? (int)$this->srcPlanetRow[self::F_PLANET_OWNER_ID] : $this->fleetOwnerId; |
|
| 229 | + $this->fleetOwnerId = !empty($this->srcPlanetRow[self::F_PLANET_OWNER_ID]) ? (int) $this->srcPlanetRow[self::F_PLANET_OWNER_ID] : $this->fleetOwnerId; |
|
| 235 | 230 | |
| 236 | 231 | return $this->srcPlanetRow; |
| 237 | 232 | } |
@@ -253,9 +248,9 @@ discard block |
||
| 253 | 248 | public function updateDstPlanetRow($dstPlanetRow = null) { |
| 254 | 249 | $this->dstPlanetRow = $dstPlanetRow; |
| 255 | 250 | |
| 256 | - $this->dstPlanetId = !empty($this->dstPlanetRow[self::F_PLANET_ID]) ? (int)$this->dstPlanetRow[self::F_PLANET_ID] : 0; |
|
| 251 | + $this->dstPlanetId = !empty($this->dstPlanetRow[self::F_PLANET_ID]) ? (int) $this->dstPlanetRow[self::F_PLANET_ID] : 0; |
|
| 257 | 252 | // Retrieving destination owner ID |
| 258 | - $this->dstPlanetOwnerId = !empty($this->dstPlanetRow[self::F_PLANET_OWNER_ID]) ? (int)$this->dstPlanetRow[self::F_PLANET_OWNER_ID] : 0; |
|
| 253 | + $this->dstPlanetOwnerId = !empty($this->dstPlanetRow[self::F_PLANET_OWNER_ID]) ? (int) $this->dstPlanetRow[self::F_PLANET_OWNER_ID] : 0; |
|
| 259 | 254 | |
| 260 | 255 | return $this->dstPlanetRow; |
| 261 | 256 | } |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | |
| 300 | 300 | $result = []; |
| 301 | 301 | while ($row = $this->db_fetch($queryResult)) { |
| 302 | - $result[] = $asArray ? $row : (object)$row; |
|
| 302 | + $result[] = $asArray ? $row : (object) $row; |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | return $result; |
@@ -782,7 +782,7 @@ discard block |
||
| 782 | 782 | // Detecting primary key name |
| 783 | 783 | $idFieldName = !empty(static::TABLE_ID_FIELD[$tableName]) ? static::TABLE_ID_FIELD[$tableName] : 'id'; |
| 784 | 784 | // Making ID mysql-safe |
| 785 | - array_walk($lockedIds, function (&$id) { $id = idval($id); }); |
|
| 785 | + array_walk($lockedIds, function(&$id) { $id = idval($id); }); |
|
| 786 | 786 | /** @noinspection SqlResolve */ |
| 787 | 787 | $queries[] = "(SELECT 1 FROM `{{{$tableName}}}` WHERE `{$idFieldName}` IN (" . implode(',', $lockedIds) . ") FOR UPDATE)"; |
| 788 | 788 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | use Planet\DBStaticPlanet; |
| 10 | 10 | use Unit\DBStaticUnit; |
| 11 | 11 | |
| 12 | -if(SN_IN_FLEET !== true) { |
|
| 12 | +if (SN_IN_FLEET !== true) { |
|
| 13 | 13 | SN::$debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
| 14 | 14 | } |
| 15 | 15 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | $errorlist .= $lang['fl_limit_galaxy']; |
| 30 | 30 | if (!$system || $system > $config->game_maxSystem || $system < 1) |
| 31 | 31 | $errorlist .= $lang['fl_limit_system']; |
| 32 | - if (!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE )) |
|
| 32 | + if (!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE)) |
|
| 33 | 33 | $errorlist .= $lang['fl_limit_planet']; |
| 34 | 34 | if ($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) |
| 35 | 35 | $errorlist .= $lang['fl_ownpl_err']; |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | // Preparing to lock both source and target users and planets |
| 54 | 54 | $recordsToLock = [ |
| 55 | - 'users' => [$user['id'],] + (!empty($TargetPlanet['id_owner']) ? [1 => $TargetPlanet['id_owner'],] : []), |
|
| 56 | - 'planets' => [$planetrow['id'],] + (!empty($TargetPlanet['id']) ? [1 => $TargetPlanet['id'],] : []), |
|
| 55 | + 'users' => [$user['id'], ] + (!empty($TargetPlanet['id_owner']) ? [1 => $TargetPlanet['id_owner'], ] : []), |
|
| 56 | + 'planets' => [$planetrow['id'], ] + (!empty($TargetPlanet['id']) ? [1 => $TargetPlanet['id'], ] : []), |
|
| 57 | 57 | ]; |
| 58 | 58 | // Adding incoming aggressive fleets from current user to this planet - to lock those fleets. They will be needed later in bashing check |
| 59 | 59 | if (!empty($TargetPlanet) && !empty($fleetsBashing = DbFleetStatic::fleet_list_bashing($user['id'], $TargetPlanet))) { |
| 60 | - foreach($fleetsBashing as $bashingFleet) { |
|
| 60 | + foreach ($fleetsBashing as $bashingFleet) { |
|
| 61 | 61 | $recordsToLock['fleets'][] = $bashingFleet['fleet_id']; |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -71,35 +71,35 @@ discard block |
||
| 71 | 71 | $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true); |
| 72 | 72 | |
| 73 | 73 | if ($target_mission == MT_EXPLORE) { |
| 74 | - if ($MaxExpeditions == 0 ) { |
|
| 74 | + if ($MaxExpeditions == 0) { |
|
| 75 | 75 | $errorlist .= $lang['fl_expe_notech']; |
| 76 | - } elseif ($FlyingExpeditions >= $MaxExpeditions ) { |
|
| 76 | + } elseif ($FlyingExpeditions >= $MaxExpeditions) { |
|
| 77 | 77 | $errorlist .= $lang['fl_expe_max']; |
| 78 | 78 | } |
| 79 | 79 | } else { |
| 80 | - if ($TargetPlanet['id_owner']){ |
|
| 80 | + if ($TargetPlanet['id_owner']) { |
|
| 81 | 81 | if ($target_mission == MT_COLONIZE) |
| 82 | 82 | $errorlist .= $lang['fl_colonized']; |
| 83 | 83 | |
| 84 | - if ($TargetPlanet['id_owner'] == $planetrow['id_owner']){ |
|
| 84 | + if ($TargetPlanet['id_owner'] == $planetrow['id_owner']) { |
|
| 85 | 85 | if ($target_mission == MT_ATTACK) |
| 86 | 86 | $errorlist .= $lang['fl_no_self_attack']; |
| 87 | 87 | |
| 88 | 88 | if ($target_mission == MT_SPY) |
| 89 | 89 | $errorlist .= $lang['fl_no_self_spy']; |
| 90 | - }else{ |
|
| 90 | + } else { |
|
| 91 | 91 | if ($target_mission == MT_RELOCATE) |
| 92 | 92 | $errorlist .= $lang['fl_only_stay_at_home']; |
| 93 | 93 | } |
| 94 | - }else{ |
|
| 95 | - if ($target_mission < MT_COLONIZE){ |
|
| 94 | + } else { |
|
| 95 | + if ($target_mission < MT_COLONIZE) { |
|
| 96 | 96 | $errorlist .= $lang['fl_unknow_target']; |
| 97 | - }else{ |
|
| 97 | + } else { |
|
| 98 | 98 | if ($target_mission == MT_DESTROY) |
| 99 | 99 | $errorlist .= $lang['fl_nomoon']; |
| 100 | 100 | |
| 101 | - if ($target_mission == MT_RECYCLE){ |
|
| 102 | - if($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) |
|
| 101 | + if ($target_mission == MT_RECYCLE) { |
|
| 102 | + if ($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) |
|
| 103 | 103 | $errorlist .= $lang['fl_nodebris']; |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | |
| 110 | - if(is_object($captainModule = moduleCaptain()) && $captain_id = sys_get_param_id('captain_id')) { |
|
| 110 | + if (is_object($captainModule = moduleCaptain()) && $captain_id = sys_get_param_id('captain_id')) { |
|
| 111 | 111 | $captain = $captainModule->unit_captain_get($planetrow['id']); |
| 112 | 112 | // mrc_get_level($user, $planetrow, UNIT_CAPTAIN, true); |
| 113 | - if(!$captain) { |
|
| 113 | + if (!$captain) { |
|
| 114 | 114 | $errorlist .= $lang['module_unit_captain_error_no_captain']; |
| 115 | - } elseif($captain['unit_location_type'] == LOC_PLANET) { |
|
| 116 | - if($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) { |
|
| 115 | + } elseif ($captain['unit_location_type'] == LOC_PLANET) { |
|
| 116 | + if ($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) { |
|
| 117 | 117 | $errorlist .= $lang['module_unit_captain_error_captain_already_bound']; |
| 118 | 118 | } |
| 119 | 119 | } else { |
@@ -137,13 +137,13 @@ discard block |
||
| 137 | 137 | $fleet_group = max(0, intval($_POST['fleet_group'])); |
| 138 | 138 | //But is it acs?? |
| 139 | 139 | //Well all acs fleets must have a fleet code. |
| 140 | - if($fleet_group) { |
|
| 140 | + if ($fleet_group) { |
|
| 141 | 141 | //Also it must be mission type 2 |
| 142 | 142 | $target_mission = MT_AKS; |
| 143 | 143 | |
| 144 | 144 | //The co-ords must be the same as where the acs fleet is going. |
| 145 | 145 | $target = "g{$galaxy}s{$system}p{$planet}t{$planet_type}"; |
| 146 | - if($_POST['acs_target_mr'] == $target) { |
|
| 146 | + if ($_POST['acs_target_mr'] == $target) { |
|
| 147 | 147 | //ACS attack must exist (if acs fleet has arrived this will also return false (2 checks in 1!!!) |
| 148 | 148 | $aks = DbFleetStatic::dbAcsGetById($fleet_group); |
| 149 | 149 | if (!$aks) { |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | //Check that a failed acs attack isn't being sent, if it is, make it an attack fleet. |
| 162 | - if(!$fleet_group && $target_mission == MT_AKS) { |
|
| 162 | + if (!$fleet_group && $target_mission == MT_AKS) { |
|
| 163 | 163 | $target_mission = MT_ATTACK; |
| 164 | 164 | } |
| 165 | 165 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | $options = [P_FLEET_ATTACK_SPEED_PERCENT_TENTH => $speed_percent, P_FLEET_ATTACK_FLEET_GROUP => $fleet_group, P_FLEET_ATTACK_RESOURCES_SUM => $StorageNeeded]; |
| 170 | 170 | $cant_attack = flt_can_attack($planetrow, $TargetPlanet, $fleetarray, $target_mission, $options); |
| 171 | 171 | |
| 172 | - if($cant_attack !== ATTACK_ALLOWED) { |
|
| 172 | + if ($cant_attack !== ATTACK_ALLOWED) { |
|
| 173 | 173 | SnTemplate::messageBox("<span class='error'><b>{$lang['fl_attack_error'][$cant_attack]}</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 99); |
| 174 | 174 | } |
| 175 | 175 | |
@@ -180,11 +180,10 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | $fleet['start_time'] = $duration + SN_TIME_NOW; |
| 182 | 182 | |
| 183 | - $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : |
|
| 184 | - ($target_mission == MT_HOLD ? 12 : 0); |
|
| 185 | - if($max_duration) { |
|
| 183 | + $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : ($target_mission == MT_HOLD ? 12 : 0); |
|
| 184 | + if ($max_duration) { |
|
| 186 | 185 | $StayDuration = sys_get_param_id('missiontime'); |
| 187 | - if($StayDuration > $max_duration || $StayDuration < 1) { |
|
| 186 | + if ($StayDuration > $max_duration || $StayDuration < 1) { |
|
| 188 | 187 | SN::$debug->warning('Supplying wrong mission time', 'Hack attempt', 302, array('base_dump' => true)); |
| 189 | 188 | die(); |
| 190 | 189 | } |
@@ -194,10 +193,10 @@ discard block |
||
| 194 | 193 | $StayDuration = 0; |
| 195 | 194 | $StayTime = 0; |
| 196 | 195 | } |
| 197 | - $fleet['end_time'] = $StayDuration + (2 * $duration) + SN_TIME_NOW; |
|
| 196 | + $fleet['end_time'] = $StayDuration + (2 * $duration) + SN_TIME_NOW; |
|
| 198 | 197 | |
| 199 | - if($aks && $target_mission == MT_AKS) { |
|
| 200 | - if ($fleet['start_time']>$aks['ankunft']) { |
|
| 198 | + if ($aks && $target_mission == MT_AKS) { |
|
| 199 | + if ($fleet['start_time'] > $aks['ankunft']) { |
|
| 201 | 200 | SnTemplate::messageBox($lang['fl_aks_too_slow'] . 'Fleet arrival: ' . date(FMT_DATE_TIME, $fleet['start_time']) . " AKS arrival: " . date(FMT_DATE_TIME, $aks['ankunft']), $lang['fl_error']); |
| 202 | 201 | } |
| 203 | 202 | $fleet['start_time'] = $aks['ankunft']; |
@@ -208,14 +207,14 @@ discard block |
||
| 208 | 207 | $FleetShipCount = 0; |
| 209 | 208 | $db_changeset = array(); |
| 210 | 209 | foreach ($fleetarray as $Ship => $Count) { |
| 211 | - $FleetStorage += get_unit_param($Ship, P_CAPACITY) * $Count; |
|
| 210 | + $FleetStorage += get_unit_param($Ship, P_CAPACITY) * $Count; |
|
| 212 | 211 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($Ship, -$Count, $user, $planetrow['id']); |
| 213 | 212 | } |
| 214 | 213 | $fleet_array = sys_unit_arr2str($fleetarray); |
| 215 | - $FleetShipCount += array_sum($fleetarray); |
|
| 216 | - $FleetStorage -= $consumption; |
|
| 214 | + $FleetShipCount += array_sum($fleetarray); |
|
| 215 | + $FleetStorage -= $consumption; |
|
| 217 | 216 | |
| 218 | - if ( $StorageNeeded > $FleetStorage) { |
|
| 217 | + if ($StorageNeeded > $FleetStorage) { |
|
| 219 | 218 | SnTemplate::messageBox("<span class='error'><b>" . $lang['fl_nostoragespa'] . HelperString::numberFloorAndFormat($StorageNeeded - $FleetStorage) . "</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
| 220 | 219 | } |
| 221 | 220 | if ($planetrow['deuterium'] < $TransDeuterium + $consumption) { |
@@ -264,7 +263,7 @@ discard block |
||
| 264 | 263 | // )); |
| 265 | 264 | // } |
| 266 | 265 | |
| 267 | - if(is_array($captain)) { |
|
| 266 | + if (is_array($captain)) { |
|
| 268 | 267 | DBStaticUnit::db_unit_set_by_id($captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$fleet_id}"); |
| 269 | 268 | } |
| 270 | 269 | |
@@ -277,7 +276,7 @@ discard block |
||
| 277 | 276 | 'START_LEFT' => floor($fleet['end_time'] + 1 - SN_TIME_NOW), |
| 278 | 277 | ); |
| 279 | 278 | |
| 280 | - if(!empty($TargetPlanet)) { |
|
| 279 | + if (!empty($TargetPlanet)) { |
|
| 281 | 280 | $template_route += array( |
| 282 | 281 | 'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']], |
| 283 | 282 | 'END_COORDS' => uni_render_coordinates($TargetPlanet), |
@@ -290,8 +289,8 @@ discard block |
||
| 290 | 289 | $template->assign_block_vars('fleets', $template_route); |
| 291 | 290 | |
| 292 | 291 | $sn_groups_fleet = sn_get_groups('fleet'); |
| 293 | - foreach($fleetarray as $ship_id => $ship_count) { |
|
| 294 | - if(in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
| 292 | + foreach ($fleetarray as $ship_id => $ship_count) { |
|
| 293 | + if (in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
| 295 | 294 | // $ship_base_data = get_ship_data($ship_id, $user); |
| 296 | 295 | $template->assign_block_vars('fleets.ships', array( |
| 297 | 296 | 'ID' => $ship_id, |
@@ -25,18 +25,24 @@ discard block |
||
| 25 | 25 | $errorlist .= !is_array($fleetarray) ? $lang['fl_no_fleetarray'] : ''; |
| 26 | 26 | |
| 27 | 27 | $errorlist = ''; |
| 28 | - if (!$galaxy || $galaxy > $config->game_maxGalaxy || $galaxy < 1) |
|
| 29 | - $errorlist .= $lang['fl_limit_galaxy']; |
|
| 30 | - if (!$system || $system > $config->game_maxSystem || $system < 1) |
|
| 31 | - $errorlist .= $lang['fl_limit_system']; |
|
| 32 | - if (!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE )) |
|
| 33 | - $errorlist .= $lang['fl_limit_planet']; |
|
| 34 | - if ($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) |
|
| 35 | - $errorlist .= $lang['fl_ownpl_err']; |
|
| 36 | - if (!$planet_type) |
|
| 37 | - $errorlist .= $lang['fl_no_planettype']; |
|
| 38 | - if ($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) |
|
| 39 | - $errorlist .= $lang['fl_fleet_err_pl']; |
|
| 28 | + if (!$galaxy || $galaxy > $config->game_maxGalaxy || $galaxy < 1) { |
|
| 29 | + $errorlist .= $lang['fl_limit_galaxy']; |
|
| 30 | + } |
|
| 31 | + if (!$system || $system > $config->game_maxSystem || $system < 1) { |
|
| 32 | + $errorlist .= $lang['fl_limit_system']; |
|
| 33 | + } |
|
| 34 | + if (!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE )) { |
|
| 35 | + $errorlist .= $lang['fl_limit_planet']; |
|
| 36 | + } |
|
| 37 | + if ($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) { |
|
| 38 | + $errorlist .= $lang['fl_ownpl_err']; |
|
| 39 | + } |
|
| 40 | + if (!$planet_type) { |
|
| 41 | + $errorlist .= $lang['fl_no_planettype']; |
|
| 42 | + } |
|
| 43 | + if ($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) { |
|
| 44 | + $errorlist .= $lang['fl_fleet_err_pl']; |
|
| 45 | + } |
|
| 40 | 46 | if (empty($missiontype[$target_mission])) { |
| 41 | 47 | $errorlist .= $lang['fl_bad_mission']; |
| 42 | 48 | } |
@@ -78,29 +84,35 @@ discard block |
||
| 78 | 84 | } |
| 79 | 85 | } else { |
| 80 | 86 | if ($TargetPlanet['id_owner']){ |
| 81 | - if ($target_mission == MT_COLONIZE) |
|
| 82 | - $errorlist .= $lang['fl_colonized']; |
|
| 87 | + if ($target_mission == MT_COLONIZE) { |
|
| 88 | + $errorlist .= $lang['fl_colonized']; |
|
| 89 | + } |
|
| 83 | 90 | |
| 84 | 91 | if ($TargetPlanet['id_owner'] == $planetrow['id_owner']){ |
| 85 | - if ($target_mission == MT_ATTACK) |
|
| 86 | - $errorlist .= $lang['fl_no_self_attack']; |
|
| 87 | - |
|
| 88 | - if ($target_mission == MT_SPY) |
|
| 89 | - $errorlist .= $lang['fl_no_self_spy']; |
|
| 90 | - }else{ |
|
| 91 | - if ($target_mission == MT_RELOCATE) |
|
| 92 | - $errorlist .= $lang['fl_only_stay_at_home']; |
|
| 92 | + if ($target_mission == MT_ATTACK) { |
|
| 93 | + $errorlist .= $lang['fl_no_self_attack']; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + if ($target_mission == MT_SPY) { |
|
| 97 | + $errorlist .= $lang['fl_no_self_spy']; |
|
| 98 | + } |
|
| 99 | + } else{ |
|
| 100 | + if ($target_mission == MT_RELOCATE) { |
|
| 101 | + $errorlist .= $lang['fl_only_stay_at_home']; |
|
| 102 | + } |
|
| 93 | 103 | } |
| 94 | - }else{ |
|
| 104 | + } else{ |
|
| 95 | 105 | if ($target_mission < MT_COLONIZE){ |
| 96 | 106 | $errorlist .= $lang['fl_unknow_target']; |
| 97 | - }else{ |
|
| 98 | - if ($target_mission == MT_DESTROY) |
|
| 99 | - $errorlist .= $lang['fl_nomoon']; |
|
| 107 | + } else{ |
|
| 108 | + if ($target_mission == MT_DESTROY) { |
|
| 109 | + $errorlist .= $lang['fl_nomoon']; |
|
| 110 | + } |
|
| 100 | 111 | |
| 101 | 112 | if ($target_mission == MT_RECYCLE){ |
| 102 | - if($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) |
|
| 103 | - $errorlist .= $lang['fl_nodebris']; |
|
| 113 | + if($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) { |
|
| 114 | + $errorlist .= $lang['fl_nodebris']; |
|
| 115 | + } |
|
| 104 | 116 | } |
| 105 | 117 | } |
| 106 | 118 | } |
@@ -148,8 +160,7 @@ discard block |
||
| 148 | 160 | $aks = DbFleetStatic::dbAcsGetById($fleet_group); |
| 149 | 161 | if (!$aks) { |
| 150 | 162 | $fleet_group = 0; |
| 151 | - } |
|
| 152 | - else |
|
| 163 | + } else |
|
| 153 | 164 | { |
| 154 | 165 | $galaxy = $aks['galaxy']; |
| 155 | 166 | $system = $aks['system']; |
@@ -23,7 +23,9 @@ |
||
| 23 | 23 | * NICHT ÄNDERN |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -if (!defined('INSIDE')) die(); |
|
| 26 | +if (!defined('INSIDE')) { |
|
| 27 | + die(); |
|
| 28 | +} |
|
| 27 | 29 | |
| 28 | 30 | |
| 29 | 31 | $a_lang_array = (array( |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | db_mysql::db_transaction_start(); |
| 59 | 59 | // Locking all necessary user/planet records |
| 60 | 60 | SN::$gc->db->lockRecords([ |
| 61 | - 'users' => [$user['id'],] + (!empty($enemy['id']) ? [1 => $enemy['id'],] : []), |
|
| 62 | - 'planets' => [$user['current_planet'],] + (!empty($target_row['id']) ? [1 => $target_row['id'],] : []), |
|
| 61 | + 'users' => [$user['id'], ] + (!empty($enemy['id']) ? [1 => $enemy['id'], ] : []), |
|
| 62 | + 'planets' => [$user['current_planet'], ] + (!empty($target_row['id']) ? [1 => $target_row['id'], ] : []), |
|
| 63 | 63 | ]); |
| 64 | 64 | |
| 65 | 65 | $user = db_user_by_id($user['id'], true); |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | //$ships_sent_js = array(); |
| 178 | 178 | $ships_sent_js = 0; |
| 179 | 179 | foreach ($fleet_array as $unit_id => $unit_count) { |
| 180 | - $ships_sent[] = "{$unit_count} {$lang['tech'][$unit_id]}"; |
|
| 180 | + $ships_sent[] = "{$unit_count} {$lang['tech'][$unit_id]}"; |
|
| 181 | 181 | $ships_sent_js += mrc_get_level($user, $planetrow, $unit_id, false, true); |
| 182 | 182 | } |
| 183 | 183 | $ships_sent = implode(', ', $ships_sent); |