Passed
Branch trunk (7dc288)
by SuperNova.WS
06:07
created
classes/template_compile.php 1 patch
Braces   +33 added lines, -66 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@  discard block
 block discarded – undo
37 37
 *
38 38
 * @package phpBB3
39 39
 */
40
-class template_compile
41
-{
40
+class template_compile {
42 41
   var $template;
43 42
 
44 43
   // Various storage arrays
@@ -58,8 +57,7 @@  discard block
 block discarded – undo
58 57
   * Load template source from file
59 58
   * @access private
60 59
   */
61
-  function _tpl_load_file($handle, $store_in_db = false)
62
-  {
60
+  function _tpl_load_file($handle, $store_in_db = false) {
63 61
     // Try and open template for read
64 62
     if (!file_exists($this->template->files[$handle]))
65 63
     {
@@ -67,8 +65,7 @@  discard block
 block discarded – undo
67 65
       {
68 66
         return;
69 67
         trigger_error("template->_tpl_load_file(): File {$this->template->files[$handle]} does not exist or is empty", E_USER_ERROR);
70
-      }
71
-      else
68
+      } else
72 69
       {
73 70
         $this->template->files[$handle] = $this->template->files_inherit[$handle];
74 71
       }
@@ -104,8 +101,7 @@  discard block
 block discarded – undo
104 101
   * the ones that exist in zend_language_scanner.l
105 102
   * @access private
106 103
   */
107
-  function remove_php_tags(&$code)
108
-  {
104
+  function remove_php_tags(&$code) {
109 105
     // This matches the information gathered from the internal PHP lexer
110 106
     $match = array(
111 107
       '#<([\?%])=?.*?\1>#s',
@@ -120,8 +116,7 @@  discard block
 block discarded – undo
120 116
   * The all seeing all doing compile method. Parts are inspired by or directly from Smarty
121 117
   * @access private
122 118
   */
123
-  function compile($code, $no_echo = false, $echo_var = '')
124
-  {
119
+  function compile($code, $no_echo = false, $echo_var = '') {
125 120
     global $config;
126 121
 
127 122
     if ($echo_var)
@@ -226,15 +221,13 @@  discard block
 block discarded – undo
226 221
               $var = substr($temp, 2, -1);
227 222
               //$file = $this->template->_tpldata['DEFINE']['.'][$var];
228 223
               $temp = "\$this->_tpldata['DEFINE']['.']['$var']";
229
-            }
230
-            else
224
+            } else
231 225
             {
232 226
               $var = substr($temp, 1, -1);
233 227
               //$file = $this->template->_rootref[$var];
234 228
               $temp = "\$this->_rootref['$var']";
235 229
             }
236
-          }
237
-          else
230
+          } else
238 231
           {
239 232
             $file = $temp;
240 233
           }
@@ -293,8 +286,7 @@  discard block
 block discarded – undo
293 286
   * Compile variables
294 287
   * @access private
295 288
   */
296
-  function compile_var_tags(&$text_blocks)
297
-  {
289
+  function compile_var_tags(&$text_blocks) {
298 290
     // including $lang variable
299 291
     global $lang, $config;
300 292
 
@@ -362,8 +354,7 @@  discard block
 block discarded – undo
362 354
   * Compile blocks
363 355
   * @access private
364 356
   */
365
-  function compile_tag_block($tag_args)
366
-  {
357
+  function compile_tag_block($tag_args) {
367 358
     $no_nesting = false;
368 359
 
369 360
     // Is the designer wanting to call another loop in a loop?
@@ -386,8 +377,7 @@  discard block
 block discarded – undo
386 377
       if ($match[2] < 0)
387 378
       {
388 379
         $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')';
389
-      }
390
-      else
380
+      } else
391 381
       {
392 382
         $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')';
393 383
       }
@@ -395,17 +385,14 @@  discard block
 block discarded – undo
395 385
       if (strlen($match[3]) < 1 || $match[3] == -1)
396 386
       {
397 387
         $loop_end = '$_' . $tag_args . '_count';
398
-      }
399
-      else if ($match[3] >= 0)
388
+      } else if ($match[3] >= 0)
400 389
       {
401 390
         $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')';
402
-      }
403
-      else //if ($match[3] < -1)
391
+      } else //if ($match[3] < -1)
404 392
       {
405 393
         $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1);
406 394
       }
407
-    }
408
-    else
395
+    } else
409 396
     {
410 397
       $loop_start = 0;
411 398
       $loop_end = '$_' . $tag_args . '_count';
@@ -418,8 +405,7 @@  discard block
 block discarded – undo
418 405
     {
419 406
       // We need to implode $no_nesting times from the end...
420 407
       $block = array_slice($this->block_names, -$no_nesting);
421
-    }
422
-    else
408
+    } else
423 409
     {
424 410
       $block = $this->block_names;
425 411
     }
@@ -429,8 +415,7 @@  discard block
 block discarded – undo
429 415
       // Block is not nested.
430 416
       $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;";
431 417
       $varref = "\$this->_tpldata['$tag_args']";
432
-    }
433
-    else
418
+    } else
434 419
     {
435 420
       // This block is nested.
436 421
       // Generate a namespace string for this block.
@@ -469,8 +454,7 @@  discard block
 block discarded – undo
469 454
   * some adaptions for our block level methods
470 455
   * @access private
471 456
   */
472
-  function compile_tag_if($tag_args, $elseif)
473
-  {
457
+  function compile_tag_if($tag_args, $elseif) {
474 458
     // Tokenize args for 'if' tag.
475 459
     preg_match_all('/(?:
476 460
       "[^"\\\\]*(?:\\\\.[^"\\\\]*)*"         |
@@ -578,8 +562,7 @@  discard block
 block discarded – undo
578 562
           if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs))
579 563
           {
580 564
             $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$this->_rootref[\'' . $varrefs[3] . '\']');
581
-          }
582
-          else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs))
565
+          } else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs))
583 566
           {
584 567
             // Allow checking if loops are set with .loopname
585 568
             // It is also possible to check the loop count by doing <!-- IF .loopname > 1 --> for example
@@ -595,8 +578,7 @@  discard block
 block discarded – undo
595 578
 
596 579
               // Add the block reference for the last child.
597 580
               $varref .= "['" . $block . "']";
598
-            }
599
-            else
581
+            } else
600 582
             {
601 583
               $varref = '$this->_tpldata';
602 584
 
@@ -604,8 +586,7 @@  discard block
 block discarded – undo
604 586
               $varref .= "['" . $blocks[0] . "']";
605 587
             }
