@@ -15,34 +15,34 @@ discard block |
||
| 15 | 15 | $template = gettemplate('notes', true); |
| 16 | 16 | |
| 17 | 17 | $result = array(); |
| 18 | -if(($result_message = sys_get_param_str('MESSAGE')) && isset($lang[$result_message])) { |
|
| 18 | +if (($result_message = sys_get_param_str('MESSAGE')) && isset($lang[$result_message])) { |
|
| 19 | 19 | $result[] = array('STATUS' => sys_get_param_int('STATUS'), 'MESSAGE' => $lang[$result_message]); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | $note_id_edit = sys_get_param_id('note_id_edit'); |
| 23 | -if(sys_get_param('note_delete')) { |
|
| 23 | +if (sys_get_param('note_delete')) { |
|
| 24 | 24 | try { |
| 25 | 25 | $not = ''; |
| 26 | 26 | $query_where = ''; |
| 27 | - switch(sys_get_param_str('note_delete_range')) { |
|
| 27 | + switch (sys_get_param_str('note_delete_range')) { |
|
| 28 | 28 | case 'all': |
| 29 | 29 | break; |
| 30 | 30 | |
| 31 | 31 | case 'marked_not': |
| 32 | 32 | $not = 'NOT'; |
| 33 | 33 | case 'marked': |
| 34 | - if(!is_array($notes_marked = sys_get_param('note'))) { |
|
| 34 | + if (!is_array($notes_marked = sys_get_param('note'))) { |
|
| 35 | 35 | throw new exception('note_err_none_selected', ERR_WARNING); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | $notes_marked_filtered = array(); |
| 39 | - foreach($notes_marked as $note_id => $note_select) { |
|
| 40 | - if($note_select == 'on' && $note_id = idval($note_id)) { |
|
| 39 | + foreach ($notes_marked as $note_id => $note_select) { |
|
| 40 | + if ($note_select == 'on' && $note_id = idval($note_id)) { |
|
| 41 | 41 | $notes_marked_filtered[] = $note_id; |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if(empty($notes_marked_filtered)) { |
|
| 45 | + if (empty($notes_marked_filtered)) { |
|
| 46 | 46 | throw new exception('note_err_none_selected', ERR_WARNING); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | doquery("DELETE FROM {{notes}} WHERE `owner` = {$user['id']} {$query_where};"); |
| 60 | 60 | sn_db_transaction_commit(); |
| 61 | 61 | throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE); |
| 62 | - } catch(exception $e) { |
|
| 62 | + } catch (exception $e) { |
|
| 63 | 63 | $note_id_edit = 0; |
| 64 | 64 | sn_db_transaction_rollback(); |
| 65 | 65 | $result[] = array( |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | 'MESSAGE' => $lang[$e->getMessage()], |
| 68 | 68 | ); |
| 69 | 69 | } |
| 70 | -} elseif(($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) { |
|
| 70 | +} elseif (($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) { |
|
| 71 | 71 | $note_title == db_escape($lang['note_new_title']) ? $note_title = '' : false; |
| 72 | 72 | ($note_text = sys_get_param_str('note_text')) == db_escape($lang['note_new_text']) ? $note_text = '' : false; |
| 73 | 73 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $note_system = max(0, min(sys_get_param_id('note_system'), classSupernova::$config->game_maxSystem)); |
| 77 | 77 | $note_planet = max(0, min(sys_get_param_id('note_planet'), classSupernova::$config->game_maxPlanet + 1)); |
| 78 | 78 | |
| 79 | - if(!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) { |
|
| 79 | + if (!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) { |
|
| 80 | 80 | throw new exception('note_err_note_empty', ERR_WARNING); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -85,15 +85,15 @@ discard block |
||
| 85 | 85 | $note_sticky = intval(sys_get_param_id('note_sticky')) ? 1 : 0; |
| 86 | 86 | |
| 87 | 87 | sn_db_transaction_start(); |
| 88 | - if($note_id_edit) { |
|
| 88 | + if ($note_id_edit) { |
|
| 89 | 89 | $check_note_id = doquery("SELECT `id`, `owner` FROM {{notes}} WHERE `id` = {$note_id_edit} LIMIT 1 FOR UPDATE", true); |
| 90 | - if(!$check_note_id) { |
|
| 90 | + if (!$check_note_id) { |
|
| 91 | 91 | throw new exception('note_err_note_not_found', ERR_ERROR); |
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if($note_id_edit) { |
|
| 96 | - if($check_note_id['owner'] != $user['id']) { |
|
| 95 | + if ($note_id_edit) { |
|
| 96 | + if ($check_note_id['owner'] != $user['id']) { |
|
| 97 | 97 | throw new exception('note_err_owner_wrong', ERR_ERROR); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | sn_db_transaction_commit(); |
| 109 | 109 | sys_redirect('notes.php?STATUS=' . ERR_NONE . '&MESSAGE=' . ($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added')); |
| 110 | 110 | // throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE); |
| 111 | - } catch(exception $e) { |
|
| 111 | + } catch (exception $e) { |
|
| 112 | 112 | $note_id_edit = 0; |
| 113 | 113 | sn_db_transaction_rollback(); |
| 114 | 114 | $result[] = array( |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | -if(!$note_id_edit) { |
|
| 121 | +if (!$note_id_edit) { |
|
| 122 | 122 | note_assign($template, array( |
| 123 | 123 | 'id' => 0, |
| 124 | 124 | 'time' => SN_TIME_NOW, |
@@ -131,13 +131,13 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | $note_exist = false; |
| 133 | 133 | $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"); |
| 134 | -while($note_row = db_fetch($notes_query)) { |
|
| 134 | +while ($note_row = db_fetch($notes_query)) { |
|
| 135 | 135 | note_assign($template, $note_row); |
| 136 | 136 | $note_exist = $note_exist || $note_row['id'] == $note_id_edit; |
| 137 | 137 | } |
| 138 | 138 | $note_id_edit = $note_exist ? $note_id_edit : 0; |
| 139 | 139 | |
| 140 | -foreach($note_priority_classes as $note_priority_id => $note_priority_class) { |
|
| 140 | +foreach ($note_priority_classes as $note_priority_id => $note_priority_class) { |
|
| 141 | 141 | $template->assign_block_vars('note_priority', array( |
| 142 | 142 | 'ID' => $note_priority_id, |
| 143 | 143 | 'CLASS' => $note_priority_classes[$note_priority_id], |
@@ -145,14 +145,14 @@ discard block |
||
| 145 | 145 | )); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | -foreach($lang['sys_planet_type'] as $planet_type_id => $planet_type_string) { |
|
| 148 | +foreach ($lang['sys_planet_type'] as $planet_type_id => $planet_type_string) { |
|
| 149 | 149 | $template->assign_block_vars('planet_type', array( |
| 150 | 150 | 'ID' => $planet_type_id, |
| 151 | 151 | 'TEXT' => $planet_type_string, |
| 152 | 152 | )); |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | -foreach($result as $result_data) { |
|
| 155 | +foreach ($result as $result_data) { |
|
| 156 | 156 | $template->assign_block_vars('result', $result_data); |
| 157 | 157 | } |
| 158 | 158 | |
@@ -22,17 +22,17 @@ discard block |
||
| 22 | 22 | $sn_group_factories = sn_get_groups('factories'); |
| 23 | 23 | $planet_density = sn_get_groups('planet_density'); |
| 24 | 24 | |
| 25 | - if(sys_get_param('save_production')) { |
|
| 25 | + if (sys_get_param('save_production')) { |
|
| 26 | 26 | $production = sys_get_param('percent'); |
| 27 | - if(is_array($production) && !empty($production)) { |
|
| 27 | + if (is_array($production) && !empty($production)) { |
|
| 28 | 28 | // sn_db_transaction_start(); |
| 29 | 29 | $query = array(); |
| 30 | 30 | $planet_row_list = DBStaticPlanet::db_planet_list_sorted($user, false, '*'); |
| 31 | 31 | // while($planet = db_fetch($planet_row_list)) |
| 32 | - foreach($planet_row_list as $planet) { |
|
| 33 | - foreach($sn_group_factories as $factory_unit_id) { |
|
| 32 | + foreach ($planet_row_list as $planet) { |
|
| 33 | + foreach ($sn_group_factories as $factory_unit_id) { |
|
| 34 | 34 | $unit_db_name_porcent = pname_factory_production_field_name($factory_unit_id); |
| 35 | - if( |
|
| 35 | + if ( |
|
| 36 | 36 | get_unit_param($factory_unit_id, P_MINING_IS_MANAGED) |
| 37 | 37 | && isset($production[$factory_unit_id][$planet['id']]) |
| 38 | 38 | && ($actual_porcent = intval($production[$factory_unit_id][$planet['id']] / 10)) >= 0 |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | - foreach($query as $planet_id => $query_data) { |
|
| 46 | + foreach ($query as $planet_id => $query_data) { |
|
| 47 | 47 | DBStaticPlanet::db_planet_set_by_id($planet_id, implode(',', $query_data)); |
| 48 | 48 | } |
| 49 | 49 | // sn_db_transaction_commit(); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | $planet_row_list = DBStaticPlanet::db_planet_list_sorted($user); |
| 54 | 54 | // while ($planet = db_fetch($planet_row_list)) |
| 55 | - foreach($planet_row_list as $planet) { |
|
| 55 | + foreach ($planet_row_list as $planet) { |
|
| 56 | 56 | sn_db_transaction_start(); |
| 57 | 57 | $global_data = sys_o_get_updated($user, $planet['id'], SN_TIME_NOW, false, true); |
| 58 | 58 | $planets[$planet['id']] = $global_data['planet']; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $template = gettemplate('imperium', $template); |
| 65 | 65 | $template->assign_var('amount', count($planets) + 2); |
| 66 | 66 | |
| 67 | - for($i = 100; $i >= 0; $i -= 10) { |
|
| 67 | + for ($i = 100; $i >= 0; $i -= 10) { |
|
| 68 | 68 | $template->assign_block_vars('percent', array('PERCENT' => $i)); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | $planet_template = tpl_parse_planet($planet); |
| 80 | 80 | |
| 81 | 81 | $planet_fleet_id = 0; |
| 82 | - $fleet_list = $planet_template['fleet_list'];//flt_get_fleets_to_planet($planet); |
|
| 83 | - if($fleet_list['own']['count']) |
|
| 82 | + $fleet_list = $planet_template['fleet_list']; //flt_get_fleets_to_planet($planet); |
|
| 83 | + if ($fleet_list['own']['count']) |
|
| 84 | 84 | { |
| 85 | 85 | $planet_fleet_id = "p{$fleet_id}"; |
| 86 | 86 | $fleets[] = tpl_parse_fleet_sn($fleet_list['own']['total'], $planet_fleet_id); |
@@ -142,19 +142,19 @@ discard block |
||
| 142 | 142 | UNIT_DEFENCE => 'defense', |
| 143 | 143 | ); |
| 144 | 144 | |
| 145 | - foreach($show_groups as $unit_group_id => $mode) |
|
| 145 | + foreach ($show_groups as $unit_group_id => $mode) |
|
| 146 | 146 | { |
| 147 | 147 | $template->assign_block_vars('prods', array( |
| 148 | 148 | 'NAME' => $lang['tech'][$unit_group_id], |
| 149 | 149 | )); |
| 150 | 150 | $unit_group = get_unit_param('techtree', $unit_group_id); |
| 151 | - foreach($unit_group as $unit_id) |
|
| 151 | + foreach ($unit_group as $unit_id) |
|
| 152 | 152 | { |
| 153 | 153 | $unit_count = $unit_count_abs = 0; |
| 154 | 154 | $block_vars = array(); |
| 155 | 155 | $unit_is_factory = in_array($unit_id, $sn_group_factories) && get_unit_param($unit_id, P_MINING_IS_MANAGED); |
| 156 | 156 | // $unit_db_name = pname_resource_name($unit_id); |
| 157 | - foreach($planets as $planet) |
|
| 157 | + foreach ($planets as $planet) |
|
| 158 | 158 | { |
| 159 | 159 | $unit_level_plain = mrc_get_level($user, $planet, $unit_id, false, true); |
| 160 | 160 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $level_plus['LEVEL_PLUS_GREEN'] = 0; |
| 164 | 164 | |
| 165 | 165 | $level_plus['PERCENT'] = $unit_is_factory ? ($unit_level_plain ? $planet[pname_factory_production_field_name($unit_id)] * 10 : -1) : -1; |
| 166 | - switch($mode) |
|
| 166 | + switch ($mode) |
|
| 167 | 167 | { |
| 168 | 168 | /* |
| 169 | 169 | case 'structures': |
@@ -178,13 +178,13 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | /** @noinspection PhpMissingBreakStatementInspection */ |
| 180 | 180 | case 'fleet': |
| 181 | - $level_plus['LEVEL_PLUS_YELLOW'] = $planet['fleet_list']['own']['total'][$unit_id]<=0 ? $planet['fleet_list']['own']['total'][$unit_id] : "+{$planet['fleet_list']['own']['total'][$unit_id]}"; |
|
| 181 | + $level_plus['LEVEL_PLUS_YELLOW'] = $planet['fleet_list']['own']['total'][$unit_id] <= 0 ? $planet['fleet_list']['own']['total'][$unit_id] : "+{$planet['fleet_list']['own']['total'][$unit_id]}"; |
|
| 182 | 182 | $total['units'][$unit_id]['LEVEL_PLUS_YELLOW'] += $level_plus['LEVEL_PLUS_YELLOW']; |
| 183 | 183 | |
| 184 | 184 | case 'structures': |
| 185 | 185 | case 'defense': |
| 186 | 186 | $level_plus_build = $ques[$planet['id']]['in_que'][que_get_unit_que($unit_id)][$user['id']][$planet['id']][$unit_id]; |
| 187 | - if($level_plus_build) |
|
| 187 | + if ($level_plus_build) |
|
| 188 | 188 | { |
| 189 | 189 | $level_plus['LEVEL_PLUS_GREEN'] = $level_plus_build < 0 ? $level_plus_build : "+{$level_plus_build}"; |
| 190 | 190 | // $level_plus['LEVEL_PLUS_GREEN'] = "+{$level_plus_build}"; |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $unit_count_abs += $unit_level_plain + abs($level_plus['LEVEL_PLUS_YELLOW']) + abs($level_plus['LEVEL_PLUS_GREEN']); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - if($unit_count_abs) |
|
| 208 | + if ($unit_count_abs) |
|
| 209 | 209 | { |
| 210 | 210 | $template->assign_block_vars('prods', array( |
| 211 | 211 | 'ID' => $unit_id, |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | 'MODE' => $mode, |
| 215 | 215 | )); |
| 216 | 216 | |
| 217 | - foreach($block_vars as $block_var) |
|
| 217 | + foreach ($block_vars as $block_var) |
|
| 218 | 218 | { |
| 219 | 219 | $template->assign_block_vars('prods.planet', $block_var); |
| 220 | 220 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | function db_unit_records_sum($unit_id, $user_skip_list_unit) |
| 105 | 105 | { |
| 106 | - return doquery ( |
|
| 106 | + return doquery( |
|
| 107 | 107 | "SELECT unit_player_id, username, sum(unit_level) as unit_level |
| 108 | 108 | FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id |
| 109 | 109 | WHERE unit_player_id != 0 AND unit_snid = {$unit_id} {$user_skip_list_unit} |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | function db_unit_records_plain($unit_id, $user_skip_list_unit) |
| 117 | 117 | { |
| 118 | - return doquery ( |
|
| 118 | + return doquery( |
|
| 119 | 119 | "SELECT unit_player_id, username, unit_level |
| 120 | 120 | FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id |
| 121 | 121 | WHERE unit_player_id != 0 AND unit_snid = {$unit_id} {$user_skip_list_unit} |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | function db_stat_list_statistic($who, $is_common_stat, $Rank, $start, $source = false) { |
| 128 | - if(!$source) { |
|
| 128 | + if (!$source) { |
|
| 129 | 129 | $source = array( |
| 130 | 130 | 'statpoints' => 'statpoints', |
| 131 | 131 | 'users' => 'users', |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | ); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if($who == 1) { |
|
| 150 | - if($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
|
| 149 | + if ($who == 1) { |
|
| 150 | + if ($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
|
| 151 | 151 | $query_str = |
| 152 | 152 | "SELECT |
| 153 | 153 | @rownum:=@rownum+1 rownum, subject.{$source['id']} as `id`, sp.{$Rank}_rank as rank, sp.{$Rank}_old_rank as rank_old, sp.{$Rank}_points as points, subject.{$source['username']} as `name`, subject.* |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | ORDER BY |
| 162 | 162 | sp.`{$Rank}_rank`, subject.{$source['id']} |
| 163 | 163 | LIMIT |
| 164 | - ". $start .",100;"; |
|
| 164 | + " . $start . ",100;"; |
|
| 165 | 165 | } else { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
| 166 | 166 | $query_str = |
| 167 | 167 | "SELECT |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | ORDER BY |
| 175 | 175 | subject.{$Rank} DESC, subject.{$source['id']} |
| 176 | 176 | LIMIT |
| 177 | - ". $start .",100;"; |
|
| 177 | + " . $start . ",100;"; |
|
| 178 | 178 | } |
| 179 | 179 | } else { |
| 180 | 180 | // TODO |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | ORDER BY |
| 192 | 192 | sp.`{$Rank}_rank`, subject.id |
| 193 | 193 | LIMIT |
| 194 | - ". $start .",100;"; |
|
| 194 | + " . $start . ",100;"; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | return doquery($query_str); |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) { |
| 278 | 278 | $current_value_safe = db_escape($current_value_unsafe); |
| 279 | 279 | $value_id = doquery("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE", true); |
| 280 | - if(!isset($value_id['id_field']) || !$value_id['id_field']) { |
|
| 280 | + if (!isset($value_id['id_field']) || !$value_id['id_field']) { |
|
| 281 | 281 | doquery("INSERT INTO {{{$db_table_name}}} (`{$db_value_field_name}`) VALUES ('{$current_value_safe}');"); |
| 282 | 282 | $variable_id = db_insert_id(); |
| 283 | 283 | } else { |
@@ -27,19 +27,19 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | function db_set_make_safe_string($set, $delta = false) { |
| 29 | 29 | $set_safe = array(); |
| 30 | - foreach($set as $field => $value) { |
|
| 31 | - if(empty($field)) { |
|
| 30 | + foreach ($set as $field => $value) { |
|
| 31 | + if (empty($field)) { |
|
| 32 | 32 | continue; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $field = '`' . db_escape($field) . '`'; |
| 36 | 36 | $new_value = $value; |
| 37 | - if($value === null) { |
|
| 37 | + if ($value === null) { |
|
| 38 | 38 | $new_value = 'NULL'; |
| 39 | - } elseif(is_string($value) && (string)($new_value = floatval($value)) != (string)$value) { |
|
| 39 | + } elseif (is_string($value) && (string) ($new_value = floatval($value)) != (string) $value) { |
|
| 40 | 40 | // non-float |
| 41 | 41 | $new_value = '"' . db_escape($value) . '"'; |
| 42 | - } elseif($delta) { |
|
| 42 | + } elseif ($delta) { |
|
| 43 | 43 | // float and DELTA-set |
| 44 | 44 | $new_value = "{$field} + ({$new_value})"; |
| 45 | 45 | } |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | function missile_list_convert_to_fleet(&$missile_db_list, &$fleet_db_list) { |
| 61 | 61 | // Missile attack |
| 62 | - foreach($missile_db_list as $irak) { |
|
| 63 | - if($irak['fleet_end_time'] >= SN_TIME_NOW) { |
|
| 62 | + foreach ($missile_db_list as $irak) { |
|
| 63 | + if ($irak['fleet_end_time'] >= SN_TIME_NOW) { |
|
| 64 | 64 | $irak['fleet_start_type'] = PT_PLANET; |
| 65 | 65 | $planet_start = DBStaticPlanet::db_planet_by_vector($irak, 'fleet_start_', false, 'name'); |
| 66 | 66 | $irak['fleet_id'] = -$irak['id']; |
@@ -8,23 +8,23 @@ discard block |
||
| 8 | 8 | $fleet_events = array(); |
| 9 | 9 | $fleet_number = 0; |
| 10 | 10 | |
| 11 | - if(empty($fleet_list)) |
|
| 11 | + if (empty($fleet_list)) |
|
| 12 | 12 | { |
| 13 | 13 | return; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - foreach($fleet_list as $fleet) |
|
| 16 | + foreach ($fleet_list as $fleet) |
|
| 17 | 17 | { |
| 18 | 18 | $planet_start_type = $fleet['fleet_start_type'] == PT_MOON ? PT_MOON : PT_PLANET; |
| 19 | 19 | $planet_start = DBStaticPlanet::db_planet_by_gspt($fleet['fleet_start_galaxy'], $fleet['fleet_start_system'], $fleet['fleet_start_planet'], $planet_start_type, false, 'name'); |
| 20 | 20 | $fleet['fleet_start_name'] = $planet_start['name']; |
| 21 | 21 | |
| 22 | 22 | $planet_end_type = $fleet['fleet_end_type'] == PT_MOON ? PT_MOON : PT_PLANET; |
| 23 | - if($fleet['fleet_end_planet'] > $config->game_maxPlanet) |
|
| 23 | + if ($fleet['fleet_end_planet'] > $config->game_maxPlanet) |
|
| 24 | 24 | { |
| 25 | 25 | $fleet['fleet_end_name'] = $lang['ov_fleet_exploration']; |
| 26 | 26 | } |
| 27 | - elseif($fleet['fleet_mission'] == MT_COLONIZE) |
|
| 27 | + elseif ($fleet['fleet_mission'] == MT_COLONIZE) |
|
| 28 | 28 | { |
| 29 | 29 | $fleet['fleet_end_name'] = $lang['ov_fleet_colonization']; |
| 30 | 30 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $fleet['fleet_end_name'] = $planet_end['name']; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if($fleet['fleet_start_time'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] != MT_MISSILE && |
|
| 37 | + if ($fleet['fleet_start_time'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] != MT_MISSILE && |
|
| 38 | 38 | ($planet_scanned === false |
| 39 | 39 | || |
| 40 | 40 | ( |
@@ -49,12 +49,12 @@ discard block |
||
| 49 | 49 | $fleet_events[] = flt_register_fleet_event($fleet, 0, $planet_end_type); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - if($fleet['fleet_end_stay'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $planet_scanned === false && $fleet['fleet_mission'] != MT_MISSILE) |
|
| 52 | + if ($fleet['fleet_end_stay'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $planet_scanned === false && $fleet['fleet_mission'] != MT_MISSILE) |
|
| 53 | 53 | { |
| 54 | 54 | $fleet_events[] = flt_register_fleet_event($fleet, 1, $planet_end_type); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if( |
|
| 57 | + if ( |
|
| 58 | 58 | $fleet['fleet_end_time'] > SN_TIME_NOW && $fleet['fleet_mission'] != MT_MISSILE && ($fleet['fleet_mess'] == 1 || ($fleet['fleet_mission'] != MT_RELOCATE && $fleet['fleet_mission'] != MT_COLONIZE)) && |
| 59 | 59 | ( |
| 60 | 60 | ($planet_scanned === false && $fleet['fleet_owner'] == $user['id']) |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $fleet_events[] = flt_register_fleet_event($fleet, 2, $planet_end_type); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if($fleet['fleet_mission'] == MT_MISSILE) |
|
| 74 | + if ($fleet['fleet_mission'] == MT_MISSILE) |
|
| 75 | 75 | { |
| 76 | 76 | $fleet_events[] = flt_register_fleet_event($fleet, 3, $planet_end_type); |
| 77 | 77 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | { |
| 85 | 85 | global $user, $planetrow, $fleet_number; |
| 86 | 86 | |
| 87 | - switch($fleet['ov_label'] = $ov_label) |
|
| 87 | + switch ($fleet['ov_label'] = $ov_label) |
|
| 88 | 88 | { |
| 89 | 89 | case 0: |
| 90 | 90 | $fleet['event_time'] = $fleet['fleet_start_time']; |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - $fleet['ov_this_planet'] = $is_this_planet;// || $planet_scanned != false; |
|
| 119 | + $fleet['ov_this_planet'] = $is_this_planet; // || $planet_scanned != false; |
|
| 120 | 120 | |
| 121 | - if($fleet['fleet_owner'] == $user['id']) |
|
| 121 | + if ($fleet['fleet_owner'] == $user['id']) |
|
| 122 | 122 | { |
| 123 | 123 | $user_data = $user; |
| 124 | 124 | } |
@@ -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 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | $Position = intval($Position); |
| 61 | 61 | |
| 62 | - if(!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
| 62 | + if (!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
| 63 | 63 | return false; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | $planet_generator = sn_get_groups('planet_generator'); |
| 70 | 70 | |
| 71 | - if($HomeWorld) { |
|
| 71 | + if ($HomeWorld) { |
|
| 72 | 72 | $position_data = $planet_generator[0]; |
| 73 | 73 | } else { |
| 74 | 74 | $position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position]; |
| 75 | - if($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
| 75 | + if ($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
| 76 | 76 | // Корректируем температуру для планеты-странника |
| 77 | 77 | $position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START); |
| 78 | 78 | } |
@@ -172,15 +172,15 @@ discard block |
||
| 172 | 172 | $moon_name = ''; |
| 173 | 173 | $moon_row = array(); |
| 174 | 174 | $moon = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_MOON, false, 'id'); |
| 175 | - if(!$moon['id']) { |
|
| 175 | + if (!$moon['id']) { |
|
| 176 | 176 | $moon_planet = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_PLANET, true, '`id`, `temp_min`, `temp_max`, `name`, `debris_metal`, `debris_crystal`'); |
| 177 | 177 | |
| 178 | - if($moon_planet['id']) { |
|
| 178 | + if ($moon_planet['id']) { |
|
| 179 | 179 | $base_storage_size = BASE_STORAGE_SIZE; |
| 180 | 180 | |
| 181 | - if(!$moon_chance) { |
|
| 181 | + if (!$moon_chance) { |
|
| 182 | 182 | $size = mt_rand(1100, 8999); |
| 183 | - } elseif($moon_chance <= 100) { |
|
| 183 | + } elseif ($moon_chance <= 100) { |
|
| 184 | 184 | $size = mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999); |
| 185 | 185 | } else { |
| 186 | 186 | $size = $moon_chance; |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | $field_max = ceil($size / 1000); |
| 198 | 198 | |
| 199 | - if(isset($options['image']) && $options['image']) { |
|
| 199 | + if (isset($options['image']) && $options['image']) { |
|
| 200 | 200 | $moon_image = $options['image']; |
| 201 | 201 | } else { |
| 202 | 202 | $moon_image = 'mond'; |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | `deuterium` = '0', `deuterium_perhour` = '0', `deuterium_max` = '{$base_storage_size}'" |
| 212 | 212 | ); |
| 213 | 213 | |
| 214 | - if($update_debris) { |
|
| 214 | + if ($update_debris) { |
|
| 215 | 215 | $debris_spent = $moon_chance * 1000000; |
| 216 | 216 | $metal_spent = round(min($moon_planet['debris_metal'], $debris_spent * mt_rand(50, 75) / 100)); |
| 217 | 217 | $crystal_spent = min($moon_planet['debris_crystal'], $debris_spent - $metal_spent); |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | $planet_row['id'] = $user['current_planet']; |
| 248 | 248 | |
| 249 | 249 | // Пытаемся переключить на новую планету |
| 250 | - if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) |
|
| 250 | + if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) |
|
| 251 | 251 | { |
| 252 | 252 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id'); |
| 253 | 253 | } |
@@ -257,15 +257,15 @@ discard block |
||
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
| 260 | - if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
| 260 | + if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
| 261 | 261 | { |
| 262 | 262 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
| 263 | 263 | // Если текущей планеты не существует - выставляем Столицу |
| 264 | - if(!isset($planet_row['id'])) |
|
| 264 | + if (!isset($planet_row['id'])) |
|
| 265 | 265 | { |
| 266 | 266 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id'); |
| 267 | 267 | // Если и столицы не существует - значит что-то очень не так с записью пользователя |
| 268 | - if(!isset($planet_row['id'])) |
|
| 268 | + if (!isset($planet_row['id'])) |
|
| 269 | 269 | { |
| 270 | 270 | global $debug; |
| 271 | 271 | $debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | // Если производилось переключение планеты - делаем запись в юзере |
| 277 | - if($user['current_planet'] != $planet_row['id']) |
|
| 277 | + if ($user['current_planet'] != $planet_row['id']) |
|
| 278 | 278 | { |
| 279 | 279 | db_user_set_by_id($user['id'], "`current_planet` = '{$planet_row['id']}'"); |
| 280 | 280 | $user['current_planet'] = $planet_row['id']; |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | { |
| 299 | 299 | global $lang; |
| 300 | 300 | |
| 301 | - if(!$from['id']) |
|
| 301 | + if (!$from['id']) |
|
| 302 | 302 | { |
| 303 | 303 | $result = $lang['sys_planet_expedition']; |
| 304 | 304 | } |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | function uni_calculate_moon_chance($FleetDebris) |
| 338 | 338 | { |
| 339 | 339 | $MoonChance = $FleetDebris / 1000000; |
| 340 | - return ($MoonChance < 1) ? 0 : ($MoonChance>30 ? 30 : $MoonChance); |
|
| 340 | + return ($MoonChance < 1) ? 0 : ($MoonChance > 30 ? 30 : $MoonChance); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | function uni_coordinates_valid($coordinates, $prefix = '') |
@@ -359,11 +359,11 @@ discard block |
||
| 359 | 359 | global $lang, $config; |
| 360 | 360 | |
| 361 | 361 | try { |
| 362 | - if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
| 362 | + if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
| 363 | 363 | throw new exception($lang['ov_teleport_err_cooldown'], ERR_ERROR); |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - if(mrc_get_level($user, false, RES_DARK_MATTER) < $config->planet_teleport_cost) { |
|
| 366 | + if (mrc_get_level($user, false, RES_DARK_MATTER) < $config->planet_teleport_cost) { |
|
| 367 | 367 | throw new exception($lang['ov_teleport_err_no_dark_matter'], ERR_ERROR); |
| 368 | 368 | } |
| 369 | 369 | |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | // if(!empty($incoming['incoming'])) { |
| 376 | 376 | // throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR); |
| 377 | 377 | // } |
| 378 | - if(fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
| 378 | + if (fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
| 379 | 379 | throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR); |
| 380 | 380 | } |
| 381 | 381 | |
@@ -384,10 +384,10 @@ discard block |
||
| 384 | 384 | // throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR); |
| 385 | 385 | //} |
| 386 | 386 | |
| 387 | - if(is_array($new_coordinates)) { |
|
| 387 | + if (is_array($new_coordinates)) { |
|
| 388 | 388 | $new_coordinates['planet_type'] = PT_PLANET; |
| 389 | 389 | $incoming = DBStaticPlanet::db_planet_by_vector($new_coordinates, '', true, 'id'); |
| 390 | - if($incoming['id']) { |
|
| 390 | + if ($incoming['id']) { |
|
| 391 | 391 | throw new exception($lang['ov_teleport_err_destination_busy'], ERR_ERROR); |
| 392 | 392 | } |
| 393 | 393 | } |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | 'result' => ERR_NONE, |
| 397 | 397 | 'message' => '', |
| 398 | 398 | ); |
| 399 | - } catch(exception $e) { |
|
| 399 | + } catch (exception $e) { |
|
| 400 | 400 | $response = array( |
| 401 | 401 | 'result' => $e->getCode(), |
| 402 | 402 | 'message' => $e->getMessage(), |
@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | array('query' => 'DELETE FROM {{aks}} WHERE `id` NOT IN (SELECT DISTINCT `fleet_group` FROM {{fleets}});', 'result' => false, 'error' => '', 'affected_rows' => 0), |
| 16 | 16 | ); |
| 17 | 17 | |
| 18 | - foreach($queries as &$query) |
|
| 18 | + foreach ($queries as &$query) |
|
| 19 | 19 | { |
| 20 | 20 | $query['result'] = doquery($query['query']); |
| 21 | 21 | $query['error'] = classSupernova::$db->db_error(); |
| 22 | - $query['affected_rows'] = classSupernova::$db->db_affected_rows(); |
|
| 22 | + $query['affected_rows'] = classSupernova::$db->db_affected_rows(); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | return $queries; |
@@ -51,30 +51,30 @@ discard block |
||
| 51 | 51 | $recorded_run = strtotime($recorded_run); |
| 52 | 52 | |
| 53 | 53 | $prev_run_array = getdate($recorded_run); |
| 54 | - $prev_run_array = array($prev_run_array['seconds'],$prev_run_array['minutes'],$prev_run_array['hours'],$prev_run_array['mday'],$prev_run_array['mon'],$prev_run_array['year']); |
|
| 54 | + $prev_run_array = array($prev_run_array['seconds'], $prev_run_array['minutes'], $prev_run_array['hours'], $prev_run_array['mday'], $prev_run_array['mon'], $prev_run_array['year']); |
|
| 55 | 55 | $today_array = getdate(SN_TIME_NOW); |
| 56 | - $today_array = array($today_array['seconds'],$today_array['minutes'],$today_array['hours'],$today_array['mday'],$today_array['mon'],$today_array['year']); |
|
| 56 | + $today_array = array($today_array['seconds'], $today_array['minutes'], $today_array['hours'], $today_array['mday'], $today_array['mon'], $today_array['year']); |
|
| 57 | 57 | $scheduleList = explode(',', $scheduleList); |
| 58 | 58 | array_walk($scheduleList, function(&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) { |
| 59 | 59 | $schedule = array('schedule_array' => array_reverse(explode(':', trim($schedule)))); |
| 60 | 60 | |
| 61 | 61 | $interval = $date_part_names_reverse[count($schedule['schedule_array'])]; |
| 62 | 62 | |
| 63 | - foreach($prev_run_array as $index => $date_part) { |
|
| 63 | + foreach ($prev_run_array as $index => $date_part) { |
|
| 64 | 64 | $schedule['array']['recorded'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $date_part; |
| 65 | 65 | $schedule['array']['now'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $today_array[$index]; |
| 66 | 66 | } |
| 67 | - if($schedule['array']['recorded'] == $schedule['array']['now']) { |
|
| 67 | + if ($schedule['array']['recorded'] == $schedule['array']['now']) { |
|
| 68 | 68 | unset($schedule['array']['now']); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - foreach($schedule['array'] as $name => $array) { |
|
| 71 | + foreach ($schedule['array'] as $name => $array) { |
|
| 72 | 72 | $schedule['string'][$name] = "{$array[5]}-{$array[4]}-{$array[3]} {$array[2]}:{$array[1]}:{$array[0]}"; |
| 73 | 73 | $schedule['string'][$name . '_next'] = $schedule['string'][$name] . ' +1 ' . $interval; |
| 74 | 74 | $schedule['string'][$name . '_prev'] = $schedule['string'][$name] . ' -1 ' . $interval; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - foreach($schedule['string'] as $string) { |
|
| 77 | + foreach ($schedule['string'] as $string) { |
|
| 78 | 78 | $timestamp = strtotime($string); |
| 79 | 79 | $schedule['timestamp'][$timestamp] = $possible_schedules[$timestamp] = date(FMT_DATE_TIME_SQL, strtotime($string)); |
| 80 | 80 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | $prev_run = 0; |
| 86 | 86 | $next_run = 0; |
| 87 | - foreach($possible_schedules as $timestamp => $string_date) { |
|
| 87 | + foreach ($possible_schedules as $timestamp => $string_date) { |
|
| 88 | 88 | $prev_run = SN_TIME_NOW >= $timestamp ? $timestamp : $prev_run; |
| 89 | 89 | $next_run = SN_TIME_NOW < $timestamp && !$next_run ? $timestamp : $next_run; |
| 90 | 90 | } |
@@ -14,13 +14,13 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | $no_data = array('user' => false, 'planet' => false, 'que' => false); |
| 16 | 16 | |
| 17 | - if(!$planet) { |
|
| 17 | + if (!$planet) { |
|
| 18 | 18 | return $no_data; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - if(!$no_user_update) { |
|
| 21 | + if (!$no_user_update) { |
|
| 22 | 22 | $user = intval(is_array($user) && $user['id'] ? $user['id'] : $user); |
| 23 | - if(!$user) { |
|
| 23 | + if (!$user) { |
|
| 24 | 24 | // TODO - Убрать позже |
| 25 | 25 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sys_o_get_updated() - USER пустой!</h1>'); |
| 26 | 26 | $backtrace = debug_backtrace(); |
@@ -32,17 +32,17 @@ discard block |
||
| 32 | 32 | $user = db_user_by_id($user, !$simulation, '*', true); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if(empty($user['id'])) { |
|
| 35 | + if (empty($user['id'])) { |
|
| 36 | 36 | return $no_data; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if(is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) { |
|
| 39 | + if (is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) { |
|
| 40 | 40 | $planet = DBStaticPlanet::db_planet_by_vector($planet, '', !$simulation); |
| 41 | 41 | } else { |
| 42 | 42 | $planet = intval(is_array($planet) && isset($planet['id']) ? $planet['id'] : $planet); |
| 43 | 43 | $planet = DBStaticPlanet::db_planet_by_id($planet, !$simulation); |
| 44 | 44 | } |
| 45 | - if(!is_array($planet) || !isset($planet['id'])) { |
|
| 45 | + if (!is_array($planet) || !isset($planet['id'])) { |
|
| 46 | 46 | return $no_data; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -65,15 +65,15 @@ discard block |
||
| 65 | 65 | RES_DEUTERIUM => 0, |
| 66 | 66 | ); |
| 67 | 67 | |
| 68 | - switch($planet['planet_type']) { |
|
| 68 | + switch ($planet['planet_type']) { |
|
| 69 | 69 | case PT_PLANET: |
| 70 | - foreach($resources_increase as $resource_id => &$increment) { |
|
| 70 | + foreach ($resources_increase as $resource_id => &$increment) { |
|
| 71 | 71 | $resource_name = pname_resource_name($resource_id); |
| 72 | 72 | $increment = $caps_real['total'][$resource_id] * $ProductionTime / 3600; |
| 73 | 73 | $store_free = $caps_real['total_storage'][$resource_id] - $planet[$resource_name]; |
| 74 | 74 | $increment = min($increment, max(0, $store_free)); |
| 75 | 75 | |
| 76 | - if($planet[$resource_name] + $increment < 0 && !$simulation) { |
|
| 76 | + if ($planet[$resource_name] + $increment < 0 && !$simulation) { |
|
| 77 | 77 | global $debug; |
| 78 | 78 | $debug->warning("Player ID {$user['id']} have negative resources on ID {$planet['id']}.{$planet['planet_type']} [{$planet['galaxy']}:{$planet['system']}:{$planet['planet']}]. Difference {$planet[$resource_name]} of {$resource_name}", 'Negative Resources', 501); |
| 79 | 79 | } |
@@ -95,13 +95,13 @@ discard block |
||
| 95 | 95 | // TODO пересчитывать размер планеты только при постройке чего-нибудь и при покупке сектора |
| 96 | 96 | $planet['field_current'] = 0; |
| 97 | 97 | $sn_group_build_allow = sn_get_groups('build_allow'); |
| 98 | - if(is_array($sn_group_build_allow[$planet['planet_type']])) { |
|
| 99 | - foreach($sn_group_build_allow[$planet['planet_type']] as $building_id) { |
|
| 98 | + if (is_array($sn_group_build_allow[$planet['planet_type']])) { |
|
| 99 | + foreach ($sn_group_build_allow[$planet['planet_type']] as $building_id) { |
|
| 100 | 100 | $planet['field_current'] += mrc_get_level($user, $planet, $building_id, !$simulation, true); |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - if($simulation) { |
|
| 104 | + if ($simulation) { |
|
| 105 | 105 | return array('user' => $user, 'planet' => $planet, 'que' => $que); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -13,13 +13,13 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | function eco_get_lab_max_effective_level(&$user, $lab_require) |
| 15 | 15 | { |
| 16 | - if(!$user['user_as_ally'] && !isset($user['laboratories_active'])) |
|
| 16 | + if (!$user['user_as_ally'] && !isset($user['laboratories_active'])) |
|
| 17 | 17 | { |
| 18 | 18 | $user['laboratories_active'] = array(); |
| 19 | 19 | $query = DBStaticUnit::db_unit_list_laboratories($user['id']); |
| 20 | - while($row = db_fetch($query)) |
|
| 20 | + while ($row = db_fetch($query)) |
|
| 21 | 21 | { |
| 22 | - if(!eco_unit_busy($user, $row, UNIT_TECHNOLOGIES)) |
|
| 22 | + if (!eco_unit_busy($user, $row, UNIT_TECHNOLOGIES)) |
|
| 23 | 23 | { |
| 24 | 24 | $row += array( |
| 25 | 25 | STRUC_LABORATORY => $level_lab = mrc_get_level($user, $row, STRUC_LABORATORY), |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | uasort($user['laboratories_active'], 'eco_lab_sort_effectivness'); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if(!isset($user['research_effective_level'][$lab_require])) |
|
| 36 | + if (!isset($user['research_effective_level'][$lab_require])) |
|
| 37 | 37 | { |
| 38 | - if($user['user_as_ally']) |
|
| 38 | + if ($user['user_as_ally']) |
|
| 39 | 39 | { |
| 40 | 40 | $lab_level = doquery("SELECT ally_members AS effective_level FROM {{alliance}} WHERE id = {$user['user_as_ally']} LIMIT 1", true); |
| 41 | 41 | } |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | $tech_intergalactic = mrc_get_level($user, false, TECH_RESEARCH) + 1; |
| 45 | 45 | $lab_level['effective_level'] = 0; |
| 46 | 46 | |
| 47 | - foreach($user['laboratories_active'] as $data) |
|
| 47 | + foreach ($user['laboratories_active'] as $data) |
|
| 48 | 48 | { |
| 49 | - if($tech_intergalactic <= 0) |
|
| 49 | + if ($tech_intergalactic <= 0) |
|
| 50 | 50 | { |
| 51 | 51 | break; |
| 52 | 52 | } |
| 53 | - if($data[STRUC_LABORATORY] >= $lab_require) |
|
| 53 | + if ($data[STRUC_LABORATORY] >= $lab_require) |
|
| 54 | 54 | { |
| 55 | 55 | $lab_level['effective_level'] += $data['laboratory_effective_level']; |
| 56 | 56 | $tech_intergalactic--; |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | $time = 0; |
| 80 | 80 | $only_dark_matter = 0; |
| 81 | 81 | $cost_in_metal = 0; |
| 82 | - foreach($unit_data[P_COST] as $resource_id => $resource_amount) { |
|
| 83 | - if($resource_id === P_FACTOR || !($resource_cost = $resource_amount * $price_increase)) { |
|
| 82 | + foreach ($unit_data[P_COST] as $resource_id => $resource_amount) { |
|
| 83 | + if ($resource_id === P_FACTOR || !($resource_cost = $resource_amount * $price_increase)) { |
|
| 84 | 84 | continue; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -89,12 +89,12 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $resource_db_name = pname_resource_name($resource_id); |
| 91 | 91 | $cost_in_metal += $cost[BUILD_CREATE][$resource_id] * $config->__get("rpg_exchange_{$resource_db_name}"); |
| 92 | - if(in_array($resource_id, sn_get_groups('resources_loot'))) { |
|
| 92 | + if (in_array($resource_id, sn_get_groups('resources_loot'))) { |
|
| 93 | 93 | $time += $resource_cost * $config->__get("rpg_exchange_{$resource_db_name}") / $rpg_exchange_deuterium; |
| 94 | 94 | $resource_got = mrc_get_level($user, $planet, $resource_id); |
| 95 | - } elseif($resource_id == RES_DARK_MATTER) { |
|
| 95 | + } elseif ($resource_id == RES_DARK_MATTER) { |
|
| 96 | 96 | $resource_got = mrc_get_level($user, null, $resource_id); |
| 97 | - } elseif($resource_id == RES_ENERGY) { |
|
| 97 | + } elseif ($resource_id == RES_ENERGY) { |
|
| 98 | 98 | $resource_got = max(0, $planet['energy_max'] - $planet['energy_used']); |
| 99 | 99 | } else { |
| 100 | 100 | $resource_got = 0; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | $resources_normalized = 0; |
| 109 | 109 | $resources_loot = sn_get_groups('resources_loot'); |
| 110 | - foreach($resources_loot as $resource_id) { |
|
| 110 | + foreach ($resources_loot as $resource_id) { |
|
| 111 | 111 | $resource_db_name = pname_resource_name($resource_id); |
| 112 | 112 | $resource_got = mrc_get_level($user, $planet, $resource_id); |
| 113 | 113 | $resources_normalized += floor($resource_got) * $config->__get("rpg_exchange_{$resource_db_name}"); |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | $cost[P_OPTIONS][P_TIME_RAW] = $time = $time * 60 * 60 / get_game_speed() / 2500; |
| 126 | 126 | |
| 127 | 127 | // TODO - Вынести в отдельную процедуру расчёт стоимости |
| 128 | - if($only_cost) { |
|
| 128 | + if ($only_cost) { |
|
| 129 | 129 | return $cost; |
| 130 | 130 | } |
| 131 | 131 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | $mercenary = 0; |
| 136 | 136 | $cost['RESULT'][BUILD_DESTROY] = BUILD_INDESTRUCTABLE; |
| 137 | - if(in_array($unit_id, sn_get_groups('structures'))) { |
|
| 137 | + if (in_array($unit_id, sn_get_groups('structures'))) { |
|
| 138 | 138 | $time = $time * pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_ROBOT) + 1); |
| 139 | 139 | $mercenary = MRC_ENGINEER; |
| 140 | 140 | $cost['RESULT'][BUILD_DESTROY] = |
@@ -144,23 +144,23 @@ discard block |
||
| 144 | 144 | : BUILD_NO_RESOURCES |
| 145 | 145 | ) |
| 146 | 146 | : BUILD_NO_UNITS; |
| 147 | - } elseif(in_array($unit_id, sn_get_groups('tech'))) { |
|
| 147 | + } elseif (in_array($unit_id, sn_get_groups('tech'))) { |
|
| 148 | 148 | $lab_level = eco_get_lab_max_effective_level($user, intval($unit_data['require'][STRUC_LABORATORY])); |
| 149 | 149 | $time = $time / $lab_level; |
| 150 | 150 | $mercenary = MRC_ACADEMIC; |
| 151 | - } elseif(in_array($unit_id, sn_get_groups('defense'))) { |
|
| 152 | - $time = $time * pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1) ; |
|
| 151 | + } elseif (in_array($unit_id, sn_get_groups('defense'))) { |
|
| 152 | + $time = $time * pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1); |
|
| 153 | 153 | $mercenary = MRC_FORTIFIER; |
| 154 | - } elseif(in_array($unit_id, sn_get_groups('fleet'))) { |
|
| 154 | + } elseif (in_array($unit_id, sn_get_groups('fleet'))) { |
|
| 155 | 155 | $time = $time * pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1); |
| 156 | 156 | $mercenary = MRC_ENGINEER; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if($mercenary) { |
|
| 159 | + if ($mercenary) { |
|
| 160 | 160 | $time = $time / mrc_modify_value($user, $planet, $mercenary, 1); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if(in_array($unit_id, sn_get_groups('governors')) || $only_dark_matter) { |
|
| 163 | + if (in_array($unit_id, sn_get_groups('governors')) || $only_dark_matter) { |
|
| 164 | 164 | $cost[RES_TIME][BUILD_CREATE] = $cost[RES_TIME][BUILD_DESTROY] = 0; |
| 165 | 165 | } else { |
| 166 | 166 | $cost[RES_TIME][BUILD_CREATE] = round($time >= 1 ? $time : 1); |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | return $cost; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | -function eco_can_build_unit($user, $planet, $unit_id){return sn_function_call('eco_can_build_unit', array($user, $planet, $unit_id, &$result));} |
|
| 173 | +function eco_can_build_unit($user, $planet, $unit_id) {return sn_function_call('eco_can_build_unit', array($user, $planet, $unit_id, &$result)); } |
|
| 174 | 174 | function sn_eco_can_build_unit($user, $planet, $unit_id, &$result) { |
| 175 | 175 | global $config; |
| 176 | 176 | |
@@ -178,11 +178,11 @@ discard block |
||
| 178 | 178 | $result = $result == BUILD_ALLOWED && eco_unit_busy($user, $planet, $unit_id) ? BUILD_UNIT_BUSY : $result; |
| 179 | 179 | |
| 180 | 180 | $unit_param = get_unit_param($unit_id); |
| 181 | - if($unit_param[P_UNIT_TYPE] != UNIT_MERCENARIES || !$config->empire_mercenary_temporary) { |
|
| 181 | + if ($unit_param[P_UNIT_TYPE] != UNIT_MERCENARIES || !$config->empire_mercenary_temporary) { |
|
| 182 | 182 | $requirement = &$unit_param[P_REQUIRE]; |
| 183 | - if($result == BUILD_ALLOWED && $requirement) { |
|
| 184 | - foreach($requirement as $require_id => $require_level) { |
|
| 185 | - if(mrc_get_level($user, $planet, $require_id) < $require_level) { |
|
| 183 | + if ($result == BUILD_ALLOWED && $requirement) { |
|
| 184 | + foreach ($requirement as $require_id => $require_level) { |
|
| 185 | + if (mrc_get_level($user, $planet, $require_id) < $require_level) { |
|
| 186 | 186 | $result = BUILD_REQUIRE_NOT_MEET; |
| 187 | 187 | break; |
| 188 | 188 | } |
@@ -199,12 +199,12 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | $unit_list = is_array($unit_list) ? $unit_list : array($unit_list => $unit_list); |
| 201 | 201 | $planet_que = explode(';', $planet_que); |
| 202 | - foreach($planet_que as $planet_que_item) |
|
| 202 | + foreach ($planet_que as $planet_que_item) |
|
| 203 | 203 | { |
| 204 | - if($planet_que_item) |
|
| 204 | + if ($planet_que_item) |
|
| 205 | 205 | { |
| 206 | 206 | list($planet_que_item) = explode(',', $planet_que_item); |
| 207 | - if(in_array($planet_que_item, $unit_list)) |
|
| 207 | + if (in_array($planet_que_item, $unit_list)) |
|
| 208 | 208 | { |
| 209 | 209 | $eco_is_builds_in_que = true; |
| 210 | 210 | break; |
@@ -215,21 +215,21 @@ discard block |
||
| 215 | 215 | return $eco_is_builds_in_que; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | -function eco_unit_busy(&$user, &$planet, $unit_id){return sn_function_call('eco_unit_busy', array(&$user, &$planet, $unit_id, &$result));} |
|
| 218 | +function eco_unit_busy(&$user, &$planet, $unit_id) {return sn_function_call('eco_unit_busy', array(&$user, &$planet, $unit_id, &$result)); } |
|
| 219 | 219 | function sn_eco_unit_busy(&$user, &$planet, $unit_id, &$result) |
| 220 | 220 | { |
| 221 | 221 | global $config; |
| 222 | 222 | |
| 223 | 223 | $result = isset($result) ? $result : false; |
| 224 | - if(!$result) |
|
| 224 | + if (!$result) |
|
| 225 | 225 | { |
| 226 | - if(($unit_id == STRUC_LABORATORY || $unit_id == STRUC_LABORATORY_NANO) && !$config->BuildLabWhileRun) |
|
| 226 | + if (($unit_id == STRUC_LABORATORY || $unit_id == STRUC_LABORATORY_NANO) && !$config->BuildLabWhileRun) |
|
| 227 | 227 | { |
| 228 | 228 | $global_que = que_get($user['id'], $planet['id'], QUE_RESEARCH, false); |
| 229 | - if(is_array($global_que['ques'][QUE_RESEARCH][$user['id']])) |
|
| 229 | + if (is_array($global_que['ques'][QUE_RESEARCH][$user['id']])) |
|
| 230 | 230 | { |
| 231 | 231 | $first_element = reset($global_que['ques'][QUE_RESEARCH][$user['id']]); |
| 232 | - if(is_array($first_element)) |
|
| 232 | + if (is_array($first_element)) |
|
| 233 | 233 | { |
| 234 | 234 | $result = true; |
| 235 | 235 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | // $result = true; |
| 240 | 240 | //} |
| 241 | 241 | } |
| 242 | - elseif(($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !$config->BuildLabWhileRun && $planet['que']) |
|
| 242 | + elseif (($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !$config->BuildLabWhileRun && $planet['que']) |
|
| 243 | 243 | { |
| 244 | 244 | $result = eco_is_builds_in_que($planet['que'], array(STRUC_LABORATORY, STRUC_LABORATORY_NANO)); |
| 245 | 245 | } |