Completed
Push — work-fleets ( 71ccb1...0d1d7f )
by SuperNova.WS
06:04
created
includes/general/math.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 function geometry_progression_sum($n, $b1, $q) {
4
-  return $q != 1 ? ($b1 * (pow($q, $n) - 1)/($q - 1)) : ($n * $b1);
4
+  return $q != 1 ? ($b1 * (pow($q, $n) - 1) / ($q - 1)) : ($n * $b1);
5 5
 }
6 6
 
7 7
 function sn_floor($value)
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
  *
44 44
  * @return float|int
45 45
  */
46
-function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false)  {
47
-  if($cut_extreme) {
46
+function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) {
47
+  if ($cut_extreme) {
48 48
     $range_start--;
49 49
     $range_end++;
50 50
   }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 {
61 61
   $args = func_get_args();
62 62
 
63
-  switch(func_num_args())
63
+  switch (func_num_args())
64 64
   {
65 65
     case 0:
66 66
       // trigger_error('median() requires at least one parameter',E_USER_WARNING);
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     // fallthrough
73 73
 
74 74
     default:
75
-      if(!is_array($args))
75
+      if (!is_array($args))
76 76
       {
77 77
         // trigger_error('median() requires a list of numbers to operate on or an array of numbers', E_USER_NOTICE);
78 78
         return false;
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
       $n = count($args);
84 84
       $h = intval($n / 2);
85 85
 
86
-      if($n % 2 == 0)
86
+      if ($n % 2 == 0)
87 87
       {
88
-        $median = ($args[$h] + $args[$h-1]) / 2;
88
+        $median = ($args[$h] + $args[$h - 1]) / 2;
89 89
       }
90 90
       else
91 91
       {
@@ -103,49 +103,49 @@  discard block
 block discarded – undo
103 103
 }
104 104
 function linear_calc(&$linear, $from = 0, $logProcess = false)
105 105
 {
106
-  for($i = $from; $i < count($linear); $i++)
106
+  for ($i = $from; $i < count($linear); $i++)
107 107
   {
108 108
     $eq = &$linear[$i];
109
-    for($j = count($eq) - 1; $j >= $from; $j--)
109
+    for ($j = count($eq) - 1; $j >= $from; $j--)
110 110
     {
111 111
       $eq[$j] /= $eq[$from];
112 112
     }
113 113
   }
114
-  if($logProcess) pdump($linear, 'Нормализовано по х' . $from);
114
+  if ($logProcess) pdump($linear, 'Нормализовано по х'.$from);
115 115
 
116
-  for($i = $from + 1; $i < count($linear); $i++)
116
+  for ($i = $from + 1; $i < count($linear); $i++)
117 117
   {
118 118
     $eq = &$linear[$i];
119
-    for($j = count($eq) - 1; $j >= $from; $j--)
119
+    for ($j = count($eq) - 1; $j >= $from; $j--)
120 120
     {
121 121
       $eq[$j] -= $linear[$from][$j];
122 122
     }
123 123
   }
124
-  if($logProcess) pdump($linear, 'Подставили х' . $from);
124
+  if ($logProcess) pdump($linear, 'Подставили х'.$from);
125 125
 
126
-  if($from < count($linear) - 1)
126
+  if ($from < count($linear) - 1)
127 127
   {
128 128
     linear_calc($linear, $from + 1, $logProcess);
129 129
   }
130 130
 
131
-  if($from)
131
+  if ($from)
132 132
   {
133
-    for($i = 0; $i < $from; $i++)
133
+    for ($i = 0; $i < $from; $i++)
134 134
     {
135 135
       $eq = &$linear[$i];
136
-      for($j = count($eq) - 1; $j >= $from; $j--)
136
+      for ($j = count($eq) - 1; $j >= $from; $j--)
137 137
       {
138 138
         $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j];
139 139
       }
140 140
     }
141
-    if($logProcess) pdump($linear, 'Подставили обратно х' . $from);
141
+    if ($logProcess) pdump($linear, 'Подставили обратно х'.$from);
142 142
   }
143 143
   else
144 144
   {
145
-    if($logProcess) pdump($linear, 'Результат' . $from);
146
-    foreach($linear as $index => &$eq)
145
+    if ($logProcess) pdump($linear, 'Результат'.$from);
146
+    foreach ($linear as $index => &$eq)
147 147
     {
148
-      pdump($eq[count($linear)], 'x' . $index);
148
+      pdump($eq[count($linear)], 'x'.$index);
149 149
     }
150 150
   }
151 151
 }
Please login to merge, or discard this patch.
includes/classes/Vector.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
   public $type = PT_NONE;
14 14
 
15 15
   public static function _staticInit() {
16
-    if(static::$_isStaticInit) {
16
+    if (static::$_isStaticInit) {
17 17
       return;
18 18
     }
19 19
     static::$knownGalaxies = intval(classSupernova::$config->game_maxGalaxy);
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
   public function __construct($galaxy = 0, $system = 0, $planet = 0, $type = PT_NONE) {
34 34
     // static::_staticInit();
35 35
 
36
-    if(is_string($galaxy) && $galaxy == VECTOR_READ_VECTOR && is_object($system) && $system instanceof Vector) {
36
+    if (is_string($galaxy) && $galaxy == VECTOR_READ_VECTOR && is_object($system) && $system instanceof Vector) {
37 37
       $this->readFromVector($system);
38
-    } elseif(is_string($galaxy) && $galaxy == VECTOR_READ_PARAMS && is_array($system)) {
38
+    } elseif (is_string($galaxy) && $galaxy == VECTOR_READ_PARAMS && is_array($system)) {
39 39
       $this->readFromParamFleets($system);
40 40
     } else {
41 41
       $this->galaxy = intval($galaxy);
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
    * @param Vector $vector
75 75
    */
76 76
   public function distance($vector) {
77
-    if($this->galaxy != $vector->galaxy) {
77
+    if ($this->galaxy != $vector->galaxy) {
78 78
       $distance = abs($this->galaxy - $vector->galaxy) * classSupernova::$config->uni_galaxy_distance;
79
-    } elseif($this->system != $vector->system) {
79
+    } elseif ($this->system != $vector->system) {
80 80
       $distance = abs($this->system - $vector->system) * 5 * 19 + 2700;
81
-    } elseif($this->planet != $vector->planet) {
81
+    } elseif ($this->planet != $vector->planet) {
82 82
       $distance = abs($this->planet - $vector->planet) * 5 + 1000;
83 83
       // TODO - uncomment
84 84
 //    } elseif($this->type != PT_NONE && $vector->type != PT_NONE && $this->type == $vector->type) {
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
    * @param array $coordinates
102 102
    */
103 103
   public static function convertToVector($coordinates, $prefix = '') {
104
-    $galaxy = !empty($coordinates[$prefix . 'galaxy']) ? intval($coordinates[$prefix . 'galaxy']) : 0;
105
-    $system = !empty($coordinates[$prefix . 'system']) ? intval($coordinates[$prefix . 'system']) : 0;
106
-    $planet = !empty($coordinates[$prefix . 'planet']) ? intval($coordinates[$prefix . 'planet']) : 0;
107
-    $type = !empty($coordinates[$prefix . 'type'])
108
-      ? intval($coordinates[$prefix . 'type'])
109
-      : (!empty($coordinates[$prefix . 'planet_type']) ? intval($coordinates[$prefix . 'planet_type']) : 0);
104
+    $galaxy = !empty($coordinates[$prefix.'galaxy']) ? intval($coordinates[$prefix.'galaxy']) : 0;
105
+    $system = !empty($coordinates[$prefix.'system']) ? intval($coordinates[$prefix.'system']) : 0;
106
+    $planet = !empty($coordinates[$prefix.'planet']) ? intval($coordinates[$prefix.'planet']) : 0;
107
+    $type = !empty($coordinates[$prefix.'type'])
108
+      ? intval($coordinates[$prefix.'type'])
109
+      : (!empty($coordinates[$prefix.'planet_type']) ? intval($coordinates[$prefix.'planet_type']) : 0);
110 110
 
111 111
     return new static($galaxy, $system, $planet, $type);
112 112
   }
Please login to merge, or discard this patch.
includes/classes/UBE/UBEReport.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
    */
14 14
   function sn_ube_report_save($ube) {
15 15
     // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем
16
-    if($ube->get_cypher()) {
16
+    if ($ube->get_cypher()) {
17 17
       return false;
18 18
     }
19 19
 
20 20
     // Генерируем уникальный секретный ключ и проверяем наличие в базе
21 21
     do {
22 22
       $ube->report_cypher = sys_random_string(32);
23
-    } while(doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE", true));
23
+    } while (doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE", true));
24 24
 
25 25
     // Инициализация таблицы для пакетной вставки информации
26 26
     $sql_perform = array(
@@ -108,24 +108,24 @@  discard block
 block discarded – undo
108 108
     $sql_str = "INSERT INTO `{{ube_report}}`
109 109
     SET
110 110
       `ube_report_cypher` = '{$ube->report_cypher}',
111
-      `ube_report_time_combat` = '" . date(FMT_DATE_TIME_SQL, $ube->combat_timestamp) . "',
111
+      `ube_report_time_combat` = '".date(FMT_DATE_TIME_SQL, $ube->combat_timestamp)."',
112 112
       `ube_report_time_spent` = {$ube->time_spent},
113 113
 
114
-      `ube_report_combat_admin` = " . (int)$ube->is_admin_in_combat . ",
114
+      `ube_report_combat_admin` = ".(int) $ube->is_admin_in_combat.",
115 115
       `ube_report_mission_type` = {$ube->mission_type_id},
116 116
 
117 117
       `ube_report_combat_result` = {$ube->combat_result},
118
-      `ube_report_combat_sfr` = " . (int)$ube->is_small_fleet_recce . ",
118
+      `ube_report_combat_sfr` = ".(int) $ube->is_small_fleet_recce.",
119 119
 
120
-      `ube_report_planet_id`          = " . (int)$ube->ube_planet_info[PLANET_ID] . ",
121
-      `ube_report_planet_name`        = '" . db_escape($ube->ube_planet_info[PLANET_NAME]) . "',
122
-      `ube_report_planet_size`        = " . (int)$ube->ube_planet_info[PLANET_SIZE] . ",
123
-      `ube_report_planet_galaxy`      = " . (int)$ube->ube_planet_info[PLANET_GALAXY] . ",
124
-      `ube_report_planet_system`      = " . (int)$ube->ube_planet_info[PLANET_SYSTEM] . ",
125
-      `ube_report_planet_planet`      = " . (int)$ube->ube_planet_info[PLANET_PLANET] . ",
126
-      `ube_report_planet_planet_type` = " . (int)$ube->ube_planet_info[PLANET_TYPE] . ",
120
+      `ube_report_planet_id`          = " . (int) $ube->ube_planet_info[PLANET_ID].",
121
+      `ube_report_planet_name`        = '" . db_escape($ube->ube_planet_info[PLANET_NAME])."',
122
+      `ube_report_planet_size`        = " . (int) $ube->ube_planet_info[PLANET_SIZE].",
123
+      `ube_report_planet_galaxy`      = " . (int) $ube->ube_planet_info[PLANET_GALAXY].",
124
+      `ube_report_planet_system`      = " . (int) $ube->ube_planet_info[PLANET_SYSTEM].",
125
+      `ube_report_planet_planet`      = " . (int) $ube->ube_planet_info[PLANET_PLANET].",
126
+      `ube_report_planet_planet_type` = " . (int) $ube->ube_planet_info[PLANET_TYPE].",
127 127
 
128
-      `ube_report_capture_result` = " . (int)$ube->capture_result . ", "
128
+      `ube_report_capture_result` = " . (int) $ube->capture_result.", "
129 129
       . $ube->debris->report_generate_sql()
130 130
       . $ube->moon_calculator->report_generate_sql();
131 131
 
@@ -134,22 +134,22 @@  discard block
 block discarded – undo
134 134
 
135 135
     // Сохраняем общую информацию по игрокам
136 136
     $player_sides = $ube->players->get_player_sides();
137
-    foreach($player_sides as $player_id => $player_side) {
137
+    foreach ($player_sides as $player_id => $player_side) {
138 138
       $sql_perform['ube_report_player'][] = array(
139 139
         $ube_report_id,
140 140
         $player_id,
141 141
 
142
-        "'" . db_escape($ube->players[$player_id]->name) . "'",
142
+        "'".db_escape($ube->players[$player_id]->name)."'",
143 143
         $ube->players[$player_id]->getSide() == UBE_PLAYER_IS_ATTACKER ? 1 : 0,
144 144
 
145
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK),
146
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD),
147
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR),
145
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK),
146
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD),
147
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR),
148 148
       );
149 149
     }
150 150
 
151 151
     // Всякая информация по флотам
152
-    foreach($ube->fleet_list->_container as $fleet_id => $UBEFleet) {
152
+    foreach ($ube->fleet_list->_container as $fleet_id => $UBEFleet) {
153 153
       // Сохраняем общую информацию по флотам
154 154
       $sql_perform['ube_report_fleet'][] = $UBEFleet->sql_generate_array($ube_report_id);
155 155
 
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
     $ube->rounds->sql_generate_unit_array($sql_perform['ube_report_unit'], $ube_report_id, $ube->fleet_list);
166 166
 
167 167
     // Пакетная вставка данных
168
-    foreach($sql_perform as $table_name => $table_data) {
169
-      if(count($table_data) < 2) {
168
+    foreach ($sql_perform as $table_name => $table_data) {
169
+      if (count($table_data) < 2) {
170 170
         continue;
171 171
       }
172
-      foreach($table_data as &$record_data) {
173
-        $record_data = '(' . implode(',', $record_data) . ')';
172
+      foreach ($table_data as &$record_data) {
173
+        $record_data = '('.implode(',', $record_data).')';
174 174
       }
175 175
       $fields = $table_data[0];
176 176
       unset($table_data[0]);
177
-      doquery("INSERT INTO {{{$table_name}}} {$fields} VALUES " . implode(',', $table_data));
177
+      doquery("INSERT INTO {{{$table_name}}} {$fields} VALUES ".implode(',', $table_data));
178 178
     }
179 179
 
180 180
     return $ube->report_cypher;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     $report_cypher = db_escape($report_cypher);
193 193
 
194 194
     $report_row = doquery("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1", true);
195
-    if(!$report_row) {
195
+    if (!$report_row) {
196 196
       return UBE_REPORT_NOT_FOUND;
197 197
     }
198 198
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
    * @param     $template_result
209 209
    */
210 210
   function sn_ube_report_generate(UBE $ube, &$template_result) {
211
-    if(!is_object($ube)) {
211
+    if (!is_object($ube)) {
212 212
       return;
213 213
     }
214 214
 
@@ -223,15 +223,15 @@  discard block
 block discarded – undo
223 223
 
224 224
     // Координаты, тип и название планеты - если есть
225 225
 //R  $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER];
226
-    if(isset($ube->ube_planet_info)) {
226
+    if (isset($ube->ube_planet_info)) {
227 227
       $template_result += $ube->ube_planet_info;
228 228
       $template_result[PLANET_NAME] = str_replace(' ', '&nbsp;', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8'));
229 229
     }
230 230
 
231 231
     // Обломки
232 232
     $debris = array();
233
-    foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) {
234
-      if($resource_amount = $ube->debris->debris_get_resource($resource_id)) {
233
+    foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) {
234
+      if ($resource_amount = $ube->debris->debris_get_resource($resource_id)) {
235 235
         $debris[] = array(
236 236
           'NAME'   => classLocale::$lang['tech'][$resource_id],
237 237
           'AMOUNT' => pretty_number($resource_amount),
Please login to merge, or discard this patch.
includes/classes/UBE/UBE.php 1 patch
Spacing   +48 added lines, -49 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     $this->players->db_load_player_by_id($player_id, UBE_PLAYER_IS_DEFENDER);
148 148
 
149 149
     $player_db_row = $this->players[$player_id]->getDbRow();
150
-    if($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) {
150
+    if ($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) {
151 151
       $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $fortifier_level);
152 152
     }
153 153
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     $this->rounds[0] = new UBERound(0);
180 180
     $this->rounds[0]->make_snapshot($this->fleet_list);
181 181
 
182
-    for($round = 1; $round <= 10; $round++) {
182
+    for ($round = 1; $round <= 10; $round++) {
183 183
       // Проводим раунд
184 184
       defined('DEBUG_UBE') ? print("Round {$round}<br>") : false;
185 185
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
       // Анализируем итоги текущего раунда и готовим данные для следующего
194 194
       $this->combat_result = $this->fleet_list->ubeAnalyzeFleetOutcome($round);
195
-      if($this->combat_result != UBE_COMBAT_RESULT_DRAW) {
195
+      if ($this->combat_result != UBE_COMBAT_RESULT_DRAW) {
196 196
         break;
197 197
       }
198 198
 
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
     // Генерируем результат боя
222 222
     $this->fleet_list->ube_analyze_fleets($this->is_simulator, $this->debris, $this->resource_exchange_rates);
223 223
 
224
-    if(!$this->is_ube_loaded) {
224
+    if (!$this->is_ube_loaded) {
225 225
       $this->moon_calculator->calculate_moon($this);
226 226
 
227 227
       // Лутаем ресурсы - если аттакер выиграл
228
-      if($this->combat_result == UBE_COMBAT_RESULT_WIN) {
228
+      if ($this->combat_result == UBE_COMBAT_RESULT_WIN) {
229 229
         $this->sn_ube_combat_analyze_loot();
230 230
       }
231 231
     }
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
       RES_DEUTERIUM => 0,
246 246
     );
247 247
 
248
-    if(
248
+    if (
249 249
       (($planet_resource_total = $this->fleet_list[0]->get_resources_amount()) > 0)
250 250
       &&
251 251
       (($total_capacity = $this->fleet_list->ube_get_capacity_attackers()) > 0)
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
       $planet_lootable_percent = $planet_lootable / $planet_resource_total;
258 258
 
259 259
       // Вычисляем сколько ресурсов вывезено
260
-      foreach($this->fleet_list->_container as $fleet_id => $fleet) {
260
+      foreach ($this->fleet_list->_container as $fleet_id => $fleet) {
261 261
         $looted_in_metal = 0;
262
-        foreach($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) {
262
+        foreach ($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) {
263 263
           // Вычисляем какой процент общей емкости трюмов атакующих будет задействован
264 264
           $fleet_lootable_percent = $fleet->fleet_capacity / $total_capacity;
265 265
           $looted = floor($resource_amount * $planet_lootable_percent * $fleet_lootable_percent);
@@ -325,16 +325,16 @@  discard block
 block discarded – undo
325 325
     $destination_user_id = $this->fleet_list[0]->owner_id;
326 326
 
327 327
     // Обновляем поле обломков на планете
328
-    if(!$this->is_admin_in_combat && $this->debris->debris_total() > 0) {
328
+    if (!$this->is_admin_in_combat && $this->debris->debris_total() > 0) {
329 329
       db_planet_set_by_gspt($this->ube_planet_info[PLANET_GALAXY], $this->ube_planet_info[PLANET_SYSTEM], $this->ube_planet_info[PLANET_PLANET], PT_PLANET,
330
-        "`debris_metal` = `debris_metal` + " . $this->debris->debris_get_resource(RES_METAL) . ", `debris_crystal` = `debris_crystal` + " . $this->debris->debris_get_resource(RES_CRYSTAL)
330
+        "`debris_metal` = `debris_metal` + ".$this->debris->debris_get_resource(RES_METAL).", `debris_crystal` = `debris_crystal` + ".$this->debris->debris_get_resource(RES_CRYSTAL)
331 331
       );
332 332
     }
333 333
 
334
-    foreach($this->fleet_list->_container as $fleet_id => $UBEFleet) {
334
+    foreach ($this->fleet_list->_container as $fleet_id => $UBEFleet) {
335 335
       $ship_count_lost = $UBEFleet->unit_list->unitCountLost();
336 336
 
337
-      if($fleet_id) {
337
+      if ($fleet_id) {
338 338
         // Флот
339 339
         $UBEFleet->db_save_combat_result_fleet($this->is_small_fleet_recce, $this->moon_calculator->get_reapers_status());
340 340
       } else {
@@ -342,19 +342,19 @@  discard block
 block discarded – undo
342 342
 
343 343
         // Сохраняем изменения ресурсов - если они есть
344 344
         $resource_delta = $UBEFleet->ube_combat_result_calculate_resources();
345
-        if(!empty($resource_delta)) {
345
+        if (!empty($resource_delta)) {
346 346
           $temp = array();
347
-          foreach($resource_delta as $resource_id => $resource_amount) {
347
+          foreach ($resource_delta as $resource_id => $resource_amount) {
348 348
             $resource_db_name = pname_resource_name($resource_id);
349 349
             $temp[] = "`{$resource_db_name}` = `{$resource_db_name}` + ({$resource_amount})";
350 350
           }
351 351
           db_planet_set_by_id($this->ube_planet_info[PLANET_ID], implode(',', $temp));
352 352
         }
353 353
 
354
-        if($ship_count_lost) {
354
+        if ($ship_count_lost) {
355 355
           $db_changeset = array();
356 356
           $planet_row_cache = $this->players[$destination_user_id]->getDbRow();
357
-          foreach($UBEFleet->unit_list->_container as $UBEUnit) {
357
+          foreach ($UBEFleet->unit_list->_container as $UBEUnit) {
358 358
             $db_changeset['unit'][] = sn_db_unit_changeset_prepare($UBEUnit->unitId, -$UBEUnit->units_lost, $planet_row_cache, $this->ube_planet_info[PLANET_ID]);
359 359
           }
360 360
           db_changeset_apply($db_changeset);
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
     // TODO: Связать сабы с флотами констраинтами ON DELETE SET NULL
366 366
     // Для САБов
367 367
     $fleet_group_id_list = $this->fleet_list->ube_get_groups();
368
-    if(!empty($fleet_group_id_list)) {
368
+    if (!empty($fleet_group_id_list)) {
369 369
       $fleet_group_id_list = implode(',', $fleet_group_id_list);
370 370
       db_acs_delete_by_list($fleet_group_id_list);
371 371
     }
@@ -374,19 +374,19 @@  discard block
 block discarded – undo
374 374
 
375 375
     $bashing_list = array();
376 376
     $players_sides = $this->players->get_player_sides();
377
-    foreach($players_sides as $player_id => $player_side) {
378
-      if($player_side != UBE_PLAYER_IS_ATTACKER) {
377
+    foreach ($players_sides as $player_id => $player_side) {
378
+      if ($player_side != UBE_PLAYER_IS_ATTACKER) {
379 379
         continue;
380 380
       }
381
-      if($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) {
381
+      if ($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) {
382 382
         $bashing_list[] = "({$player_id}, {$this->ube_planet_info[PLANET_ID]}, {$this->combat_timestamp})";
383 383
       }
384
-      if($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) {
384
+      if ($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) {
385 385
         $str_loose_or_win = $this->combat_result == UBE_COMBAT_RESULT_WIN ? 'raidswin' : 'raidsloose';
386 386
         db_user_set_by_id($player_id, "`xpraid` = `xpraid` + 1, `raids` = `raids` + 1, `{$str_loose_or_win}` = `{$str_loose_or_win}` + 1");
387 387
       }
388 388
     }
389
-    if(!empty($bashing_list)) {
389
+    if (!empty($bashing_list)) {
390 390
       $bashing_list = implode(',', $bashing_list);
391 391
       db_bashing_insert($bashing_list);
392 392
     }
@@ -413,20 +413,19 @@  discard block
 block discarded – undo
413 413
       $planet_info[PLANET_SYSTEM],
414 414
       $planet_info[PLANET_PLANET],
415 415
       htmlentities($planet_info[PLANET_NAME], ENT_COMPAT, 'UTF-8'),
416
-      classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' :
417
-        ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')]
416
+      classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')]
418 417
     );
419 418
 
420 419
     $text_defender = '';
421 420
     $debris = $this->debris->get_debris();
422
-    foreach($debris as $resource_id => $resource_amount) {
423
-      if($resource_id == RES_DEUTERIUM) {
421
+    foreach ($debris as $resource_id => $resource_amount) {
422
+      if ($resource_id == RES_DEUTERIUM) {
424 423
         continue;
425 424
       }
426 425
 
427
-      $text_defender .= "{$classLocale['tech'][$resource_id]}: " . pretty_number($resource_amount) . '<br />';
426
+      $text_defender .= "{$classLocale['tech'][$resource_id]}: ".pretty_number($resource_amount).'<br />';
428 427
     }
429
-    if($text_defender) {
428
+    if ($text_defender) {
430 429
       $text_defender = "{$classLocale['ube_report_msg_body_debris']}{$text_defender}<br />";
431 430
     }
432 431
 
@@ -436,8 +435,8 @@  discard block
 block discarded – undo
436 435
 
437 436
     // TODO: Оптимизировать отсылку сообщений - отсылать пакетами
438 437
     $player_sides = $this->players->get_player_sides();
439
-    foreach($player_sides as $player_id => $player_side) {
440
-      $message = $text_common . ($this->is_small_fleet_recce && ($player_side == UBE_PLAYER_IS_ATTACKER) ? classLocale::$lang['ube_report_msg_body_sfr'] : $text_defender);
438
+    foreach ($player_sides as $player_id => $player_side) {
439
+      $message = $text_common.($this->is_small_fleet_recce && ($player_side == UBE_PLAYER_IS_ATTACKER) ? classLocale::$lang['ube_report_msg_body_sfr'] : $text_defender);
441 440
       msg_send_simple_message($player_id, '', $this->combat_timestamp, MSG_TYPE_COMBAT, classLocale::$lang['sys_mess_tower'], classLocale::$lang['sys_mess_attack_report'], $message);
442 441
     }
443 442
 
@@ -473,11 +472,11 @@  discard block
 block discarded – undo
473 472
     $player_id = $player_id == -1 ? $this->players->count() : $player_id;
474 473
     $fleet_id = $player_id; // FOR SIMULATOR!
475 474
 
476
-    if(empty($this->players[$player_id])) {
475
+    if (empty($this->players[$player_id])) {
477 476
       $this->players[$player_id] = new UBEPlayer();
478 477
     }
479 478
 
480
-    foreach($side_info as $fleet_data) {
479
+    foreach ($side_info as $fleet_data) {
481 480
       $this->players[$player_id]->name = $player_id;
482 481
       $this->players[$player_id]->setSide($attacker);
483 482
 
@@ -485,32 +484,32 @@  discard block
 block discarded – undo
485 484
       $this->fleet_list[$fleet_id] = $objFleet;
486 485
 
487 486
       $this->fleet_list[$fleet_id]->owner_id = $player_id;
488
-      foreach($fleet_data as $unit_id => $unit_count) {
489
-        if(!$unit_count) {
487
+      foreach ($fleet_data as $unit_id => $unit_count) {
488
+        if (!$unit_count) {
490 489
           continue;
491 490
         }
492 491
 
493 492
         $unit_type = get_unit_param($unit_id, P_UNIT_TYPE);
494 493
 
495
-        if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
494
+        if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
496 495
           $this->fleet_list[$fleet_id]->unit_list->unitAdjustCount($unit_id, $unit_count);
497
-        } elseif($unit_type == UNIT_RESOURCES) {
496
+        } elseif ($unit_type == UNIT_RESOURCES) {
498 497
           $this->fleet_list[$fleet_id]->resource_list[$unit_id] = $unit_count;
499
-        } elseif($unit_type == UNIT_TECHNOLOGIES) {
500
-          if($unit_id == TECH_WEAPON) {
498
+        } elseif ($unit_type == UNIT_TECHNOLOGIES) {
499
+          if ($unit_id == TECH_WEAPON) {
501 500
             $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_WEAPON, $unit_count);
502
-          } elseif($unit_id == TECH_SHIELD) {
501
+          } elseif ($unit_id == TECH_SHIELD) {
503 502
             $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_SHIELD, $unit_count);
504
-          } elseif($unit_id == TECH_ARMOR) {
503
+          } elseif ($unit_id == TECH_ARMOR) {
505 504
             $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_ARMOR, $unit_count);
506 505
           }
507
-        } elseif($unit_type == UNIT_GOVERNORS) {
508
-          if($unit_id == MRC_FORTIFIER) {
506
+        } elseif ($unit_type == UNIT_GOVERNORS) {
507
+          if ($unit_id == MRC_FORTIFIER) {
509 508
             // Фортифаер даёт бонус ко всему
510 509
             $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $unit_count);
511 510
           }
512
-        } elseif($unit_type == UNIT_MERCENARIES) {
513
-          if($unit_id == MRC_ADMIRAL) {
511
+        } elseif ($unit_type == UNIT_MERCENARIES) {
512
+          if ($unit_id == MRC_ADMIRAL) {
514 513
             $this->players[$player_id]->player_bonus->add_unit_by_snid(MRC_ADMIRAL, $unit_count);
515 514
           }
516 515
         }
@@ -565,7 +564,7 @@  discard block
 block discarded – undo
565 564
 
566 565
     $ube->sn_ube_message_send();
567 566
 
568
-    defined('DEBUG_UBE') ? die('DIE at ' . __FILE__ . ' ' . __LINE__) : false;
567
+    defined('DEBUG_UBE') ? die('DIE at '.__FILE__.' '.__LINE__) : false;
569 568
 
570 569
     return false;
571 570
   }
@@ -580,7 +579,7 @@  discard block
 block discarded – undo
580 579
 
581 580
     $ube_report = new UBEReport();
582 581
     $ube = $ube_report->sn_ube_report_load(sys_get_param_str('cypher'));
583
-    if($ube != UBE_REPORT_NOT_FOUND) {
582
+    if ($ube != UBE_REPORT_NOT_FOUND) {
584 583
       $ube_report->sn_ube_report_generate($ube, $template_result);
585 584
 
586 585
       $template = gettemplate('ube_combat_report', $template);
@@ -608,9 +607,9 @@  discard block
 block discarded – undo
608 607
     $ube->sn_ube_combat();
609 608
     $ube_report = new UBEReport();
610 609
 
611
-    if(sys_get_param_str('reload')) {
610
+    if (sys_get_param_str('reload')) {
612 611
       $ube_new = $ube_report->sn_ube_report_load($ube->get_cypher()); // $combat_data = sn_ube_report_load($combat_data[UBE_REPORT_CYPHER]);
613
-      if($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) {
612
+      if ($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) {
614 613
         $ube = $ube_new;
615 614
       }
616 615
     }
@@ -658,7 +657,7 @@  discard block
 block discarded – undo
658 657
     $this->debris->load_from_report_row($report_row);
659 658
 
660 659
     $query = doquery("SELECT * FROM {{ube_report_player}} WHERE `ube_report_id` = {$report_row['ube_report_id']}");
661
-    while($player_row = db_fetch($query)) {
660
+    while ($player_row = db_fetch($query)) {
662 661
       $this->players->init_player_from_report_info($player_row);
663 662
     }
664 663
 
Please login to merge, or discard this patch.
includes/classes/UBE/UBEDebris.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
    */
31 31
   public function debris_add_resource($resource_id, $resource_amount) {
32 32
     // В обломках может быть только металл или кристалл
33
-    if($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) {
33
+    if ($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) {
34 34
       return;
35 35
     }
36 36
     $this->debris[$resource_id] += $resource_amount;
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
    * @param bool  $is_simulator
42 42
    */
43 43
   public function add_wrecks(array $wreckage, $is_simulator) {
44
-    foreach($wreckage as $resource_id => $resource_amount) {
44
+    foreach ($wreckage as $resource_id => $resource_amount) {
45 45
       $this->debris_add_resource($resource_id, floor($resource_amount *
46 46
         ($is_simulator
47 47
           ? UBE_SHIP_WRECKS_TO_DEBRIS_AVG
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
    * @param bool  $is_simulator
58 58
    */
59 59
   public function add_cargo_drop(array $dropped_resources, $is_simulator) {
60
-    foreach($dropped_resources as $resource_id => $resource_amount) {
60
+    foreach ($dropped_resources as $resource_id => $resource_amount) {
61 61
       $this->debris_add_resource($resource_id, floor($resource_amount *
62 62
         ($is_simulator
63 63
           ? UBE_CARGO_DROPPED_TO_DEBRIS_AVG
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
    * @param $moon_debris_left_part
97 97
    */
98 98
   public function debris_adjust_proportional($moon_debris_left_part) {
99
-    foreach($this->debris as $resource_id => &$resource_amount) {
99
+    foreach ($this->debris as $resource_id => &$resource_amount) {
100 100
       $resource_amount = floor($resource_amount * $moon_debris_left_part);
101 101
     }
102 102
   }
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
    */
118 118
   public function report_generate_sql() {
119 119
     return "
120
-      `ube_report_debris_metal` = " . (float)$this->debris_get_resource(RES_METAL) . ",
121
-      `ube_report_debris_crystal` = " . (float)$this->debris_get_resource(RES_CRYSTAL) . ",
122
-      `ube_report_debris_total_in_metal` = " . (float)$this->debris_in_metal() . ", ";
120
+      `ube_report_debris_metal` = " . (float) $this->debris_get_resource(RES_METAL).",
121
+      `ube_report_debris_crystal` = " . (float) $this->debris_get_resource(RES_CRYSTAL).",
122
+      `ube_report_debris_total_in_metal` = " . (float) $this->debris_in_metal().", ";
123 123
   }
124 124
 
125 125
   /**
Please login to merge, or discard this patch.
includes/classes/UBE/UBEDebug.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
    * @version 41a6.49
12 12
    */
13 13
   public static function unit_dump_header() {
14
-    if(!defined('DEBUG_UBE')) {
14
+    if (!defined('DEBUG_UBE')) {
15 15
       return;
16 16
     }
17 17
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
    * @version 41a6.49
49 49
    */
50 50
   public static function unit_dump(UBEUnit $unit, $desc = '', UBEUnit $before = null) {
51
-    if(!defined('DEBUG_UBE')) {
51
+    if (!defined('DEBUG_UBE')) {
52 52
       return;
53 53
     }
54 54
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 //  print("<td>" . $this->units_lost . "</td>");
76 76
 //  print("<td>" . $this->units_restored . "</td>");
77 77
 //  print("<td>" . $this->capacity . "</td>");
78
-    print("<td>" . round($unit->share_of_side_armor, 4) . "</td>");
78
+    print("<td>".round($unit->share_of_side_armor, 4)."</td>");
79 79
     print('</tr>');
80 80
   }
81 81
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
    * @version 41a6.49
87 87
    */
88 88
   public static function unit_dump_footer() {
89
-    if(!defined('DEBUG_UBE')) {
89
+    if (!defined('DEBUG_UBE')) {
90 90
       return;
91 91
     }
92 92
 
@@ -101,16 +101,16 @@  discard block
 block discarded – undo
101 101
    * @return UBEUnit
102 102
    */
103 103
   public static function unit_dump_defender(UBEUnit $attacking_unit_pool, UBEUnit $defending_unit_pool, $defending_fleet_id) {
104
-    if(!defined('DEBUG_UBE')) {
104
+    if (!defined('DEBUG_UBE')) {
105 105
       return null;
106 106
     }
107 107
 
108 108
     $classLocale = classLocale::$lang;
109 109
 
110
-    print("[{$attacking_unit_pool->unitId}]{$classLocale['tech'][$attacking_unit_pool->unitId]}" .
111
-      ' attacks ' .
112
-      $defending_fleet_id . '@' . "[{$defending_unit_pool->unitId}]{$classLocale['tech'][$defending_unit_pool->unitId]}" .
113
-      ' with ' . pretty_number($defending_unit_pool->attack_income) .
110
+    print("[{$attacking_unit_pool->unitId}]{$classLocale['tech'][$attacking_unit_pool->unitId]}".
111
+      ' attacks '.
112
+      $defending_fleet_id.'@'."[{$defending_unit_pool->unitId}]{$classLocale['tech'][$defending_unit_pool->unitId]}".
113
+      ' with '.pretty_number($defending_unit_pool->attack_income).
114 114
       '<br>'
115 115
     );
116 116
     $before = clone $defending_unit_pool;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
    * @version 41a6.49
128 128
    */
129 129
   public static function unit_dump_delta(UBEUnit $unit, $field, UBEUnit $before = null) {
130
-    if(!defined('DEBUG_UBE')) {
130
+    if (!defined('DEBUG_UBE')) {
131 131
       return;
132 132
     }
133 133
 
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
     print(pretty_number($unit->$field));
137 137
     print("</td>");
138 138
     print("<td>");
139
-    if(!empty($before)) {
140
-      print('' . pretty_number($unit->$field - $before->$field) . '');
139
+    if (!empty($before)) {
140
+      print(''.pretty_number($unit->$field - $before->$field).'');
141 141
     }
142 142
     print("</td>");
143 143
   }
Please login to merge, or discard this patch.
includes/classes/UBE/UBEFleet.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -162,20 +162,20 @@  discard block
 block discarded – undo
162 162
       $this->owner_id,
163 163
       $this->db_id,
164 164
 
165
-      (float)$this->UBE_PLANET[PLANET_ID],
166
-      "'" . db_escape($this->UBE_PLANET[PLANET_NAME]) . "'",
167
-      (int)$this->UBE_PLANET[PLANET_GALAXY],
168
-      (int)$this->UBE_PLANET[PLANET_SYSTEM],
169
-      (int)$this->UBE_PLANET[PLANET_PLANET],
170
-      (int)$this->UBE_PLANET[PLANET_TYPE],
171
-
172
-      (float)$this->resource_list[RES_METAL],
173
-      (float)$this->resource_list[RES_CRYSTAL],
174
-      (float)$this->resource_list[RES_DEUTERIUM],
175
-
176
-      (float)$this->fleet_bonus->calcBonus(P_ATTACK),
177
-      (float)$this->fleet_bonus->calcBonus(P_SHIELD),
178
-      (float)$this->fleet_bonus->calcBonus(P_ARMOR),
165
+      (float) $this->UBE_PLANET[PLANET_ID],
166
+      "'".db_escape($this->UBE_PLANET[PLANET_NAME])."'",
167
+      (int) $this->UBE_PLANET[PLANET_GALAXY],
168
+      (int) $this->UBE_PLANET[PLANET_SYSTEM],
169
+      (int) $this->UBE_PLANET[PLANET_PLANET],
170
+      (int) $this->UBE_PLANET[PLANET_TYPE],
171
+
172
+      (float) $this->resource_list[RES_METAL],
173
+      (float) $this->resource_list[RES_CRYSTAL],
174
+      (float) $this->resource_list[RES_DEUTERIUM],
175
+
176
+      (float) $this->fleet_bonus->calcBonus(P_ATTACK),
177
+      (float) $this->fleet_bonus->calcBonus(P_SHIELD),
178
+      (float) $this->fleet_bonus->calcBonus(P_ARMOR),
179 179
     );
180 180
   }
181 181
 
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
     $this->group_id = $objFleet->group_id;
191 191
 
192 192
     $fleet_unit_list = $objFleet->shipsGetArray();
193
-    foreach($fleet_unit_list as $unit_id => $unit_count) {
194
-      if(!$unit_count) {
193
+    foreach ($fleet_unit_list as $unit_id => $unit_count) {
194
+      if (!$unit_count) {
195 195
         continue;
196 196
       }
197 197
 
198 198
       $unit_type = get_unit_param($unit_id, P_UNIT_TYPE);
199
-      if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
199
+      if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
200 200
         $this->unit_list->unitAdjustCount($unit_id, $unit_count);
201 201
       }
202 202
     }
@@ -232,13 +232,13 @@  discard block
 block discarded – undo
232 232
 //      }
233 233
 //    }
234 234
 
235
-    foreach($sn_group_combat as $unit_id) {
236
-      if($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) {
235
+    foreach ($sn_group_combat as $unit_id) {
236
+      if ($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) {
237 237
         $this->unit_list->unitAdjustCount($unit_id, $unit_count);
238 238
       }
239 239
     }
240 240
 
241
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
241
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
242 242
       $this->resource_list[$resource_id] = floor(mrc_get_level($player_db_row, $planet_row, $resource_id));
243 243
     }
244 244
 
@@ -297,27 +297,27 @@  discard block
 block discarded – undo
297 297
       $ube_report_id,
298 298
       $this->db_id,
299 299
 
300
-      (float)$this->resources_lost_on_units[RES_METAL],
301
-      (float)$this->resources_lost_on_units[RES_CRYSTAL],
302
-      (float)$this->resources_lost_on_units[RES_DEUTERIUM],
303
-      (float)$this->cargo_dropped[RES_METAL],
304
-      (float)$this->cargo_dropped[RES_CRYSTAL],
305
-      (float)$this->cargo_dropped[RES_DEUTERIUM],
306
-      (float)$this->resources_looted[RES_METAL],
307
-      (float)$this->resources_looted[RES_CRYSTAL],
308
-      (float)$this->resources_looted[RES_DEUTERIUM],
309
-      (float)$this->resources_lost_in_metal[RES_METAL],
300
+      (float) $this->resources_lost_on_units[RES_METAL],
301
+      (float) $this->resources_lost_on_units[RES_CRYSTAL],
302
+      (float) $this->resources_lost_on_units[RES_DEUTERIUM],
303
+      (float) $this->cargo_dropped[RES_METAL],
304
+      (float) $this->cargo_dropped[RES_CRYSTAL],
305
+      (float) $this->cargo_dropped[RES_DEUTERIUM],
306
+      (float) $this->resources_looted[RES_METAL],
307
+      (float) $this->resources_looted[RES_CRYSTAL],
308
+      (float) $this->resources_looted[RES_DEUTERIUM],
309
+      (float) $this->resources_lost_in_metal[RES_METAL],
310 310
     );
311 311
   }
312 312
 
313 313
   public function report_render_outcome_side_fleet() {
314 314
     $UBE_DEFENCE_RESTORE = array();
315 315
     $UBE_UNITS_LOST = array();
316
-    foreach($this->unit_list->_container as $UBEUnit) {
317
-      if($UBEUnit->units_restored) {
316
+    foreach ($this->unit_list->_container as $UBEUnit) {
317
+      if ($UBEUnit->units_restored) {
318 318
         $UBE_DEFENCE_RESTORE[$UBEUnit->unitId] = $UBEUnit->units_restored;
319 319
       }
320
-      if($UBEUnit->units_lost) {
320
+      if ($UBEUnit->units_lost) {
321 321
         $UBE_UNITS_LOST[$UBEUnit->unitId] = $UBEUnit->units_lost;
322 322
       }
323 323
     }
@@ -342,16 +342,16 @@  discard block
 block discarded – undo
342 342
    */
343 343
   protected function report_render_outcome_side_fleet_line(&$array, $lang_header_index) {
344 344
     $result = array();
345
-    if(!empty($array)) {
346
-      foreach($array as $unit_id => $unit_count) {
347
-        if($unit_count) {
345
+    if (!empty($array)) {
346
+      foreach ($array as $unit_id => $unit_count) {
347
+        if ($unit_count) {
348 348
           $result[] = array(
349 349
             'NAME' => classLocale::$lang['tech'][$unit_id],
350 350
             'LOSS' => pretty_number($unit_count),
351 351
           );
352 352
         }
353 353
       }
354
-      if($lang_header_index && count($result)) {
354
+      if ($lang_header_index && count($result)) {
355 355
         array_unshift($result, array('NAME' => classLocale::$lang[$lang_header_index]));
356 356
       }
357 357
     }
@@ -364,16 +364,16 @@  discard block
 block discarded – undo
364 364
     $fleet_id = $this->db_id;
365 365
 
366 366
     $unit_sort_order = 0;
367
-    foreach($this->unit_list->_container as $UBEUnit) {
368
-      if($UBEUnit->units_lost || $UBEUnit->units_restored) {
367
+    foreach ($this->unit_list->_container as $UBEUnit) {
368
+      if ($UBEUnit->units_lost || $UBEUnit->units_restored) {
369 369
         $unit_sort_order++;
370 370
         $sql_perform_report_unit[] = array(
371 371
           $ube_report_id,
372 372
           $fleet_id,
373 373
 
374 374
           $UBEUnit->unitId,
375
-          (float)$UBEUnit->units_restored,
376
-          (float)$UBEUnit->units_lost,
375
+          (float) $UBEUnit->units_restored,
376
+          (float) $UBEUnit->units_lost,
377 377
 
378 378
           $unit_sort_order,
379 379
         );
@@ -389,9 +389,9 @@  discard block
 block discarded – undo
389 389
   function ube_combat_result_calculate_resources() {
390 390
     $resource_delta_fleet = array();
391 391
     // Если во флоте остались юниты или это планета - генерируем изменение ресурсов
392
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
393
-      $resource_change = (float)$this->resources_looted[$resource_id] + (float)$this->cargo_dropped[$resource_id];
394
-      if($resource_change) {
392
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
393
+      $resource_change = (float) $this->resources_looted[$resource_id] + (float) $this->cargo_dropped[$resource_id];
394
+      if ($resource_change) {
395 395
         $resource_delta_fleet[$resource_id] = -($resource_change);
396 396
       }
397 397
     }
@@ -424,12 +424,12 @@  discard block
 block discarded – undo
424 424
     );
425 425
 
426 426
     $this->fleet_capacity = 0;
427
-    foreach($this->unit_list->_container as $UBEUnit) {
427
+    foreach ($this->unit_list->_container as $UBEUnit) {
428 428
       $this->fleet_capacity += $UBEUnit->capacity * $UBEUnit->getCount();
429 429
 
430
-      if($UBEUnit->units_lost) {
431
-        foreach($UBEUnit->price as $resource_id => $unit_resource_price) {
432
-          if(!$unit_resource_price) {
430
+      if ($UBEUnit->units_lost) {
431
+        foreach ($UBEUnit->price as $resource_id => $unit_resource_price) {
432
+          if (!$unit_resource_price) {
433 433
             continue;
434 434
           }
435 435
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
           $this->resources_lost_on_units[$resource_id] += $resources_lost;
438 438
           // Если это корабль - прибавляем потери к обломкам на орбите
439 439
           // TODO - опция выбрасывания обороны в обломки
440
-          if($UBEUnit->getType() == UNIT_SHIPS) {
440
+          if ($UBEUnit->getType() == UNIT_SHIPS) {
441 441
             $this->resources_lost_on_ships[$resource_id] += $resources_lost;
442 442
           }
443 443
         }
@@ -449,11 +449,11 @@  discard block
 block discarded – undo
449 449
 
450 450
     // Если емкость трюмов меньше количество ресурсов - часть ресов выбрасываем нахуй
451 451
     // На планете ($fleet_id = 0) ресурсы в космос не выбрасываются
452
-    if($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) {
452
+    if ($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) {
453 453
       $drop_share = 1 - $this->fleet_capacity / $fleet_total_resources; // Какая часть ресурсов выброшена
454
-      foreach($this->resource_list as $resource_id => &$resource_amount) {
454
+      foreach ($this->resource_list as $resource_id => &$resource_amount) {
455 455
         // Не просчитываем ресурсы, которых нет на борту кораблей флота
456
-        if(!$resource_amount) {
456
+        if (!$resource_amount) {
457 457
           continue;
458 458
         }
459 459
 
@@ -474,19 +474,19 @@  discard block
 block discarded – undo
474 474
     $objFleet2->setDbId($this->db_id);
475 475
 
476 476
     // Если это была миссия Уничтожения И звезда смерти взорвалась И мы работаем с аттакерами - значит все аттакеры умерли
477
-    if($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) {
477
+    if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) {
478 478
       $objFleet2->dbDelete();
479
-    } elseif($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial ||
479
+    } elseif ($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial ||
480 480
       $objFleet2->dbDelete();
481 481
     } else {
482
-      if($ship_count_lost) {
482
+      if ($ship_count_lost) {
483 483
         // Просматриваем результаты изменения флотов
484
-        foreach($this->unit_list->_container as $UBEUnit) {
484
+        foreach ($this->unit_list->_container as $UBEUnit) {
485 485
           // Перебираем аутком на случай восстановления юнитов
486 486
 //          if(($units_left = $UBEUnit->getCount() - (float)$UBEUnit->units_lost) > 0) {
487 487
 //            $fleet_real_array[$UBEUnit->unitId] = $units_left;
488 488
 //          };
489
-          if(floatval($UBEUnit->units_lost) != 0) {
489
+          if (floatval($UBEUnit->units_lost) != 0) {
490 490
             $objFleet2->shipAdjustCount($UBEUnit->unitId, floatval($UBEUnit->units_lost));
491 491
           };
492 492
         }
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
       $objFleet2->resourcesAdjust($resource_delta_fleet);
497 497
 
498 498
       // Если защитник и не РМФ - отправляем флот назад
499
-      if($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) {
499
+      if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) {
500 500
         $objFleet2->markReturned();
501 501
       }
502 502
       $objFleet2->dbSave();
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
   public function calculate_unit_partial_data(UBEASA $side_ASA) {
527 527
     $this->fleet_share_of_side_armor = $this->total_stats[P_ARMOR] / $side_ASA->getArmor();
528 528
 
529
-    foreach($this->unit_list->_container as $UBEUnit) {
529
+    foreach ($this->unit_list->_container as $UBEUnit) {
530 530
       $UBEUnit->share_of_side_armor = $UBEUnit->pool_armor / $side_ASA->getArmor();
531 531
     }
532 532
   }
@@ -538,9 +538,9 @@  discard block
 block discarded – undo
538 538
    * @version 2016-02-25 23:42:45 41a4.68
539 539
    */
540 540
   public function attack_fleets(UBEFleetList $fleet_list, $is_simulator) {
541
-    foreach($fleet_list->_container as $defending_fleet) {
541
+    foreach ($fleet_list->_container as $defending_fleet) {
542 542
       // Не атакуются флоты на своей стороне
543
-      if($this->is_attacker == $defending_fleet->is_attacker) {
543
+      if ($this->is_attacker == $defending_fleet->is_attacker) {
544 544
         continue;
545 545
       }
546 546
       $this->attack_fleet($defending_fleet, $is_simulator);
@@ -556,12 +556,12 @@  discard block
 block discarded – undo
556 556
   public function attack_fleet(UBEFleet $defending_fleet, $is_simulator) {
557 557
     UBEDebug::unit_dump_header();
558 558
 
559
-    foreach($this->unit_list->_container as $attacking_unit_pool) {
559
+    foreach ($this->unit_list->_container as $attacking_unit_pool) {
560 560
       UBEDebug::unit_dump($attacking_unit_pool, 'attacker');
561 561
 
562 562
       // if($attack_unit_count <= 0) continue; // TODO: Это пока нельзя включать - вот если будут "боевые порядки юнитов..."
563
-      foreach($defending_fleet->unit_list->_container as $defending_unit_pool) {
564
-        if($defending_unit_pool->isEmpty()) {
563
+      foreach ($defending_fleet->unit_list->_container as $defending_unit_pool) {
564
+        if ($defending_unit_pool->isEmpty()) {
565 565
           continue;
566 566
         }
567 567
 
Please login to merge, or discard this patch.
includes/classes/UnitList.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
    */
90 90
   public function offsetSet($offset, $value) {
91 91
     if (isset($this->mapUnitIdToDb[$value->unitId])) {
92
-      classSupernova::$debug->error('UnitList::offsetSet: Unit with UnitId ' . $value->unitId . ' already exists');
92
+      classSupernova::$debug->error('UnitList::offsetSet: Unit with UnitId '.$value->unitId.' already exists');
93 93
     }
94 94
     $this->mapUnitIdToDb[$value->unitId] = $value;
95 95
     parent::offsetSet($offset, $value);
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 
203 203
   public function unitGetCount($unit_id) {
204 204
     if (empty($this->mapUnitIdToDb[$unit_id])) {
205
-      throw new Exception('Unit [' . $unit_id . '] is not exists in UnitList');
205
+      throw new Exception('Unit ['.$unit_id.'] is not exists in UnitList');
206 206
     }
207 207
 
208 208
     return $this->mapUnitIdToDb[$unit_id]->count;
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
      */
322 322
     $objFleet = $this->getLocatedAt();
323 323
     if (empty($objFleet)) {
324
-      throw new Exception('No fleet owner on UnitList::unitsRender() in ' . __FILE__ . '@' . __LINE__);
324
+      throw new Exception('No fleet owner on UnitList::unitsRender() in '.__FILE__.'@'.__LINE__);
325 325
     }
326 326
 
327 327
     $tplShips = array();
@@ -464,8 +464,8 @@  discard block
 block discarded – undo
464 464
 
465 465
   // TODO - DEBUG - REMOVE =============================================================================================
466 466
   public function _dump() {
467
-    print(__FILE__ . ':' . __LINE__ . "<br />");
468
-    print("Located at " . $this->getLocationDbId() . " type " . $this->getLocationType() . "<br />");
467
+    print(__FILE__.':'.__LINE__."<br />");
468
+    print("Located at ".$this->getLocationDbId()." type ".$this->getLocationType()."<br />");
469 469
 
470 470
     print('<table border="1">');
471 471
     print('<tr>');
@@ -521,11 +521,11 @@  discard block
 block discarded – undo
521 521
 
522 522
       print('<td>');
523 523
       $type = $unit->getType();
524
-      print("[{$type}] " . classLocale::$lang['tech'][$type]);
524
+      print("[{$type}] ".classLocale::$lang['tech'][$type]);
525 525
       print('</td>');
526 526
 
527 527
       print('<td>');
528
-      print("[{$unit->unitId}] " . classLocale::$lang['tech'][$unit->unitId]);
528
+      print("[{$unit->unitId}] ".classLocale::$lang['tech'][$unit->unitId]);
529 529
       print('</td>');
530 530
 
531 531
       print('<td>');
Please login to merge, or discard this patch.
includes/classes/RequestInfo.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -89,15 +89,15 @@  discard block
 block discarded – undo
89 89
     // Инфа об устройстве и браузере - общая для всех
90 90
     sn_db_transaction_start();
91 91
     $this->device_cypher = $_COOKIE[SN_COOKIE_D];
92
-    if($this->device_cypher) {
92
+    if ($this->device_cypher) {
93 93
       $cypher_safe = db_escape($this->device_cypher);
94 94
       $device_id = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true);
95
-      if(!empty($device_id['device_id'])) {
95
+      if (!empty($device_id['device_id'])) {
96 96
         $this->device_id = $device_id['device_id'];
97 97
       }
98 98
     }
99 99
 
100
-    if($this->device_id <= 0) {
100
+    if ($this->device_id <= 0) {
101 101
       do {
102 102
         $cypher_safe = db_escape($this->device_cypher = sys_random_string());
103 103
         $row = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true);
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
     $this->page_address_id = db_get_set_unique_id_value($this->page_address, 'url_id', 'security_url', 'url_string');
119 119
     sn_db_transaction_commit();
120 120
 
121
-    if($this->write_full_url) {
121
+    if ($this->write_full_url) {
122 122
       sn_db_transaction_start();
123 123
       $this->page_url = substr($_SERVER['REQUEST_URI'], strlen(SN_ROOT_RELATIVE));
124
-      if(strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) {
124
+      if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) {
125 125
         $this->page_url = '/simulator.php';
126 126
       }
127 127
       $this->page_url_id = db_get_set_unique_id_value($this->page_url, 'url_id', 'security_url', 'url_string');
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
    */
145 145
   public function db_security_entry_insert($user_id_unsafe) {
146 146
     // TODO $user_id = !empty(self::$user['id']) ? self::$user['id'] : 'NULL';
147
-    if(empty($user_id_unsafe)) {
147
+    if (empty($user_id_unsafe)) {
148 148
       // self::flog('Нет ИД пользователя');
149 149
       return true;
150 150
     }
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
     // self::flog('Вставляем запись системы безопасности');
155 155
     return doquery(
156 156
       "INSERT IGNORE INTO {{security_player_entry}} (`player_id`, `device_id`, `browser_id`, `user_ip`, `user_proxy`)
157
-        VALUES ({$user_id_safe}," . $this->device_id . "," . $this->browser_id . "," .
158
-      $this->ip_v4_int . ", '" . db_escape($this->ip_v4_proxy_chain) . "');"
157
+        VALUES ({$user_id_safe},".$this->device_id.",".$this->browser_id.",".
158
+      $this->ip_v4_int.", '".db_escape($this->ip_v4_proxy_chain)."');"
159 159
     );
160 160
   }
161 161
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
   public function db_counter_insert($user_id_unsafe) {
168 168
     global $sys_stop_log_hit;
169 169
 
170
-    if($sys_stop_log_hit || !classSupernova::$config->game_counter) {
170
+    if ($sys_stop_log_hit || !classSupernova::$config->game_counter) {
171 171
       return;
172 172
     }
173 173
 
@@ -177,14 +177,14 @@  discard block
 block discarded – undo
177 177
     classSupernova::$db->isWatching = true;
178 178
     doquery(
179 179
       "INSERT INTO {{counter}} SET
180
-        `visit_time` = '" . SN_TIME_SQL. "',
180
+        `visit_time` = '" . SN_TIME_SQL."',
181 181
         `user_id` = {$user_id_safe},
182 182
         `device_id` = {$this->device_id},
183 183
         `browser_id` = {$this->browser_id},
184 184
         `user_ip` = {$this->ip_v4_int},
185 185
         `user_proxy` = '{$proxy_safe}',
186
-        `page_url_id` = {$this->page_address_id}" .
187
-        ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '' ).
186
+        `page_url_id` = {$this->page_address_id}".
187
+        ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '').
188 188
       ";");
189 189
 
190 190
     classSupernova::$db->isWatching = false;
Please login to merge, or discard this patch.