606 588
             $token = "sizeof($varref)";
607
-          }
608
-          else if (!empty($token))
589
+          } else if (!empty($token))
609 590
           {
610 591
             $token = '(' . $token . ')';
611 592
           }
@@ -626,8 +607,7 @@  discard block
 block discarded – undo
626 607
   * Compile DEFINE tags
627 608
   * @access private
628 609
   */
629
-  function compile_tag_define($tag_args, $op)
630
-  {
610
+  function compile_tag_define($tag_args, $op) {
631 611
     preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match);
632 612
 
633 613
     if (empty($match[2]) || (!isset($match[4]) && $op))
@@ -650,8 +630,7 @@  discard block
 block discarded – undo
650 630
 
651 631
       // Now replace the php code
652 632
       $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'";
653
-    }
654
-    else
633
+    } else
655 634
     {
656 635
       preg_match('#true|false|\.#i', $match[4], $type);
657 636
 
@@ -679,8 +658,7 @@  discard block
 block discarded – undo
679 658
   * Compile INCLUDE tag
680 659
   * @access private
681 660
   */
682
-  function compile_tag_include($tag_args)
683
-  {
661
+  function compile_tag_include($tag_args) {
684 662
     // Process dynamic includes
685 663
     if ($tag_args[0] == '$')
686 664
     {
@@ -694,8 +672,7 @@  discard block
 block discarded – undo
694 672
   * Compile INCLUDE_PHP tag
695 673
   * @access private
696 674
   */
697
-  function compile_tag_include_php($tag_args)
698
-  {
675
+  function compile_tag_include_php($tag_args) {
699 676
     return "\$this->_php_include('$tag_args');";
700 677
   }
701 678
 
@@ -704,8 +681,7 @@  discard block
 block discarded – undo
704 681
   * This is from Smarty
705 682
   * @access private
706 683
   */
707
-  function _parse_is_expr($is_arg, $tokens)
708
-  {
684
+  function _parse_is_expr($is_arg, $tokens) {
709 685
     $expr_end = 0;
710 686
     $negate_expr = false;
711 687
 
@@ -713,8 +689,7 @@  discard block
 block discarded – undo
713 689
     {
714 690
       $negate_expr = true;
715 691
       $expr_type = array_shift($tokens);
716
-    }
717
-    else
692
+    } else
718 693
     {
719 694
       $expr_type = $first_token;
720 695
     }
@@ -727,8 +702,7 @@  discard block
 block discarded – undo
727 702
           $expr_end++;
728 703
           $expr_arg = $tokens[$expr_end++];
729 704
           $expr = "!(($is_arg / $expr_arg) % $expr_arg)";
730
-        }
731
-        else
705
+        } else
732 706
         {
733 707
           $expr = "!($is_arg & 1)";
734 708
         }
@@ -740,8 +714,7 @@  discard block
 block discarded – undo
740 714
           $expr_end++;
741 715
           $expr_arg = $tokens[$expr_end++];
742 716
           $expr = "(($is_arg / $expr_arg) % $expr_arg)";
743
-        }
744
-        else
717
+        } else
745 718
         {
746 719
           $expr = "($is_arg & 1)";
747 720
         }
@@ -775,8 +748,7 @@  discard block
 block discarded – undo
775 748
   * NOTE: expects a trailing "." on the namespace.
776 749
   * @access private
777 750
   */
778
-  function generate_block_varref($namespace, $varname, $echo = true, $defop = false)
779
-  {
751
+  function generate_block_varref($namespace, $varname, $echo = true, $defop = false) {
780 752
     // Strip the trailing period.
781 753
     $namespace = substr($namespace, 0, -1);
782 754
 
@@ -800,8 +772,7 @@  discard block
 block discarded – undo
800 772
   * NOTE: does not expect a trailing "." on the blockname.
801 773
   * @access private
802 774
   */
803
-  function generate_block_data_ref($blockname, $include_last_iterator, $defop = false)
804
-  {
775
+  function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) {
805 776
     // Get an array of the blocks involved.
806 777
     $blocks = explode('.', $blockname);
807 778
     $blockcount = sizeof($blocks) - 1;
@@ -823,12 +794,10 @@  discard block
 block discarded – undo
823 794
         $varref .= '[$_' . $blocks[$blockcount] . '_i]';
824 795
       }
825 796
       return $varref;
826
-    }
827
-    else if ($include_last_iterator)
797
+    } else if ($include_last_iterator)
828 798
     {
829 799
       return '$_'. $blocks[$blockcount] . '_val';
830
-    }
831
-    else
800
+    } else
832 801
     {
833 802
       return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']';
834 803
     }
@@ -838,8 +807,7 @@  discard block
 block discarded – undo
838 807
   * Write compiled file to cache directory
839 808
   * @access private
840 809
   */
841
-  function compile_write($handle, $data)
842
-  {
810
+  function compile_write($handle, $data) {
843 811
     $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX;
844 812
 
845 813
     $data = "<?php if (!defined('INSIDE')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data);
@@ -863,8 +831,7 @@  discard block
 block discarded – undo
863 831
   * Minifies template w/i PHP code by removing extra spaces
864 832
   * @access private
865 833
   */
866
-  function minify($html)
867
-  {
834
+  function minify($html) {
868 835
     global $config;
869 836
 
870 837
     if(!$config->tpl_minifier)
Please login to merge, or discard this patch.
includes/pages/techtree.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,8 +6,7 @@
 block discarded – undo
6 6
  * version 2.0 copyright (c) 2012 by Gorlum for http://supernova.ws
7 7
  */
8 8
 
9
-function sn_techtree_view($template = null)
10
-{
9
+function sn_techtree_view($template = null) {
11 10
   global $lang, $user, $planetrow;
12 11
 
13 12
   $tech_tree = array();
Please login to merge, or discard this patch.
includes/includes/ube_attack_calculate.php 1 patch
Braces   +45 added lines, -70 removed lines patch added patch discarded remove patch
@@ -79,8 +79,7 @@  discard block
 block discarded – undo
79 79
 
80 80
 // ------------------------------------------------------------------------------------------------
81 81
 // Заполняет данные по игроку
82
-function ube_attack_prepare_player(&$combat_data, $player_id, $is_attacker)
83
-{
82
+function ube_attack_prepare_player(&$combat_data, $player_id, $is_attacker) {
84 83
   global $ube_convert_techs;
85 84
 
86 85
   if(!isset($combat_data[UBE_PLAYERS][$player_id]))
@@ -99,8 +98,7 @@  discard block
 block discarded – undo
99 98
     {
100 99
       $player_info[UBE_BONUSES][$ube_id] += mrc_get_level($player_data, false, $unit_id) * get_unit_param($unit_id, P_BONUS_VALUE) / 100 + $admiral_bonus;
101 100
     }
102
-  }
103
-  else
101
+  } else
104 102
   {
105 103
     $combat_data[UBE_PLAYERS][$player_id][UBE_ATTACKER] = $combat_data[UBE_PLAYERS][$player_id][UBE_ATTACKER] || $is_attacker;
106 104
   }
@@ -109,8 +107,7 @@  discard block
 block discarded – undo
109 107
 // ------------------------------------------------------------------------------------------------
110 108
 // Заполняет данные по флоту
111 109
 function ube_attack_prepare_fleet(&$combat_data, &$fleet, $is_attacker){return sn_function_call('ube_attack_prepare_fleet', array(&$combat_data, &$fleet, $is_attacker));}
112
-function sn_ube_attack_prepare_fleet(&$combat_data, &$fleet, $is_attacker)
113
-{
110
+function sn_ube_attack_prepare_fleet(&$combat_data, &$fleet, $is_attacker) {
114 111
   $fleet_owner_id = $fleet['fleet_owner'];
115 112
   $fleet_id = $fleet['fleet_id'];
116 113
 
@@ -257,8 +254,7 @@  discard block
 block discarded – undo
257 254
     foreach($acs_fleet_list as $fleet) {
258 255
       ube_attack_prepare_fleet($combat_data, $fleet, true);
259 256
     }
260
-  }
261
-  else
257
+  } else
262 258
   {
263 259
     ube_attack_prepare_fleet($combat_data, $fleet_row, true);
264 260
   }
@@ -273,8 +269,7 @@  discard block
 block discarded – undo
273 269
 }
274 270
 
275 271
 // ------------------------------------------------------------------------------------------------
276
-function sn_ube_combat_prepare_first_round(&$combat_data)
277
-{
272
+function sn_ube_combat_prepare_first_round(&$combat_data) {
278 273
   global $ube_combat_bonus_list, $ube_convert_to_techs;
279 274
 
280 275
   // Готовим информацию для первого раунда - проводим все нужные вычисления из исходных данных
@@ -339,8 +334,7 @@  discard block
 block discarded – undo
339 334
 
340 335
 // ------------------------------------------------------------------------------------------------
341 336
 // Вычисление дополнительной информации для расчета раунда
342
-function sn_ube_combat_round_prepare(&$combat_data, $round)
343
-{
337
+function sn_ube_combat_round_prepare(&$combat_data, $round) {
344 338
   global $ube_combat_bonus_list;
345 339
 
346 340
   $is_simulator = $combat_data[UBE_OPTIONS][UBE_SIMULATOR];
@@ -401,8 +395,7 @@  discard block
 block discarded – undo
401 395
 
402 396
 // ------------------------------------------------------------------------------------------------
403 397
 // Рассчитывает результат столкновения флотов ака раунд
404
-function sn_ube_combat_round_crossfire_fleet(&$combat_data, $round)
405
-{
398
+function sn_ube_combat_round_crossfire_fleet(&$combat_data, $round) {
406 399
   if(BE_DEBUG === true)
407 400
   {
408 401
     // sn_ube_combat_helper_round_header($round);
@@ -437,8 +430,7 @@  discard block
 block discarded – undo
437 430
 
438 431
 // ------------------------------------------------------------------------------------------------
439 432
 // Рассчитывает результат столкновения двух юнитов ака ход
440
-function sn_ube_combat_round_crossfire_unit(&$attack_fleet_data, &$defend_fleet_data, $attack_unit_id, $defend_unit_id, &$combat_options)
441
-{
433
+function sn_ube_combat_round_crossfire_unit(&$attack_fleet_data, &$defend_fleet_data, $attack_unit_id, $defend_unit_id, &$combat_options) {
442 434
   $attack_fleet_info = &$attack_fleet_data[UBE_FLEET_INFO];
443 435
   $defend_fleet_info = &$defend_fleet_data[UBE_FLEET_INFO];
444 436
   $defend_unit_armor = $defend_fleet_info[UBE_ARMOR][$defend_unit_id];
@@ -518,8 +510,7 @@  discard block
 block discarded – undo
518 510
   }
519 511
 }
520 512
 
521
-function sn_ube_combat_round_crossfire_unit_damage_current(&$defend_fleet_data, $defend_unit_id, &$amplified_damage, &$units_lost, &$units_boomed, &$combat_options)
522
-{
513
+function sn_ube_combat_round_crossfire_unit_damage_current(&$defend_fleet_data, $defend_unit_id, &$amplified_damage, &$units_lost, &$units_boomed, &$combat_options) {
523 514
   $unit_is_lost = false;
524 515
 
525 516
   $units_boomed = $units_boomed ? $units_boomed : 0;
@@ -580,8 +571,7 @@  discard block
 block discarded – undo
580 571
 
581 572
 // ------------------------------------------------------------------------------------------------
582 573
 // Рассчитывает результат столкновения двух юнитов ака ход
583
-function sn_ube_combat_round_crossfire_unit2(&$attack_fleet_data, &$defend_fleet_data, $attack_unit_id, $defend_unit_id, &$combat_options)
584
-{
574
+function sn_ube_combat_round_crossfire_unit2(&$attack_fleet_data, &$defend_fleet_data, $attack_unit_id, $defend_unit_id, &$combat_options) {
585 575
   if($defend_fleet_data[UBE_COUNT][$defend_unit_id] <= 0)
586 576
   {
587 577
     return;
@@ -618,8 +608,7 @@  discard block
 block discarded – undo
618 608
 
619 609
 // ------------------------------------------------------------------------------------------------
620 610
 // Анализирует результаты раунда и генерирует данные для следующего раунда
621
-function sn_ube_combat_round_analyze(&$combat_data, $round)
622
-{
611
+function sn_ube_combat_round_analyze(&$combat_data, $round) {
623 612
   $round_data = &$combat_data[UBE_ROUNDS][$round];
624 613
   $round_data[UBE_OUTCOME] = UBE_COMBAT_RESULT_DRAW;
625 614
 
@@ -649,12 +638,10 @@  discard block
 block discarded – undo
649 638
   if(count($outcome) == 0 || $round == 10)
650 639
   {
651 640
     $round_data[UBE_OUTCOME] = UBE_COMBAT_RESULT_DRAW_END;
652
-  }
653
-  elseif(count($outcome) == 1)
641
+  } elseif(count($outcome) == 1)
654 642
   {
655 643
     $round_data[UBE_OUTCOME] = isset($outcome[UBE_ATTACKERS]) ? UBE_COMBAT_RESULT_WIN : UBE_COMBAT_RESULT_LOSS;
656
-  }
657
-  elseif(count($outcome) == 2)
644
+  } elseif(count($outcome) == 2)
658 645
   {
659 646
     if($round < 10)
660 647
     {
@@ -667,8 +654,7 @@  discard block
 block discarded – undo
667 654
 
668 655
 // ------------------------------------------------------------------------------------------------
669 656
 // Общий алгоритм расчета боя
670
-function sn_ube_combat(&$combat_data)
671
-{
657
+function sn_ube_combat(&$combat_data) {
672 658
   // TODO: Сделать атаку по типам,  когда они будут
673 659
 
674 660
   $start = microtime(true);
@@ -696,8 +682,7 @@  discard block
 block discarded – undo
696 682
 
697 683
 // ------------------------------------------------------------------------------------------------
698 684
 // Разбирает данные боя для генерации отчета
699
-function sn_ube_combat_analyze(&$combat_data)
700
-{
685
+function sn_ube_combat_analyze(&$combat_data) {
701 686
   global $config;
702 687
 
703 688
 //  $combat_data[UBE_OUTCOME] = array();
@@ -742,14 +727,12 @@  discard block
 block discarded – undo
742 727
         if($combat_data[UBE_OPTIONS][UBE_SIMULATOR])
743 728
         { // for simulation just return 75% of loss
744 729
           $units_giveback = round($units_lost * $giveback_chance / 100);
745
-        }
746
-        else
730
+        } else
747 731
         {
748 732
           if($unit_count > 10)
749 733
           { // if there were more then 10 defense elements - mass-calculating giveback
750 734
             $units_giveback = round($units_lost * mt_rand($giveback_chance * 0.8, $giveback_chance * 1.2) / 100);
751
-          }
752
-          else
735
+          } else
753 736
           { //if there were less then 10 defense elements - calculating giveback per element
754 737
             $units_giveback = 0;
755 738
             for($i = 1; $i <= $units_lost; $i++)
@@ -852,8 +835,7 @@  discard block
 block discarded – undo
852 835
     if($combat_data[UBE_OPTIONS][UBE_MOON_WAS])
853 836
     {
854 837
       $outcome[UBE_MOON] = UBE_MOON_WAS;
855
-    }
856
-    else
838
+    } else
857 839
     {
858 840
       sn_ube_combat_analyze_moon($outcome, $combat_data[UBE_OPTIONS][UBE_SIMULATOR]);
859 841
     }
@@ -872,8 +854,7 @@  discard block
 block discarded – undo
872 854
 }
873 855
 
874 856
 // ------------------------------------------------------------------------------------------------
875
-function sn_ube_combat_analyze_loot(&$combat_data)
876
-{
857
+function sn_ube_combat_analyze_loot(&$combat_data) {
877 858
   $exchange = &$combat_data[UBE_OPTIONS][UBE_EXCHANGE];
878 859
   $planet_resource_list = &$combat_data[UBE_FLEETS][0][UBE_RESOURCES];
879 860
   $outcome = &$combat_data[UBE_OUTCOME];
@@ -916,13 +897,14 @@  discard block
 block discarded – undo
916 897
 }
917 898
 
918 899
 // ------------------------------------------------------------------------------------------------
919
-function sn_ube_combat_analyze_moon(&$outcome, $is_simulator)
920
-{
900
+function sn_ube_combat_analyze_moon(&$outcome, $is_simulator) {
921 901
   $outcome[UBE_DEBRIS_TOTAL] = 0;
922
-  foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) // TODO via array
902
+  foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) {
903
+    // TODO via array
923 904
   {
924 905
     $outcome[UBE_DEBRIS_TOTAL] += $outcome[UBE_DEBRIS][$resource_id];
925 906
   }
907
+  }
926 908
 
927 909
   if($outcome[UBE_DEBRIS_TOTAL])
928 910
   {
@@ -941,35 +923,33 @@  discard block
 block discarded – undo
941 923
         {
942 924
           $outcome[UBE_DEBRIS_TOTAL] = 0;
943 925
           $outcome[UBE_DEBRIS] = array();
944
-        }
945
-        else
926
+        } else
946 927
         {
947 928
           $moon_debris_spent = 30000000;
948 929
           $moon_debris_left_percent = ($outcome[UBE_DEBRIS_TOTAL] - $moon_debris_spent) / $outcome[UBE_DEBRIS_TOTAL];
949 930
 
950 931
           $outcome[UBE_DEBRIS_TOTAL] = 0;
951
-          foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) // TODO via array
932
+          foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) {
933
+            // TODO via array
952 934
           {
953 935
             $outcome[UBE_DEBRIS][$resource_id] = floor($outcome[UBE_DEBRIS][$resource_id] * $moon_debris_left_percent);
936
+          }
954 937
             $outcome[UBE_DEBRIS_TOTAL] += $outcome[UBE_DEBRIS][$resource_id];
955 938
           }
956 939
         }
957
-      }
958
-      else
940
+      } else
959 941
       {
960 942
         $outcome[UBE_MOON] = UBE_MOON_CREATE_FAILED;
961 943
       }
962 944
     }
963
-  }
964
-  else
945
+  } else
965 946
   {
966 947
     $outcome[UBE_MOON] = UBE_MOON_NONE;
967 948
   }
968 949
 }
969 950
 
970 951
 // ------------------------------------------------------------------------------------------------
971
-function sn_ube_combat_analyze_moon_destroy(&$combat_data)
972
-{
952
+function sn_ube_combat_analyze_moon_destroy(&$combat_data) {
973 953
   // TODO: $is_simulator
974 954
   $reapers = 0;
975 955
   foreach($combat_data[UBE_ROUNDS][count($combat_data[UBE_ROUNDS])-1][UBE_FLEETS] as $fleet_data)
@@ -993,8 +973,7 @@  discard block
 block discarded – undo
993 973
     $combat_data[UBE_OUTCOME][UBE_MOON] = $random <= $combat_data[UBE_OUTCOME][UBE_MOON_DESTROY_CHANCE] ? UBE_MOON_DESTROY_SUCCESS : UBE_MOON_DESTROY_FAILED;
994 974
     $random = mt_rand(1, 100);
995 975
     $combat_data[UBE_OUTCOME][UBE_MOON_REAPERS] = $random <= $combat_data[UBE_OUTCOME][UBE_MOON_REAPERS_DIE_CHANCE] ? UBE_MOON_REAPERS_DIED : UBE_MOON_REAPERS_RETURNED;
996
-  }
997
-  else
976
+  } else
998 977
   {
999 978
     $combat_data[UBE_OUTCOME][UBE_MOON_REAPERS] = UBE_MOON_REAPERS_NONE;
1000 979
   }
@@ -1002,8 +981,7 @@  discard block
 block discarded – undo
1002 981
 
1003 982
 // ------------------------------------------------------------------------------------------------
1004 983
 // Рассылает письма всем участникам боя
1005
-function sn_ube_message_send(&$combat_data)
1006
-{
984
+function sn_ube_message_send(&$combat_data) {
1007 985
   global $lang;
1008 986
 
1009 987
   // TODO: Отсылать каждому игроку сообщение на его языке!
@@ -1042,8 +1020,7 @@  discard block
 block discarded – undo
1042 1020
   if($outcome[UBE_MOON] == UBE_MOON_CREATE_SUCCESS)
1043 1021
   {
1044 1022
     $text_defender .= "{$lang['ube_report_moon_created']} {$outcome[UBE_MOON_SIZE]} {$lang['sys_kilometers_short']}<br /><br />";
1045
-  }
1046
-  elseif($outcome[UBE_MOON] == UBE_MOON_CREATE_FAILED)
1023
+  } elseif($outcome[UBE_MOON] == UBE_MOON_CREATE_FAILED)
1047 1024
   {
1048 1025
     $text_defender .= "{$lang['ube_report_moon_chance']} {$outcome[UBE_MOON_CHANCE]}%<br /><br />";
1049 1026
   }
@@ -1053,8 +1030,7 @@  discard block
 block discarded – undo
1053 1030
     if($outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_NONE)
1054 1031
     {
1055 1032
       $text_defender .= $lang['ube_report_moon_reapers_none'];
1056
-    }
1057
-    else
1033
+    } else
1058 1034
     {
1059 1035
       $text_defender .= "{$lang['ube_report_moon_reapers_wave']}. {$lang['ube_report_moon_reapers_chance']} {$outcome[UBE_MOON_DESTROY_CHANCE]}%. ";
1060 1036
       $text_defender .= $lang[$outcome[UBE_MOON] == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure'] . "<br />";
@@ -1081,8 +1057,7 @@  discard block
 block discarded – undo
1081 1057
 // Записывает результат боя в БД
1082 1058
 /** @noinspection SpellCheckingInspection */
1083 1059
 function ube_combat_result_apply(&$combat_data){return sn_function_call('ube_combat_result_apply', array(&$combat_data));}
1084
-function sn_ube_combat_result_apply(&$combat_data)
1085
-{
1060
+function sn_ube_combat_result_apply(&$combat_data) {
1086 1061
 // TODO: Поменять все отладки на запросы
1087 1062
   $destination_user_id = $combat_data[UBE_FLEETS][0][UBE_OWNER];
1088 1063
 
@@ -1130,8 +1105,7 @@  discard block
 block discarded – undo
1130 1105
         {
1131 1106
           // Не планета - всегда сразу записываем строку итогов флота
1132 1107
           $fleet_query[$unit_id] = "{$unit_id},{$units_left}";
1133
-        }
1134
-        elseif($units_lost)
1108
+        } elseif($units_lost)
1135 1109
         {
1136 1110
           // Планета - записываем в ИД юнита его потери только если есть потери
1137 1111
           $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, -$units_lost, $combat_data[UBE_PLAYERS][$destination_user_id][UBE_PLAYER_DATA], $planet_id);
@@ -1186,11 +1160,13 @@  discard block
 block discarded – undo
1186 1160
 
1187 1161
 //global $debug;
1188 1162
 //    $fleet_query = implode(',', $fleet_query);
1189
-    if($fleet_id) // Не планета
1163
+    if($fleet_id) {
1164
+      // Не планета
1190 1165
     {
1191 1166
       if($fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS && $outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_DIED)
1192 1167
       {
1193 1168
         $new_fleet_count = 0;
1169
+    }
1194 1170
       }
1195 1171
 
1196 1172
       if($new_fleet_count)
@@ -1202,16 +1178,14 @@  discard block
 block discarded – undo
1202 1178
           $fleet_query['fleet_amount'] = $new_fleet_count;
1203 1179
           fleet_update_set($fleet_id, $fleet_query, $fleet_delta);
1204 1180
         }
1205
-      }
1206
-      else
1181
+      } else
1207 1182
       {
1208 1183
         // Удаляем пустые флоты
1209 1184
         // doquery("DELETE FROM {{fleets}} WHERE `fleet_id` = {$fleet_id} LIMIT 1");
1210 1185
         db_fleet_delete($fleet_id);
1211 1186
         DBStaticUnit::db_unit_list_delete(0, LOC_FLEET, $fleet_id, 0);
1212 1187
       }
1213
-    }
1214
-    else // Планета
1188
+    } else // Планета
1215 1189
     {
1216 1190
       // Сохраняем изменения ресурсов - если они есть
1217 1191
       if(!empty($fleet_delta))
@@ -1222,10 +1196,12 @@  discard block
 block discarded – undo
1222 1196
         }
1223 1197
         DBStaticPlanet::db_planet_set_by_id($planet_id, implode(',', $temp));
1224 1198
       }
1225
-      if(!empty($db_changeset)) // Сохраняем изменения юнитов на планете - если они есть
1199
+      if(!empty($db_changeset)) {
1200
+        // Сохраняем изменения юнитов на планете - если они есть
1226 1201
       {
1227 1202
         OldDbChangeSet::db_changeset_apply($db_changeset);
1228 1203
       }
1204
+      }
1229 1205
     }
1230 1206
   }
1231 1207
 
@@ -1242,8 +1218,7 @@  discard block
 block discarded – undo
1242 1218
     $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $outcome[UBE_MOON_SIZE], '', false);
1243 1219
     $outcome[UBE_MOON_NAME] = $moon_row['name'];
1244 1220
     unset($moon_row);
1245
-  }
1246
-  elseif($outcome[UBE_MOON] == UBE_MOON_DESTROY_SUCCESS)
1221
+  } elseif($outcome[UBE_MOON] == UBE_MOON_DESTROY_SUCCESS)
1247 1222
   {
1248 1223
     DBStaticPlanet::db_planet_delete_by_id($planet_id);
1249 1224
   }
Please login to merge, or discard this patch.
includes/includes/flt_functions.php 1 patch
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-function flt_fleet_speed($user, $fleet)
4
-{
3
+function flt_fleet_speed($user, $fleet) {
5 4
   if (!is_array($fleet))
6 5
   {
7 6
     $fleet = array($fleet => 1);
@@ -29,16 +28,13 @@  discard block
 block discarded – undo
29 28
   if($from['galaxy'] != $to['galaxy'])
30 29
   {
31 30
     $distance = abs($from['galaxy'] - $to['galaxy']) * $config->uni_galaxy_distance;
32
-  }
33
-  elseif($from['system'] != $to['system'])
31
+  } elseif($from['system'] != $to['system'])
34 32
   {
35 33
     $distance = abs($from['system'] - $to['system']) * 5 * 19 + 2700;
36
-  }
37
-  elseif($from['planet'] != $to['planet'])
34
+  } elseif($from['planet'] != $to['planet'])
38 35
   {
39 36
     $distance = abs($from['planet'] - $to['planet']) * 5 + 1000;
40
-  }
41
-  else
37
+  } else
42 38
   {
43 39
     $distance = 5;
44 40
   }
@@ -55,8 +51,7 @@  discard block
 block discarded – undo
55 51
  *
56 52
  * @return array
57 53
  */
58
-function flt_travel_data($user_row, $from, $to, $fleet_array, $speed_percent = 10)
59
-{
54
+function flt_travel_data($user_row, $from, $to, $fleet_array, $speed_percent = 10) {
60 55
   $distance = flt_travel_distance($from, $to);
61 56
 
62 57
   $consumption = 0;
@@ -120,8 +115,7 @@  discard block
 block discarded – undo
120 115
   );
121 116
 }
122 117
 
123
-function flt_bashing_check($user, $enemy, $planet_dst, $mission, $flight_duration, $fleet_group = 0)
124
-{
118
+function flt_bashing_check($user, $enemy, $planet_dst, $mission, $flight_duration, $fleet_group = 0) {
125 119
   global $config;
126 120
 
127 121
   $config_bashing_attacks = $config->fleet_bashing_attacks;
@@ -531,8 +525,7 @@  discard block
 block discarded – undo
531 525
       $fleet_ship_count += $amount;
532 526
       $fleet_string     .= "{$unit_id},{$amount};";
533 527
       $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, -$amount, $user, $from['id']);
534
-    }
535
-    elseif(in_array($unit_id, sn_get_groups('resources_loot')))
528
+    } elseif(in_array($unit_id, sn_get_groups('resources_loot')))
536 529
     {
537 530
       $planet_fields[pname_resource_name($unit_id)]['delta'] -= $amount;
538 531
     }
@@ -624,8 +617,7 @@  discard block
 block discarded – undo
624 617
 //ini_set('error_reporting', E_ALL ^ E_NOTICE);
625 618
 }
626 619
 
627
-function flt_calculate_ship_to_transport_sort($a, $b)
628
-{
620
+function flt_calculate_ship_to_transport_sort($a, $b) {
629 621
   return $a['transport_effectivness'] == $b['transport_effectivness'] ? 0 : ($a['transport_effectivness'] > $b['transport_effectivness'] ? -1 : 1);
630 622
 }
631 623
 
@@ -634,8 +626,7 @@  discard block
 block discarded – undo
634 626
 // $resource_amount - how much amount of resources need to be transported
635 627
 // $from - transport from
636 628
 // $to - transport to
637
-function flt_calculate_fleet_to_transport($ship_list, $resource_amount, $from, $to)
638
-{
629
+function flt_calculate_fleet_to_transport($ship_list, $resource_amount, $from, $to) {
639 630
   global $user;
640 631
 
641 632
   $ship_data = array();
Please login to merge, or discard this patch.
jumpgate.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -115,8 +115,7 @@
 block discarded – undo
115 115
     ));
116 116
 
117 117
     display($template, $lang['tech'][STRUC_MOON_GATE]);
118
-  }
119
-  else
118
+  } else
120 119
   {
121 120
     messageBox($lang['gate_no_src_ga'], $lang['tech'][STRUC_MOON_GATE], "overview.php", 10);
122 121
   }
Please login to merge, or discard this patch.
includes/alliance/ali_internal_admin.inc 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -74,14 +74,12 @@  discard block
 block discarded – undo
74 74
     doquery("UPDATE {{alliance}} SET " . implode(',', $ally_changeset) . " WHERE `id`='{$ally['id']}' LIMIT 1;");
75 75
     sys_redirect('alliance.php?mode=admin&edit=ally');
76 76
   }
77
-}
78
-elseif(sys_get_param_str('isSaveText'))
77
+} elseif(sys_get_param_str('isSaveText'))
79 78
 {
80 79
   $text = sys_get_param_str_both('text');
81 80
   doquery("UPDATE {{alliance}} SET `{$text_list[$allyTextID]['db_field']}`='{$text['safe']}' WHERE `id`='{$ally['id']}';");
82 81
   $ally[$text_list[$allyTextID]['db_field']] = $text['unsafe'];
83
-}
84
-elseif(sys_get_param_str('isTransfer') && $idNewLeader = sys_get_param_id('idNewLeader'))
82
+} elseif(sys_get_param_str('isTransfer') && $idNewLeader = sys_get_param_id('idNewLeader'))
85 83
 {
86 84
   if(!$isAllyOwner)
87 85
   {
@@ -98,8 +96,7 @@  discard block
 block discarded – undo
98 96
     sn_db_transaction_commit();
99 97
     sys_redirect('alliance.php');
100 98
   }
101
-}
102
-elseif(sys_get_param_str('isDisband') && sys_get_param_str('isConfirmDisband'))
99
+} elseif(sys_get_param_str('isDisband') && sys_get_param_str('isConfirmDisband'))
103 100
 {
104 101
   if(!$isAllyOwner)
105 102
   {
Please login to merge, or discard this patch.
includes/alliance/ali_info.inc 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,16 +23,14 @@  discard block
 block discarded – undo
23 23
     $lang['Go_out_welldone'] = str_replace("%s", $ally_name, $lang['Go_out_welldone']);
24 24
     messageBox(sprintf($lang['ali_info_leave_success'], $ally['ally_name']), $lang['sys_alliance']);
25 25
   }
26
-}
27
-elseif($mode == 'ainfo')
26
+} elseif($mode == 'ainfo')
28 27
 {
29 28
   $tag = sys_get_param_str('tag');
30 29
   $id_ally = sys_get_param_id('a');
31 30
   if($tag)
32 31
   {
33 32
     $ally = doquery("SELECT * FROM {{alliance}} WHERE ally_tag='{$tag}' LIMIT 1;", '', true);
34
-  }
35
-  elseif($id_ally)
33
+  } elseif($id_ally)
36 34
   {
37 35
     $ally = doquery("SELECT * FROM {{alliance}} WHERE id='{$id_ally}' LIMIT 1;", '', true);
38 36
   }
