Completed
Push — work-fleets ( f5fbda...1bdd41 )
by SuperNova.WS
06:04
created
includes/includes/flt_functions.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
+/**
4
+ * @return double
5
+ */
3 6
 function flt_fleet_speed($user, $fleet)
4 7
 {
5 8
   if (!is_array($fleet))
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 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, sn_get_groups(array('fleet', 'missile')))) {
9
+  if (!empty($fleet)) {
10
+    foreach ($fleet as $ship_id => $amount) {
11
+      if ($amount && in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) {
12 12
         $single_ship_data = get_ship_data($ship_id, $user);
13 13
         $speeds[] = $single_ship_data['speed'];
14 14
       }
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
 }
20 20
 
21 21
 function flt_travel_distance($from, $to) {
22
-  if($from['galaxy'] != $to['galaxy']) {
22
+  if ($from['galaxy'] != $to['galaxy']) {
23 23
     $distance = abs($from['galaxy'] - $to['galaxy']) * classSupernova::$config->uni_galaxy_distance;
24
-  } elseif($from['system'] != $to['system']) {
24
+  } elseif ($from['system'] != $to['system']) {
25 25
     $distance = abs($from['system'] - $to['system']) * 5 * 19 + 2700;
26
-  } elseif($from['planet'] != $to['planet']) {
26
+  } elseif ($from['planet'] != $to['planet']) {
27 27
     $distance = abs($from['planet'] - $to['planet']) * 5 + 1000;
28 28
   } else {
29 29
     $distance = 5;
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 
51 51
   $game_fleet_speed = flt_server_flight_speed_multiplier();
52 52
   $fleet_speed = flt_fleet_speed($user_row, $fleet_array);
53
-  if(!empty($fleet_array) && $fleet_speed && $game_fleet_speed) {
53
+  if (!empty($fleet_array) && $fleet_speed && $game_fleet_speed) {
54 54
     $speed_percent = $speed_percent ? max(min($speed_percent, 10), 1) : 10;
55 55
     $real_speed = $speed_percent * sqrt($fleet_speed);
56 56
 
57 57
     $duration = max(1, round((35000 / $speed_percent * sqrt($distance * 10 / $fleet_speed) + 10) / $game_fleet_speed));
58 58
 
59
-    foreach($fleet_array as $ship_id => $ship_count) {
60
-      if(!$ship_id || !$ship_count) {
59
+    foreach ($fleet_array as $ship_id => $ship_count) {
60
+      if (!$ship_id || !$ship_count) {
61 61
         continue;
62 62
       }
63 63
 
@@ -85,19 +85,19 @@  discard block
 block discarded – undo
85 85
 function flt_bashing_check($user, $enemy, $planet_dst, $mission, $flight_duration, $fleet_group = 0) {
86 86
   $config_bashing_attacks = classSupernova::$config->fleet_bashing_attacks;
87 87
   $config_bashing_interval = classSupernova::$config->fleet_bashing_interval;
88
-  if(!$config_bashing_attacks) {
88
+  if (!$config_bashing_attacks) {
89 89
     // Bashing allowed - protection disabled
90 90
     return ATTACK_ALLOWED;
91 91
   }
92 92
 
93 93
   $bashing_result = ATTACK_BASHING;
94
-  if($user['ally_id'] && $enemy['ally_id']) {
94
+  if ($user['ally_id'] && $enemy['ally_id']) {
95 95
     $relations = ali_relations($user['ally_id'], $enemy['ally_id']);
96
-    if(!empty($relations)) {
96
+    if (!empty($relations)) {
97 97
       $relations = $relations[$enemy['ally_id']];
98
-      switch($relations['alliance_diplomacy_relation']) {
98
+      switch ($relations['alliance_diplomacy_relation']) {
99 99
         case ALLY_DIPLOMACY_WAR:
100
-          if(SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) {
100
+          if (SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) {
101 101
             $bashing_result = ATTACK_BASHING_WAR_DELAY;
102 102
           } else {
103 103
             return ATTACK_ALLOWED;
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 
120 120
   // Retrieving flying fleets
121 121
   $objFleetsBashing = FleetList::dbGetFleetListBashing($user['id'], $planet_dst);
122
-  foreach($objFleetsBashing->_container as $fleetBashing) {
122
+  foreach ($objFleetsBashing->_container as $fleetBashing) {
123 123
     // Checking for ACS - each ACS count only once
124
-    if($fleetBashing->group_id) {
124
+    if ($fleetBashing->group_id) {
125 125
       $bashing_list["{$user['id']}_{$fleetBashing->group_id}"] = $fleetBashing->time_arrive_to_target;
126 126
     } else {
127 127
       $bashing_list[] = $fleetBashing->time_arrive_to_target;
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
   }
130 130
 
131 131
   // Check for joining to ACS - if there are already fleets in ACS no checks should be done
132
-  if($mission == MT_AKS && $bashing_list["{$user['id']}_{$fleet_group}"]) {
132
+  if ($mission == MT_AKS && $bashing_list["{$user['id']}_{$fleet_group}"]) {
133 133
     return ATTACK_ALLOWED;
134 134
   }
135 135
 
136 136
   $query = db_bashing_list_get($user, $planet_dst, $time_limit);
137
-  while($bashing_row = db_fetch($query)) {
137
+  while ($bashing_row = db_fetch($query)) {
138 138
     $bashing_list[] = $bashing_row['bashing_time'];
139 139
   }
140 140
 
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
   $last_attack = 0;
144 144
   $wave = 0;
145 145
   $attack = 1;
146
-  foreach($bashing_list as &$bash_time) {
146
+  foreach ($bashing_list as &$bash_time) {
147 147
     $attack++;
148
-    if($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) {
148
+    if ($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) {
149 149
       $attack = 1;
150 150
       $wave++;
151 151
     }
@@ -162,16 +162,16 @@  discard block
 block discarded – undo
162 162
   //TODO: try..catch
163 163
   global $user;
164 164
 
165
-  if($user['vacation']) {
165
+  if ($user['vacation']) {
166 166
     return $result = ATTACK_OWN_VACATION;
167 167
   }
168 168
 
169
-  if(empty($fleet) || !is_array($fleet)) {
169
+  if (empty($fleet) || !is_array($fleet)) {
170 170
     return $result = ATTACK_NO_FLEET;
171 171
   }
172 172
 
173 173
   $sn_groups_mission = sn_get_groups('missions');
174
-  if(!isset($sn_groups_mission[$mission])) {
174
+  if (!isset($sn_groups_mission[$mission])) {
175 175
     return $result = ATTACK_MISSION_ABSENT;
176 176
   }
177 177
   $sn_data_mission = $sn_groups_mission[$mission];
@@ -190,32 +190,32 @@  discard block
 block discarded – undo
190 190
   $resources = 0;
191 191
   $ship_ids = sn_get_groups('fleet');
192 192
   $resource_ids = sn_get_groups('resources_loot');
193
-  foreach($fleet as $ship_id => $ship_count) {
193
+  foreach ($fleet as $ship_id => $ship_count) {
194 194
     $is_ship = in_array($ship_id, $ship_ids);
195 195
     $is_resource = in_array($ship_id, $resource_ids);
196
-    if(!$is_ship && !$is_resource) {
196
+    if (!$is_ship && !$is_resource) {
197 197
       // TODO Спецобработчик для Капитана и модулей
198 198
 //      return ATTACK_WRONG_UNIT;
199 199
     }
200 200
 
201
-    if($ship_count < 0) {
201
+    if ($ship_count < 0) {
202 202
       return $result = $is_ship ? ATTACK_SHIP_COUNT_WRONG : ATTACK_RESOURCE_COUNT_WRONG;
203 203
     }
204 204
 
205
-    if($ship_count > mrc_get_level($user, $planet_src, $ship_id)) {
205
+    if ($ship_count > mrc_get_level($user, $planet_src, $ship_id)) {
206 206
       // TODO ATTACK_NO_MISSILE
207 207
       return $result = $is_ship ? ATTACK_NO_SHIPS : ATTACK_NO_RESOURCES;
208 208
     }
209 209
 
210
-    if($is_ship) {
210
+    if ($is_ship) {
211 211
       $single_ship_data = get_ship_data($ship_id, $user);
212
-      if($single_ship_data[P_SPEED] <= 0) {
212
+      if ($single_ship_data[P_SPEED] <= 0) {
213 213
         return $result = ATTACK_ZERO_SPEED;
214 214
       }
215 215
       $ships += $ship_count;
216 216
       $recyclers += in_array($ship_id, sn_get_groups('flt_recyclers')) ? $ship_count : 0;
217 217
       $spies += $ship_id == SHIP_SPY ? $ship_count : 0;
218
-    } elseif($is_resource) {
218
+    } elseif ($is_resource) {
219 219
       $resources += $ship_count;
220 220
     }
221 221
   }
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     }
227 227
   */
228 228
 
229
-  if(isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) {
229
+  if (isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) {
230 230
     return $result = ATTACK_RESOURCE_FORBIDDEN;
231 231
   }
232 232
 
@@ -238,78 +238,78 @@  discard block
 block discarded – undo
238 238
   */
239 239
 
240 240
   $speed = $options['fleet_speed_percent'];
241
-  if($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) {
241
+  if ($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) {
242 242
     return $result = ATTACK_WRONG_SPEED;
243 243
   }
244 244
 
245 245
   $travel_data = flt_travel_data($user, $planet_src, $planet_dst, $fleet, $options['fleet_speed_percent']);
246 246
 
247 247
 
248
-  if(mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) {
248
+  if (mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) {
249 249
     return $result = ATTACK_NO_FUEL;
250 250
   }
251 251
 
252
-  if($travel_data['consumption'] > $travel_data['capacity']) {
252
+  if ($travel_data['consumption'] > $travel_data['capacity']) {
253 253
     return $result = ATTACK_TOO_FAR;
254 254
   }
255 255
 
256
-  if($travel_data['hold'] < $resources) {
256
+  if ($travel_data['hold'] < $resources) {
257 257
     return $result = ATTACK_OVERLOADED;
258 258
   }
259 259
 
260 260
   $fleet_start_time = SN_TIME_NOW + $travel_data['duration'];
261 261
 
262 262
   $fleet_group = $options['fleet_group'];
263
-  if($fleet_group) {
264
-    if($mission != MT_AKS) {
263
+  if ($fleet_group) {
264
+    if ($mission != MT_AKS) {
265 265
       return $result = ATTACK_WRONG_MISSION;
266 266
     };
267 267
 
268 268
     $acs = db_acs_get_by_group_id($fleet_group);
269
-    if(!$acs['id']) {
269
+    if (!$acs['id']) {
270 270
       return $result = ATTACK_NO_ACS;
271 271
     }
272 272
 
273
-    if($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) {
273
+    if ($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) {
274 274
       return $result = ATTACK_ACS_WRONG_TARGET;
275 275
     }
276 276
 
277
-    if($fleet_start_time > $acs['ankunft']) {
277
+    if ($fleet_start_time > $acs['ankunft']) {
278 278
       return $result = ATTACK_ACS_TOO_LATE;
279 279
     }
280 280
   }
281 281
 
282 282
   $flying_fleets = $options['flying_fleets'];
283
-  if(!$flying_fleets) {
283
+  if (!$flying_fleets) {
284 284
     $flying_fleets = FleetList::fleet_count_flying($user['id']);
285 285
   }
286
-  if(GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) {
286
+  if (GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) {
287 287
     return $result = ATTACK_NO_SLOTS;
288 288
   }
289 289
 
290 290
   // В одиночку шпионские зонды могут летать только в миссии Шпионаж, Передислокация и Транспорт
291
-  if($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) {
291
+  if ($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) {
292 292
     return $result = ATTACK_SPIES_LONLY;
293 293
   }
294 294
 
295 295
   // Checking for no planet
296
-  if(!$planet_dst['id_owner']) {
297
-    if($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) {
296
+  if (!$planet_dst['id_owner']) {
297
+    if ($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) {
298 298
       return $result = ATTACK_NO_COLONIZER;
299 299
     }
300 300
 
301
-    if($mission == MT_EXPLORE || $mission == MT_COLONIZE) {
301
+    if ($mission == MT_EXPLORE || $mission == MT_COLONIZE) {
302 302
       return $result = ATTACK_ALLOWED;
303 303
     }
304 304
 
305 305
     return $result = ATTACK_NO_TARGET;
306 306
   }
307 307
 
308
-  if($mission == MT_RECYCLE) {
309
-    if($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) {
308
+  if ($mission == MT_RECYCLE) {
309
+    if ($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) {
310 310
       return $result = ATTACK_NO_DEBRIS;
311 311
     }
312
-    if($recyclers <= 0) {
312
+    if ($recyclers <= 0) {
313 313
       return $result = ATTACK_NO_RECYCLERS;
314 314
     }
315 315
 
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
   }
318 318
 
319 319
   // Got planet. Checking if it is ours
320
-  if($planet_dst['id_owner'] == $user['id']) {
321
-    if($mission == MT_TRANSPORT || $mission == MT_RELOCATE) {
320
+  if ($planet_dst['id_owner'] == $user['id']) {
321
+    if ($mission == MT_TRANSPORT || $mission == MT_RELOCATE) {
322 322
       return $result = ATTACK_ALLOWED;
323 323
     }
324 324
 
@@ -326,19 +326,19 @@  discard block
 block discarded – undo
326 326
   }
327 327
 
328 328
   // No, planet not ours. Cutting mission that can't be send to not-ours planet
329
-  if($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) {
329
+  if ($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) {
330 330
     return $result = ATTACK_WRONG_MISSION;
331 331
   }
332 332
 
333 333
   $enemy = db_user_by_id($planet_dst['id_owner']);
334 334
   // We cannot attack or send resource to users in VACATION mode
335
-  if($enemy['vacation'] && $mission != MT_RECYCLE) {
335
+  if ($enemy['vacation'] && $mission != MT_RECYCLE) {
336 336
     return $result = ATTACK_VACATION;
337 337
   }
338 338
 
339 339
   // Multi IP protection
340 340
   // TODO: Here we need a procedure to check proxies
341
-  if(sys_is_multiaccount($user, $enemy)) {
341
+  if (sys_is_multiaccount($user, $enemy)) {
342 342
     return $result = ATTACK_SAME_IP;
343 343
   }
344 344
 
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
   $enemy_points = $enemy['total_points'];
347 347
 
348 348
   // Is it transport? If yes - checking for buffing to prevent mega-alliance destroyer
349
-  if($mission == MT_TRANSPORT) {
350
-    if($user_points >= $enemy_points || classSupernova::$config->allow_buffing) {
349
+  if ($mission == MT_TRANSPORT) {
350
+    if ($user_points >= $enemy_points || classSupernova::$config->allow_buffing) {
351 351
       return $result = ATTACK_ALLOWED;
352 352
     } else {
353 353
       return $result = ATTACK_BUFFING;
@@ -357,66 +357,66 @@  discard block
 block discarded – undo
357 357
   // Only aggresive missions passed to this point. HOLD counts as passive but aggresive
358 358
 
359 359
   // Is it admin with planet protection?
360
-  if($planet_dst['id_level'] > $user['authlevel']) {
360
+  if ($planet_dst['id_level'] > $user['authlevel']) {
361 361
     return $result = ATTACK_ADMIN;
362 362
   }
363 363
 
364 364
   // Okay. Now skipping protection checks for inactive longer then 1 week
365
-  if(!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) {
366
-    if(
365
+  if (!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) {
366
+    if (
367 367
       ($enemy_points <= classSupernova::$config->game_noob_points && $user_points > classSupernova::$config->game_noob_points)
368 368
       ||
369 369
       (classSupernova::$config->game_noob_factor && $user_points > $enemy_points * classSupernova::$config->game_noob_factor)
370 370
     ) {
371
-      if($mission != MT_HOLD) {
371
+      if ($mission != MT_HOLD) {
372 372
         return $result = ATTACK_NOOB;
373 373
       }
374
-      if($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) {
374
+      if ($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) {
375 375
         return $result = ATTACK_NOOB;
376 376
       }
377 377
     }
378 378
   }
379 379
 
380 380
   // Is it HOLD mission? If yes - there should be ally deposit
381
-  if($mission == MT_HOLD) {
382
-    if(mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) {
381
+  if ($mission == MT_HOLD) {
382
+    if (mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) {
383 383
       return $result = ATTACK_ALLOWED;
384 384
     }
385 385
 
386 386
     return $result = ATTACK_NO_ALLY_DEPOSIT;
387 387
   }
388 388
 
389
-  if($mission == MT_SPY) {
389
+  if ($mission == MT_SPY) {
390 390
     return $result = $spies >= 1 ? ATTACK_ALLOWED : ATTACK_NO_SPIES;
391 391
   }
392 392
 
393 393
   // Is it MISSILE mission?
394
-  if($mission == MT_MISSILE) {
394
+  if ($mission == MT_MISSILE) {
395 395
     $sn_data_mip = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET);
396
-    if(mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) {
396
+    if (mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) {
397 397
       return $result = ATTACK_NO_SILO;
398 398
     }
399 399
 
400
-    if(!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) {
400
+    if (!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) {
401 401
       return $result = ATTACK_NO_MISSILE;
402 402
     }
403 403
 
404 404
     $distance = abs($planet_dst['system'] - $planet_src['system']);
405 405
     $mip_range = flt_get_missile_range($user);
406
-    if($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) {
406
+    if ($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) {
407 407
       return $result = ATTACK_MISSILE_TOO_FAR;
408 408
     }
409 409
 
410
-    if(isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) {
410
+    if (isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) {
411 411
       return $result = ATTACK_WRONG_STRUCTURE;
412 412
     }
413 413
   }
414 414
 
415
-  if($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) {
415
+  if ($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) {
416 416
     return $result = ATTACK_WRONG_MISSION;
417 417
   }
418 418
 
419
-  if($mission == MT_ATTACK || $mission == MT_AKS || $mission == MT_DESTROY) {
419
+  if ($mission == MT_ATTACK || $mission == MT_AKS || $mission == MT_DESTROY) {
420 420
     return $result = flt_bashing_check($user, $enemy, $planet_dst, $mission, $travel_data['duration'], $fleet_group);
421 421
   }
422 422
 
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
   $from = $from['planet'];
444 444
 
445 445
   $can_attack = flt_can_attack($from, $to, $fleet_REAL_array, $mission, $options);
446
-  if($can_attack != ATTACK_ALLOWED) {
446
+  if ($can_attack != ATTACK_ALLOWED) {
447 447
     $internal_transaction ? sn_db_transaction_rollback() : false;
448 448
 
449 449
     return $can_attack;
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
   $travel_data = flt_travel_data($user, $from, $to, $fleet_REAL_array, $options['fleet_speed_percent']);
455 455
 
456 456
   $time_on_mission = 0;
457
-  if($mission == MT_EXPLORE || $mission == MT_HOLD) {
457
+  if ($mission == MT_EXPLORE || $mission == MT_HOLD) {
458 458
     // TODO - include some checks about maximum and minumum stay_duration
459 459
     $time_on_mission = $options['stay_time'] * 3600;
460 460
   }
@@ -477,14 +477,14 @@  discard block
 block discarded – undo
477 477
   $sn_group_resources_loot = sn_get_groups('resources_loot');
478 478
   $db_changeset = array();
479 479
   $planet_row_changed_fields = array();
480
-  foreach($fleet_REAL_array as $unit_id => $amount) {
481
-    if(!$amount || !$unit_id) {
480
+  foreach ($fleet_REAL_array as $unit_id => $amount) {
481
+    if (!$amount || !$unit_id) {
482 482
       continue;
483 483
     }
484 484
 
485
-    if(in_array($unit_id, $sn_group_fleet)) {
485
+    if (in_array($unit_id, $sn_group_fleet)) {
486 486
       $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, -$amount, $user, $from['id']);
487
-    } elseif(in_array($unit_id, $sn_group_resources_loot)) {
487
+    } elseif (in_array($unit_id, $sn_group_resources_loot)) {
488 488
       $planet_row_changed_fields[pname_resource_name($unit_id)]['delta'] -= $amount;
489 489
     }
490 490
   }
@@ -523,16 +523,16 @@  discard block
 block discarded – undo
523 523
 
524 524
   $ship_data = array();
525 525
   $fleet_array = array();
526
-  foreach($ship_list as $transport_id => $cork) {
526
+  foreach ($ship_list as $transport_id => $cork) {
527 527
     $ship_data[$transport_id] = flt_travel_data($user, $from, $to, array($transport_id => 1), 10);
528 528
   }
529 529
   uasort($ship_data, 'flt_calculate_ship_to_transport_sort');
530 530
 
531 531
   $fleet_capacity = 0;
532 532
   $fuel_total = $fuel_left = mrc_get_level($user, $from, RES_DEUTERIUM);
533
-  foreach($ship_data as $transport_id => &$ship_info) {
533
+  foreach ($ship_data as $transport_id => &$ship_info) {
534 534
     $ship_loaded = min($ship_list[$transport_id], ceil($resource_amount / $ship_info['hold']), floor($fuel_left / $ship_info['consumption']));
535
-    if($ship_loaded) {
535
+    if ($ship_loaded) {
536 536
       $fleet_array[$transport_id] = $ship_loaded;
537 537
       $resource_amount -= min($resource_amount, $ship_info['hold'] * $ship_loaded);
538 538
       $fuel_left -= $ship_info['consumption'] * $ship_loaded;
Please login to merge, or discard this patch.
includes/includes/flt_mission_spy.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -29,6 +29,9 @@
 block discarded – undo
29 29
   }
30 30
 }
31 31
 
32
+/**
33
+ * @param string $group_name
34
+ */
32 35
 function flt_spy_scan($target_planet, $group_name, $section_title, $target_user = array())
33 36
 {
34 37
   global $lang;
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
  */
12 12
 // ----------------------------------------------------------------------------------------------------------------
13 13
 function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array()) {
14
-  foreach($unit_group as $unit_id) {
15
-    if(($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) {
14
+  foreach ($unit_group as $unit_id) {
15
+    if (($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) {
16 16
       $compress_data[$unit_id] = $unit_count;
17 17
     }
18 18
   }
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
   global $lang;
23 23
 
24 24
   $result = "<tr><td class=\"c\" colspan=\"4\">{$section_title}</td></tr>";
25
-  foreach(sn_get_groups($group_name) as $unit_id) {
26
-    if(($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) {
25
+  foreach (sn_get_groups($group_name) as $unit_id) {
26
+    if (($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) {
27 27
       $result .= "<tr><td align=\"left\" colspan=\"3\">{$lang['tech'][$unit_id]}</td><td align=\"right\">{$unit_amount}</td></tr>";
28 28
     }
29 29
 
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
 
55 55
   $objFleet = $mission_data->fleet;
56 56
 
57
-  if(empty($target_user_row['id']) || empty($target_planet_row['id']) || empty($spying_user_row['id'])) {
57
+  if (empty($target_user_row['id']) || empty($target_planet_row['id']) || empty($spying_user_row['id'])) {
58 58
     $objFleet->mark_fleet_as_returned_and_save();
59 59
 
60 60
     return $result;
61 61
   }
62 62
 
63 63
   $spy_probes = $objFleet->shipCountById(SHIP_SPY);
64
-  if($spy_probes > 0) {
64
+  if ($spy_probes > 0) {
65 65
     $TargetSpyLvl = GetSpyLevel($target_user_row);
66 66
     $CurrentSpyLvl = GetSpyLevel($spying_user_row);
67 67
     $spy_diff_empire = $CurrentSpyLvl - $TargetSpyLvl;
@@ -85,19 +85,19 @@  discard block
 block discarded – undo
85 85
     $spy_message .= "<td width=220>{$lang['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium']) . "</td>";
86 86
     $spy_message .= "<td width=220>{$lang['sys_energy']}</td><td width=220 align=right>" . pretty_number($target_planet_row['energy_max']) . "</td>";
87 87
     $spy_message .= "</tr>";
88
-    if($spy_diff >= 2) {
88
+    if ($spy_diff >= 2) {
89 89
       $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'fleet', $lang['tech'][UNIT_SHIPS], $target_user_row) . "</div>";
90 90
       coe_compress_add_units(sn_get_groups('fleet'), $target_planet_row, $combat_pack[0]);
91 91
     }
92
-    if($spy_diff >= 3) {
92
+    if ($spy_diff >= 3) {
93 93
       $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'defense', $lang['tech'][UNIT_DEFENCE], $target_user_row) . "</div>";
94 94
       coe_compress_add_units(sn_get_groups('defense_active'), $target_planet_row, $combat_pack[0]);
95 95
     }
96
-    if($spy_diff >= 5) {
96
+    if ($spy_diff >= 5) {
97 97
       $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'structures', $lang['tech'][UNIT_STRUCTURES], $target_user_row) . "</div>";
98 98
     }
99 99
 
100
-    if($spy_diff_empire >= 0) {
100
+    if ($spy_diff_empire >= 0) {
101 101
       $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'tech', $lang['tech'][UNIT_TECHNOLOGIES], $target_user_row) . "</div>";
102 102
       coe_compress_add_units(array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR), $target_planet_row, $combat_pack[0], $target_user_row);
103 103
     }
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
     $simulator_link = sn_ube_simulator_encode_replay($combat_pack, 'D');
107 107
 
108 108
     $target_unit_list = 0;
109
-    foreach(sn_get_groups('fleet') as $unit_id) {
109
+    foreach (sn_get_groups('fleet') as $unit_id) {
110 110
       $target_unit_list += max(0, mrc_get_level($target_user_row, $target_planet_row, $unit_id, false, true));
111 111
     }
112 112
 
113 113
     $spy_detected = $spy_probes * $target_unit_list / 4 * pow(2, $TargetSpyLvl - $CurrentSpyLvl);
114 114
 
115
-    if(mt_rand(0, 99) > $spy_detected) {
115
+    if (mt_rand(0, 99) > $spy_detected) {
116 116
       $spy_outcome_str = sprintf($lang['sys_mess_spy_detect_chance'], $spy_detected);
117 117
       $spy_detected = false;
118 118
     } else {
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     $target_message = "{$lang['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} " . uni_render_coordinates_href($spying_planet_row, '', 3);
133 133
     $target_message .= " {$lang['sys_mess_spy_seen_at']} {$target_planet_row['name']} " . uni_render_coordinates($target_planet_row);
134 134
 
135
-    if($spy_detected) {
135
+    if ($spy_detected) {
136 136
       $debris_planet_id = $target_planet_row['planet_type'] == PT_PLANET ? $target_planet_row['id'] : $target_planet_row['parent_planet'];
137 137
 
138 138
       $spy_cost = get_unit_param(SHIP_SPY, P_COST);
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, $lang['sys_mess_spy_control'], $lang['sys_mess_spy_activity'], $target_message);
150 150
   }
151 151
 
152
-  if($spy_detected) {
152
+  if ($spy_detected) {
153 153
     $objFleet->db_delete_this_fleet();
154 154
   } else {
155 155
     $objFleet->mark_fleet_as_returned_and_save();
Please login to merge, or discard this patch.
includes/includes/mrc_mercenary.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -26,6 +26,10 @@
 block discarded – undo
26 26
   return true;
27 27
 }
28 28
 
29
+/**
30
+ * @param integer $mode
31
+ * @param integer $mercenary_id
32
+ */
29 33
 function mrc_mercenary_hire($mode, $user, $mercenary_id) {
30 34
   global $config, $lang, $sn_powerup_buy_discounts;
31 35
 
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -4,13 +4,13 @@  discard block
 block discarded – undo
4 4
 
5 5
 function mrc_officer_accessible(&$user, $mercenary_id) {
6 6
   $mercenary_info = get_unit_param($mercenary_id);
7
-  if(classSupernova::$config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) {
7
+  if (classSupernova::$config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) {
8 8
     return true;
9 9
   }
10 10
 
11
-  if(isset($mercenary_info[P_REQUIRE])) {
12
-    foreach($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) {
13
-      if(mrc_get_level($user, null, $unit_id) < $unit_level) {
11
+  if (isset($mercenary_info[P_REQUIRE])) {
12
+    foreach ($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) {
13
+      if (mrc_get_level($user, null, $unit_id) < $unit_level) {
14 14
         return false;
15 15
       }
16 16
     }
@@ -26,35 +26,35 @@  discard block
 block discarded – undo
26 26
     $is_permanent = $mode == UNIT_PLANS || !classSupernova::$config->empire_mercenary_temporary;
27 27
     $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? classSupernova::$config->ali_bonus_members : 1);
28 28
     $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1;
29
-    if(!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) {
29
+    if (!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) {
30 30
       throw new Exception(classLocale::$lang['mrc_msg_error_wrong_mercenary'], ERR_ERROR);
31 31
     }
32 32
 
33
-    if(!mrc_officer_accessible($user, $mercenary_id)) {
33
+    if (!mrc_officer_accessible($user, $mercenary_id)) {
34 34
       throw new Exception(classLocale::$lang['mrc_msg_error_requirements'], ERR_ERROR);
35 35
     }
36 36
 
37 37
     $mercenary_level = sys_get_param_int('mercenary_level');
38
-    if($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) {
38
+    if ($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) {
39 39
       throw new Exception(classLocale::$lang['mrc_msg_error_wrong_level'], ERR_ERROR);
40 40
     }
41 41
 
42
-    if($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) {
42
+    if ($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) {
43 43
       throw new Exception(classLocale::$lang['mrc_msg_error_wrong_period'], ERR_ERROR);
44 44
     }
45 45
 
46 46
     sn_db_transaction_start();
47 47
 
48 48
     $mercenary_level_old = mrc_get_level($user, $planetrow, $mercenary_id, true, true);
49
-    if(classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) {
49
+    if (classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) {
50 50
       throw new Exception(classLocale::$lang['mrc_msg_error_already_hired'], ERR_ERROR); // Can't hire already hired temp mercenary - dismiss first
51
-    } elseif(classSupernova::$config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) {
51
+    } elseif (classSupernova::$config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) {
52 52
       throw new Exception('', ERR_NONE); // Can't dismiss (!$mercenary_level) not hired (!$mercenary_level_old) temp mercenary. But no error
53 53
     }
54 54
 
55
-    if($mercenary_level) {
55
+    if ($mercenary_level) {
56 56
       $darkmater_cost = eco_get_total_cost($mercenary_id, $mercenary_level);
57
-      if(!classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old) {
57
+      if (!classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old) {
58 58
         $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old);
59 59
         $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER];
60 60
       }
@@ -64,13 +64,13 @@  discard block
 block discarded – undo
64 64
     }
65 65
     $darkmater_cost *= $cost_alliance_multiplyer;
66 66
 
67
-    if(mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) {
67
+    if (mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) {
68 68
       throw new Exception(classLocale::$lang['mrc_msg_error_no_resource'], ERR_ERROR);
69 69
     }
70 70
 
71
-    if(($darkmater_cost && $mercenary_level) || !$is_permanent) {
71
+    if (($darkmater_cost && $mercenary_level) || !$is_permanent) {
72 72
       $unit_row = db_unit_by_location($user['id'], LOC_USER, $user['id'], $mercenary_id);
73
-      if(is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) {
73
+      if (is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) {
74 74
         $dismiss_full_cost = eco_get_total_cost($mercenary_id, $unit_row['unit_level']);
75 75
         $dismiss_full_cost = $dismiss_full_cost[BUILD_CREATE][RES_DARK_MATTER];
76 76
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
       db_unit_list_delete($user['id'], LOC_USER, $user['id'], $mercenary_id);
84 84
     }
85 85
 
86
-    if($darkmater_cost && $mercenary_level) {
86
+    if ($darkmater_cost && $mercenary_level) {
87 87
       db_unit_set_insert(
88 88
         "unit_player_id = {$user['id']},
89 89
         unit_location_type = " . LOC_USER . ",
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     }
101 101
     sn_db_transaction_commit();
102 102
     sys_redirect($_SERVER['REQUEST_URI']);
103
-  } catch(Exception $e) {
103
+  } catch (Exception $e) {
104 104
     sn_db_transaction_rollback();
105 105
     $operation_result = array(
106 106
       'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
   $mode = in_array($mode, array(UNIT_MERCENARIES, UNIT_PLANS)) ? $mode : UNIT_MERCENARIES;
119 119
   $is_permanent = $mode == UNIT_PLANS || !classSupernova::$config->empire_mercenary_temporary;
120 120
 
121
-  if($mercenary_id = sys_get_param_int('mercenary_id')) {
121
+  if ($mercenary_id = sys_get_param_int('mercenary_id')) {
122 122
     $operation_result = mrc_mercenary_hire($mode, $user, $mercenary_id);
123 123
   }
124 124
 
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 
127 127
   $template = gettemplate('mrc_mercenary_hire', true);
128 128
 
129
-  if(!empty($operation_result)) {
129
+  if (!empty($operation_result)) {
130 130
     $template->assign_block_vars('result', $operation_result);
131 131
   }
132 132
 
133
-  foreach($sn_powerup_buy_discounts as $hire_period => $hire_discount) {
133
+  foreach ($sn_powerup_buy_discounts as $hire_period => $hire_discount) {
134 134
     $template->assign_block_vars('period', array(
135 135
       'LENGTH'   => $hire_period,
136 136
       'TEXT'     => classLocale::$lang['mrc_period_list'][$hire_period],
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
   $user_dark_matter = mrc_get_level($user, null, RES_DARK_MATTER);
143 143
   $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? classSupernova::$config->ali_bonus_members : 1);
144 144
   $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1;
145
-  foreach(sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) {
145
+  foreach (sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) {
146 146
     {
147 147
       $mercenary = get_unit_param($mercenary_id);
148 148
       $mercenary_bonus = $mercenary['bonus'];
149 149
       $mercenary_bonus = $mercenary_bonus >= 0 ? "+{$mercenary_bonus}" : "{$mercenary_bonus}";
150
-      switch($mercenary['bonus_type']) {
150
+      switch ($mercenary['bonus_type']) {
151 151
         case BONUS_PERCENT:
152 152
           $mercenary_bonus = "{$mercenary_bonus}% ";
153 153
         break;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
       $mercenary_level = mrc_get_level($user, null, $mercenary_id, false, true);
165 165
       $mercenary_level_bonus = max(0, mrc_get_level($user, null, $mercenary_id) - $mercenary_level);
166 166
       $total_cost_old = 0;
167
-      if($is_permanent) {
167
+      if ($is_permanent) {
168 168
         $total_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level);
169 169
         $total_cost_old = $total_cost_old[BUILD_CREATE][RES_DARK_MATTER] * $cost_alliance_multiplyer;
170 170
       }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
       ));
194 194
 
195 195
       $upgrade_cost = 1;
196
-      for($i = classSupernova::$config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) {
196
+      for ($i = classSupernova::$config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) {
197 197
         $total_cost = eco_get_total_cost($mercenary_id, $i);
198 198
         $total_cost[BUILD_CREATE][RES_DARK_MATTER] *= $cost_alliance_multiplyer;
199 199
         $upgrade_cost = $total_cost[BUILD_CREATE][RES_DARK_MATTER] - $total_cost_old;
Please login to merge, or discard this patch.
resources.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
   ));
47 47
 };
48 48
 
49
-$ValidList['percent'] = array (  0,  10,  20,  30,  40,  50,  60,  70,  80,  90, 100 );
49
+$ValidList['percent'] = array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100);
50 50
 $template = gettemplate('resources', true);
51 51
 
52 52
 $transmutation_result = sn_sys_planet_core_transmute($user, $planetrow);
53
-if(!empty($transmutation_result))
53
+if (!empty($transmutation_result))
54 54
 {
55 55
   $template->assign_block_vars('result', $transmutation_result); // array('STATUS' => $transmutation_result['STATUS'], 'MESSAGE' => $transmutation_result['MESSAGE']));
56 56
 }
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
 $production = $_POST['production'];
60 60
 //$SubQry     = '';
61 61
 $SubQry     = array();
62
-if(is_array($production)) {
63
-  foreach($production as $prod_id => $percent) {
64
-    if($percent > 100 || $percent < 0) {
62
+if (is_array($production)) {
63
+  foreach ($production as $prod_id => $percent) {
64
+    if ($percent > 100 || $percent < 0) {
65 65
       $debug->warning('Supplying wrong production percent (less then 0 or greater then 100)', 'Hack attempt', 302, array('base_dump' => true));
66 66
       die();
67 67
     }
68 68
 
69 69
     $prod_id = intval($prod_id);
70
-    if(in_array($prod_id, $sn_group_factories) && get_unit_param($prod_id, P_MINING_IS_MANAGED)) {
70
+    if (in_array($prod_id, $sn_group_factories) && get_unit_param($prod_id, P_MINING_IS_MANAGED)) {
71 71
       $field_name              = pname_factory_production_field_name($prod_id);
72 72
       $percent                 = floor($percent / 10);
73 73
       $planetrow[$field_name]  = $percent;
74 74
       //$SubQry                 .= "`{$field_name}` = '{$percent}',";
75
-      $SubQry[]                 = "`{$field_name}` = '{$percent}'";
75
+      $SubQry[] = "`{$field_name}` = '{$percent}'";
76 76
     } else {
77 77
       $debug->warning('Supplying wrong ID in production array - attempt to change some field - ID' . $prod_id, 'Resource Page', 301);
78 78
       continue;
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
   'ENERGY_TYPE'    => pretty_number($caps_real['production'][RES_ENERGY][0], true, true),
109 109
 ));
110 110
 
111
-foreach($sn_group_factories as $unit_id)
111
+foreach ($sn_group_factories as $unit_id)
112 112
 {
113
-  if(mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id))
113
+  if (mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id))
114 114
   {
115 115
     $level_plain = mrc_get_level($user, $planetrow, $unit_id, false, true);
116 116
     $template->assign_block_vars('production', array(
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
 
93 93
 for ($Option = 10; $Option >= 0; $Option--)
94 94
 {
95
- $template->assign_block_vars('option', array(
96
-   'VALUE' => $Option * 10,
97
- ));
95
+  $template->assign_block_vars('option', array(
96
+    'VALUE' => $Option * 10,
97
+  ));
98 98
 }
99 99
 
100 100
 $caps_real = eco_get_planet_caps($user, $planetrow, 3600);
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
 int_calc_storage_bar(RES_DEUTERIUM);
164 164
 
165 165
 $template->assign_vars(array(
166
- 'PLANET_NAME'          => $planetrow['name'],
167
- 'PLANET_TYPE'          => $planetrow['planet_type'],
168
- 'PLANET_DENSITY_INDEX' => $planet_density_index,
169
- 'PLANET_CORE_TEXT'     => classLocale::$lang['uni_planet_density_types'][$planet_density_index],
166
+  'PLANET_NAME'          => $planetrow['name'],
167
+  'PLANET_TYPE'          => $planetrow['planet_type'],
168
+  'PLANET_DENSITY_INDEX' => $planet_density_index,
169
+  'PLANET_CORE_TEXT'     => classLocale::$lang['uni_planet_density_types'][$planet_density_index],
170 170
 
171
- 'PRODUCTION_LEVEL'     => floor($caps_real['efficiency'] * 100),
171
+  'PRODUCTION_LEVEL'     => floor($caps_real['efficiency'] * 100),
172 172
 
173
- 'PAGE_HINT'            => classLocale::$lang['res_hint'],
173
+  'PAGE_HINT'            => classLocale::$lang['res_hint'],
174 174
 ));
175 175
 
176 176
 display($template, classLocale::$lang['res_planet_production']);
Please login to merge, or discard this patch.
admin/adm_user_analyze.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,8 +39,8 @@
 block discarded – undo
39 39
     0 => $row['visit_time'], // start
40 40
     1 => $row['visit_time'], // end
41 41
   )
42
-   //: false
43
-   ;
42
+    //: false
43
+    ;
44 44
 }
45 45
 
46 46
 $session_list = array();
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -12,20 +12,20 @@  discard block
 block discarded – undo
12 12
 
13 13
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
14 14
 
15
-if($user['authlevel'] < 3) {
15
+if ($user['authlevel'] < 3) {
16 16
   AdminMessage($lang['adm_err_denied']);
17 17
 }
18 18
 
19 19
 // define('SESSION_INTERRUPT', 15*60); // Можно увеличить до 4 часов - никито не может сидеть 2 суток с перерывом менее 4 часов
20 20
 // define('SUSPICIOUS_LONG', 2 * 60*60); // Тогда это увеличиваем до, скажем суток - и там смотрим
21 21
 
22
-define('SESSION_INTERRUPT', 1 * 60*60); // Можно увеличить до 4 часов - никито не может сидеть 2 суток с перерывом менее 4 часов
23
-define('SUSPICIOUS_LONG', 16 * 60*60); // Тогда это увеличиваем до, скажем суток - и там смотрим
22
+define('SESSION_INTERRUPT', 1 * 60 * 60); // Можно увеличить до 4 часов - никито не может сидеть 2 суток с перерывом менее 4 часов
23
+define('SUSPICIOUS_LONG', 16 * 60 * 60); // Тогда это увеличиваем до, скажем суток - и там смотрим
24 24
 
25 25
 
26 26
 function check_suspicious(&$session, &$session_list_last_id, &$row) {
27 27
   $session[2] = $session[1] - $session[0];
28
-  if($session[2] > SUSPICIOUS_LONG)
28
+  if ($session[2] > SUSPICIOUS_LONG)
29 29
   {
30 30
     $session[2] = pretty_time($session[2]);
31 31
     $session[0] = date(FMT_DATE_TIME_SQL, $session[0]);
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
 $session_list = array();
47 47
 $query = doquery("SELECT `visit_time`, user_id FROM {{counter}} where user_id <> 0 and visit_time > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 DAY)) order by user_id, visit_time;");
48 48
 $session = array();
49
-if($row = db_fetch($query)) {
49
+if ($row = db_fetch($query)) {
50 50
   $session = array(
51 51
     0 => strtotime($row['visit_time']), // start
52 52
     1 => strtotime($row['visit_time']), // end
53 53
   );
54 54
   $last_id = $row['user_id'];
55 55
 }
56
-while($row = db_fetch($query)) {
56
+while ($row = db_fetch($query)) {
57 57
   $row['visit_time'] = strtotime($row['visit_time']);
58
-  if($last_id == $row['user_id']) {
58
+  if ($last_id == $row['user_id']) {
59 59
     // Тот же юзер
60
-    if($row['visit_time'] - $session[1] <= SESSION_INTERRUPT) { // Та же сессия
60
+    if ($row['visit_time'] - $session[1] <= SESSION_INTERRUPT) { // Та же сессия
61 61
       $session[1] = $row['visit_time'];
62 62
     } else {
63 63
       // Новая сессия
64 64
 //      check_suspicious($session, $session_list[$last_id], $row);
65 65
       $session[2] = $session[1] - $session[0];
66
-      if($session[2] > SUSPICIOUS_LONG)
66
+      if ($session[2] > SUSPICIOUS_LONG)
67 67
       {
68 68
         $session[2] = pretty_time($session[2]);
69 69
         $session[0] = date(FMT_DATE_TIME_SQL, $session[0]);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
   } else {
79 79
 //    check_suspicious($session, $session_list[$last_id], $row);
80 80
     $session[2] = $session[1] - $session[0];
81
-      if($session[2] > SUSPICIOUS_LONG)
81
+      if ($session[2] > SUSPICIOUS_LONG)
82 82
       {
83 83
         $session[2] = pretty_time($session[2]);
84 84
         $session[0] = date(FMT_DATE_TIME_SQL, $session[0]);
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
   }
94 94
 }
95 95
 
96
-if($last_id) {
96
+if ($last_id) {
97 97
   // check_suspicious($session, $session_list[$last_id], $row = array('time' => 0));
98 98
   $session[2] = $session[1] - $session[0];
99 99
 
100
-  if($session[2] > SUSPICIOUS_LONG)
100
+  if ($session[2] > SUSPICIOUS_LONG)
101 101
   {
102 102
     $session[2] = pretty_time($session[2]);
103 103
     $session[0] = date(FMT_DATE_TIME_SQL, $session[0]);
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 print("<td>ID</td><td>Username</td><td>Start</td><td>End</td><td>Length</td>");
112 112
 print("<td>Last online</td>");
113 113
 print("</tr>");
114
-foreach($session_list as $user_id => $value) {
114
+foreach ($session_list as $user_id => $value) {
115 115
   $user_record = doquery("SELECT `username`, onlinetime FROM {{users}} WHERE id = {$user_id};", true);
116
-  foreach($value as $interval_data) {
116
+  foreach ($value as $interval_data) {
117 117
     print("<tr>");
118 118
     print("<td>{$user_id}</td><td>{$user_record['username']}</td><td>{$interval_data[0]}</td><td>{$interval_data[1]}</td><td>{$interval_data[2]}</td>");
119 119
     print("<td>" . date(FMT_DATE_TIME_SQL, $user_record['onlinetime']) . "</td>");
Please login to merge, or discard this patch.
admin/add_moon.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@
 block discarded – undo
14 14
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
15 15
 
16 16
 // if ($user['authlevel'] < 2)
17
-if($user['authlevel'] < 3)
17
+if ($user['authlevel'] < 3)
18 18
 {
19 19
   AdminMessage($lang['adm_err_denied']);
20 20
 }
21 21
 
22 22
 $template = gettemplate("admin/add_moon", true);
23 23
 
24
-if(sys_get_param_str('mode') == 'addit')
24
+if (sys_get_param_str('mode') == 'addit')
25 25
 {
26 26
   $PlanetID = sys_get_param_id('user');
27 27
   $MoonName = sys_get_param_str('name');
Please login to merge, or discard this patch.
admin/planet_edit.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
8 8
 
9 9
 // if($user['authlevel'] < 2)
10
-if($user['authlevel'] < 3)
10
+if ($user['authlevel'] < 3)
11 11
 {
12 12
   AdminMessage($lang['adm_err_denied']);
13 13
 }
@@ -21,30 +21,30 @@  discard block
 block discarded – undo
21 21
 $planet_id = sys_get_param_id('planet_id');
22 22
 
23 23
 $unit_list = sys_get_param('unit_list');
24
-if(sys_get_param('change_data') && !empty($unit_list))
24
+if (sys_get_param('change_data') && !empty($unit_list))
25 25
 {
26 26
   $query_string = array();
27
-  foreach($unit_list as $unit_id => $unit_amount)
27
+  foreach ($unit_list as $unit_id => $unit_amount)
28 28
   {
29
-    if($unit_query_string = admin_planet_edit_query_string($unit_id, $unit_amount, $mode))
29
+    if ($unit_query_string = admin_planet_edit_query_string($unit_id, $unit_amount, $mode))
30 30
     {
31 31
       $query_string[] = $unit_query_string;
32 32
     }
33 33
   }
34 34
 
35
-  if(!empty($query_string))
35
+  if (!empty($query_string))
36 36
   {
37 37
     db_planet_set_by_id($planet_id, implode(', ', $query_string));
38 38
   }
39 39
 }
40 40
 
41
-if($planet_id)
41
+if ($planet_id)
42 42
 {
43 43
   $edit_planet_row = db_planet_by_id($planet_id);
44 44
   admin_planet_edit_template($template, $edit_planet_row, $mode);
45 45
 }
46 46
 
47
-foreach($admin_planet_edit_mode_list as $page_mode => $mode_locale)
47
+foreach ($admin_planet_edit_mode_list as $page_mode => $mode_locale)
48 48
 {
49 49
   $template->assign_block_vars('page_menu', array(
50 50
     'ID' => $page_mode,
Please login to merge, or discard this patch.
admin/adm_quest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-define('INSIDE'  , true);
11
-define('INSTALL' , false);
12
-define('IN_ADMIN'  , true);
10
+define('INSIDE', true);
11
+define('INSTALL', false);
12
+define('IN_ADMIN', true);
13 13
 
14 14
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
15 15
 
16
-if($user['authlevel'] < 2)
16
+if ($user['authlevel'] < 2)
17 17
 {
18 18
   AdminMessage($lang['adm_err_denied']);
19 19
 }
Please login to merge, or discard this patch.
admin/admin_locale.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -7,25 +7,25 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-define('INSIDE'  , true);
11
-define('INSTALL' , false);
12
-define('IN_ADMIN'  , true);
10
+define('INSIDE', true);
11
+define('INSTALL', false);
12
+define('IN_ADMIN', true);
13 13
 
14 14
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
15 15
 
16
-if($user['authlevel'] < 3) {
16
+if ($user['authlevel'] < 3) {
17 17
   AdminMessage($lang['adm_err_denied']);
18 18
 }
19 19
 
20 20
 function adm_lng_assign_string($lang_id, $locale_string_name, $value) {
21 21
   global $locale_string_template, $languages_info, $languages, $domain;
22 22
 
23
-  if(is_array($value)) {
24
-    foreach($value as $sub_key => $sub_value) {
23
+  if (is_array($value)) {
24
+    foreach ($value as $sub_key => $sub_value) {
25 25
       adm_lng_assign_string($lang_id, "{$locale_string_name}[{$sub_key}]", $sub_value);
26 26
     }
27
-  } elseif($value) {
28
-    if(!isset($locale_string_template[$locale_string_name])) {
27
+  } elseif ($value) {
28
+    if (!isset($locale_string_template[$locale_string_name])) {
29 29
       $locale_string_template[$locale_string_name] = array();
30 30
     }
31 31
     $locale_string_template[$locale_string_name] = array_merge($locale_string_template[$locale_string_name], array("[{$lang_id}]" => htmlentities($value, ENT_COMPAT, 'utf-8')));
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
   global $domain, $lang_id;
47 47
 
48 48
   $return = "{$ident}'{$string_name}' => ";
49
-  if(isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) {
49
+  if (isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) {
50 50
     $return .= "'" . str_replace(array("\\", "'"), array('\\\\', "\\'"), $string_value[$lang_id]) . "',";
51 51
   } else {
52 52
     $return .= "array(\r\n";
53
-    foreach($string_value as $arr_name => $arr_data) {
53
+    foreach ($string_value as $arr_name => $arr_data) {
54 54
       $return .= adm_lng_parse_string($arr_name, $arr_data, $ident . '  ');
55 55
     }
56 56
     $return .= "{$ident}),\r\n";
@@ -103,12 +103,12 @@  discard block
 block discarded – undo
103 103
 
104 104
   $string_name_new = false;
105 105
 
106
-  if(isset($honor_constants[$domain][$string_name_prefix])) {
106
+  if (isset($honor_constants[$domain][$string_name_prefix])) {
107 107
     $found_constants = array_keys($constants, $string_name);
108
-    foreach($found_constants as $constant_name) {
108
+    foreach ($found_constants as $constant_name) {
109 109
       $honor_prefix_list = is_array($honor_constants[$domain][$string_name_prefix]) ? $honor_constants[$domain][$string_name_prefix] : array($honor_constants[$domain][$string_name_prefix]);
110
-      foreach($honor_prefix_list as $honor_prefix) {
111
-        if(strpos($constant_name, $honor_prefix) === 0) {
110
+      foreach ($honor_prefix_list as $honor_prefix) {
111
+        if (strpos($constant_name, $honor_prefix) === 0) {
112 112
           $string_name_new = $constant_name;
113 113
           break;
114 114
         }
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 
119 119
   $string_name_new = $string_name_new ? $string_name_new : "'{$string_name}'";
120 120
   fwrite($file_handler, "{$ident}{$string_name_new} => ");
121
-  if(isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) {
121
+  if (isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) {
122 122
     fwrite($file_handler, "'" . str_replace(array("\\", "'"), array('\\\\', "\\'"), $string_value[$lang_id]) . "',");
123 123
   } else {
124 124
     $string_name_prefix = $string_name_prefix . "[{$string_name}]";
125 125
     fwrite($file_handler, "array(\r\n");
126
-    foreach($string_value as $arr_name => $arr_data) {
126
+    foreach ($string_value as $arr_name => $arr_data) {
127 127
       adm_lng_write_string($arr_name, $arr_data, $ident . '  ', $string_name_prefix);
128 128
     }
129 129
     fwrite($file_handler, "{$ident}),\r\n");
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
 $languages_info = lng_get_list();
144 144
 $domain = sys_get_param_str('domain');
145 145
 
146
-if($domain) {
146
+if ($domain) {
147 147
   $lang_new = sys_get_param('lang_new');
148
-  if(!empty($lang_new)) {
148
+  if (!empty($lang_new)) {
149 149
     $constants = get_defined_constants(true);
150 150
     $constants = $constants['user'];
151 151
     ksort($constants);
152
-    foreach($languages_info as $lang_id => $land_data) {
152
+    foreach ($languages_info as $lang_id => $land_data) {
153 153
       $file_handler = fopen(SN_ROOT_PHYSICAL . "language/{$lang_id}/{$domain}.mo.php.new", 'w');
154 154
       fwrite($file_handler, "<?php\r\n\r\n/*\r\n#############################################################################
155 155
 #  Filename: {$domain}.mo.php
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 #  Website: http://www.supernova.ws
158 158
 #  Description: Massive Multiplayer Online Browser Space Startegy Game\r\n#\r\n");
159 159
 
160
-      foreach($land_data['LANG_COPYRIGHT'] as $lang_copyright) {
160
+      foreach ($land_data['LANG_COPYRIGHT'] as $lang_copyright) {
161 161
         $lang_copyright = str_replace(array('&copy;', '&quot;', '&lt;', '&gt;'), array('©', '"', '<', '>'), $lang_copyright);
162 162
         fwrite($file_handler, "#  {$lang_copyright}\r\n");
163 163
       }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 /**\r\n*\r\n* @package language\r\n* @system [{$land_data['LANG_NAME_ENGLISH']}]\r\n* @version " . SN_VERSION . "\r\n*\r\n*/\r\n
166 166
 /**\r\n* DO NOT CHANGE\r\n*/\r\n\r\nif (!defined('INSIDE')) die();\r\n
167 167
 \$a_lang_array = array(\r\n");
168
-      foreach($lang_new as $string_name => $string_value) {
168
+      foreach ($lang_new as $string_name => $string_value) {
169 169
         adm_lng_write_string($string_name, $string_value);
170 170
       }
171 171
       fwrite($file_handler, ");\r\n");
@@ -176,21 +176,21 @@  discard block
 block discarded – undo
176 176
     die();
177 177
   }
178 178
 
179
-  foreach($languages_info as $lang_id => $lang_data) {
179
+  foreach ($languages_info as $lang_id => $lang_data) {
180 180
     $template->assign_block_vars('language', $lang_data);
181 181
     $full_filename = SN_ROOT_PHYSICAL . "language/{$lang_id}/{$domain}.mo.php";
182 182
     $languages[$lang_id] = adm_lng_load($full_filename . (file_exists($full_filename . '.new') ? '.new' : ''));
183
-    foreach($languages[$lang_id] as $locale_string_name => $cork) {
183
+    foreach ($languages[$lang_id] as $locale_string_name => $cork) {
184 184
       adm_lng_assign_string($lang_id, "[{$locale_string_name}]", $languages[$lang_id][$locale_string_name]);
185 185
     }
186 186
   }
187 187
 
188
-  foreach($locale_string_template as $locale_string_name => $locale_string_list) {
188
+  foreach ($locale_string_template as $locale_string_name => $locale_string_list) {
189 189
     $template->assign_block_vars('string', array(
190 190
       'NAME' => $locale_string_name,
191 191
     ));
192 192
 
193
-    foreach($languages_info as $lang_id => $cork2) {
193
+    foreach ($languages_info as $lang_id => $cork2) {
194 194
       $template->assign_block_vars('string.locale', array(
195 195
         'LANG' => $lang_id,
196 196
         'VALUE' => $locale_string_list["[{$lang_id}]"],
@@ -206,17 +206,17 @@  discard block
 block discarded – undo
206 206
   $dir = dir($path);
207 207
   while (false !== ($lang_id = $dir->read())) {
208 208
     $full_path = $path . $lang_id;
209
-    if($lang_id[0] != "." && is_dir($full_path)) {
209
+    if ($lang_id[0] != "." && is_dir($full_path)) {
210 210
       $lang_file_list = dir($full_path);
211 211
       while (false !== ($filename = $lang_file_list->read())) {
212 212
         $lang_domain = strtolower(substr($filename, 0, strpos($filename, '.')));
213
-        if(!$lang_domain) {
213
+        if (!$lang_domain) {
214 214
           continue;
215 215
         }
216 216
 
217 217
         $file_ext = strtolower(substr($filename, strpos($filename, '.')));
218
-        if($lang_domain != 'language') {
219
-          if($file_ext == '.mo.php.new' || ($file_ext == '.mo.php' && empty($languages[$lang_id][$lang_domain]))) {
218
+        if ($lang_domain != 'language') {
219
+          if ($file_ext == '.mo.php.new' || ($file_ext == '.mo.php' && empty($languages[$lang_id][$lang_domain]))) {
220 220
             $language_domains[$lang_domain] = $lang_domain;
221 221
             $languages[$lang_id][$lang_domain] = $lang_domain;
222 222
           }
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
   }
227 227
   $dir->close();
228 228
 
229
-  foreach($language_domains as $lang_domain) {
229
+  foreach ($language_domains as $lang_domain) {
230 230
     $template->assign_block_vars('domain', array(
231 231
       'NAME' => $lang_domain,
232 232
     ));
Please login to merge, or discard this patch.