Completed
Push — work-fleets ( 7f5906...04acf9 )
by SuperNova.WS
06:14
created
includes/pages/options.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
   $language_new = sys_get_param_str('langer', $user['lang']);
14 14
 
15
-  if($language_new != $user['lang']) {
15
+  if ($language_new != $user['lang']) {
16 16
     classLocale::$lang->lng_switch($language_new);
17 17
   }
18 18
 
@@ -21,41 +21,41 @@  discard block
 block discarded – undo
21 21
 
22 22
   $FMT_DATE = preg_replace(array('/d/', '/m/', '/Y/'), array('DD', 'MM', 'YYYY'), FMT_DATE);
23 23
 
24
-  if(sys_get_param_str('mode') == 'change') {
25
-    if($user['authlevel'] > 0) {
24
+  if (sys_get_param_str('mode') == 'change') {
25
+    if ($user['authlevel'] > 0) {
26 26
       $planet_protection = sys_get_param_int('adm_pl_prot') ? $user['authlevel'] : 0;
27 27
       DBStaticPlanet::db_planet_set_by_owner($user['id'], "`id_level` = '{$planet_protection}'");
28 28
       DBStaticUser::db_user_set_by_id($user['id'], "`admin_protection` = '{$planet_protection}'");
29 29
       $user['admin_protection'] = $planet_protection;
30 30
     }
31 31
 
32
-    if(sys_get_param_int('vacation') && !classSupernova::$config->user_vacation_disable) {
32
+    if (sys_get_param_int('vacation') && !classSupernova::$config->user_vacation_disable) {
33 33
       sn_db_transaction_start();
34
-      if($user['authlevel'] < 3) {
35
-        if($user['vacation_next'] > SN_TIME_NOW) {
34
+      if ($user['authlevel'] < 3) {
35
+        if ($user['vacation_next'] > SN_TIME_NOW) {
36 36
           message(classLocale::$lang['opt_vacation_err_timeout'], classLocale::$lang['Error'], 'index.php?page=options', 5);
37 37
           die();
38 38
         }
39 39
 
40
-        if(FleetList::fleet_count_flying($user['id'])) {
40
+        if (FleetList::fleet_count_flying($user['id'])) {
41 41
           message(classLocale::$lang['opt_vacation_err_your_fleet'], classLocale::$lang['Error'], 'index.php?page=options', 5);
42 42
           die();
43 43
         }
44 44
 
45 45
         $que = que_get($user['id'], false);
46
-        if(!empty($que)) {
46
+        if (!empty($que)) {
47 47
           message(classLocale::$lang['opt_vacation_err_que'], classLocale::$lang['Error'], 'index.php?page=options', 5);
48 48
           die();
49 49
         }
50 50
 
51 51
         $query = classSupernova::db_get_record_list(LOC_PLANET, "`id_owner` = {$user['id']}");
52
-        foreach($query as $planet) {
52
+        foreach ($query as $planet) {
53 53
           // $planet = sys_o_get_updated($user, $planet, SN_TIME_NOW);
54 54
           // $planet = $planet['planet'];
55 55
 
56 56
           $classConfig = classSupernova::$config;
57 57
           DBStaticPlanet::db_planet_set_by_id($planet['id'],
58
-            "last_update = " . SN_TIME_NOW . ", energy_used = '0', energy_max = '0',
58
+            "last_update = ".SN_TIME_NOW.", energy_used = '0', energy_max = '0',
59 59
             metal_perhour = '{$classConfig->metal_basic_income}', crystal_perhour = '{$classConfig->crystal_basic_income}', deuterium_perhour = '{$classConfig->deuterium_basic_income}',
60 60
             metal_mine_porcent = '0', crystal_mine_porcent = '0', deuterium_sintetizer_porcent = '0', solar_plant_porcent = '0',
61 61
             fusion_plant_porcent = '0', solar_satelit_porcent = '0', ship_sattelite_sloth_porcent = 0"
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
       sn_db_transaction_commit();
69 69
     }
70 70
 
71
-    foreach($user_option_list as $option_group_id => $option_group) {
72
-      foreach($option_group as $option_name => $option_value) {
73
-        if($user[$option_name] !== null) {
71
+    foreach ($user_option_list as $option_group_id => $option_group) {
72
+      foreach ($option_group as $option_name => $option_value) {
73
+        if ($user[$option_name] !== null) {
74 74
           $user[$option_name] = sys_get_param_str($option_name);
75 75
         } else {
76 76
           $user[$option_name] = $option_value;
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 
82 82
 
83 83
     $player_options = sys_get_param('options');
84
-    if(!empty($player_options)) {
85
-      array_walk($player_options, function (&$value) {
84
+    if (!empty($player_options)) {
85
+      array_walk($player_options, function(&$value) {
86 86
         // TODO - Когда будет больше параметров - сделать больше проверок
87 87
         $value = intval($value);
88 88
       });
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 
94 94
     $username = substr(sys_get_param_str_unsafe('username'), 0, 32);
95 95
     $username_safe = db_escape($username);
96
-    if($username && $user['username'] != $username && classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
96
+    if ($username && $user['username'] != $username && classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
97 97
       // проверка на корректность
98 98
       sn_db_transaction_start();
99 99
       $name_check = db_player_name_history_get_name_by_name($username_safe);
100
-      if(!$name_check || $name_check['player_id'] == $user['id']) {
100
+      if (!$name_check || $name_check['player_id'] == $user['id']) {
101 101
         $user = DBStaticUser::db_user_by_id($user['id'], true);
102
-        switch(classSupernova::$config->game_user_changename) {
102
+        switch (classSupernova::$config->game_user_changename) {
103 103
           case SERVER_PLAYER_NAME_CHANGE_PAY:
104
-            if(mrc_get_level($user, $planetrow, RES_DARK_MATTER) < classSupernova::$config->game_user_changename_cost) {
104
+            if (mrc_get_level($user, $planetrow, RES_DARK_MATTER) < classSupernova::$config->game_user_changename_cost) {
105 105
               $template_result['.']['result'][] = array(
106 106
                 'STATUS'  => ERR_ERROR,
107 107
                 'MESSAGE' => classLocale::$lang['opt_msg_name_change_err_no_dm'],
@@ -131,18 +131,18 @@  discard block
 block discarded – undo
131 131
       sn_db_transaction_commit();
132 132
     }
133 133
 
134
-    if($new_password = sys_get_param('newpass1')) {
134
+    if ($new_password = sys_get_param('newpass1')) {
135 135
       try {
136
-        if($new_password != sys_get_param('newpass2')) {
136
+        if ($new_password != sys_get_param('newpass2')) {
137 137
           throw new Exception(classLocale::$lang['opt_err_pass_unmatched'], ERR_WARNING);
138 138
         }
139 139
 
140
-        if(!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) {
140
+        if (!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) {
141 141
           throw new Exception(classLocale::$lang['opt_err_pass_wrong'], ERR_WARNING);
142 142
         }
143 143
 
144 144
         throw new Exception(classLocale::$lang['opt_msg_pass_changed'], ERR_NONE);
145
-      } catch(Exception $e) {
145
+      } catch (Exception $e) {
146 146
         $template_result['.']['result'][] = array(
147 147
           'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
148 148
           'MESSAGE' => $e->getMessage()
@@ -164,12 +164,12 @@  discard block
 block discarded – undo
164 164
     $user['gender'] = $user['gender'] == GENDER_UNKNOWN ? $gender : $user['gender'];
165 165
 
166 166
     try {
167
-      if($user['birthday']) {
167
+      if ($user['birthday']) {
168 168
         throw new exception();
169 169
       }
170 170
 
171 171
       $user_birthday = sys_get_param_str_unsafe('user_birthday');
172
-      if(!$user_birthday || $user_birthday == $FMT_DATE) {
172
+      if (!$user_birthday || $user_birthday == $FMT_DATE) {
173 173
         throw new exception();
174 174
       }
175 175
 
@@ -179,16 +179,16 @@  discard block
 block discarded – undo
179 179
       $pos['Y'] = strpos(FMT_DATE, 'Y');
180 180
       asort($pos);
181 181
       $i = 0;
182
-      foreach($pos as &$position) {
182
+      foreach ($pos as &$position) {
183 183
         $position = ++$i;
184 184
       }
185 185
 
186
-      $regexp = "/" . preg_replace(array('/\\\\/', '/\//', '/\./', '/\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\/', '\.', '\-', '(\d?\d)', '(\d?\d)', '(\d{4})'), FMT_DATE) . "/";
187
-      if(!preg_match($regexp, $user_birthday, $match)) {
186
+      $regexp = "/".preg_replace(array('/\\\\/', '/\//', '/\./', '/\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\/', '\.', '\-', '(\d?\d)', '(\d?\d)', '(\d{4})'), FMT_DATE)."/";
187
+      if (!preg_match($regexp, $user_birthday, $match)) {
188 188
         throw new exception();
189 189
       }
190 190
 
191
-      if(!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) {
191
+      if (!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) {
192 192
         throw new exception();
193 193
       }
194 194
 
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
       // EOF black magic! Now we have valid SQL date in $user['user_birthday'] - independent of date format
197 197
 
198 198
       $year = date('Y', SN_TIME_NOW);
199
-      if(mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) {
199
+      if (mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) {
200 200
         $year--;
201 201
       }
202 202
       $user['user_birthday_celebrated'] = db_escape("{$year}-{$match[$pos['m']]}-{$match[$pos['d']]}");
203 203
 
204 204
       $user_birthday = ", `user_birthday` = '{$user['user_birthday']}', `user_birthday_celebrated` = '{$user['user_birthday_celebrated']}'";
205
-    } catch(exception $e) {
205
+    } catch (exception $e) {
206 206
       $user_birthday = '';
207 207
     }
208 208
 
@@ -212,14 +212,14 @@  discard block
 block discarded – undo
212 212
     $template_result['.']['result'][] = $avatar_upload_result;
213 213
 
214 214
     $user_time_diff = playerTimeDiff::user_time_diff_get();
215
-    if(sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) {
215
+    if (sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) {
216 216
       playerTimeDiff::user_time_diff_set(array(
217 217
         PLAYER_OPTION_TIME_DIFF              => sys_get_param_int('PLAYER_OPTION_TIME_DIFF'),
218 218
         PLAYER_OPTION_TIME_DIFF_UTC_OFFSET   => 0,
219 219
         PLAYER_OPTION_TIME_DIFF_FORCED       => 1,
220 220
         PLAYER_OPTION_TIME_DIFF_MEASURE_TIME => SN_TIME_SQL,
221 221
       ));
222
-    } elseif(sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) {
222
+    } elseif (sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) {
223 223
       playerTimeDiff::user_time_diff_set(array(
224 224
         PLAYER_OPTION_TIME_DIFF              => '',
225 225
         PLAYER_OPTION_TIME_DIFF_UTC_OFFSET   => 0,
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
       'STATUS'  => ERR_NONE,
240 240
       'MESSAGE' => classLocale::$lang['opt_msg_saved']
241 241
     );
242
-  } elseif(sys_get_param_str('result') == 'ok') {
242
+  } elseif (sys_get_param_str('result') == 'ok') {
243 243
     $template_result['.']['result'][] = array(
244 244
       'STATUS'  => ERR_NONE,
245 245
       'MESSAGE' => classLocale::$lang['opt_msg_saved']
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 
263 263
   $template = gettemplate('options', $template);
264 264
 
265
-  $dir = dir(SN_ROOT_PHYSICAL . 'skins');
266
-  while(($entry = $dir->read()) !== false) {
267
-    if(is_dir("skins/{$entry}") && $entry[0] != '.') {
265
+  $dir = dir(SN_ROOT_PHYSICAL.'skins');
266
+  while (($entry = $dir->read()) !== false) {
267
+    if (is_dir("skins/{$entry}") && $entry[0] != '.') {
268 268
       $template_result['.']['skin_list'][] = array(
269 269
         'VALUE'    => $entry,
270 270
         'NAME'     => $entry,
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
   }
275 275
   $dir->close();
276 276
 
277
-  foreach(classLocale::$lang['opt_planet_sort_options'] as $key => &$value) {
277
+  foreach (classLocale::$lang['opt_planet_sort_options'] as $key => &$value) {
278 278
     $template_result['.']['planet_sort_options'][] = array(
279 279
       'VALUE'    => $key,
280 280
       'NAME'     => $value,
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
     );
283 283
   }
284 284
 
285
-  foreach(classLocale::$lang['sys_gender_list'] as $key => $value) {
285
+  foreach (classLocale::$lang['sys_gender_list'] as $key => $value) {
286 286
     $template_result['.']['gender_list'][] = array(
287 287
       'VALUE'    => $key,
288 288
       'NAME'     => $value,
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
   }
292 292
 
293 293
   $lang_list = lng_get_list();
294
-  foreach($lang_list as $lang_id => $lang_data) {
294
+  foreach ($lang_list as $lang_id => $lang_data) {
295 295
     $template_result['.']['languages'][] = array(
296 296
       'VALUE'    => $lang_id,
297 297
       'NAME'     => $lang_data['LANG_NAME_NATIVE'],
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
   }
301 301
 
302 302
 
303
-  if(isset(classLocale::$lang['menu_customize_show_hide_button_state'])) {
304
-    foreach(classLocale::$lang['menu_customize_show_hide_button_state'] as $key => $value) {
303
+  if (isset(classLocale::$lang['menu_customize_show_hide_button_state'])) {
304
+    foreach (classLocale::$lang['menu_customize_show_hide_button_state'] as $key => $value) {
305 305
       $template->assign_block_vars('menu_customize_show_hide_button_state', array(
306 306
         'ID'   => $key,
307 307
         'NAME' => $value,
@@ -408,10 +408,10 @@  discard block
 block discarded – undo
408 408
     'PAGE_HEADER' => classLocale::$lang['opt_header'],
409 409
   ));
410 410
 
411
-  foreach($user_option_list as $option_group_id => $option_group) {
412
-    if($option_group_id == OPT_MESSAGE) {
413
-      foreach(DBStaticMessages::$snMessageClassList as $message_class_id => $message_class_data) {
414
-        if($message_class_data['switchable'] || ($message_class_data['email'] && classSupernova::$config->game_email_pm)) {
411
+  foreach ($user_option_list as $option_group_id => $option_group) {
412
+    if ($option_group_id == OPT_MESSAGE) {
413
+      foreach (DBStaticMessages::$snMessageClassList as $message_class_id => $message_class_data) {
414
+        if ($message_class_data['switchable'] || ($message_class_data['email'] && classSupernova::$config->game_email_pm)) {
415 415
           $option_name = $message_class_data['name'];
416 416
 
417 417
           $template->assign_block_vars("options_{$option_group_id}", array(
@@ -423,8 +423,8 @@  discard block
 block discarded – undo
423 423
         }
424 424
       }
425 425
     } else {
426
-      foreach($option_group as $option_name => $option_value) {
427
-        if(array_key_exists($option_name, $user_option_types)) {
426
+      foreach ($option_group as $option_name => $option_value) {
427
+        if (array_key_exists($option_name, $user_option_types)) {
428 428
           $option_type = $user_option_types[$option_name];
429 429
         } else {
430 430
           $option_type = 'switch';
Please login to merge, or discard this patch.
messages.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
3
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
4 4
 
5 5
 $template = gettemplate('viewreport', true);
6 6
 $template->assign_var('PAGE_HINT', classLocale::$lang['cr_view_hint']);
Please login to merge, or discard this patch.
blitz_register.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
3
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
4 4
 
5 5
 global $user;
6 6
 
7
-if($user['authlevel'] < AUTH_LEVEL_DEVELOPER) {
7
+if ($user['authlevel'] < AUTH_LEVEL_DEVELOPER) {
8 8
   $error_message = classSupernova::$config->game_mode == GAME_BLITZ ? 'sys_blitz_page_disabled' : (
9 9
   !classSupernova::$config->game_blitz_register ? 'sys_blitz_registration_disabled' : ''
10 10
   );
11 11
 
12
-  if($error_message) {
12
+  if ($error_message) {
13 13
     message(classLocale::$lang[$error_message], classLocale::$lang['sys_error'], 'overview.php', 10);
14 14
     die();
15 15
   }
@@ -18,16 +18,16 @@  discard block
 block discarded – undo
18 18
 $current_round = intval(classSupernova::$config->db_loadItem('game_blitz_register_round'));
19 19
 $current_price = intval(classSupernova::$config->db_loadItem('game_blitz_register_price'));
20 20
 
21
-if(classSupernova::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) {
21
+if (classSupernova::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) {
22 22
   sn_db_transaction_start();
23 23
   $user = DBStaticUser::db_user_by_id($user['id'], true);
24 24
   $is_registered = db_blitz_reg_get_id_by_player_and_round($user, $current_round);
25
-  if(sys_get_param_str('register_me')) {
26
-    if(empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) {
25
+  if (sys_get_param_str('register_me')) {
26
+    if (empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) {
27 27
       db_blitz_reg_insert($user, $current_round);
28 28
       classSupernova::$auth->account->metamatter_change(RPG_BLITZ_REGISTRATION, -$current_price, "Регистрация в раунде {$current_round} Блица");
29 29
     }
30
-  } elseif(sys_get_param_str('register_me_not') && !empty($is_registered)) {
30
+  } elseif (sys_get_param_str('register_me_not') && !empty($is_registered)) {
31 31
     db_blitz_reg_delete($user, $current_round);
32 32
     classSupernova::$auth->account->metamatter_change(RPG_BLITZ_REGISTRATION_CANCEL, $current_price, "Отмена регистрации в раунде {$current_round} Блица");
33 33
   }
@@ -42,17 +42,17 @@  discard block
 block discarded – undo
42 42
 $blitz_players = 0;
43 43
 $blitz_prize_dark_matter = 0;
44 44
 $blitz_prize_places = 0;
45
-if($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) {
46
-  if(sys_get_param_str('generate')) {
45
+if ($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) {
46
+  if (sys_get_param_str('generate')) {
47 47
     $next_id = 0;
48 48
     $query = db_blitz_reg_get_random_id($current_round);
49
-    while($row = db_fetch($query)) {
49
+    while ($row = db_fetch($query)) {
50 50
       $next_id++;
51
-      $blitz_name = 'Игрок' . $next_id;
51
+      $blitz_name = 'Игрок'.$next_id;
52 52
       $blitz_password = sys_random_string(8);
53 53
       db_blitz_reg_update_with_name_and_password($blitz_name, $blitz_password, $row, $current_round);
54 54
     }
55
-  } elseif(sys_get_param_str('import_generated')) {
55
+  } elseif (sys_get_param_str('import_generated')) {
56 56
     // ЭТО НА БЛИЦЕ!!!
57 57
     DBStaticUser::db_player_list_blitz_delete_players();
58 58
     DBStaticPlanet::db_planets_purge();
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     $system = $system_step;
75 75
     $planet = round(Vector::$knownPlanets / 2);
76 76
 
77
-    foreach($imported_string as &$string_data) {
77
+    foreach ($imported_string as &$string_data) {
78 78
       $string_data = explode(',', $string_data);
79 79
       $username_safe = $string_data[0];
80 80
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 
95 95
       $moon_row = uni_create_moon($galaxy, $system, $planet, $user_new['id'], 30, '', false);
96 96
 
97
-      if(($system += $system_step) >= Vector::$knownSystems) {
97
+      if (($system += $system_step) >= Vector::$knownSystems) {
98 98
         $galaxy++;
99 99
         $system = $system_step;
100 100
       }
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
     classSupernova::$config->db_saveItem('users_amount', classSupernova::$config->users_amount + $new_players);
105 105
     // pdump($imported_string);
106 106
     // generated_string
107
-  } elseif(sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) {
107
+  } elseif (sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) {
108 108
     $blitz_result = explode(';', $blitz_result_string);
109 109
     $blitz_last_update = $blitz_result[0]; // Пока не используется
110 110
     unset($blitz_result[0]);
111
-    foreach($blitz_result as $blitz_result_data) {
111
+    foreach ($blitz_result as $blitz_result_data) {
112 112
       $blitz_result_data = explode(',', $blitz_result_data);
113
-      if(count($blitz_result_data) == 5) {
113
+      if (count($blitz_result_data) == 5) {
114 114
         $blitz_result_data[1] = db_escape($blitz_result_data[1]);
115 115
         db_blitz_reg_update_results($blitz_result_data, $current_round);
116 116
       }
@@ -118,14 +118,14 @@  discard block
 block discarded – undo
118 118
     $blitz_result = array();
119 119
   }
120 120
 
121
-  if(classSupernova::$config->game_mode == GAME_BLITZ) {
121
+  if (classSupernova::$config->game_mode == GAME_BLITZ) {
122 122
     $blitz_result = array(classSupernova::$config->db_loadItem('var_stat_update'));
123
-    foreach(DBStaticUser::db_player_list_export_blitz_info() as $row) {
123
+    foreach (DBStaticUser::db_player_list_export_blitz_info() as $row) {
124 124
       $blitz_result[] = "{$row['id']},{$row['username']},{$row['onlinetime']},{$row['total_rank']},{$row['total_points']}";
125 125
     }
126 126
   } else {
127 127
     $query = db_blitz_reg_get_player_list($current_round);
128
-    while($row = db_fetch($query)) {
128
+    while ($row = db_fetch($query)) {
129 129
       $blitz_generated[] = "{$row['blitz_name']},{$row['blitz_password']}";
130 130
       $row['blitz_online'] ? $blitz_prize_players_active++ : false;
131 131
       $blitz_players++;
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
     $blitz_prize_dark_matter = $blitz_prize_players_active * 20000;
134 134
     $blitz_prize_places = ceil($blitz_prize_players_active / 5);
135 135
 
136
-    if(sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) {
136
+    if (sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) {
137 137
       // $blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter');
138 138
       $blitz_prize_places_actual = sys_get_param_int('blitz_prize_places');
139 139
       sn_db_transaction_start();
140 140
       $query = db_blitz_reg_get_player_list_order_by_place($current_round);
141
-      while($row = db_fetch($query)) {
142
-        if(!$row['blitz_place']) {
141
+      while ($row = db_fetch($query)) {
142
+        if (!$row['blitz_place']) {
143 143
           continue;
144 144
         }
145 145
 
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 
149 149
         $reward = $blitz_prize_dark_matter_actual - $row['blitz_reward_dark_matter'];
150 150
         pdump("{{$row['id']}} {$row['blitz_name']}, Place {$row['blitz_place']}, Prize places {$blitz_prize_places_actual}, Prize {$reward}", $row['id']);
151
-        if($reward) {
151
+        if ($reward) {
152 152
           rpg_points_change($row['user_id'], RPG_BLITZ, $reward, sprintf(
153 153
             classLocale::$lang['sys_blitz_reward_log_message'], $row['blitz_place'], $row['blitz_name']
154 154
           ));
155 155
           db_blitz_reg_update_apply_results($reward, $row, $current_round);
156 156
         }
157 157
 
158
-        if(!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) {
158
+        if (!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) {
159 159
           break;
160 160
         }
161 161
       }
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
 
171 171
 $player_registered = false;
172 172
 $query = db_blitz_reg_get_player_list_and_users($current_round);
173
-while($row = db_fetch($query)) {
173
+while ($row = db_fetch($query)) {
174 174
   $tpl_player_data = array(
175 175
     'NAME' => player_nick_render_to_html($row, array('icons' => true, 'color' => true, 'ally' => true)),
176 176
   );
177 177
 
178
-  if(classSupernova::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) {
178
+  if (classSupernova::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) {
179 179
     // Вот так хитро, что бы не было не единого шанса попадания на страницу данных об игроках Блиц-сервера до закрытия раунда
180 180
     $tpl_player_data = array_merge($tpl_player_data, array(
181 181
       'ID'                       => $row['id'],
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
   }
189 189
 
190 190
   $template->assign_block_vars('registrations', $tpl_player_data);
191
-  if($row['id'] == $user['id']) {
191
+  if ($row['id'] == $user['id']) {
192 192
     $player_registered = $row;
193 193
   }
194 194
 }
Please login to merge, or discard this patch.
includes/classes/DBMysqliStatementIterator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 
15 15
     $fields[0] = &$this->_result;
16 16
 
17
-    while($field = mysqli_fetch_field($data)) {
17
+    while ($field = mysqli_fetch_field($data)) {
18 18
       $fields[] = &$out[$field->name];
19 19
     }
20 20
 
Please login to merge, or discard this patch.
includes/classes/UBE/ContainerArrayOfObject.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
    * @param array  $arguments
20 20
    */
21 21
   public function __call($method_name, array $arguments) {
22
-    foreach($this->_container as $object) {
23
-      if(is_object($object) && method_exists($object, $method_name)) {
22
+    foreach ($this->_container as $object) {
23
+      if (is_object($object) && method_exists($object, $method_name)) {
24 24
         call_user_func_array(array($object, $method_name), $arguments);
25 25
       }
26 26
     }
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
    */
36 36
   public function getSumProperty($property_name) {
37 37
     $result = 0.0;
38
-    foreach($this->_container as $object) {
39
-      if(is_object($object) && property_exists($object, $property_name)) {
38
+    foreach ($this->_container as $object) {
39
+      if (is_object($object) && property_exists($object, $property_name)) {
40 40
         $result += $object->$property_name;
41 41
       }
42 42
     }
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
    * @return mixed
53 53
    */
54 54
   public function aggregateByMethod($method_name, &$result) {
55
-    foreach($this->_container as $object) {
56
-      if(is_object($object) && method_exists($object, $method_name)) {
55
+    foreach ($this->_container as $object) {
56
+      if (is_object($object) && method_exists($object, $method_name)) {
57 57
         call_user_func(array($object, $method_name), $result);
58 58
       }
59 59
     }
Please login to merge, or discard this patch.
includes/classes/UnitList.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
    */
90 90
   public function offsetSet($offset, $value) {
91 91
     if (isset($this->mapUnitIdToDb[$value->unitId])) {
92
-      classSupernova::$debug->error('UnitList::offsetSet: Unit with UnitId ' . $value->unitId . ' already exists');
92
+      classSupernova::$debug->error('UnitList::offsetSet: Unit with UnitId '.$value->unitId.' already exists');
93 93
     }
94 94
     $this->mapUnitIdToDb[$value->unitId] = $value;
95 95
     parent::offsetSet($offset, $value);
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 
203 203
   public function unitGetCount($unit_id) {
204 204
     if (empty($this->mapUnitIdToDb[$unit_id])) {
205
-      throw new Exception('Unit [' . $unit_id . '] is not exists in UnitList');
205
+      throw new Exception('Unit ['.$unit_id.'] is not exists in UnitList');
206 206
     }
207 207
 
208 208
     return $this->mapUnitIdToDb[$unit_id]->count;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
    */
248 248
   public function unitsCostInMetal($shipCostInMetalPerPiece) {
249 249
     $shipsCostInMetal = array();
250
-    foreach($this->mapUnitIdToDb as $ship_id => $ship) {
250
+    foreach ($this->mapUnitIdToDb as $ship_id => $ship) {
251 251
       $shipsCostInMetal[$ship_id] = $ship->count * $shipCostInMetalPerPiece[$ship_id];
252 252
     }
253 253
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
      */
330 330
     $objFleet = $this->getLocatedAt();
331 331
     if (empty($objFleet)) {
332
-      throw new Exception('No fleet owner on UnitList::unitsRender() in ' . __FILE__ . '@' . __LINE__);
332
+      throw new Exception('No fleet owner on UnitList::unitsRender() in '.__FILE__.'@'.__LINE__);
333 333
     }
334 334
 
335 335
     $tplShips = array();
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 
473 473
   // TODO - DEBUG - REMOVE =============================================================================================
474 474
   public function _dump() {
475
-    print(__FILE__ . ':' . __LINE__ . "<br />");
476
-    print("Located at " . $this->getLocationDbId() . " type " . $this->getLocationType() . "<br />");
475
+    print(__FILE__.':'.__LINE__."<br />");
476
+    print("Located at ".$this->getLocationDbId()." type ".$this->getLocationType()."<br />");
477 477
 
478 478
     print('<table border="1">');
479 479
     print('<tr>');
@@ -529,11 +529,11 @@  discard block
 block discarded – undo
529 529
 
530 530
       print('<td>');
531 531
       $type = $unit->getType();
532
-      print("[{$type}] " . classLocale::$lang['tech'][$type]);
532
+      print("[{$type}] ".classLocale::$lang['tech'][$type]);
533 533
       print('</td>');
534 534
 
535 535
       print('<td>');
536
-      print("[{$unit->unitId}] " . classLocale::$lang['tech'][$unit->unitId]);
536
+      print("[{$unit->unitId}] ".classLocale::$lang['tech'][$unit->unitId]);
537 537
       print('</td>');
538 538
 
539 539
       print('<td>');
Please login to merge, or discard this patch.
includes/classes/UBE/UBEFleet.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -162,20 +162,20 @@  discard block
 block discarded – undo
162 162
       $this->owner_id,
163 163
       $this->db_id,
164 164
 
165
-      (float)$this->UBE_PLANET[PLANET_ID],
166
-      "'" . db_escape($this->UBE_PLANET[PLANET_NAME]) . "'",
167
-      (int)$this->UBE_PLANET[PLANET_GALAXY],
168
-      (int)$this->UBE_PLANET[PLANET_SYSTEM],
169
-      (int)$this->UBE_PLANET[PLANET_PLANET],
170
-      (int)$this->UBE_PLANET[PLANET_TYPE],
171
-
172
-      (float)$this->resource_list[RES_METAL],
173
-      (float)$this->resource_list[RES_CRYSTAL],
174
-      (float)$this->resource_list[RES_DEUTERIUM],
175
-
176
-      (float)$this->fleet_bonus->calcBonus(P_ATTACK),
177
-      (float)$this->fleet_bonus->calcBonus(P_SHIELD),
178
-      (float)$this->fleet_bonus->calcBonus(P_ARMOR),
165
+      (float) $this->UBE_PLANET[PLANET_ID],
166
+      "'".db_escape($this->UBE_PLANET[PLANET_NAME])."'",
167
+      (int) $this->UBE_PLANET[PLANET_GALAXY],
168
+      (int) $this->UBE_PLANET[PLANET_SYSTEM],
169
+      (int) $this->UBE_PLANET[PLANET_PLANET],
170
+      (int) $this->UBE_PLANET[PLANET_TYPE],
171
+
172
+      (float) $this->resource_list[RES_METAL],
173
+      (float) $this->resource_list[RES_CRYSTAL],
174
+      (float) $this->resource_list[RES_DEUTERIUM],
175
+
176
+      (float) $this->fleet_bonus->calcBonus(P_ATTACK),
177
+      (float) $this->fleet_bonus->calcBonus(P_SHIELD),
178
+      (float) $this->fleet_bonus->calcBonus(P_ARMOR),
179 179
     );
180 180
   }
181 181
 
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
     $this->owner_id = $objFleet->playerOwnerId;
190 190
     $this->group_id = $objFleet->group_id;
191 191
 
192
-    foreach($objFleet->shipsIterator() as $unit_id => $unit) {
193
-      if(!$unit->count) {
192
+    foreach ($objFleet->shipsIterator() as $unit_id => $unit) {
193
+      if (!$unit->count) {
194 194
         continue;
195 195
       }
196 196
 
197 197
       $unit_type = get_unit_param($unit_id, P_UNIT_TYPE);
198
-      if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
198
+      if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
199 199
         $this->unit_list->unitAdjustCount($unit_id, $unit->count);
200 200
       }
201 201
     }
@@ -231,13 +231,13 @@  discard block
 block discarded – undo
231 231
 //      }
232 232
 //    }
233 233
 
234
-    foreach($sn_group_combat as $unit_id) {
235
-      if($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) {
234
+    foreach ($sn_group_combat as $unit_id) {
235
+      if ($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) {
236 236
         $this->unit_list->unitAdjustCount($unit_id, $unit_count);
237 237
       }
238 238
     }
239 239
 
240
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
240
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
241 241
       $this->resource_list[$resource_id] = floor(mrc_get_level($player_db_row, $planet_row, $resource_id));
242 242
     }
243 243
 
@@ -296,27 +296,27 @@  discard block
 block discarded – undo
296 296
       $ube_report_id,
297 297
       $this->db_id,
298 298
 
299
-      (float)$this->resources_lost_on_units[RES_METAL],
300
-      (float)$this->resources_lost_on_units[RES_CRYSTAL],
301
-      (float)$this->resources_lost_on_units[RES_DEUTERIUM],
302
-      (float)$this->cargo_dropped[RES_METAL],
303
-      (float)$this->cargo_dropped[RES_CRYSTAL],
304
-      (float)$this->cargo_dropped[RES_DEUTERIUM],
305
-      (float)$this->resources_looted[RES_METAL],
306
-      (float)$this->resources_looted[RES_CRYSTAL],
307
-      (float)$this->resources_looted[RES_DEUTERIUM],
308
-      (float)$this->resources_lost_in_metal[RES_METAL],
299
+      (float) $this->resources_lost_on_units[RES_METAL],
300
+      (float) $this->resources_lost_on_units[RES_CRYSTAL],
301
+      (float) $this->resources_lost_on_units[RES_DEUTERIUM],
302
+      (float) $this->cargo_dropped[RES_METAL],
303
+      (float) $this->cargo_dropped[RES_CRYSTAL],
304
+      (float) $this->cargo_dropped[RES_DEUTERIUM],
305
+      (float) $this->resources_looted[RES_METAL],
306
+      (float) $this->resources_looted[RES_CRYSTAL],
307
+      (float) $this->resources_looted[RES_DEUTERIUM],
308
+      (float) $this->resources_lost_in_metal[RES_METAL],
309 309
     );
310 310
   }
311 311
 
312 312
   public function report_render_outcome_side_fleet() {
313 313
     $UBE_DEFENCE_RESTORE = array();
314 314
     $UBE_UNITS_LOST = array();
315
-    foreach($this->unit_list->_container as $UBEUnit) {
316
-      if($UBEUnit->units_restored) {
315
+    foreach ($this->unit_list->_container as $UBEUnit) {
316
+      if ($UBEUnit->units_restored) {
317 317
         $UBE_DEFENCE_RESTORE[$UBEUnit->unitId] = $UBEUnit->units_restored;
318 318
       }
319
-      if($UBEUnit->units_lost) {
319
+      if ($UBEUnit->units_lost) {
320 320
         $UBE_UNITS_LOST[$UBEUnit->unitId] = $UBEUnit->units_lost;
321 321
       }
322 322
     }
@@ -341,16 +341,16 @@  discard block
 block discarded – undo
341 341
    */
342 342
   protected function report_render_outcome_side_fleet_line(&$array, $lang_header_index) {
343 343
     $result = array();
344
-    if(!empty($array)) {
345
-      foreach($array as $unit_id => $unit_count) {
346
-        if($unit_count) {
344
+    if (!empty($array)) {
345
+      foreach ($array as $unit_id => $unit_count) {
346
+        if ($unit_count) {
347 347
           $result[] = array(
348 348
             'NAME' => classLocale::$lang['tech'][$unit_id],
349 349
             'LOSS' => pretty_number($unit_count),
350 350
           );
351 351
         }
352 352
       }
353
-      if($lang_header_index && count($result)) {
353
+      if ($lang_header_index && count($result)) {
354 354
         array_unshift($result, array('NAME' => classLocale::$lang[$lang_header_index]));
355 355
       }
356 356
     }
@@ -363,16 +363,16 @@  discard block
 block discarded – undo
363 363
     $fleet_id = $this->db_id;
364 364
 
365 365
     $unit_sort_order = 0;
366
-    foreach($this->unit_list->_container as $UBEUnit) {
367
-      if($UBEUnit->units_lost || $UBEUnit->units_restored) {
366
+    foreach ($this->unit_list->_container as $UBEUnit) {
367
+      if ($UBEUnit->units_lost || $UBEUnit->units_restored) {
368 368
         $unit_sort_order++;
369 369
         $sql_perform_report_unit[] = array(
370 370
           $ube_report_id,
371 371
           $fleet_id,
372 372
 
373 373
           $UBEUnit->unitId,
374
-          (float)$UBEUnit->units_restored,
375
-          (float)$UBEUnit->units_lost,
374
+          (float) $UBEUnit->units_restored,
375
+          (float) $UBEUnit->units_lost,
376 376
 
377 377
           $unit_sort_order,
378 378
         );
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
   function ube_combat_result_calculate_resources() {
389 389
     $resource_delta_fleet = array();
390 390
     // Если во флоте остались юниты или это планета - генерируем изменение ресурсов
391
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
392
-      $resource_change = (float)$this->resources_looted[$resource_id] + (float)$this->cargo_dropped[$resource_id];
393
-      if($resource_change) {
391
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
392
+      $resource_change = (float) $this->resources_looted[$resource_id] + (float) $this->cargo_dropped[$resource_id];
393
+      if ($resource_change) {
394 394
         $resource_delta_fleet[$resource_id] = -($resource_change);
395 395
       }
396 396
     }
@@ -423,12 +423,12 @@  discard block
 block discarded – undo
423 423
     );
424 424
 
425 425
     $this->fleet_capacity = 0;
426
-    foreach($this->unit_list->_container as $UBEUnit) {
426
+    foreach ($this->unit_list->_container as $UBEUnit) {
427 427
       $this->fleet_capacity += $UBEUnit->capacity * $UBEUnit->getCount();
428 428
 
429
-      if($UBEUnit->units_lost) {
430
-        foreach($UBEUnit->price as $resource_id => $unit_resource_price) {
431
-          if(!$unit_resource_price) {
429
+      if ($UBEUnit->units_lost) {
430
+        foreach ($UBEUnit->price as $resource_id => $unit_resource_price) {
431
+          if (!$unit_resource_price) {
432 432
             continue;
433 433
           }
434 434
 
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
           $this->resources_lost_on_units[$resource_id] += $resources_lost;
437 437
           // Если это корабль - прибавляем потери к обломкам на орбите
438 438
           // TODO - опция выбрасывания обороны в обломки
439
-          if($UBEUnit->getType() == UNIT_SHIPS) {
439
+          if ($UBEUnit->getType() == UNIT_SHIPS) {
440 440
             $this->resources_lost_on_ships[$resource_id] += $resources_lost;
441 441
           }
442 442
         }
@@ -448,11 +448,11 @@  discard block
 block discarded – undo
448 448
 
449 449
     // Если емкость трюмов меньше количество ресурсов - часть ресов выбрасываем нахуй
450 450
     // На планете ($fleet_id = 0) ресурсы в космос не выбрасываются
451
-    if($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) {
451
+    if ($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) {
452 452
       $drop_share = 1 - $this->fleet_capacity / $fleet_total_resources; // Какая часть ресурсов выброшена
453
-      foreach($this->resource_list as $resource_id => &$resource_amount) {
453
+      foreach ($this->resource_list as $resource_id => &$resource_amount) {
454 454
         // Не просчитываем ресурсы, которых нет на борту кораблей флота
455
-        if(!$resource_amount) {
455
+        if (!$resource_amount) {
456 456
           continue;
457 457
         }
458 458
 
@@ -473,19 +473,19 @@  discard block
 block discarded – undo
473 473
     $objFleet2->setDbId($this->db_id);
474 474
 
475 475
     // Если это была миссия Уничтожения И звезда смерти взорвалась И мы работаем с аттакерами - значит все аттакеры умерли
476
-    if($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) {
476
+    if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) {
477 477
       $objFleet2->dbDelete();
478
-    } elseif($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial ||
478
+    } elseif ($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial ||
479 479
       $objFleet2->dbDelete();
480 480
     } else {
481
-      if($ship_count_lost) {
481
+      if ($ship_count_lost) {
482 482
         // Просматриваем результаты изменения флотов
483
-        foreach($this->unit_list->_container as $UBEUnit) {
483
+        foreach ($this->unit_list->_container as $UBEUnit) {
484 484
           // Перебираем аутком на случай восстановления юнитов
485 485
 //          if(($units_left = $UBEUnit->getCount() - (float)$UBEUnit->units_lost) > 0) {
486 486
 //            $fleet_real_array[$UBEUnit->unitId] = $units_left;
487 487
 //          };
488
-          if(floatval($UBEUnit->units_lost) != 0) {
488
+          if (floatval($UBEUnit->units_lost) != 0) {
489 489
             $objFleet2->shipAdjustCount($UBEUnit->unitId, floatval($UBEUnit->units_lost));
490 490
           };
491 491
         }
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
       $objFleet2->resourcesAdjust($resource_delta_fleet);
496 496
 
497 497
       // Если защитник и не РМФ - отправляем флот назад
498
-      if($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) {
498
+      if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) {
499 499
         $objFleet2->markReturned();
500 500
       }
501 501
       $objFleet2->dbSave();
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
   public function calculate_unit_partial_data(UBEASA $side_ASA) {
526 526
     $this->fleet_share_of_side_armor = $this->total_stats[P_ARMOR] / $side_ASA->getArmor();
527 527
 
528
-    foreach($this->unit_list->_container as $UBEUnit) {
528
+    foreach ($this->unit_list->_container as $UBEUnit) {
529 529
       $UBEUnit->share_of_side_armor = $UBEUnit->pool_armor / $side_ASA->getArmor();
530 530
     }
531 531
   }
@@ -537,9 +537,9 @@  discard block
 block discarded – undo
537 537
    * @version 2016-02-25 23:42:45 41a4.68
538 538
    */
539 539
   public function attack_fleets(UBEFleetList $fleet_list, $is_simulator) {
540
-    foreach($fleet_list->_container as $defending_fleet) {
540
+    foreach ($fleet_list->_container as $defending_fleet) {
541 541
       // Не атакуются флоты на своей стороне
542
-      if($this->is_attacker == $defending_fleet->is_attacker) {
542
+      if ($this->is_attacker == $defending_fleet->is_attacker) {
543 543
         continue;
544 544
       }
545 545
       $this->attack_fleet($defending_fleet, $is_simulator);
@@ -555,12 +555,12 @@  discard block
 block discarded – undo
555 555
   public function attack_fleet(UBEFleet $defending_fleet, $is_simulator) {
556 556
     UBEDebug::unit_dump_header();
557 557
 
558
-    foreach($this->unit_list->_container as $attacking_unit_pool) {
558
+    foreach ($this->unit_list->_container as $attacking_unit_pool) {
559 559
       UBEDebug::unit_dump($attacking_unit_pool, 'attacker');
560 560
 
561 561
       // if($attack_unit_count <= 0) continue; // TODO: Это пока нельзя включать - вот если будут "боевые порядки юнитов..."
562
-      foreach($defending_fleet->unit_list->_container as $defending_unit_pool) {
563
-        if($defending_unit_pool->isEmpty()) {
562
+      foreach ($defending_fleet->unit_list->_container as $defending_unit_pool) {
563
+        if ($defending_unit_pool->isEmpty()) {
564 564
           continue;
565 565
         }
566 566
 
Please login to merge, or discard this patch.
includes/functions/tpl_helpers.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
50 50
     'DEUTERIUM' => $fleet[RES_DEUTERIUM],
51 51
   );
52 52
 
53
-  foreach($fleet as $ship_id => $ship_amount) {
54
-    if(in_array($ship_id, Fleet::$snGroupFleet)) {
53
+  foreach ($fleet as $ship_id => $ship_amount) {
54
+    if (in_array($ship_id, Fleet::$snGroupFleet)) {
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
 block discarded – undo
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 = DBStaticFleetACS::db_acs_get_by_group_id($objFleet->group_id);
99 99
   }
100 100
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     'MISSION'      => $objFleet->mission_type,
114 114
     'MISSION_NAME' => classLocale::$lang['type_mission'][$objFleet->mission_type],
115 115
     'ACS'          => !empty($aks['name']) ? $aks['name'] : (!empty($objFleet->group_id) ? $objFleet->group_id : ''),
116
-    'AMOUNT'       => $spy_level >= 4 ? (pretty_number($objFleet->shipsGetTotal()) . (array_sum($fleet_resources) ? '+' : '')) : '?',
116
+    'AMOUNT'       => $spy_level >= 4 ? (pretty_number($objFleet->shipsGetTotal()).(array_sum($fleet_resources) ? '+' : '')) : '?',
117 117
 
118 118
     'METAL'     => $spy_level >= 8 ? $fleet_resources[RES_METAL] : 0,
119 119
     'CRYSTAL'   => $spy_level >= 8 ? $fleet_resources[RES_CRYSTAL] : 0,
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
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) : '',
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
 
154 154
   $ship_id = 0;
155 155
   $result['ships'] = array();
156
-  if($spy_level >= 6) {
157
-    foreach($objFleet->shipsIterator() as $ship_sn_id => $ship) {
158
-      if($spy_level >= 10) {
156
+  if ($spy_level >= 6) {
157
+    foreach ($objFleet->shipsIterator() as $ship_sn_id => $ship) {
158
+      if ($spy_level >= 10) {
159 159
         $single_ship_data = get_ship_data($ship_sn_id, $user_data);
160 160
         $result['ships'][$ship_sn_id] = array(
161 161
           'ID'          => $ship_sn_id,
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 function tpl_parse_planet_que($que, $planet, $que_id) {
189 189
   $hangar_que = array();
190 190
   $que_hangar = $que['ques'][$que_id][$planet['id_owner']][$planet['id']];
191
-  if(!empty($que_hangar)) {
192
-    foreach($que_hangar as $que_item) {
191
+  if (!empty($que_hangar)) {
192
+    foreach ($que_hangar as $que_item) {
193 193
       $hangar_que['que'][] = array('id' => $que_item['que_unit_id'], 'count' => $que_item['que_unit_amount']);
194 194
       $hangar_que[$que_item['que_unit_id']] += $que_item['que_unit_amount'];
195 195
     }
@@ -249,10 +249,10 @@  discard block
 block discarded – undo
249 249
     'PLANET_GOVERNOR_LEVEL_MAX' => get_unit_param($planet['PLANET_GOVERNOR_ID'], P_MAX_STACK),
250 250
   );
251 251
 
252
-  if(!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) {
252
+  if (!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) {
253 253
     $result['building_que'] = array();
254 254
     $building_que = &$que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']];
255
-    foreach($building_que as $que_element) {
255
+    foreach ($building_que as $que_element) {
256 256
       $result['building_que'][] = que_tpl_parse_element($que_element);
257 257
     }
258 258
   }
@@ -271,19 +271,19 @@  discard block
 block discarded – undo
271 271
   static $snGroupFleet;
272 272
   !$snGroupFleet ? $snGroupFleet = Fleet::$snGroupFleet : false;
273 273
 
274
-  if(empty($array_of_Fleet)) {
274
+  if (empty($array_of_Fleet)) {
275 275
     return false;
276 276
   }
277 277
 
278 278
   $fleet_list = array();
279
-  foreach($array_of_Fleet as $fleet) {
280
-    if($fleet->playerOwnerId == $user['id']) {
281
-      if($fleet->mission_type == MT_MISSILE) {
279
+  foreach ($array_of_Fleet as $fleet) {
280
+    if ($fleet->playerOwnerId == $user['id']) {
281
+      if ($fleet->mission_type == MT_MISSILE) {
282 282
         continue;
283 283
       }
284 284
       $fleet_ownage = 'own';
285 285
     } else {
286
-      switch($fleet->mission_type) {
286
+      switch ($fleet->mission_type) {
287 287
         case MT_ATTACK:
288 288
         case MT_ACS:
289 289
         case MT_DESTROY:
@@ -300,9 +300,9 @@  discard block
 block discarded – undo
300 300
 
301 301
     $fleet_list[$fleet_ownage]['fleets'][$fleet->dbId] = $fleet;
302 302
 
303
-    if($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) {
304
-      foreach($fleet->shipsIterator() as $ship_id => $ship) {
305
-        if(!empty($snGroupFleet[$ship_id])) {
303
+    if ($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) {
304
+      foreach ($fleet->shipsIterator() as $ship_id => $ship) {
305
+        if (!empty($snGroupFleet[$ship_id])) {
306 306
           $fleet_list[$fleet_ownage]['total'][$ship_id] += $ship->count;
307 307
         }
308 308
       }
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
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
 
Please login to merge, or discard this patch.
includes/includes/flt_functions.php 1 patch
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
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, Fleet::$snGroupFleetAndMissiles)) {
9
+  if (!empty($fleet)) {
10
+    foreach ($fleet as $ship_id => $amount) {
11
+      if ($amount && in_array($ship_id, Fleet::$snGroupFleetAndMissiles)) {
12 12
         $single_ship_data = get_ship_data($ship_id, $user);
13 13
         $speeds[] = $single_ship_data['speed'];
14 14
       }
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
 
41 41
   $game_fleet_speed = flt_server_flight_speed_multiplier();
42 42
   $fleet_speed = flt_fleet_speed($user_row, $fleet_array);
43
-  if(!empty($fleet_array) && $fleet_speed && $game_fleet_speed) {
43
+  if (!empty($fleet_array) && $fleet_speed && $game_fleet_speed) {
44 44
     $speed_percent = $speed_percent ? max(min($speed_percent, 10), 1) : 10;
45 45
     $real_speed = $speed_percent * sqrt($fleet_speed);
46 46
 
47 47
     $duration = max(1, round((35000 / $speed_percent * sqrt($distance * 10 / $fleet_speed) + 10) / $game_fleet_speed));
48 48
 
49
-    foreach($fleet_array as $ship_id => $ship_count) {
50
-      if(!$ship_id || !$ship_count) {
49
+    foreach ($fleet_array as $ship_id => $ship_count) {
50
+      if (!$ship_id || !$ship_count) {
51 51
         continue;
52 52
       }
53 53
 
@@ -75,19 +75,19 @@  discard block
 block discarded – undo
75 75
 function flt_bashing_check($user, $enemy, $planet_dst, $mission, $flight_duration, $fleet_group = 0) {
76 76
   $config_bashing_attacks = classSupernova::$config->fleet_bashing_attacks;
77 77
   $config_bashing_interval = classSupernova::$config->fleet_bashing_interval;
78
-  if(!$config_bashing_attacks) {
78
+  if (!$config_bashing_attacks) {
79 79
     // Bashing allowed - protection disabled
80 80
     return FLIGHT_ALLOWED;
81 81
   }
82 82
 
83 83
   $bashing_result = FLIGHT_MISSION_ATTACK_BASHING;
84
-  if($user['ally_id'] && $enemy['ally_id']) {
84
+  if ($user['ally_id'] && $enemy['ally_id']) {
85 85
     $relations = ali_relations($user['ally_id'], $enemy['ally_id']);
86
-    if(!empty($relations)) {
86
+    if (!empty($relations)) {
87 87
       $relations = $relations[$enemy['ally_id']];
88
-      switch($relations['alliance_diplomacy_relation']) {
88
+      switch ($relations['alliance_diplomacy_relation']) {
89 89
         case ALLY_DIPLOMACY_WAR:
90
-          if(SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) {
90
+          if (SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) {
91 91
             $bashing_result = FLIGHT_MISSION_ATTACK_BASHING_WAR_DELAY;
92 92
           } else {
93 93
             return FLIGHT_ALLOWED;
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
 
110 110
   // Retrieving flying fleets
111 111
   $objFleetsBashing = FleetList::dbGetFleetListBashing($user['id'], $planet_dst);
112
-  foreach($objFleetsBashing->_container as $fleetBashing) {
112
+  foreach ($objFleetsBashing->_container as $fleetBashing) {
113 113
     // Checking for ACS - each ACS count only once
114
-    if($fleetBashing->group_id) {
114
+    if ($fleetBashing->group_id) {
115 115
       $bashing_list["{$user['id']}_{$fleetBashing->group_id}"] = $fleetBashing->time_arrive_to_target;
116 116
     } else {
117 117
       $bashing_list[] = $fleetBashing->time_arrive_to_target;
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
   }
120 120
 
121 121
   // Check for joining to ACS - if there are already fleets in ACS no checks should be done
122
-  if($mission == MT_ACS && $bashing_list["{$user['id']}_{$fleet_group}"]) {
122
+  if ($mission == MT_ACS && $bashing_list["{$user['id']}_{$fleet_group}"]) {
123 123
     return FLIGHT_ALLOWED;
124 124
   }
125 125
 
126 126
   $query = DBStaticFleetBashing::db_bashing_list_get($user, $planet_dst, $time_limit);
127
-  while($bashing_row = db_fetch($query)) {
127
+  while ($bashing_row = db_fetch($query)) {
128 128
     $bashing_list[] = $bashing_row['bashing_time'];
129 129
   }
130 130
 
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
   $last_attack = 0;
134 134
   $wave = 0;
135 135
   $attack = 1;
136
-  foreach($bashing_list as &$bash_time) {
136
+  foreach ($bashing_list as &$bash_time) {
137 137
     $attack++;
138
-    if($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) {
138
+    if ($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) {
139 139
       $attack = 1;
140 140
       $wave++;
141 141
     }
@@ -152,16 +152,16 @@  discard block
 block discarded – undo
152 152
   //TODO: try..catch
153 153
   global $user;
154 154
 
155
-  if($user['vacation']) {
155
+  if ($user['vacation']) {
156 156
     return $result = FLIGHT_PLAYER_VACATION_OWN;
157 157
   }
158 158
 
159
-  if(empty($fleet) || !is_array($fleet)) {
159
+  if (empty($fleet) || !is_array($fleet)) {
160 160
     return $result = FLIGHT_SHIPS_NO_SHIPS;
161 161
   }
162 162
 
163 163
   $sn_groups_mission = sn_get_groups('missions');
164
-  if(!isset($sn_groups_mission[$mission])) {
164
+  if (!isset($sn_groups_mission[$mission])) {
165 165
     return $result = FLIGHT_MISSION_UNKNOWN;
166 166
   }
167 167
   $sn_data_mission = $sn_groups_mission[$mission];
@@ -180,32 +180,32 @@  discard block
 block discarded – undo
180 180
   $resources = 0;
181 181
   $ship_ids = Fleet::$snGroupFleet;
182 182
   $resource_ids = sn_get_groups('resources_loot');
183
-  foreach($fleet as $ship_id => $ship_count) {
183
+  foreach ($fleet as $ship_id => $ship_count) {
184 184
     $is_ship = in_array($ship_id, $ship_ids);
185 185
     $is_resource = in_array($ship_id, $resource_ids);
186
-    if(!$is_ship && !$is_resource) {
186
+    if (!$is_ship && !$is_resource) {
187 187
       // TODO Спецобработчик для Капитана и модулей
188 188
 //      return FLIGHT_SHIPS_UNIT_WRONG;
189 189
     }
190 190
 
191
-    if($ship_count < 0) {
191
+    if ($ship_count < 0) {
192 192
       return $result = $is_ship ? FLIGHT_SHIPS_NEGATIVE : FLIGHT_RESOURCES_NEGATIVE;
193 193
     }
194 194
 
195
-    if($ship_count > mrc_get_level($user, $planet_src, $ship_id)) {
195
+    if ($ship_count > mrc_get_level($user, $planet_src, $ship_id)) {
196 196
       // TODO FLIGHT_MISSION_MISSILE_NO_MISSILES
197 197
       return $result = $is_ship ? FLIGHT_SHIPS_NOT_ENOUGH_OR_RESOURCES : FLIGHT_RESOURCES_NOT_ENOUGH;
198 198
     }
199 199
 
200
-    if($is_ship) {
200
+    if ($is_ship) {
201 201
       $single_ship_data = get_ship_data($ship_id, $user);
202
-      if($single_ship_data[P_SPEED] <= 0) {
202
+      if ($single_ship_data[P_SPEED] <= 0) {
203 203
         return $result = FLIGHT_SHIPS_UNMOVABLE;
204 204
       }
205 205
       $ships += $ship_count;
206 206
       $recyclers += in_array($ship_id, Fleet::$snGroupRecyclers) ? $ship_count : 0;
207 207
       $spies += $ship_id == SHIP_SPY ? $ship_count : 0;
208
-    } elseif($is_resource) {
208
+    } elseif ($is_resource) {
209 209
       $resources += $ship_count;
210 210
     }
211 211
   }
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
     }
217 217
   */
218 218
 
219
-  if(isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) {
219
+  if (isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) {
220 220
     return $result = FLIGHT_RESOURCES_FORBIDDEN;
221 221
   }
222 222
 
@@ -228,78 +228,78 @@  discard block
 block discarded – undo
228 228
   */
229 229
 
230 230
   $speed = $options['fleet_speed_percent'];
231
-  if($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) {
231
+  if ($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) {
232 232
     return $result = FLIGHT_FLEET_SPEED_WRONG;
233 233
   }
234 234
 
235 235
   $travel_data = flt_travel_data($user, $planet_src, $planet_dst, $fleet, $options['fleet_speed_percent']);
236 236
 
237 237
 
238
-  if(mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) {
238
+  if (mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) {
239 239
     return $result = FLIGHT_RESOURCES_FUEL_NOT_ENOUGH;
240 240
   }
241 241
 
242
-  if($travel_data['consumption'] > $travel_data['capacity']) {
242
+  if ($travel_data['consumption'] > $travel_data['capacity']) {
243 243
     return $result = FLIGHT_FLEET_TOO_FAR;
244 244
   }
245 245
 
246
-  if($travel_data['hold'] < $resources) {
246
+  if ($travel_data['hold'] < $resources) {
247 247
     return $result = FLIGHT_FLEET_OVERLOAD;
248 248
   }
249 249
 
250 250
   $fleet_start_time = SN_TIME_NOW + $travel_data['duration'];
251 251
 
252 252
   $fleet_group = $options['fleet_group'];
253
-  if($fleet_group) {
254
-    if($mission != MT_ACS) {
253
+  if ($fleet_group) {
254
+    if ($mission != MT_ACS) {
255 255
       return $result = FLIGHT_MISSION_IMPOSSIBLE;
256 256
     };
257 257
 
258 258
     $acs = DBStaticFleetACS::db_acs_get_by_group_id($fleet_group);
259
-    if(!$acs['id']) {
259
+    if (!$acs['id']) {
260 260
       return $result = FLIGHT_MISSION_ACS_NOT_EXISTS;
261 261
     }
262 262
 
263
-    if($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) {
263
+    if ($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) {
264 264
       return $result = FLIGHT_MISSION_ACS_WRONG_TARGET;
265 265
     }
266 266
 
267
-    if($fleet_start_time > $acs['ankunft']) {
267
+    if ($fleet_start_time > $acs['ankunft']) {
268 268
       return $result = FLIGHT_MISSION_ACS_TOO_LATE;
269 269
     }
270 270
   }
271 271
 
272 272
   $flying_fleets = $options['flying_fleets'];
273
-  if(!$flying_fleets) {
273
+  if (!$flying_fleets) {
274 274
     $flying_fleets = FleetList::fleet_count_flying($user['id']);
275 275
   }
276
-  if(GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) {
276
+  if (GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) {
277 277
     return $result = FLIGHT_FLEET_NO_SLOTS;
278 278
   }
279 279
 
280 280
   // В одиночку шпионские зонды могут летать только в миссии Шпионаж, Передислокация и Транспорт
281
-  if($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) {
281
+  if ($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) {
282 282
     return $result = FLIGHT_SHIPS_NOT_ONLY_SPIES;
283 283
   }
284 284
 
285 285
   // Checking for no planet
286
-  if(!$planet_dst['id_owner']) {
287
-    if($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) {
286
+  if (!$planet_dst['id_owner']) {
287
+    if ($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) {
288 288
       return $result = FLIGHT_SHIPS_NO_COLONIZER;
289 289
     }
290 290
 
291
-    if($mission == MT_EXPLORE || $mission == MT_COLONIZE) {
291
+    if ($mission == MT_EXPLORE || $mission == MT_COLONIZE) {
292 292
       return $result = FLIGHT_ALLOWED;
293 293
     }
294 294
 
295 295
     return $result = FLIGHT_VECTOR_NO_TARGET;
296 296
   }
297 297
 
298
-  if($mission == MT_RECYCLE) {
299
-    if($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) {
298
+  if ($mission == MT_RECYCLE) {
299
+    if ($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) {
300 300
       return $result = FLIGHT_MISSION_RECYCLE_NO_DEBRIS;
301 301
     }
302
-    if($recyclers <= 0) {
302
+    if ($recyclers <= 0) {
303 303
       return $result = FLIGHT_SHIPS_NO_RECYCLERS;
304 304
     }
305 305
 
@@ -307,8 +307,8 @@  discard block
 block discarded – undo
307 307
   }
308 308
 
309 309
   // Got planet. Checking if it is ours
310
-  if($planet_dst['id_owner'] == $user['id']) {
311
-    if($mission == MT_TRANSPORT || $mission == MT_RELOCATE) {
310
+  if ($planet_dst['id_owner'] == $user['id']) {
311
+    if ($mission == MT_TRANSPORT || $mission == MT_RELOCATE) {
312 312
       return $result = FLIGHT_ALLOWED;
313 313
     }
314 314
 
@@ -316,19 +316,19 @@  discard block
 block discarded – undo
316 316
   }
317 317
 
318 318
   // No, planet not ours. Cutting mission that can't be send to not-ours planet
319
-  if($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) {
319
+  if ($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) {
320 320
     return $result = FLIGHT_MISSION_IMPOSSIBLE;
321 321
   }
322 322
 
323 323
   $enemy = DBStaticUser::db_user_by_id($planet_dst['id_owner']);
324 324
   // We cannot attack or send resource to users in VACATION mode
325
-  if($enemy['vacation'] && $mission != MT_RECYCLE) {
325
+  if ($enemy['vacation'] && $mission != MT_RECYCLE) {
326 326
     return $result = FLIGHT_PLAYER_VACATION;
327 327
   }
328 328
 
329 329
   // Multi IP protection
330 330
   // TODO: Here we need a procedure to check proxies
331
-  if(sys_is_multiaccount($user, $enemy)) {
331
+  if (sys_is_multiaccount($user, $enemy)) {
332 332
     return $result = FLIGHT_PLAYER_SAME_IP;
333 333
   }
334 334
 
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
   $enemy_points = $enemy['total_points'];
337 337
 
338 338
   // Is it transport? If yes - checking for buffing to prevent mega-alliance destroyer
339
-  if($mission == MT_TRANSPORT) {
340
-    if($user_points >= $enemy_points || classSupernova::$config->allow_buffing) {
339
+  if ($mission == MT_TRANSPORT) {
340
+    if ($user_points >= $enemy_points || classSupernova::$config->allow_buffing) {
341 341
       return $result = FLIGHT_ALLOWED;
342 342
     } else {
343 343
       return $result = FLIGHT_PLAYER_BUFFING;
@@ -347,66 +347,66 @@  discard block
 block discarded – undo
347 347
   // Only aggresive missions passed to this point. HOLD counts as passive but aggresive
348 348
 
349 349
   // Is it admin with planet protection?
350
-  if($planet_dst['id_level'] > $user['authlevel']) {
350
+  if ($planet_dst['id_level'] > $user['authlevel']) {
351 351
     return $result = FLIGHT_PLAYER_ADMIN;
352 352
   }
353 353
 
354 354
   // Okay. Now skipping protection checks for inactive longer then 1 week
355
-  if(!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) {
356
-    if(
355
+  if (!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) {
356
+    if (
357 357
       ($enemy_points <= classSupernova::$config->game_noob_points && $user_points > classSupernova::$config->game_noob_points)
358 358
       ||
359 359
       (classSupernova::$config->game_noob_factor && $user_points > $enemy_points * classSupernova::$config->game_noob_factor)
360 360
     ) {
361
-      if($mission != MT_HOLD) {
361
+      if ($mission != MT_HOLD) {
362 362
         return $result = FLIGHT_PLAYER_NOOB;
363 363
       }
364
-      if($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) {
364
+      if ($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) {
365 365
         return $result = FLIGHT_PLAYER_NOOB;
366 366
       }
367 367
     }
368 368
   }
369 369
 
370 370
   // Is it HOLD mission? If yes - there should be ally deposit
371
-  if($mission == MT_HOLD) {
372
-    if(mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) {
371
+  if ($mission == MT_HOLD) {
372
+    if (mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) {
373 373
       return $result = FLIGHT_ALLOWED;
374 374
     }
375 375
 
376 376
     return $result = FLIGHT_MISSION_HOLD_NO_ALLY_DEPOSIT;
377 377
   }
378 378
 
379
-  if($mission == MT_SPY) {
379
+  if ($mission == MT_SPY) {
380 380
     return $result = $spies >= 1 ? FLIGHT_ALLOWED : FLIGHT_MISSION_SPY_NO_SPIES;
381 381
   }
382 382
 
383 383
   // Is it MISSILE mission?
384
-  if($mission == MT_MISSILE) {
384
+  if ($mission == MT_MISSILE) {
385 385
     $sn_data_mip = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET);
386
-    if(mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) {
386
+    if (mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) {
387 387
       return $result = FLIGHT_MISSION_MISSILE_NO_SILO;
388 388
     }
389 389
 
390
-    if(!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) {
390
+    if (!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) {
391 391
       return $result = FLIGHT_MISSION_MISSILE_NO_MISSILES;
392 392
     }
393 393
 
394 394
     $distance = abs($planet_dst['system'] - $planet_src['system']);
395 395
     $mip_range = flt_get_missile_range($user);
396
-    if($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) {
396
+    if ($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) {
397 397
       return $result = FLIGHT_MISSION_MISSILE_TOO_FAR;
398 398
     }
399 399
 
400
-    if(isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) {
400
+    if (isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) {
401 401
       return $result = FLIGHT_MISSION_MISSILE_WRONG_STRUCTURE;
402 402
     }
403 403
   }
404 404
 
405
-  if($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) {
405
+  if ($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) {
406 406
     return $result = FLIGHT_MISSION_IMPOSSIBLE;
407 407
   }
408 408
 
409
-  if($mission == MT_ATTACK || $mission == MT_ACS || $mission == MT_DESTROY) {
409
+  if ($mission == MT_ATTACK || $mission == MT_ACS || $mission == MT_DESTROY) {
410 410
     return $result = flt_bashing_check($user, $enemy, $planet_dst, $mission, $travel_data['duration'], $fleet_group);
411 411
   }
412 412
 
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
   $from = $from['planet'];
434 434
 
435 435
   $can_attack = flt_can_attack($from, $to, $fleet_REAL_array, $mission, $options);
436
-  if($can_attack != FLIGHT_ALLOWED) {
436
+  if ($can_attack != FLIGHT_ALLOWED) {
437 437
     $internal_transaction ? sn_db_transaction_rollback() : false;
438 438
 
439 439
     return $can_attack;
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
   $travel_data = flt_travel_data($user, $from, $to, $fleet_REAL_array, $options['fleet_speed_percent']);
445 445
 
446 446
   $time_on_mission = 0;
447
-  if($mission == MT_EXPLORE || $mission == MT_HOLD) {
447
+  if ($mission == MT_EXPLORE || $mission == MT_HOLD) {
448 448
     // TODO - include some checks about maximum and minumum stay_duration
449 449
     $time_on_mission = $options['stay_time'] * 3600;
450 450
   }
@@ -467,14 +467,14 @@  discard block
 block discarded – undo
467 467
   $sn_group_resources_loot = sn_get_groups('resources_loot');
468 468
   $db_changeset = array();
469 469
   $planet_row_changed_fields = array();
470
-  foreach($fleet_REAL_array as $unit_id => $amount) {
471
-    if(!$amount || !$unit_id) {
470
+  foreach ($fleet_REAL_array as $unit_id => $amount) {
471
+    if (!$amount || !$unit_id) {
472 472
       continue;
473 473
     }
474 474
 
475
-    if(in_array($unit_id, $sn_group_fleet)) {
475
+    if (in_array($unit_id, $sn_group_fleet)) {
476 476
       $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, -$amount, $user, $from['id']);
477
-    } elseif(in_array($unit_id, $sn_group_resources_loot)) {
477
+    } elseif (in_array($unit_id, $sn_group_resources_loot)) {
478 478
       $planet_row_changed_fields[pname_resource_name($unit_id)]['delta'] -= $amount;
479 479
     }
480 480
   }
@@ -513,16 +513,16 @@  discard block
 block discarded – undo
513 513
 
514 514
   $ship_data = array();
515 515
   $fleet_array = array();
516
-  foreach($ship_list as $transport_id => $cork) {
516
+  foreach ($ship_list as $transport_id => $cork) {
517 517
     $ship_data[$transport_id] = flt_travel_data($user, $from, $to, array($transport_id => 1), 10);
518 518
   }
519 519
   uasort($ship_data, 'flt_calculate_ship_to_transport_sort');
520 520
 
521 521
   $fleet_capacity = 0;
522 522
   $fuel_total = $fuel_left = mrc_get_level($user, $from, RES_DEUTERIUM);
523
-  foreach($ship_data as $transport_id => &$ship_info) {
523
+  foreach ($ship_data as $transport_id => &$ship_info) {
524 524
     $ship_loaded = min($ship_list[$transport_id], ceil($resource_amount / $ship_info['hold']), floor($fuel_left / $ship_info['consumption']));
525
-    if($ship_loaded) {
525
+    if ($ship_loaded) {
526 526
       $fleet_array[$transport_id] = $ship_loaded;
527 527
       $resource_amount -= min($resource_amount, $ship_info['hold'] * $ship_loaded);
528 528
       $fuel_left -= $ship_info['consumption'] * $ship_loaded;
Please login to merge, or discard this patch.