@@ -52,20 +50,17 @@  discard block
 block discarded – undo
52 50
     'USER_ALLY_ID' => $user['ally_id'],
53 51
   ));
54 52
   $page_header          = $lang['sys_alliance'];
55
-}
56
-else
53
+} else
57 54
 {
58 55
   $page_header = $lang['your_alliance'];
59 56
 
60 57
   if($ally['ally_owner'] == $user['id'])
61 58
   {
62 59
     $range = $ally['ally_owner_range'] ? $ally['ally_owner_range'] : $lang['Founder'];
63
-  }
64
-  elseif($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name']))
60
+  } elseif($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name']))
65 61
   {
66 62
     $range = $ranks[$user['ally_rank_id']]['name'];
67
-  }
68
-  else
63
+  } else
69 64
   {
70 65
     $range = $lang['member'];
71 66
   }
Please login to merge, or discard this patch.
includes/alliance/ali_internal_admin_diplomacy.inc 1 patch
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -66,8 +66,7 @@  discard block
 block discarded – undo
66 66
       ->doInsert();
67 67
 
68 68
     $accept_offer = false;
69
-  }
70
-  else
69
+  } else
71 70
   {
72 71
     $accept_offer = true;
73 72
     $negotiation = array(
@@ -78,8 +77,7 @@  discard block
 block discarded – undo
78 77
       'alliance_negotiation_relation' => $alliance_negotiation_relation,
79 78
     );
80 79
   }
