Completed
Push — work-fleets ( cb2521...9eb2f3 )
by SuperNova.WS
08:26
created
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/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.
includes/includes/flt_mission_explore.php 1 patch
Spacing   +33 added lines, -34 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
   // TODO - Currently $ship_data is one for all players
22 22
   static $shipCostInMetalPerPiece, $rates;
23 23
 
24
-  if(empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) {
24
+  if (empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) {
25 25
     return CACHE_NONE;
26 26
   }
27 27
 
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
   $outcome_value = &$result['$outcome_value'];
47 47
   $outcome_list = &$result['$outcome_list'];
48 48
 
49
-  if(!$shipCostInMetalPerPiece) {
49
+  if (!$shipCostInMetalPerPiece) {
50 50
     $rates = get_resource_exchange();
51 51
 
52
-    foreach(Fleet::$snGroupFleet as $unit_id) {
52
+    foreach (Fleet::$snGroupFleet as $unit_id) {
53 53
       $unit_info = get_unit_param($unit_id);
54
-      if($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) {
54
+      if ($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) {
55 55
         continue;
56 56
       }
57 57
       $shipCostInMetalPerPiece[$unit_id] = get_unit_cost_in($unit_info[P_COST], RES_METAL);
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
   $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1 / 1.7));
72 72
 
73 73
   $chance_max = 0;
74
-  foreach($outcome_list as $key => &$value) {
75
-    if(!$value['chance']) {
74
+  foreach ($outcome_list as $key => &$value) {
75
+    if (!$value['chance']) {
76 76
       unset($outcome_list[$key]);
77 77
       continue;
78 78
     }
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
   }
81 81
   $outcome_value = mt_rand(0, $chance_max);
82 82
   $outcome_description = &$outcome_list[$mission_outcome = FLT_EXPEDITION_OUTCOME_NONE];
83
-  foreach($outcome_list as $key => &$value) {
84
-    if(!$value['chance']) {
83
+  foreach ($outcome_list as $key => &$value) {
84
+    if (!$value['chance']) {
85 85
       continue;
86 86
     }
87 87
     $mission_outcome = $key;
88 88
     $outcome_description = $value;
89
-    if($outcome_value <= $outcome_description['value']) {
89
+    if ($outcome_value <= $outcome_description['value']) {
90 90
       break;
91 91
     }
92 92
   }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 //  $outcome_mission_sub = -1;
104 104
 
105 105
   $fleet_found = array();
106
-  switch($mission_outcome) {
106
+  switch ($mission_outcome) {
107 107
     case FLT_EXPEDITION_OUTCOME_LOST_FLEET:
108 108
       $objFleet->shipsCountApplyLossMultiplier(mt_rand(1, 3) * mt_rand(200000, 300000) / 1000000);
109 109
     break;
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 
125 125
       // Ограничиваем корабли только теми, чья стоимость в металле меньше или равно стоимости самого дорогого корабля
126 126
       $can_be_found = array();
127
-      foreach($shipCostInMetalPerPiece as $ship_id => $shipMetalCost) {
128
-        if($shipMetalCost < $max_metal_cost) {
127
+      foreach ($shipCostInMetalPerPiece as $ship_id => $shipMetalCost) {
128
+        if ($shipMetalCost < $max_metal_cost) {
129 129
           $can_be_found[$ship_id] = $shipMetalCost;
130 130
         }
131 131
       }
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
       unset($can_be_found[SHIP_COLONIZER]);
134 134
       unset($can_be_found[SHIP_SPY]);
135 135
 
136
-      while(count($can_be_found) && $found_in_metal >= max($can_be_found)) {
136
+      while (count($can_be_found) && $found_in_metal >= max($can_be_found)) {
137 137
         $found_index = mt_rand(1, count($can_be_found)) - 1;
138 138
         $found_ship = array_slice($can_be_found, $found_index, 1, true);
139 139
         $found_ship_cost = reset($found_ship);
140 140
         $found_ship_id = key($found_ship);
141 141
 
142
-        if($found_ship_cost > $found_in_metal) {
142
+        if ($found_ship_cost > $found_in_metal) {
143 143
           unset($can_be_found[$found_ship_id]);
144 144
         } else {
145 145
           $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost));
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
         }
149 149
       }
150 150
 
151
-      if(empty($fleet_found)) {
151
+      if (empty($fleet_found)) {
152 152
         $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
153 153
       } else {
154
-        foreach($fleet_found as $unit_id => $unit_amount) {
154
+        foreach ($fleet_found as $unit_id => $unit_amount) {
155 155
           $objFleet->shipAdjustCount($unit_id, $unit_amount);
156 156
         }
157 157
       }
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 
176 176
       $objFleet->resourcesAdjust($resources_found);
177 177
 
178
-      if(array_sum($resources_found) == 0) {
178
+      if (array_sum($resources_found) == 0) {
179 179
         $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
180 180
       }
181 181
     break;
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
       // Рассчитываем количество найденной ТМ
187 187
       $found_dark_matter = floor(min($outcome_percent * $result['$fleet_metal_points'] / $rates[RES_DARK_MATTER], 10000) * mt_rand(750000, 1000000) / 1000000);
188 188
 
189
-      if(!$found_dark_matter) {
189
+      if (!$found_dark_matter) {
190 190
         $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
191 191
       }
192 192
     break;
@@ -200,46 +200,45 @@  discard block
 block discarded – undo
200 200
 
201 201
   mission_expedition_result_adjust($result, $objFleet);
202 202
 
203
-  if($found_dark_matter) {
203
+  if ($found_dark_matter) {
204 204
     rpg_points_change($objFleet->playerOwnerId, RPG_EXPEDITION, $found_dark_matter, 'Expedition Bonus');
205 205
     $msg_text_addon = sprintf(classLocale::$lang['flt_mission_expedition']['found_dark_matter'], $found_dark_matter);
206 206
   }
207 207
 
208
-  if(!empty($fleet_lost)) {
208
+  if (!empty($fleet_lost)) {
209 209
     $msg_text_addon = classLocale::$lang['flt_mission_expedition']['lost_fleet'];
210
-    foreach($fleet_lost as $ship_id => $ship_amount) {
211
-      $msg_text_addon .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n";
210
+    foreach ($fleet_lost as $ship_id => $ship_amount) {
211
+      $msg_text_addon .= classLocale::$lang['tech'][$ship_id].' - '.$ship_amount."\r\n";
212 212
     }
213 213
   }
214 214
 
215
-  if(!empty($fleet_found)) {
215
+  if (!empty($fleet_found)) {
216 216
     $msg_text_addon = classLocale::$lang['flt_mission_expedition']['found_fleet'];
217
-    foreach($fleet_found as $ship_id => $ship_amount) {
218
-      $msg_text_addon .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n";
217
+    foreach ($fleet_found as $ship_id => $ship_amount) {
218
+      $msg_text_addon .= classLocale::$lang['tech'][$ship_id].' - '.$ship_amount."\r\n";
219 219
     }
220 220
   }
221 221
 
222
-  if(!empty($resources_found) && array_sum($resources_found) > 0) {
222
+  if (!empty($resources_found) && array_sum($resources_found) > 0) {
223 223
     $msg_text_addon = classLocale::$lang['flt_mission_expedition']['found_resources'];
224
-    foreach($resources_found as $resource_id => $resource_amount) {
225
-      $msg_text_addon .= classLocale::$lang['tech'][$resource_id] . ' - ' . $resource_amount . "\r\n";
224
+    foreach ($resources_found as $resource_id => $resource_amount) {
225
+      $msg_text_addon .= classLocale::$lang['tech'][$resource_id].' - '.$resource_amount."\r\n";
226 226
     }
227 227
   }
228 228
 
229
-  if(!$msg_text) {
229
+  if (!$msg_text) {
230 230
     $messages = &classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['messages'];
231
-    if($outcome_mission_sub >= 0 && is_array($messages)) {
231
+    if ($outcome_mission_sub >= 0 && is_array($messages)) {
232 232
       $messages = &$messages[$outcome_mission_sub];
233 233
     }
234 234
 
235
-    $msg_text = is_string($messages) ? $messages :
236
-      (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : '');
235
+    $msg_text = is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : '');
237 236
   }
238 237
 
239 238
   $fleet_row_end_coordinates_without_type = $objFleet->target_coordinates_without_type();
240 239
 
241
-  $msg_text = sprintf($msg_text, $objFleet->dbId, uni_render_coordinates($fleet_row_end_coordinates_without_type)) .
242
-    ($msg_text_addon ? "\r\n" . $msg_text_addon : '');
240
+  $msg_text = sprintf($msg_text, $objFleet->dbId, uni_render_coordinates($fleet_row_end_coordinates_without_type)).
241
+    ($msg_text_addon ? "\r\n".$msg_text_addon : '');
243 242
 
244 243
   DBStaticMessages::msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_mission_job_complete, MSG_TYPE_EXPLORE, $msg_sender, $msg_title, $msg_text);
245 244
 
Please login to merge, or discard this patch.
includes/includes/sys_stat.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -39,23 +39,23 @@  discard block
 block discarded – undo
39 39
 
40 40
   $sta_update_msg = db_escape($sta_update_msg);
41 41
 
42
-  if($next_step) {
42
+  if ($next_step) {
43 43
     $sta_update_step++;
44 44
   }
45 45
   $sta_update_msg = "Update in progress. Step {$sta_update_step}/14: {$sta_update_msg}.";
46 46
 
47 47
   classSupernova::$config->db_saveItem('var_stat_update_msg', $sta_update_msg);
48
-  if($next_step) {
48
+  if ($next_step) {
49 49
     classSupernova::$debug->warning($sta_update_msg, 'Stat update', LOG_INFO_STAT_PROCESS);
50 50
   }
51 51
 }
52 52
 
53 53
 function sys_stat_calculate_flush(&$data, $force = false) {
54
-  if(count($data) < 25 && !$force) {
54
+  if (count($data) < 25 && !$force) {
55 55
     return;
56 56
   }
57 57
 
58
-  if(!empty($data)) {
58
+  if (!empty($data)) {
59 59
     doquery('REPLACE INTO {{statpoints}}
60 60
       (`id_owner`, `id_ally`, `stat_type`, `stat_code`, `tech_points`, `tech_count`, `build_points`, `build_count`,
61 61
        `defs_points`, `defs_count`, `fleet_points`, `fleet_count`, `res_points`, `res_count`, `total_points`,
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
   $user_list = DBStaticUser::db_user_list('', true, 'id, dark_matter, metal, crystal, deuterium, user_as_ally, ally_id');
96 96
   $row_num = count($user_list);
97 97
   // while($player = db_fetch($query))
98
-  foreach($user_list as $player) {
99
-    if($i++ % 100 == 0) {
98
+  foreach ($user_list as $player) {
99
+    if ($i++ % 100 == 0) {
100 100
       sta_set_time_limit("calculating players stats (player {$i}/{$row_num})", false);
101 101
     }
102
-    if(array_key_exists($user_id = $player['id'], $user_skip_list)) {
102
+    if (array_key_exists($user_id = $player['id'], $user_skip_list)) {
103 103
       continue;
104 104
     }
105 105
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     // $points[$user_id][UNIT_RESOURCES] += $resources;
110 110
 
111 111
     // А здесь мы фильтруем пользователей по $user_skip_list - далее не нужно этого делать, потому что
112
-    if(!isset($user_skip_list[$user_id])) {
112
+    if (!isset($user_skip_list[$user_id])) {
113 113
       $user_allies[$user_id] = $player['ally_id'];
114 114
     }
115 115
   }
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
   $i = 0;
124 124
   $query = DBStaticPlanet::db_planet_list_resources_by_owner();
125 125
   $row_num = db_num_rows($query);
126
-  while($planet = db_fetch($query)) {
127
-    if($i++ % 100 == 0) {
126
+  while ($planet = db_fetch($query)) {
127
+    if ($i++ % 100 == 0) {
128 128
       sta_set_time_limit("calculating planets stats (planet {$i}/{$row_num})", false);
129 129
     }
130
-    if(array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) {
130
+    if (array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) {
131 131
       continue;
132 132
     }
133 133
 
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
   $i = 0;
143 143
   $query = FleetList::dbQueryAllId();
144 144
   $row_num = db_num_rows($query);
145
-  while($fleet_row = db_fetch($query)) {
146
-    if($i++ % 100 == 0) {
145
+  while ($fleet_row = db_fetch($query)) {
146
+    if ($i++ % 100 == 0) {
147 147
       sta_set_time_limit("calculating flying fleets stats (fleet {$i}/{$row_num})", false);
148 148
     }
149 149
     $objFleet = new Fleet();
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
     // К тому же при включённом кэшировании это быстро забъёт кэш холодными данными
152 152
     // $objFleet->_reset();
153 153
     $objFleet->dbRowParse($fleet_row);
154
-    if(array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) {
154
+    if (array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) {
155 155
       continue;
156 156
     }
157 157
 
158
-    foreach($objFleet->shipsIterator() as $unit_id => $unit) {
158
+    foreach ($objFleet->shipsIterator() as $unit_id => $unit) {
159 159
       $counts[$user_id][UNIT_SHIPS] += $unit->count;
160 160
 
161
-      if(!isset($unit_cost_cache[$unit_id][0])) {
161
+      if (!isset($unit_cost_cache[$unit_id][0])) {
162 162
         $unit_cost_cache[$unit_id][0] = get_unit_param($unit_id, P_COST);
163 163
       }
164 164
       $unit_cost_data = &$unit_cost_cache[$unit_id][0];
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
   $i = 0;
179 179
   $query = DBStaticUnit::db_unit_list_stat_calculate();
180 180
   $row_num = db_num_rows($query);
181
-  while($unit = db_fetch($query)) {
182
-    if($i++ % 100 == 0) {
181
+  while ($unit = db_fetch($query)) {
182
+    if ($i++ % 100 == 0) {
183 183
       sta_set_time_limit("calculating unit stats (unit {$i}/{$row_num})", false);
184 184
     }
185
-    if(array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) {
185
+    if (array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) {
186 186
       continue;
187 187
     }
188 188
 
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
   $i = 0;
197 197
   $query = DBStaticQue::db_que_list_stat();
198 198
   $row_num = db_num_rows($query);
199
-  while($que_item = db_fetch($query)) {
200
-    if($i++ % 100 == 0) {
199
+  while ($que_item = db_fetch($query)) {
200
+    if ($i++ % 100 == 0) {
201 201
       sta_set_time_limit("calculating ques stats (que item {$i}/{$row_num})", false);
202 202
     }
203
-    if(array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) {
203
+    if (array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) {
204 204
       continue;
205 205
     }
206 206
     $que_unit_amount = $que_item['que_unit_amount'];
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
   sta_set_time_limit('posting new user stats to DB');
221 221
   $data = array();
222
-  foreach($user_allies as $user_id => $ally_id) {
222
+  foreach ($user_allies as $user_id => $ally_id) {
223 223
     // $counts[UNIT_RESOURCES] дублирует $points[UNIT_RESOURCES], поэтому $points не заполняем, а берем $counts и делим на 1000
224 224
     $points[$user_id][UNIT_RESOURCES] = $counts[$user_id][UNIT_RESOURCES] / 1000;
225 225
     $points[$user_id] = array_map('floor', $points[$user_id]);
@@ -231,10 +231,10 @@  discard block
 block discarded – undo
231 231
     $user_points = array_sum($points[$user_id]);
232 232
     $user_counts = array_sum($counts[$user_id]);
233 233
 
234
-    $data[] = $q = "({$user_id},{$ally_id},1,1,'{$points[$user_id][UNIT_TECHNOLOGIES]}','{$counts[$user_id][UNIT_TECHNOLOGIES]}'," .
235
-      "'{$points[$user_id][UNIT_STRUCTURES]}','{$counts[$user_id][UNIT_STRUCTURES]}','{$user_defence_points}','{$user_defence_counts}'," .
236
-      "'{$points[$user_id][UNIT_SHIPS]}','{$counts[$user_id][UNIT_SHIPS]}','{$points[$user_id][UNIT_RESOURCES]}','{$counts[$user_id][UNIT_RESOURCES]}'," .
237
-      "{$user_points},{$user_counts}," . SN_TIME_NOW . ")";
234
+    $data[] = $q = "({$user_id},{$ally_id},1,1,'{$points[$user_id][UNIT_TECHNOLOGIES]}','{$counts[$user_id][UNIT_TECHNOLOGIES]}',".
235
+      "'{$points[$user_id][UNIT_STRUCTURES]}','{$counts[$user_id][UNIT_STRUCTURES]}','{$user_defence_points}','{$user_defence_counts}',".
236
+      "'{$points[$user_id][UNIT_SHIPS]}','{$counts[$user_id][UNIT_SHIPS]}','{$points[$user_id][UNIT_RESOURCES]}','{$counts[$user_id][UNIT_RESOURCES]}',".
237
+      "{$user_points},{$user_counts},".SN_TIME_NOW.")";
238 238
 
239 239
     sys_stat_calculate_flush($data);
240 240
   }
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
         SUM(u.`tech_points`)+aus.`tech_points`, SUM(u.`tech_count`)+aus.`tech_count`, SUM(u.`build_points`)+aus.`build_points`, SUM(u.`build_count`)+aus.`build_count`,
255 255
         SUM(u.`defs_points`)+aus.`defs_points`, SUM(u.`defs_count`)+aus.`defs_count`, SUM(u.`fleet_points`)+aus.`fleet_points`, SUM(u.`fleet_count`)+aus.`fleet_count`,
256 256
         SUM(u.`res_points`)+aus.`res_points`, SUM(u.`res_count`)+aus.`res_count`, SUM(u.`total_points`)+aus.`total_points`, SUM(u.`total_count`)+aus.`total_count`,
257
-        " . SN_TIME_NOW . ", NULL, u.`id_ally`, 2, 1,
257
+        " . SN_TIME_NOW.", NULL, u.`id_ally`, 2, 1,
258 258
         a.tech_rank, a.build_rank, a.defs_rank, a.fleet_rank, a.res_rank, a.total_rank
259 259
       FROM {{statpoints}} AS u
260 260
         JOIN {{alliance}} AS al ON al.id = u.id_ally
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
   // Updating player's ranks
277 277
   sta_set_time_limit("updating ranks for players");
278
-  foreach($rankNames as $rankName) {
278
+  foreach ($rankNames as $rankName) {
279 279
     sta_set_time_limit("updating player rank '{$rankName}'", false);
280 280
     doquery($qryResetRowNum);
281 281
     doquery(sprintf($qryFormat, $rankName, 1));
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 
284 284
   sta_set_time_limit("updating ranks for Alliances");
285 285
   // --- Updating Allie's ranks
286
-  foreach($rankNames as $rankName) {
286
+  foreach ($rankNames as $rankName) {
287 287
     sta_set_time_limit("updating Alliances rank '{$rankName}'", false);
288 288
     doquery($qryResetRowNum);
289 289
     doquery(sprintf($qryFormat, $rankName, 2));
Please login to merge, or discard this patch.
galaxy.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * Galaxy view
7 7
  */
8 8
 
9
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
9
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
10 10
 
11 11
 lng_include('universe');
12 12
 lng_include('stat');
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 $uni_system = sys_get_param_int('system', $planetrow['system']);
17 17
 $planet = sys_get_param_int('planet', $planetrow['planet']);
18 18
 
19
-if($mode == 'name') {
19
+if ($mode == 'name') {
20 20
   require_once('includes/includes/uni_rename.php');
21 21
 }
22 22
 
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 
38 38
 $flying_fleet_count = FleetList::fleet_count_flying($user['id']);
39 39
 
40
-if($mode == 1) {
41
-} elseif($mode == 2 || $mode == 3) {
40
+if ($mode == 1) {
41
+} elseif ($mode == 2 || $mode == 3) {
42 42
   $planet = $planetrow['planet'];
43 43
 } else {
44 44
   $uni_galaxy = $planetrow['galaxy'];
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
   $planet = $planetrow['planet'];
47 47
 }
48 48
 
49
-$uni_galaxy = $uni_galaxy < 1 ? 1 : ($uni_galaxy > Vector::$knownGalaxies? Vector::$knownGalaxies: $uni_galaxy);
49
+$uni_galaxy = $uni_galaxy < 1 ? 1 : ($uni_galaxy > Vector::$knownGalaxies ? Vector::$knownGalaxies : $uni_galaxy);
50 50
 $uni_system = $uni_system < 1 ? 1 : ($uni_system > Vector::$knownSystems ? Vector::$knownSystems : $uni_system);
51 51
 $planet = $planet < 1 ? 1 : ($planet > Vector::$knownPlanets + 1 ? Vector::$knownPlanets + 1 : $planet);
52 52
 
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 $PhalanxRange = GetPhalanxRange($HavePhalanx);
65 65
 
66 66
 $planet_precache_query = DBStaticPlanet::db_planet_list_in_system($uni_galaxy, $uni_system);
67
-if(!empty($planet_precache_query)) {
68
-  foreach($planet_precache_query as $planet_row) {
67
+if (!empty($planet_precache_query)) {
68
+  foreach ($planet_precache_query as $planet_row) {
69 69
     $planet_list[$planet_row['planet']][$planet_row['planet_type']] = $planet_row;
70 70
   }
71 71
 }
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
  * @var Fleet[][][] $fleet_list
84 84
  */
85 85
 $fleet_list = array();
86
-foreach($system_fleet_list->_container as $objFleetSystem) {
87
-  if(!$objFleetSystem->isReturning()) {
86
+foreach ($system_fleet_list->_container as $objFleetSystem) {
87
+  if (!$objFleetSystem->isReturning()) {
88 88
     $fleet_planet = $objFleetSystem->fleet_end_planet;
89 89
     $fleet_type = $objFleetSystem->fleet_end_type;
90 90
   } else {
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 $recycler_info = array();
100 100
 $planet_recyclers_orbiting = 0;
101 101
 $recyclers_fleet = array();
102
-foreach(Fleet::$snGroupRecyclers as $recycler_id) {
102
+foreach (Fleet::$snGroupRecyclers as $recycler_id) {
103 103
   $recycler_info[$recycler_id] = get_ship_data($recycler_id, $user);
104 104
   $recyclers_fleet[$recycler_id] = mrc_get_level($user, $planetrow, $recycler_id);
105 105
   $planet_recyclers_orbiting += $recyclers_fleet[$recycler_id];
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 $fleet_id = 1;
110 110
 $fleets = array();
111 111
 $config_game_max_planet = Vector::$knownPlanets + 1;
112
-for($Planet = 1; $Planet < $config_game_max_planet; $Planet++) {
112
+for ($Planet = 1; $Planet < $config_game_max_planet; $Planet++) {
113 113
   unset($uni_galaxyRowPlanet);
114 114
   unset($uni_galaxyRowMoon);
115 115
   unset($uni_galaxyRowUser);
@@ -119,27 +119,27 @@  discard block
 block discarded – undo
119 119
   $uni_galaxyRowPlanet = $planet_list[$Planet][PT_PLANET];
120 120
 
121 121
   $planet_fleet_id = 0;
122
-  if($uni_galaxyRowPlanet['destruyed']) {
122
+  if ($uni_galaxyRowPlanet['destruyed']) {
123 123
     CheckAbandonPlanetState($uni_galaxyRowPlanet);
124
-  } elseif($uni_galaxyRowPlanet['id']) {
125
-    if($cached['users'][$uni_galaxyRowPlanet['id_owner']]) {
124
+  } elseif ($uni_galaxyRowPlanet['id']) {
125
+    if ($cached['users'][$uni_galaxyRowPlanet['id_owner']]) {
126 126
       $uni_galaxyRowUser = $cached['users'][$uni_galaxyRowPlanet['id_owner']];
127 127
     } else {
128 128
       $uni_galaxyRowUser = DBStaticUser::db_user_by_id($uni_galaxyRowPlanet['id_owner']);
129 129
       $cached['users'][$uni_galaxyRowUser['id']] = $uni_galaxyRowUser;
130 130
     }
131 131
 
132
-    if(!$uni_galaxyRowUser['id']) {
132
+    if (!$uni_galaxyRowUser['id']) {
133 133
       classSupernova::$debug->warning("Planet '{$uni_galaxyRowPlanet['name']}' [{$uni_galaxy}:{$uni_system}:{$Planet}] has no owner!", 'Userless planet', 503);
134 134
       $uni_galaxyRowPlanet['destruyed'] = SN_TIME_NOW + 60 * 60 * 24;
135 135
       $uni_galaxyRowPlanet['id_owner'] = 0;
136 136
       DBStaticPlanet::db_planet_set_by_id($uni_galaxyRowPlanet['id'], "id_owner = 0, destruyed = {$uni_galaxyRowPlanet['destruyed']}");
137 137
     }
138 138
 
139
-    if($uni_galaxyRowUser['id']) {
139
+    if ($uni_galaxyRowUser['id']) {
140 140
       $planetcount++;
141
-      if($uni_galaxyRowUser['ally_id']) {
142
-        if($cached['allies'][$uni_galaxyRowUser['ally_id']]) {
141
+      if ($uni_galaxyRowUser['ally_id']) {
142
+        if ($cached['allies'][$uni_galaxyRowUser['ally_id']]) {
143 143
           $allyquery = $cached['allies'][$uni_galaxyRowUser['ally_id']];
144 144
         } else {
145 145
           $allyquery = DBStaticAlly::db_ally_get_by_id($uni_galaxyRowUser['ally_id']);
@@ -148,19 +148,19 @@  discard block
 block discarded – undo
148 148
       }
149 149
 
150 150
       $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_PLANET]);
151
-      if(!empty($fleets_to_planet['own']['count'])) {
151
+      if (!empty($fleets_to_planet['own']['count'])) {
152 152
         $planet_fleet_id = $fleet_id;
153 153
         $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id);
154 154
         $fleet_id++;
155 155
       }
156 156
 
157 157
       $uni_galaxyRowMoon = $planet_list[$Planet][PT_MOON];
158
-      if($uni_galaxyRowMoon['destruyed']) {
158
+      if ($uni_galaxyRowMoon['destruyed']) {
159 159
         CheckAbandonPlanetState($uni_galaxyRowMoon);
160 160
       } else {
161 161
         $moon_fleet_id = 0;
162 162
         $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_MOON]);
163
-        if(!empty($fleets_to_planet['own']['count'])) {
163
+        if (!empty($fleets_to_planet['own']['count'])) {
164 164
           $moon_fleet_id = $fleet_id;
165 165
           $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id);
166 166
           $fleet_id++;
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
 
172 172
   $recyclers_incoming_capacity = 0;
173 173
   $uni_galaxyRowPlanet['debris'] = $uni_galaxyRowPlanet['debris_metal'] + $uni_galaxyRowPlanet['debris_crystal'];
174
-  if($uni_galaxyRowPlanet['debris']) {
175
-    if(!empty($fleet_list[$Planet][PT_DEBRIS])) {
176
-      foreach($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) {
177
-        if($objFleetToDebris->playerOwnerId == $user['id']) {
174
+  if ($uni_galaxyRowPlanet['debris']) {
175
+    if (!empty($fleet_list[$Planet][PT_DEBRIS])) {
176
+      foreach ($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) {
177
+        if ($objFleetToDebris->playerOwnerId == $user['id']) {
178 178
           $recyclers_incoming_capacity += $objFleetToDebris->shipsGetCapacityRecyclers($recycler_info);
179 179
         }
180 180
       }
@@ -251,21 +251,21 @@  discard block
 block discarded – undo
251 251
 
252 252
 tpl_assign_fleet($template, $fleets);
253 253
 
254
-foreach(sn_get_groups('defense_active') as $unit_id) {
254
+foreach (sn_get_groups('defense_active') as $unit_id) {
255 255
   $template->assign_block_vars('defense_active', array(
256 256
     'ID'   => $unit_id,
257 257
     'NAME' => classLocale::$lang['tech'][$unit_id],
258 258
   ));
259 259
 }
260 260
 
261
-foreach($cached['users'] as $PlanetUser) {
262
-  if(!$PlanetUser) {
261
+foreach ($cached['users'] as $PlanetUser) {
262
+  if (!$PlanetUser) {
263 263
     continue;
264 264
   }
265 265
 
266 266
   $user_ally = $cached['allies'][$PlanetUser['ally_id']];
267
-  if(isset($user_ally)) {
268
-    if($PlanetUser['id'] == $user_ally['ally_owner']) {
267
+  if (isset($user_ally)) {
268
+    if ($PlanetUser['id'] == $user_ally['ally_owner']) {
269 269
       $user_rank_title = $user_ally['ally_owner_range'];
270 270
     } else {
271 271
       $ally_ranks = explode(';', $user_ally['ranklist']);
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
   ));
289 289
 }
290 290
 
291
-foreach($cached['allies'] as $PlanetAlly) {
292
-  if($PlanetAlly) {
291
+foreach ($cached['allies'] as $PlanetAlly) {
292
+  if ($PlanetAlly) {
293 293
     $template->assign_block_vars('alliances', array(
294 294
       'ID'      => $PlanetAlly['id'],
295 295
       'NAME_JS' => js_safe_string($PlanetAlly['ally_name']),
Please login to merge, or discard this patch.
includes/functions/sys_bbcode.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -103,23 +103,23 @@
 block discarded – undo
103 103
 
104 104
   !empty(classSupernova::$config->url_faq) ? $msg = str_replace('faq://', classSupernova::$config->url_faq, $msg) : false;
105 105
 
106
-  foreach(classSupernova::$design['bbcodes'] as $auth_level => $replaces) {
107
-    if($auth_level > $author_auth) {
106
+  foreach (classSupernova::$design['bbcodes'] as $auth_level => $replaces) {
107
+    if ($auth_level > $author_auth) {
108 108
       continue;
109 109
     }
110 110
 
111
-    foreach($replaces as $key => $html) {
111
+    foreach ($replaces as $key => $html) {
112 112
       $msg = preg_replace(''.$key.'', $html, $msg);
113 113
     }
114 114
   }
115 115
 
116
-  foreach(classSupernova::$design['smiles'] as $auth_level => $replaces) {
117
-    if($auth_level > $author_auth) {
116
+  foreach (classSupernova::$design['smiles'] as $auth_level => $replaces) {
117
+    if ($auth_level > $author_auth) {
118 118
       continue;
119 119
     }
120 120
 
121
-    foreach($replaces as $key => $imgName) {
122
-      $msg = preg_replace("#" . addcslashes($key, '()[]{}') . "#isU","<img src=\"design/images/smileys/".$imgName.".gif\" align=\"absmiddle\" title=\"".$key."\" alt=\"".$key."\">",$msg);
121
+    foreach ($replaces as $key => $imgName) {
122
+      $msg = preg_replace("#".addcslashes($key, '()[]{}')."#isU", "<img src=\"design/images/smileys/".$imgName.".gif\" align=\"absmiddle\" title=\"".$key."\" alt=\"".$key."\">", $msg);
123 123
     }
124 124
   }
125 125
 
Please login to merge, or discard this patch.
admin/userlist.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 define('INSIDE', true);
13 13
 define('INSTALL', false);
14 14
 define('IN_ADMIN', true);
15
-require('../common.' . substr(strrchr(__FILE__, '.'), 1));
15
+require('../common.'.substr(strrchr(__FILE__, '.'), 1));
16 16
 
17 17
 global $user;
18
-if($user['authlevel'] < 3) {
18
+if ($user['authlevel'] < 3) {
19 19
   AdminMessage(classLocale::$lang['adm_err_denied']);
20 20
 }
21 21
 
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
 $sort = sys_get_param_int('sort', SORT_ID);
40 40
 $sort = $sort_fields[$sort] ? $sort : SORT_ID;
41 41
 
42
-if(($action = sys_get_param_int('action')) && ($user_id = sys_get_param_id('uid'))) {
42
+if (($action = sys_get_param_int('action')) && ($user_id = sys_get_param_id('uid'))) {
43 43
   $user_selected = DBStaticUser::db_user_by_id($user_id, false, 'id, username, authlevel');
44
-  if($user_selected['authlevel'] < $user['authlevel'] && $user['authlevel'] >= 3) {
45
-    switch($action) {
44
+  if ($user_selected['authlevel'] < $user['authlevel'] && $user['authlevel'] >= 3) {
45
+    switch ($action) {
46 46
       case ACTION_DELETE:
47 47
         DeleteSelectedUser($user_id);
48 48
         sys_redirect("{$_SERVER['SCRIPT_NAME']}?sort={$sort}");
@@ -62,20 +62,20 @@  discard block
 block discarded – undo
62 62
 $template = gettemplate('admin/userlist', true);
63 63
 
64 64
 $multi_ip = array();
65
-foreach(DBStaticUser::db_user_list_admin_multiaccounts() as $ip) {
65
+foreach (DBStaticUser::db_user_list_admin_multiaccounts() as $ip) {
66 66
   $multi_ip[$ip['user_lastip']] = $ip['ip_count'];
67 67
 }
68 68
 
69 69
 $geoip = geoip_status();
70 70
 $count = 0;
71
-foreach(DBStaticUser::db_user_list_admin_sorted($sort_fields[$sort], $is_players_online_page) as $user_row ) {
71
+foreach (DBStaticUser::db_user_list_admin_sorted($sort_fields[$sort], $is_players_online_page) as $user_row) {
72 72
   $count++;
73
-  if($user_row['banaday']) {
73
+  if ($user_row['banaday']) {
74 74
     $ban_details = db_ban_list_get_details($user_row);
75 75
   }
76 76
 
77 77
   $geoip_info = $geoip ? geoip_ip_info(ip2longu($user_row['user_lastip'])) : array();
78
-  foreach($geoip_info as $key => $value) {
78
+  foreach ($geoip_info as $key => $value) {
79 79
     $geoip_info[strtoupper($key)] = $value;
80 80
     unset($geoip_info[$key]);
81 81
   }
Please login to merge, or discard this patch.
includes/vars/vars_mission_checks.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
   'checkSpeedPercentOld'       => FLIGHT_FLEET_SPEED_WRONG,
11 11
   'checkTargetInUniverse'      => FLIGHT_VECTOR_BEYOND_UNIVERSE,
12 12
   'checkTargetNotSource'       => FLIGHT_VECTOR_SAME_SOURCE,
13
-  'checkSenderNoVacation'      => FLIGHT_PLAYER_VACATION_OWN,  // tODO
13
+  'checkSenderNoVacation'      => FLIGHT_PLAYER_VACATION_OWN, // tODO
14 14
   'checkTargetNoVacation'      => FLIGHT_PLAYER_VACATION,
15 15
   'checkFleetNotEmpty'         => FLIGHT_SHIPS_NO_SHIPS,
16 16
   // 'checkUnitsPositive'         => FLIGHT_SHIPS_NEGATIVE, // Unused - 'cause it's not allowed to put negative units into Unit class
Please login to merge, or discard this patch.