Completed
Branch trunk (78000f)
by SuperNova.WS
25:55 queued 09:00
created
includes/functions/uni_functions.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
 
8 8
   $possible_cores = array();
9 9
   $probability = 0;
10
-  foreach($density_list as $possible_core_id => $core_data) {
11
-    if(!$core_data[UNIT_PLANET_DENSITY_RARITY]) {
10
+  foreach ($density_list as $possible_core_id => $core_data) {
11
+    if (!$core_data[UNIT_PLANET_DENSITY_RARITY]) {
12 12
       continue;
13 13
     }
14 14
 
15
-    if(
15
+    if (
16 16
       // Core type exists
17 17
       in_array($possible_core_id, $position_data['core_types'])
18 18
       // Limit core type with planet sector count
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 
34 34
   $random = mt_rand(1, $probability);
35 35
   $selected_core = null;
36
-  foreach($possible_cores as $core_type => $core_info) {
37
-    if($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) {
36
+  foreach ($possible_cores as $core_type => $core_info) {
37
+    if ($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) {
38 38
       $selected_core = $core_info;
39 39
       break;
40 40
     }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
   $Position = intval($Position);
61 61
 
62
-  if(!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) {
62
+  if (!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) {
63 63
     return false;
64 64
   }
65 65
 
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 
69 69
   $planet_generator = sn_get_groups('planet_generator');
70 70
 
71
-  if($HomeWorld) {
71
+  if ($HomeWorld) {
72 72
     $position_data = $planet_generator[0];
73 73
   } else {
74 74
     $position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position];
75
-    if($Position >= UNIVERSE_RANDOM_PLANET_START) {
75
+    if ($Position >= UNIVERSE_RANDOM_PLANET_START) {
76 76
       // Корректируем температуру для планеты-странника
77 77
       $position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START);
78 78
     }
@@ -172,15 +172,15 @@  discard block
 block discarded – undo
172 172
   $moon_name = '';
173 173
   $moon_row = array();
174 174
   $moon = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_MOON, false, 'id');
175
-  if(!$moon['id']) {
175
+  if (!$moon['id']) {
176 176
     $moon_planet = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_PLANET, true, '`id`, `temp_min`, `temp_max`, `name`, `debris_metal`, `debris_crystal`');
177 177
 
178
-    if($moon_planet['id']) {
178
+    if ($moon_planet['id']) {
179 179
       $base_storage_size = BASE_STORAGE_SIZE;
180 180
 
181
-      if(!$moon_chance) {
181
+      if (!$moon_chance) {
182 182
         $size = mt_rand(1100, 8999);
183
-      } elseif($moon_chance <= 100) {
183
+      } elseif ($moon_chance <= 100) {
184 184
         $size = mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999);
185 185
       } else {
186 186
         $size = $moon_chance;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
       $field_max = ceil($size / 1000);
198 198
 
199
-      if(isset($options['image']) && $options['image']) {
199
+      if (isset($options['image']) && $options['image']) {
200 200
         $moon_image = $options['image'];
201 201
       } else {
202 202
         $moon_image = 'mond';
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
           `deuterium` = '0', `deuterium_perhour` = '0', `deuterium_max` = '{$base_storage_size}'"
212 212
       );
213 213
 
214
-      if($update_debris) {
214
+      if ($update_debris) {
215 215
         $debris_spent = $moon_chance * 1000000;
216 216
         $metal_spent  = round(min($moon_planet['debris_metal'], $debris_spent * mt_rand(50, 75) / 100));
217 217
         $crystal_spent = min($moon_planet['debris_crystal'], $debris_spent - $metal_spent);
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
   $planet_row['id'] = $user['current_planet'];
248 248
 
249 249
   // Пытаемся переключить на новую планету
250
-  if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet'])
250
+  if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet'])
251 251
   {
252 252
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id');
253 253
   }
@@ -257,15 +257,15 @@  discard block
 block discarded – undo
257 257
   }
258 258
 
259 259
   // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету
260
-  if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet']
260
+  if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet']
261 261
   {
262 262
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id');
263 263
     // Если текущей планеты не существует - выставляем Столицу
264
-    if(!isset($planet_row['id']))
264
+    if (!isset($planet_row['id']))
265 265
     {
266 266
       $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id');
267 267
       // Если и столицы не существует - значит что-то очень не так с записью пользователя
268
-      if(!isset($planet_row['id']))
268
+      if (!isset($planet_row['id']))
269 269
       {
270 270
         global $debug;
271 271
         $debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502);
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
   }
275 275
 
276 276
   // Если производилось переключение планеты - делаем запись в юзере
277
-  if($user['current_planet'] != $planet_row['id'])
277
+  if ($user['current_planet'] != $planet_row['id'])
278 278
   {
279 279
     db_user_set_by_id($user['id'], "`current_planet` = '{$planet_row['id']}'");
280 280
     $user['current_planet'] = $planet_row['id'];
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 {
299 299
   global $lang;
300 300
 
301
-  if(!$from['id'])
301
+  if (!$from['id'])
302 302
   {
303 303
     $result = $lang['sys_planet_expedition'];
304 304
   }
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 function uni_calculate_moon_chance($FleetDebris)
338 338
 {
339 339
   $MoonChance = $FleetDebris / 1000000;
340
-  return ($MoonChance < 1) ? 0 : ($MoonChance>30 ? 30 : $MoonChance);
340
+  return ($MoonChance < 1) ? 0 : ($MoonChance > 30 ? 30 : $MoonChance);
341 341
 }
342 342
 
343 343
 function uni_coordinates_valid($coordinates, $prefix = '')
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
   global $lang, $config;
360 360
 
361 361
   try {
362
-    if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) {
362
+    if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) {
363 363
       throw new exception($lang['ov_teleport_err_cooldown'], ERR_ERROR);
364 364
     }
365 365
 
366
-    if(mrc_get_level($user, false, RES_DARK_MATTER) < $config->planet_teleport_cost) {
366
+    if (mrc_get_level($user, false, RES_DARK_MATTER) < $config->planet_teleport_cost) {
367 367
       throw new exception($lang['ov_teleport_err_no_dark_matter'], ERR_ERROR);
368 368
     }
369 369
 
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 //    if(!empty($incoming['incoming'])) {
376 376
 //      throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR);
377 377
 //    }
378
-    if(fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) {
378
+    if (fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) {
379 379
       throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR);
380 380
     }
381 381
 
@@ -384,10 +384,10 @@  discard block
 block discarded – undo
384 384
     //  throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR);
385 385
     //}
386 386
 
387
-    if(is_array($new_coordinates)) {
387
+    if (is_array($new_coordinates)) {
388 388
       $new_coordinates['planet_type'] = PT_PLANET;
389 389
       $incoming = DBStaticPlanet::db_planet_by_vector($new_coordinates, '', true, 'id');
390
-      if($incoming['id']) {
390
+      if ($incoming['id']) {
391 391
         throw new exception($lang['ov_teleport_err_destination_busy'], ERR_ERROR);
392 392
       }
393 393
     }
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
       'result'  => ERR_NONE,
397 397
       'message' => '',
398 398
     );
399
-  } catch(exception $e) {
399
+  } catch (exception $e) {
400 400
     $response = array(
401 401
       'result'  => $e->getCode(),
402 402
       'message' => $e->getMessage(),
Please login to merge, or discard this patch.
Braces   +14 added lines, -23 removed lines patch added patch discarded remove patch
@@ -242,24 +242,24 @@  discard block
 block discarded – undo
242 242
  * 1 - copyright 2008 By Chlorel for XNova
243 243
  *
244 244
  */
245
-function SetSelectedPlanet(&$user)
246
-{
245
+function SetSelectedPlanet(&$user) {
247 246
   $planet_row['id'] = $user['current_planet'];
248 247
 
249 248
   // Пытаемся переключить на новую планету
250 249
   if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet'])
251 250
   {
252 251
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id');
253
-  }
254
-  else
252
+  } else
255 253
   {
256 254
     $planet_row = DBStaticPlanet::db_planet_by_id($planet_row['id']);
257 255
   }
258 256
 
259 257
   // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету
260
-  if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet']
258
+  if(!isset($planet_row['id'])) {
259
+    // || $planet_row['id'] != $user['current_planet']
261 260
   {
262 261
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id');
262
+  }
263 263
     // Если текущей планеты не существует - выставляем Столицу
264 264
     if(!isset($planet_row['id']))
265 265
     {
@@ -284,25 +284,21 @@  discard block
 block discarded – undo
284 284
 }
285 285
 
286 286
 // ----------------------------------------------------------------------------------------------------------------
287
-function uni_render_coordinates($from, $prefix = '')
288
-{
287
+function uni_render_coordinates($from, $prefix = '') {
289 288
   return "[{$from[$prefix . 'galaxy']}:{$from[$prefix . 'system']}:{$from[$prefix . 'planet']}]";
290 289
 }
291 290
 
292
-function uni_render_planet($from)
293
-{
291
+function uni_render_planet($from) {
294 292
   return "{$from['name']} [{$from['galaxy']}:{$from['system']}:{$from['planet']}]";
295 293
 }
296 294
 
297
-function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false)
298
-{
295
+function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) {
299 296
   global $lang;
300 297
 
301 298
   if(!$from['id'])
302 299
   {
303 300
     $result = $lang['sys_planet_expedition'];
304
-  }
305
-  else
301
+  } else
306 302
   {
307 303
     $from_planet_id = $include_id ? (
308 304
       'ID {' . ($from['id'] ? $from['id'] : ($from[$prefix . 'planet_id'] ? $from[$prefix . 'planet_id'] : 0)) . '} '
@@ -318,30 +314,25 @@  discard block
 block discarded – undo
318 314
   return $result;
319 315
 }
320 316
 
321
-function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php')
322
-{
317
+function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php') {
323 318
   return $page . (strpos($page, '?') === false ? '?' : '&') . "galaxy={$from[$prefix . 'galaxy']}&system={$from[$prefix . 'system']}&planet={$from[$prefix . 'planet']}";
324 319
 }
325 320
 
326
-function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '')
327
-{
321
+function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '') {
328 322
   return '<a href="' . uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}") . '"' . ($fleet_type ? " {$fleet_type}" : '') . '>' . uni_render_coordinates($from, $prefix) . '</a>';
329 323
 }
330 324
 
331
-function uni_get_time_to_jump($moon_row)
332
-{
325
+function uni_get_time_to_jump($moon_row) {
333 326
   $jump_gate_level = mrc_get_level($user, $moon_row, STRUC_MOON_GATE);
334 327
   return $jump_gate_level ? max(0, $moon_row['last_jump_time'] + abs(60 * 60 / $jump_gate_level) - SN_TIME_NOW) : 0;
335 328
 }
336 329
 
337
-function uni_calculate_moon_chance($FleetDebris)
338
-{
330
+function uni_calculate_moon_chance($FleetDebris) {
339 331
   $MoonChance = $FleetDebris / 1000000;
340 332
   return ($MoonChance < 1) ? 0 : ($MoonChance>30 ? 30 : $MoonChance);
341 333
 }
342 334
 
343
-function uni_coordinates_valid($coordinates, $prefix = '')
344
-{
335
+function uni_coordinates_valid($coordinates, $prefix = '') {
345 336
   global $config;
346 337
 
347 338
   // array_walk($coordinates, 'intval');
Please login to merge, or discard this patch.
includes/functions/flt_mission_missile.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,7 @@  discard block
 block discarded – undo
4 4
 // Open Source
5 5
 // V1
6 6
 //
7
-function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0')
8
-{
7
+function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0') {
9 8
   // Here we select which part of defense should take damage: structure or shield
10 9
   // $damageTo = P_SHIELD;
11 10
   // $damageTo = P_STRUCTURE;
@@ -34,8 +33,7 @@  discard block
 block discarded – undo
34 33
     $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] );
35 34
     $structures[$targetedStructure][0] -= $structsDestroyed;
36 35
     $MIPDamage -= $structsDestroyed*$damageDone;
37
-  }
38
-  else
36
+  } else
39 37
   {
40 38
     // REALLY random attack
41 39
     $can_be_damaged = sn_get_groups('defense_active');
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
   $mip_data = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET);
15 15
   $MIPDamage = floor(mrc_modify_value($attackerTech, false, TECH_WEAPON, $MIPs * $mip_data[P_ATTACK] * mt_rand(80, 120) / 100));
16
-  foreach($structures as $key => $structure)
16
+  foreach ($structures as $key => $structure)
17 17
   {
18 18
     $unit_info = get_unit_param($key);
19 19
     $amplify = isset($mip_data[P_AMPLIFY][$key]) ? $mip_data[P_AMPLIFY][$key] : 1;
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
   {
32 32
     //attacking only selected structure
33 33
     $damageDone = $structures[$targetedStructure][$damageTo];
34
-    $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] );
34
+    $structsDestroyed = min(floor($MIPDamage / $damageDone), $structures[$targetedStructure][0]);
35 35
     $structures[$targetedStructure][0] -= $structsDestroyed;
36
-    $MIPDamage -= $structsDestroyed*$damageDone;
36
+    $MIPDamage -= $structsDestroyed * $damageDone;
37 37
   }
38 38
   else
39 39
   {
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
     do
45 45
     {
46 46
       // finding is there any structure that can be damaged with leftovers of $MIPDamage
47
-      foreach($can_be_damaged as $key => $unit_id)
47
+      foreach ($can_be_damaged as $key => $unit_id)
48 48
       {
49 49
 //debug($structures[$unit_id][0]);
50 50
 //debug($structures[$unit_id][$damageTo], $MIPDamage);
51
-        if($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage)
51
+        if ($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage)
52 52
         {
53 53
           unset($can_be_damaged[$key]);
54 54
         }
55 55
       }
56
-      if(empty($can_be_damaged))
56
+      if (empty($can_be_damaged))
57 57
       {
58 58
         break;
59 59
       }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 //debug($destroyed, 'Actually destroyed');
73 73
 
74 74
 //print('<hr>');
75
-    } while($MIPDamage > 0 && !empty($can_be_damaged));
75
+    } while ($MIPDamage > 0 && !empty($can_be_damaged));
76 76
 //debug($MIPDamage, 'MIPDamage left');
77 77
   }
78 78
 //debug($structures);//die();
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
     $crystal += $destroyed * $unit_info[P_COST][RES_CRYSTAL] / 4;
88 88
   }
89 89
 
90
-  $return['structures'] = $structures;     // Structures left after attack
91
-  $return['metal']      = floor($metal);   // Metal scraps
90
+  $return['structures'] = $structures; // Structures left after attack
91
+  $return['metal']      = floor($metal); // Metal scraps
92 92
   $return['crystal']    = floor($crystal); // Crystal scraps
93 93
 
94 94
   return $return;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
   $iraks = doquery("SELECT * FROM {{iraks}} WHERE `fleet_end_time` <= " . SN_TIME_NOW . " FOR UPDATE;");
114 114
 
115
-  while($fleetRow = db_fetch($iraks)) {
115
+  while ($fleetRow = db_fetch($iraks)) {
116 116
     set_time_limit(15);
117 117
     $db_changeset = array();
118 118
 
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 
129 129
     $rowAttacker = db_user_by_id($fleetRow['fleet_owner'], true);
130 130
 
131
-    if($target_planet_row['id']) {
131
+    if ($target_planet_row['id']) {
132 132
       $planetDefense = array();
133
-      foreach(sn_get_groups('defense_active') as $unit_id) {
133
+      foreach (sn_get_groups('defense_active') as $unit_id) {
134 134
         $planetDefense[$unit_id] = array(mrc_get_level($targetUser, $target_planet_row, $unit_id, true, true));
135 135
       }
136 136
 
@@ -141,23 +141,23 @@  discard block
 block discarded – undo
141 141
         $message = $lang['mip_all_destroyed'];
142 142
         $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit(UNIT_DEF_MISSILE_INTERCEPTOR, -$missiles, $targetUser, $target_planet_row['id']);
143 143
       } else {
144
-        if($interceptors) {
144
+        if ($interceptors) {
145 145
           $message = sprintf($lang['mip_destroyed'], $interceptors);
146 146
           $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit(UNIT_DEF_MISSILE_INTERCEPTOR, -$interceptors, $targetUser, $target_planet_row['id']);
147 147
         }
148 148
 
149 149
         $attackResult = COE_missileAttack($targetUser, $rowAttacker, $missiles - $interceptors, $planetDefense, $fleetRow['primaer']);
150 150
 
151
-        foreach($attackResult['structures'] as $key => $structure) {
151
+        foreach ($attackResult['structures'] as $key => $structure) {
152 152
           $destroyed = $planetDefense[$key][0] - $structure[0];
153
-          if($destroyed) {
153
+          if ($destroyed) {
154 154
             $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($key, -$destroyed, $targetUser, $target_planet_row['id']);
155 155
 
156 156
             $message .= "&nbsp;&nbsp;{$lang['tech'][$key]} - {$destroyed} {$lang['quantity']}<br>";
157 157
           }
158 158
         }
159 159
 
160
-        if(!empty($message)) {
160
+        if (!empty($message)) {
161 161
           $message = $lang['mip_defense_destroyed'] . $message . "{$lang['mip_recycled']}{$lang['Metal']}: {$attackResult['metal']}, {$lang['Crystal']}: {$attackResult['crystal']}<br>";
162 162
 
163 163
           DBStaticPlanet::db_planet_set_by_id($target_planet_row['id'], "`metal` = `metal` + {$attackResult['metal']}, `crystal` = `crystal` + {$attackResult['crystal']}");
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 
175 175
       empty($message) ? $message = $lang['mip_no_defense'] : false;
176 176
 
177
-      msg_send_simple_message ( $fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message );
178
-      msg_send_simple_message ( $fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message );
177
+      msg_send_simple_message($fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message);
178
+      msg_send_simple_message($fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message);
179 179
     }
180 180
     doquery("DELETE FROM {{iraks}} WHERE id = '{$fleetRow['id']}';");
181 181
   }
Please login to merge, or discard this patch.
includes/functions/sys_maintenance.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
     array('query' => 'DELETE FROM {{aks}} WHERE `id` NOT IN (SELECT DISTINCT `fleet_group` FROM {{fleets}});', 'result' => false, 'error' => '', 'affected_rows' => 0),
16 16
   );
17 17
 
18
-  foreach($queries as &$query)
18
+  foreach ($queries as &$query)
19 19
   {
20 20
     $query['result'] = doquery($query['query']);
21 21
     $query['error']  = classSupernova::$db->db_error();
22
-    $query['affected_rows']  = classSupernova::$db->db_affected_rows();
22
+    $query['affected_rows'] = classSupernova::$db->db_affected_rows();
23 23
   }
24 24
 
25 25
   return $queries;
@@ -51,30 +51,30 @@  discard block
 block discarded – undo
51 51
   $recorded_run = strtotime($recorded_run);
52 52
 
53 53
   $prev_run_array = getdate($recorded_run);
54
-  $prev_run_array = array($prev_run_array['seconds'],$prev_run_array['minutes'],$prev_run_array['hours'],$prev_run_array['mday'],$prev_run_array['mon'],$prev_run_array['year']);
54
+  $prev_run_array = array($prev_run_array['seconds'], $prev_run_array['minutes'], $prev_run_array['hours'], $prev_run_array['mday'], $prev_run_array['mon'], $prev_run_array['year']);
55 55
   $today_array = getdate(SN_TIME_NOW);
56
-  $today_array = array($today_array['seconds'],$today_array['minutes'],$today_array['hours'],$today_array['mday'],$today_array['mon'],$today_array['year']);
56
+  $today_array = array($today_array['seconds'], $today_array['minutes'], $today_array['hours'], $today_array['mday'], $today_array['mon'], $today_array['year']);
57 57
   $scheduleList = explode(',', $scheduleList);
58 58
   array_walk($scheduleList, function(&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) {
59 59
     $schedule = array('schedule_array' => array_reverse(explode(':', trim($schedule))));
60 60
 
61 61
     $interval = $date_part_names_reverse[count($schedule['schedule_array'])];
62 62
 
63
-    foreach($prev_run_array as $index => $date_part) {
63
+    foreach ($prev_run_array as $index => $date_part) {
64 64
       $schedule['array']['recorded'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $date_part;
65 65
       $schedule['array']['now'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $today_array[$index];
66 66
     }
67
-    if($schedule['array']['recorded'] == $schedule['array']['now']) {
67
+    if ($schedule['array']['recorded'] == $schedule['array']['now']) {
68 68
       unset($schedule['array']['now']);
69 69
     }
70 70
 
71
-    foreach($schedule['array'] as $name => $array) {
71
+    foreach ($schedule['array'] as $name => $array) {
72 72
       $schedule['string'][$name] = "{$array[5]}-{$array[4]}-{$array[3]} {$array[2]}:{$array[1]}:{$array[0]}";
73 73
       $schedule['string'][$name . '_next'] = $schedule['string'][$name] . ' +1 ' . $interval;
74 74
       $schedule['string'][$name . '_prev'] = $schedule['string'][$name] . ' -1 ' . $interval;
75 75
     }
76 76
 
77
-    foreach($schedule['string'] as $string) {
77
+    foreach ($schedule['string'] as $string) {
78 78
       $timestamp = strtotime($string);
79 79
       $schedule['timestamp'][$timestamp] = $possible_schedules[$timestamp] = date(FMT_DATE_TIME_SQL, strtotime($string));
80 80
     }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
   $prev_run = 0;
86 86
   $next_run = 0;
87
-  foreach($possible_schedules as $timestamp => $string_date) {
87
+  foreach ($possible_schedules as $timestamp => $string_date) {
88 88
     $prev_run = SN_TIME_NOW >= $timestamp ? $timestamp : $prev_run;
89 89
     $next_run = SN_TIME_NOW < $timestamp && !$next_run ? $timestamp : $next_run;
90 90
   }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-function sys_maintenance()
4
-{
3
+function sys_maintenance() {
5 4
   global $config;
6 5
 
7 6
   $bashing_time_limit = SN_TIME_NOW - $config->fleet_bashing_scope;
@@ -42,8 +41,7 @@  discard block
 block discarded – undo
42 41
  * TODO: 2. [<m|w|d|h|m|s>@]<time>
43 42
  */
44 43
 
45
-function sys_schedule_get_prev_run($scheduleList, $recorded_run = SN_TIME_NOW, $return_next_run = false)
46
-{
44
+function sys_schedule_get_prev_run($scheduleList, $recorded_run = SN_TIME_NOW, $return_next_run = false) {
47 45
   static $date_part_names_reverse = array('seconds', 'minutes', 'hours', 'days', 'months', 'years',);
48 46
 
49 47
   $possible_schedules = array();
Please login to merge, or discard this patch.
includes/functions/lng_language.php 1 patch
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,14 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // ----------------------------------------------------------------------------------------------------------------
4
-function lng_try_filepath($path, $file_path_relative)
5
-{
4
+function lng_try_filepath($path, $file_path_relative) {
6 5
   $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative;
7 6
   return file_exists($file_path) ? $file_path : false;
8 7
 }
9 8
 
10
-function lng_die_not_an_object()
11
-{
9
+function lng_die_not_an_object() {
12 10
   print('Ошибка - $lang не объект! Сообщите Администратору сервера и приложите содержимое страницы');
13 11
   $trace = debug_backtrace();
14 12
   unset($trace[0]);
@@ -17,32 +15,27 @@  discard block
 block discarded – undo
17 15
 }
18 16
 
19 17
 // ----------------------------------------------------------------------------------------------------------------
20
-function lng_include($filename, $path = '', $ext = '.mo.php')
21
-{
18
+function lng_include($filename, $path = '', $ext = '.mo.php') {
22 19
   global $lang;
23 20
   return is_object($lang) ? $lang->lng_include($filename, $path, $ext) : lng_die_not_an_object();
24 21
 }
25 22
 
26
-function lng_get_list()
27
-{
23
+function lng_get_list() {
28 24
   global $lang;
29 25
   return is_object($lang) ? $lang->lng_get_list() : lng_die_not_an_object();
30 26
 }
31 27
 
32
-function lng_get_info($entry)
33
-{
28
+function lng_get_info($entry) {
34 29
   global $lang;
35 30
   return is_object($lang) ? $lang->lng_get_info($entry) : lng_die_not_an_object();
36 31
 }
37 32
 
38
-function lng_switch($language_new)
39
-{
33
+function lng_switch($language_new) {
40 34
   global $lang;
41 35
   return is_object($lang) ? $lang->lng_switch($language_new) : lng_die_not_an_object();
42 36
 }
43 37
 
44
-function lng_load_i18n($i18n)
45
-{
38
+function lng_load_i18n($i18n) {
46 39
   global $lang;
47 40
   return is_object($lang) ? $lang->lng_load_i18n($i18n) : lng_die_not_an_object();
48 41
 }
Please login to merge, or discard this patch.
includes/functions/eco_planet_update.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 
15 15
   $no_data = array('user' => false, 'planet' => false, 'que' => false);
16 16
 
17
-  if(!$planet) {
17
+  if (!$planet) {
18 18
     return $no_data;
19 19
   }
20 20
 
21
-  if(!$no_user_update) {
21
+  if (!$no_user_update) {
22 22
     $user = intval(is_array($user) && $user['id'] ? $user['id'] : $user);
23
-    if(!$user) {
23
+    if (!$user) {
24 24
       // TODO - Убрать позже
25 25
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sys_o_get_updated() - USER пустой!</h1>');
26 26
       $backtrace = debug_backtrace();
@@ -32,17 +32,17 @@  discard block
 block discarded – undo
32 32
     $user = db_user_by_id($user, !$simulation, '*', true);
33 33
   }
34 34
 
35
-  if(empty($user['id'])) {
35
+  if (empty($user['id'])) {
36 36
     return $no_data;
37 37
   }
38 38
 
39
-  if(is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) {
39
+  if (is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) {
40 40
     $planet = DBStaticPlanet::db_planet_by_vector($planet, '', !$simulation);
41 41
   } else {
42 42
     $planet = intval(is_array($planet) && isset($planet['id']) ? $planet['id'] : $planet);
43 43
     $planet = DBStaticPlanet::db_planet_by_id($planet, !$simulation);
44 44
   }
45
-  if(!is_array($planet) || !isset($planet['id'])) {
45
+  if (!is_array($planet) || !isset($planet['id'])) {
46 46
     return $no_data;
47 47
   }
48 48
 
@@ -65,15 +65,15 @@  discard block
 block discarded – undo
65 65
     RES_DEUTERIUM => 0,
66 66
   );
67 67
 
68
-  switch($planet['planet_type']) {
68
+  switch ($planet['planet_type']) {
69 69
     case PT_PLANET:
70
-      foreach($resources_increase as $resource_id => &$increment) {
70
+      foreach ($resources_increase as $resource_id => &$increment) {
71 71
         $resource_name = pname_resource_name($resource_id);
72 72
         $increment = $caps_real['total'][$resource_id] * $ProductionTime / 3600;
73 73
         $store_free = $caps_real['total_storage'][$resource_id] - $planet[$resource_name];
74 74
         $increment = min($increment, max(0, $store_free));
75 75
 
76
-        if($planet[$resource_name] + $increment < 0 && !$simulation) {
76
+        if ($planet[$resource_name] + $increment < 0 && !$simulation) {
77 77
           global $debug;
78 78
           $debug->warning("Player ID {$user['id']} have negative resources on ID {$planet['id']}.{$planet['planet_type']} [{$planet['galaxy']}:{$planet['system']}:{$planet['planet']}]. Difference {$planet[$resource_name]} of {$resource_name}", 'Negative Resources', 501);
79 79
         }
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
   // TODO пересчитывать размер планеты только при постройке чего-нибудь и при покупке сектора
96 96
   $planet['field_current'] = 0;
97 97
   $sn_group_build_allow = sn_get_groups('build_allow');
98
-  if(is_array($sn_group_build_allow[$planet['planet_type']])) {
99
-    foreach($sn_group_build_allow[$planet['planet_type']] as $building_id) {
98
+  if (is_array($sn_group_build_allow[$planet['planet_type']])) {
99
+    foreach ($sn_group_build_allow[$planet['planet_type']] as $building_id) {
100 100
       $planet['field_current'] += mrc_get_level($user, $planet, $building_id, !$simulation, true);
101 101
     }
102 102
   }
103 103
 
104
-  if($simulation) {
104
+  if ($simulation) {
105 105
     return array('user' => $user, 'planet' => $planet, 'que' => $que);
106 106
   }
107 107
 
Please login to merge, or discard this patch.
includes/includes/flt_mission_hold.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 function flt_mission_hold(&$mission_data)
4 4
 {
5
-  if($mission_data['fleet']['fleet_end_stay'] < SN_TIME_NOW)
5
+  if ($mission_data['fleet']['fleet_end_stay'] < SN_TIME_NOW)
6 6
   {
7 7
     fleet_send_back($mission_data['fleet']);
8 8
     // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;");
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-function flt_mission_hold(&$mission_data)
4
-{
3
+function flt_mission_hold(&$mission_data) {
5 4
   if($mission_data['fleet']['fleet_end_stay'] < SN_TIME_NOW)
6 5
   {
7 6
     fleet_send_back($mission_data['fleet']);
Please login to merge, or discard this patch.
includes/includes/flt_page5.inc 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 *
13 13
 **/
14 14
 
15
-if(SN_IN_FLEET !== true) {
15
+if (SN_IN_FLEET !== true) {
16 16
   $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
17 17
 }
18 18
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
   $planet_list = array();
27 27
 
28
-  if(is_array($resources_taken))
28
+  if (is_array($resources_taken))
29 29
   {
30 30
     $query = implode(',', array_keys($resources_taken));
31 31
     $query = " AND `destruyed` = 0 AND `id` IN ({$query})";
@@ -33,16 +33,16 @@  discard block
 block discarded – undo
33 33
     $query = '';
34 34
   }
35 35
 
36
-  foreach(sn_get_groups('flt_transports') as $transport_id) {
36
+  foreach (sn_get_groups('flt_transports') as $transport_id) {
37 37
     $transports[$transport_id] = get_unit_param($transport_id, P_CAPACITY);
38 38
   }
39 39
   arsort($transports);
40 40
 
41 41
   $planets_db_list = DBStaticPlanet::db_planet_list_sorted($user, $planetrow['id'], '*', $query);
42 42
   !is_array($planets_db_list) ? $planets_db_list = array() : false;
43
-  foreach($planets_db_list as $planet_db_data) {
43
+  foreach ($planets_db_list as $planet_db_data) {
44 44
   // begin planet loop
45
-    if(!$query) {
45
+    if (!$query) {
46 46
       $resources_taken[$planet_db_data['id']] = 1;
47 47
     }
48 48
     sn_db_transaction_start();
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
     $planet_id = $planet_db_data['id'];
55 55
 
56 56
     $planet_resources = 0;
57
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
58
-      if($resources_taken[$planet_id] == 1 || $resources_taken[$planet_id][$resource_id]) {
57
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
58
+      if ($resources_taken[$planet_id] == 1 || $resources_taken[$planet_id][$resource_id]) {
59 59
         $planet_resources += floor(mrc_get_level($user, $planet_db_data, $resource_id, true, true)); // $planet_db_data[get_unit_param($resource_id, P_NAME)]);
60 60
       }
61 61
     }
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
     $fleet_capacity = 0;
87 87
     $ship_loadout = array();
88 88
     $fleet = array();
89
-    foreach($transports as $ship_id => $ship_capacity) {
90
-      if($ship_count = mrc_get_level($user, $planet_db_data, $ship_id, true, true)) {
89
+    foreach ($transports as $ship_id => $ship_capacity) {
90
+      if ($ship_count = mrc_get_level($user, $planet_db_data, $ship_id, true, true)) {
91 91
         $ship_loadout[$ship_id]['capacity'] = $ship_count * $ship_capacity;
92 92
         $ship_loadout[$ship_id]['taken'] = 0;
93 93
         $fleet_capacity += $ship_loadout[$ship_id]['capacity'];
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 
99 99
     $will_take = min($planet_resources, $fleet_capacity);
100 100
 
101
-    foreach($ship_loadout as $ship_id => &$planet_ship) {
101
+    foreach ($ship_loadout as $ship_id => &$planet_ship) {
102 102
       $can_take = min($will_take, $planet_ship['capacity']);
103
-      if($can_take <= 0) {
103
+      if ($can_take <= 0) {
104 104
         continue;
105 105
       }
106 106
       $planet_ship['capacity'] -= $can_take;
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
       $fleet[$ship_id] = ceil($planet_ship['taken'] / $transports[$ship_id]);
109 109
 
110 110
       $will_take -= $can_take;
111
-      if($will_take <= 0) {
111
+      if ($will_take <= 0) {
112 112
         break;
113 113
       }
114 114
     }
115 115
 
116
-    if(!empty($fleet)) {
116
+    if (!empty($fleet)) {
117 117
       $travel_data = flt_travel_data($user, $planetrow, $planet_db_data, $fleet, 10);
118 118
       $planet_data['FLEET_SPEED'] = $travel_data['fleet_speed'];
119 119
       $planet_data['DISTANCE']    = $travel_data['distance'];
120 120
       $planet_data['DURATION']    = $travel_data['duration'];
121 121
       $planet_data['CONSUMPTION'] = $travel_data['consumption'];
122 122
 
123
-      if(floor(mrc_get_level($user, $planet_db_data, RES_DEUTERIUM, true)) >= $planet_data['CONSUMPTION']) {
123
+      if (floor(mrc_get_level($user, $planet_db_data, RES_DEUTERIUM, true)) >= $planet_data['CONSUMPTION']) {
124 124
         $will_take = min($planet_resources, $fleet_capacity) - $planet_data['CONSUMPTION'];
125 125
 
126
-        foreach(sn_get_groups('resources_loot') as $resource_id) {
127
-          if($resources_taken[$planet_id] != 1 && !$resources_taken[$planet_id][$resource_id]) {
126
+        foreach (sn_get_groups('resources_loot') as $resource_id) {
127
+          if ($resources_taken[$planet_id] != 1 && !$resources_taken[$planet_id][$resource_id]) {
128 128
             continue;
129 129
           }
130 130
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
           $fleet[$resource_id] = min($will_take, $resource_amount);
134 134
           $will_take -= $resource_amount;
135 135
 
136
-          if($will_take <= 0) {
136
+          if ($will_take <= 0) {
137 137
             break;
138 138
           }
139 139
         }
@@ -157,19 +157,19 @@  discard block
 block discarded – undo
157 157
 
158 158
 $resources_taken = sys_get_param('resources');
159 159
 
160
-if(!empty($resources_taken))  { // begin processing parameters
160
+if (!empty($resources_taken)) { // begin processing parameters
161 161
   $planet_list = flt_build_gathering($resources_taken);
162 162
 
163
-  foreach($planet_list as $planet_id => $planet_data) {
164
-    if($planet_data['RESULT'] == ATTACK_ALLOWED) {
163
+  foreach ($planet_list as $planet_id => $planet_data) {
164
+    if ($planet_data['RESULT'] == ATTACK_ALLOWED) {
165 165
       $planet_data['RESULT'] = flt_t_send_fleet($user, $planet_data['PLANET_DB_DATA'], $planetrow, $planet_data['FLEET'], MT_TRANSPORT);
166 166
     }
167 167
 
168 168
     $planet_data['MESSAGE'] = $lang['fl_attack_error'][$planet_data['RESULT']];
169 169
 
170 170
     $template->assign_block_vars('results', $planet_data);
171
-    if(!empty($planet_data['FLEET']) && $planet_data['RESULT'] == ATTACK_ALLOWED) {
172
-      foreach($planet_data['FLEET'] as $unit_id => $amount) {
171
+    if (!empty($planet_data['FLEET']) && $planet_data['RESULT'] == ATTACK_ALLOWED) {
172
+      foreach ($planet_data['FLEET'] as $unit_id => $amount) {
173 173
         $template->assign_block_vars('results.units', array(
174 174
           'ID'     => $unit_id,
175 175
           'NAME'   => $lang['tech'][$unit_id],
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
 // Building list of own planets & moons
184 184
 $planet_list = flt_build_gathering();
185
-foreach($planet_list as $planet_data) {
185
+foreach ($planet_list as $planet_data) {
186 186
   $planet_data['DURATION'] = $planet_data['DURATION'] ? pretty_time($planet_data['DURATION']) : $lang['flt_no_fuel'];
187 187
   $template->assign_block_vars('colonies', $planet_data);
188 188
 }
Please login to merge, or discard this patch.
includes/includes/flt_mission_recycle.php 3 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
   $fleet_row          = &$mission_data['fleet'];
13 13
   $destination_planet = &$mission_data['dst_planet'];
14 14
 
15
-  if(!$fleet_row)
15
+  if (!$fleet_row)
16 16
   {
17 17
     return CACHE_NOTHING;
18 18
   }
19 19
 
20
-  if(!isset($destination_planet['id']))
20
+  if (!isset($destination_planet['id']))
21 21
   {
22 22
     // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;");
23 23
     fleet_send_back($mission_data['fleet']);
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
   $RecyclerCapacity    = 0;
30 30
   $OtherFleetCapacity  = 0;
31 31
   $fleet_array = sys_unit_str2arr($fleet_row['fleet_array']);
32
-  foreach($fleet_array as $unit_id => $unit_count)
32
+  foreach ($fleet_array as $unit_id => $unit_count)
33 33
   {
34
-    if(in_array($unit_id, sn_get_groups('fleet')))
34
+    if (in_array($unit_id, sn_get_groups('fleet')))
35 35
     {
36 36
       $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit_count;
37
-      if(in_array($unit_id, sn_get_groups('flt_recyclers')))
37
+      if (in_array($unit_id, sn_get_groups('flt_recyclers')))
38 38
       {
39 39
         $RecyclerCapacity += $capacity;
40 40
       }
@@ -46,19 +46,19 @@  discard block
 block discarded – undo
46 46
   }
47 47
 
48 48
   $IncomingFleetGoods = $fleet_row["fleet_resource_metal"] + $fleet_row["fleet_resource_crystal"] + $fleet_row["fleet_resource_deuterium"];
49
-  if($IncomingFleetGoods > $OtherFleetCapacity)
49
+  if ($IncomingFleetGoods > $OtherFleetCapacity)
50 50
   {
51 51
     $RecyclerCapacity -= ($IncomingFleetGoods - $OtherFleetCapacity);
52 52
   }
53 53
 
54
-  if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity)
54
+  if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity)
55 55
   {
56 56
     $RecycledGoods["metal"]   = $destination_planet["debris_metal"];
57 57
     $RecycledGoods["crystal"] = $destination_planet["debris_crystal"];
58 58
   }
59 59
   else
60 60
   {
61
-    if (($destination_planet["debris_metal"]   > $RecyclerCapacity / 2) AND
61
+    if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) AND
62 62
       ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2))
63 63
       {
64 64
       $RecycledGoods["metal"]   = $RecyclerCapacity / 2;
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
       }
93 93
     }
94 94
   }
95
-  $NewCargo['Metal']     = $fleet_row["fleet_resource_metal"]   + $RecycledGoods["metal"];
95
+  $NewCargo['Metal']     = $fleet_row["fleet_resource_metal"] + $RecycledGoods["metal"];
96 96
   $NewCargo['Crystal']   = $fleet_row["fleet_resource_crystal"] + $RecycledGoods["crystal"];
97 97
   $NewCargo['Deuterium'] = $fleet_row["fleet_resource_deuterium"];
98 98
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
   );
102 102
 
103 103
   $Message = sprintf($lang['sys_recy_gotten'], pretty_number($RecycledGoods["metal"]), $lang['Metal'], pretty_number($RecycledGoods["crystal"]), $lang['Crystal']);
104
-  msg_send_simple_message ( $fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_RECYCLE, $lang['sys_mess_spy_control'], $lang['sys_recy_report'], $Message);
104
+  msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_RECYCLE, $lang['sys_mess_spy_control'], $lang['sys_recy_report'], $Message);
105 105
 
106 106
 //  $QryUpdateFleet  = "UPDATE {{fleets}} SET `fleet_mess` = 1,`fleet_resource_metal` = '{$NewCargo['Metal']}',`fleet_resource_crystal` = '{$NewCargo['Crystal']}',`fleet_resource_deuterium` = '{$NewCargo['Deuterium']}' ";
107 107
 //  $QryUpdateFleet .= "WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;";
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@  discard block
 block discarded – undo
7 7
  * @copyright 2008 By Chlorel for XNova
8 8
  */
9 9
 
10
-function flt_mission_recycle(&$mission_data)
11
-{
10
+function flt_mission_recycle(&$mission_data) {
12 11
   $fleet_row          = &$mission_data['fleet'];
13 12
   $destination_planet = &$mission_data['dst_planet'];
14 13
 
@@ -37,8 +36,7 @@  discard block
 block discarded – undo
37 36
       if(in_array($unit_id, sn_get_groups('flt_recyclers')))
38 37
       {
39 38
         $RecyclerCapacity += $capacity;
40
-      }
41
-      else
39
+      } else
42 40
       {
43 41
         $OtherFleetCapacity += $capacity;
44 42
       }
@@ -55,16 +53,14 @@  discard block
 block discarded – undo
55 53
   {
56 54
     $RecycledGoods["metal"]   = $destination_planet["debris_metal"];
57 55
     $RecycledGoods["crystal"] = $destination_planet["debris_crystal"];
58
-  }
59
-  else
56
+  } else
60 57
   {
61 58
     if (($destination_planet["debris_metal"]   > $RecyclerCapacity / 2) AND
62 59
       ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2))
63 60
       {
64 61
       $RecycledGoods["metal"]   = $RecyclerCapacity / 2;
65 62
       $RecycledGoods["crystal"] = $RecyclerCapacity / 2;
66
-    }
67
-    else
63
+    } else
68 64
     {
69 65
       if ($destination_planet["debris_metal"] > $destination_planet["debris_crystal"])
70 66
       {
@@ -72,20 +68,17 @@  discard block
 block discarded – undo
72 68
         if ($destination_planet["debris_metal"] > ($RecyclerCapacity - $RecycledGoods["crystal"]))
73 69
         {
74 70
           $RecycledGoods["metal"] = $RecyclerCapacity - $RecycledGoods["crystal"];
75
-        }
76
-        else
71
+        } else
77 72
         {
78 73
           $RecycledGoods["metal"] = $destination_planet["debris_metal"];
79 74
         }
80
-      }
81
-      else
75
+      } else
82 76
       {
83 77
         $RecycledGoods["metal"] = $destination_planet["debris_metal"];
84 78
         if ($destination_planet["debris_crystal"] > ($RecyclerCapacity - $RecycledGoods["metal"]))
85 79
         {
86 80
           $RecycledGoods["crystal"] = $RecyclerCapacity - $RecycledGoods["metal"];
87
-        }
88
-        else
81
+        } else
89 82
         {
90 83
           $RecycledGoods["crystal"] = $destination_planet["debris_crystal"];
91 84
         }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
   }
59 59
   else
60 60
   {
61
-    if (($destination_planet["debris_metal"]   > $RecyclerCapacity / 2) AND
61
+    if (($destination_planet["debris_metal"]   > $RecyclerCapacity / 2) and
62 62
       ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2))
63 63
       {
64 64
       $RecycledGoods["metal"]   = $RecyclerCapacity / 2;
Please login to merge, or discard this patch.
includes/includes/flt_mission_explore.php 1 patch
Spacing   +37 added lines, -38 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
 
15 15
   $fleet_left = 1 - mt_rand(1, 3) * mt_rand(200000, 300000) / 1000000;
16 16
   $fleet_lost = array();
17
-  foreach($fleet as $unit_id => &$unit_amount) {
17
+  foreach ($fleet as $unit_id => &$unit_amount) {
18 18
     $ships_left = floor($unit_amount * $fleet_left);
19 19
     $fleet_lost[$unit_id] = $unit_amount - $ships_left;
20 20
     $unit_amount = $ships_left;
21
-    if(!$unit_amount) {
21
+    if (!$unit_amount) {
22 22
       unset($fleet[$unit_id]);
23 23
     }
24 24
   }
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
 //  $fleet = array();
32 32
 }
33 33
 
34
-function flt_mission_explore_addon(&$result){return sn_function_call('flt_mission_explore_addon', array(&$result));}
34
+function flt_mission_explore_addon(&$result) {return sn_function_call('flt_mission_explore_addon', array(&$result)); }
35 35
 function sn_flt_mission_explore_addon(&$result) {
36 36
   return $result;
37 37
 }
38 38
 
39 39
 
40 40
 function flt_mission_explore(&$mission_data) {
41
-  if(!isset($mission_data['fleet_event']) || $mission_data['fleet_event'] != EVENT_FLT_ACOMPLISH) {
41
+  if (!isset($mission_data['fleet_event']) || $mission_data['fleet_event'] != EVENT_FLT_ACOMPLISH) {
42 42
     return CACHE_NONE;
43 43
   }
44 44
 
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
   $outcome_list = &$result['$outcome_list'];
72 72
   $fleet_metal_points = &$result['$fleet_metal_points'];
73 73
 
74
-  if(!$ship_data) {
75
-    foreach(sn_get_groups('fleet') as $unit_id) {
74
+  if (!$ship_data) {
75
+    foreach (sn_get_groups('fleet') as $unit_id) {
76 76
       $unit_info = get_unit_param($unit_id);
77
-      if($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) {
77
+      if ($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) {
78 78
         continue;
79 79
       }
80 80
       $ship_data[$unit_id][P_COST_METAL] = get_unit_cost_in($unit_info[P_COST]);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
   $fleet = sys_unit_str2arr($fleet_row['fleet_array']);
87 87
   $fleet_capacity = 0;
88 88
   $fleet_metal_points = 0;
89
-  foreach($fleet as $ship_id => $ship_amount) {
89
+  foreach ($fleet as $ship_id => $ship_amount) {
90 90
     $unit_info = get_unit_param($ship_id);
91 91
     $fleet_capacity += $ship_amount * $unit_info[P_CAPACITY];
92 92
     $fleet_metal_points += $ship_amount * $ship_data[$ship_id][P_COST_METAL];
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
   $flt_stay_hours = ($fleet_row['fleet_end_stay'] - $fleet_row['fleet_start_time']) / 3600 * ($config->game_speed_expedition ? $config->game_speed_expedition : 1);
97 97
 
98 98
   $outcome_list = sn_get_groups('mission_explore_outcome_list');
99
-  $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1/1.7));
99
+  $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1 / 1.7));
100 100
 
101 101
   $chance_max = 0;
102
-  foreach($outcome_list as $key => &$value) {
103
-    if(!$value['chance']) {
102
+  foreach ($outcome_list as $key => &$value) {
103
+    if (!$value['chance']) {
104 104
       unset($outcome_list[$key]);
105 105
       continue;
106 106
     }
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
   $outcome_value = mt_rand(0, $chance_max);
110 110
 // $outcome_value = 409;
111 111
   $outcome_description = &$outcome_list[$mission_outcome = FLT_EXPEDITION_OUTCOME_NONE];
112
-  foreach($outcome_list as $key => &$value) {
113
-    if(!$value['chance']) {
112
+  foreach ($outcome_list as $key => &$value) {
113
+    if (!$value['chance']) {
114 114
       continue;
115 115
     }
116 116
     $mission_outcome = $key;
117 117
     $outcome_description = $value;
118
-    if($outcome_value <= $outcome_description['value']) {
118
+    if ($outcome_value <= $outcome_description['value']) {
119 119
       break;
120 120
     }
121 121
   }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
   $found_dark_matter = 0;
132 132
 //  $outcome_mission_sub = -1;
133 133
 
134
-  switch($mission_outcome) {
134
+  switch ($mission_outcome) {
135 135
 //  switch(FLT_EXPEDITION_OUTCOME_LOST_FLEET) { // TODO DEBUG!
136 136
     case FLT_EXPEDITION_OUTCOME_LOST_FLEET:
137 137
       flt_mission_explore_outcome_lost_fleet($result);
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
 
167 167
       // Рассчитываем стоимость самого дорого корабля в металле
168 168
       $max_metal_cost = 0;
169
-      foreach($fleet as $ship_id => $ship_amount) {
169
+      foreach ($fleet as $ship_id => $ship_amount) {
170 170
         $max_metal_cost = max($max_metal_cost, $ship_data[$ship_id]['metal_cost']);
171 171
       }
172 172
 
173 173
       // Ограничиваем корабли только теми, чья стоимость в металле меньше или равно стоимости самого дорогого корабля
174 174
       $can_be_found = array();
175
-      foreach($ship_data as $ship_id => $ship_info) {
176
-        if($ship_info['metal_cost'] < $max_metal_cost) {
175
+      foreach ($ship_data as $ship_id => $ship_info) {
176
+        if ($ship_info['metal_cost'] < $max_metal_cost) {
177 177
           $can_be_found[$ship_id] = $ship_info['metal_cost'];
178 178
         }
179 179
       }
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
       unset($can_be_found[SHIP_SPY]);
183 183
 
184 184
       $fleet_found = array();
185
-      while(count($can_be_found) && $found_in_metal >= max($can_be_found)) {
185
+      while (count($can_be_found) && $found_in_metal >= max($can_be_found)) {
186 186
         $found_index = mt_rand(1, count($can_be_found)) - 1;
187 187
         $found_ship = array_slice($can_be_found, $found_index, 1, true);
188 188
         $found_ship_cost = reset($found_ship);
189 189
         $found_ship_id = key($found_ship);
190 190
 
191
-        if($found_ship_cost > $found_in_metal) {
191
+        if ($found_ship_cost > $found_in_metal) {
192 192
           unset($can_be_found[$found_ship_id]);
193 193
         } else {
194 194
           $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost));
@@ -197,10 +197,10 @@  discard block
 block discarded – undo
197 197
         }
198 198
       }
199 199
 
200
-      if(empty($fleet_found)) {
200
+      if (empty($fleet_found)) {
201 201
         $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
202 202
       } else {
203
-        foreach($fleet_found as $unit_id => $unit_amount) {
203
+        foreach ($fleet_found as $unit_id => $unit_amount) {
204 204
           $fleet[$unit_id] += $unit_amount;
205 205
         }
206 206
       }
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
       $fleet_row['fleet_resource_crystal'] += $resources_found[RES_CRYSTAL];
227 227
       $fleet_row['fleet_resource_deuterium'] += $resources_found[RES_DEUTERIUM];
228 228
 
229
-      if(array_sum($resources_found) == 0) {
229
+      if (array_sum($resources_found) == 0) {
230 230
         $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
231 231
       }
232 232
     break;
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
       // Рассчитываем количество найденной ТМ
238 238
       $found_dark_matter = floor(min($outcome_percent * $fleet_metal_points / $rates[RES_DARK_MATTER], 10000) * mt_rand(750000, 1000000) / 1000000);
239 239
 
240
-      if(!$found_dark_matter) {
240
+      if (!$found_dark_matter) {
241 241
         $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
242 242
       }
243 243
     break;
@@ -251,31 +251,31 @@  discard block
 block discarded – undo
251 251
 
252 252
   flt_mission_explore_addon($result);
253 253
 
254
-  if($found_dark_matter) {
254
+  if ($found_dark_matter) {
255 255
     rpg_points_change($fleet_row['fleet_owner'], RPG_EXPEDITION, $found_dark_matter, 'Expedition Bonus');
256 256
     $msg_text_addon = sprintf($lang['flt_mission_expedition']['found_dark_matter'], $found_dark_matter);
257 257
   }
258 258
 
259
-  if(!empty($fleet_lost)) {
259
+  if (!empty($fleet_lost)) {
260 260
     $msg_text_addon = $lang['flt_mission_expedition']['lost_fleet'];
261
-    foreach($fleet_lost as $ship_id => $ship_amount) {
261
+    foreach ($fleet_lost as $ship_id => $ship_amount) {
262 262
       $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n";
263 263
     }
264 264
   }
265 265
 
266 266
   $fleet_row['fleet_amount'] = array_sum($fleet);
267
-  if(!empty($fleet) && $fleet_row['fleet_amount']) {
268
-    if(!empty($fleet_found)) {
267
+  if (!empty($fleet) && $fleet_row['fleet_amount']) {
268
+    if (!empty($fleet_found)) {
269 269
       $msg_text_addon = $lang['flt_mission_expedition']['found_fleet'];
270
-      foreach($fleet_found as $ship_id => $ship_amount) {
270
+      foreach ($fleet_found as $ship_id => $ship_amount) {
271 271
         $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n";
272 272
       }
273 273
     }
274 274
 
275 275
     $query_delta = array();
276
-    if(!empty($resources_found) && array_sum($resources_found) > 0) {
276
+    if (!empty($resources_found) && array_sum($resources_found) > 0) {
277 277
       $msg_text_addon = $lang['flt_mission_expedition']['found_resources'];
278
-      foreach($resources_found as $ship_id => $ship_amount) {
278
+      foreach ($resources_found as $ship_id => $ship_amount) {
279 279
         $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n";
280 280
       }
281 281
 
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
     }
289 289
 
290 290
     $query_data = array();
291
-    if(!empty($fleet_lost) || !empty($fleet_found)) {
291
+    if (!empty($fleet_lost) || !empty($fleet_found)) {
292 292
       $fleet_row['fleet_array'] = sys_unit_arr2str($fleet);
293 293
 
294 294
 //      $query_data[] = "`fleet_amount` = {$fleet_row['fleet_amount']}";
@@ -316,17 +316,16 @@  discard block
 block discarded – undo
316 316
 
317 317
   db_user_set_by_id($fleet_row['fleet_owner'], "`player_rpg_explore_xp` = `player_rpg_explore_xp` + 1");
318 318
 
319
-  if(!$msg_text) {
319
+  if (!$msg_text) {
320 320
     $messages = &$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['messages'];
321
-    if($outcome_mission_sub >= 0 && is_array($messages)) {
321
+    if ($outcome_mission_sub >= 0 && is_array($messages)) {
322 322
       $messages = &$messages[$outcome_mission_sub];
323 323
     }
324 324
 
325
-    $msg_text = is_string($messages) ? $messages :
326
-      (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : '');
325
+    $msg_text = is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : '');
327 326
   }
328 327
   $msg_text = sprintf($msg_text, $fleet_row['fleet_id'], uni_render_coordinates($fleet_row, 'fleet_end_')) .
329
-    ($msg_text_addon ? "\r\n" . $msg_text_addon: '');
328
+    ($msg_text_addon ? "\r\n" . $msg_text_addon : '');
330 329
 
331 330
   msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_end_stay'], MSG_TYPE_EXPLORE, $msg_sender, $msg_title, $msg_text);
332 331
 
Please login to merge, or discard this patch.