81
-}
82
-else
80
+} else
83 81
 {
84 82
   $offer_id = sys_get_param_id('offer_id');
85 83
   if($offer_id)
@@ -90,31 +88,26 @@  discard block
 block discarded – undo
90 88
     if(!$negotiation)
91 89
     {
92 90
       messageBox($lang['ali_dip_err_offer_none'], $page_title);
93
-    }
94
-    elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id'])
91
+    } elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id'])
95 92
     {
96 93
       // TODO: Add log of hack attempt
97 94
       messageBox($lang['ali_dip_err_offer_alien'], $page_title);
98
-    }
99
-    elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id'])
95
+    } elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id'])
100 96
     {
101 97
       if($offer_answer == 'accept')
102 98
       {
103 99
         // TODO: Add log of hack attempt
104 100
         messageBox($lang['ali_dip_err_offer_accept_own'], $page_title);
105
-      }
106
-      elseif($offer_answer == 'deny')
101
+      } elseif($offer_answer == 'deny')
107 102
       {
108 103
         doquery("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_id = {$offer_id} LIMIT 1;");
109 104
       }
110
-    }
111
-    else
105
+    } else
112 106
     {
113 107
       if($offer_answer == 'accept')
114 108
       {
115 109
         $accept_offer = true;
116
-      }
117
-      elseif($offer_answer == 'deny')
110
+      } elseif($offer_answer == 'deny')
118 111
       {
119 112
         DBStaticAlly::db_ally_negotiation_update_status_1($offer_id);
120 113
       }
Please login to merge, or discard this patch.
admin/statbuilder.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@
 block discarded – undo
37 37
   </script>';
38 38
 
39 39
   messageBoxAdmin("{$script}<img src=\"design/images/progressbar.gif\"><br>{$lang['sys_wait']}", $lang['adm_stat_title'], '', 0);
40
-}
41
-else
40
+} else
42 41
 {
43 42
   messageBoxAdmin($lang['adm_stat_already_started'], $lang['adm_stat_title'], 'admin/overview.php');
44 43
 }
Please login to merge, or discard this patch.