Passed
Push — master ( bc874f...230097 )
by SuperNova.WS
04:01
created
includes/includes/coe_simulator_helpers.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
+/**
4
+ * @param string $type
5
+ */
3 6
 function sn_ube_simulator_encode_replay($combat, $type)
4 7
 {
5 8
   $strPacked = "{$type}!";
@@ -58,6 +61,9 @@  discard block
 block discarded – undo
58 61
 
59 62
 // ------------------------------------------------------------------------------------------------
60 63
 // Преобразовывает данные симулятора в данные для расчета боя
64
+/**
65
+ * @param boolean $attacker
66
+ */
61 67
 function sn_ube_simulator_fill_side(&$combat_data, $side_info, $attacker, $player_id = -1)
62 68
 {
63 69
   global $ube_convert_techs;
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -4,9 +4,9 @@  discard block
 block discarded – undo
4 4
 {
5 5
   $strPacked = "{$type}!";
6 6
 
7
-  foreach($combat as $fleetID => $fleetCompress)
7
+  foreach ($combat as $fleetID => $fleetCompress)
8 8
   {
9
-    foreach($fleetCompress as $key => $value)
9
+    foreach ($fleetCompress as $key => $value)
10 10
     {
11 11
       $value = intval($value);
12 12
       $strPacked .= "{$key},{$value};";
@@ -22,29 +22,29 @@  discard block
 block discarded – undo
22 22
   $fleet_id = 0;
23 23
 
24 24
   $arr_data_unpacked = explode('!', $str_data);
25
-  foreach($arr_data_unpacked as $data_piece)
25
+  foreach ($arr_data_unpacked as $data_piece)
26 26
   {
27
-    if(!$data_piece)
27
+    if (!$data_piece)
28 28
     {
29 29
       continue;
30 30
     }
31 31
 
32
-    if($data_piece == 'A' || $data_piece == 'D')
32
+    if ($data_piece == 'A' || $data_piece == 'D')
33 33
     {
34 34
       $fleet_type = $data_piece;
35 35
       continue;
36 36
     }
37 37
 
38 38
     $arr_unit_strings = explode(';', $data_piece);
39
-    foreach($arr_unit_strings as $str_unit_string)
39
+    foreach ($arr_unit_strings as $str_unit_string)
40 40
     {
41
-      if(!$str_unit_string)
41
+      if (!$str_unit_string)
42 42
       {
43 43
         continue;
44 44
       }
45 45
 
46 46
       $arr_unit_data = explode(',', $str_unit_string);
47
-      if($arr_unit_data[1])
47
+      if ($arr_unit_data[1])
48 48
       {
49 49
         $unpacked[$fleet_type][$fleet_id][$arr_unit_data[0]] = intval($arr_unit_data[1]);
50 50
       }
@@ -64,48 +64,48 @@  discard block
 block discarded – undo
64 64
 
65 65
   $player_id = $player_id == -1 ? count($combat_data[UBE_PLAYERS]) : $player_id;
66 66
 
67
-  foreach($side_info as $fleet_data)
67
+  foreach ($side_info as $fleet_data)
68 68
   {
69 69
     $combat_data[UBE_PLAYERS][$player_id][UBE_NAME] = $attacker ? 'Attacker' : 'Defender';
70 70
     $combat_data[UBE_PLAYERS][$player_id][UBE_ATTACKER] = $attacker;
71 71
 
72 72
     $combat_data[UBE_FLEETS][$player_id][UBE_OWNER] = $player_id;
73
-    foreach($fleet_data as $unit_id => $unit_count)
73
+    foreach ($fleet_data as $unit_id => $unit_count)
74 74
     {
75
-      if(!$unit_count)
75
+      if (!$unit_count)
76 76
       {
77 77
         continue;
78 78
       }
79 79
 
80 80
       $unit_type = get_unit_param($unit_id, P_UNIT_TYPE);
81 81
 
82
-      if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE)
82
+      if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE)
83 83
       {
84 84
         $combat_data[UBE_FLEETS][$player_id][UBE_COUNT][$unit_id] = $unit_count;
85 85
       }
86
-      elseif($unit_type == UNIT_RESOURCES)
86
+      elseif ($unit_type == UNIT_RESOURCES)
87 87
       {
88 88
         $combat_data[UBE_FLEETS][$player_id][UBE_RESOURCES][$unit_id] = $unit_count;
89 89
       }
90
-      elseif($unit_type == UNIT_TECHNOLOGIES)
90
+      elseif ($unit_type == UNIT_TECHNOLOGIES)
91 91
       {
92 92
         $combat_data[UBE_PLAYERS][$player_id][UBE_BONUSES][$ube_convert_techs[$unit_id]] += $unit_count * get_unit_param($unit_id, P_BONUS_VALUE) / 100;
93 93
       }
94
-      elseif($unit_type == UNIT_GOVERNORS)
94
+      elseif ($unit_type == UNIT_GOVERNORS)
95 95
       {
96
-        if($unit_id == MRC_FORTIFIER)
96
+        if ($unit_id == MRC_FORTIFIER)
97 97
         {
98
-          foreach($ube_convert_techs as $ube_id)
98
+          foreach ($ube_convert_techs as $ube_id)
99 99
           {
100 100
             $combat_data[UBE_FLEETS][$player_id][UBE_BONUSES][$ube_id] += $unit_count * get_unit_param($unit_id, P_BONUS_VALUE) / 100;
101 101
           }
102 102
         }
103 103
       }
104
-      elseif($unit_type == UNIT_MERCENARIES)
104
+      elseif ($unit_type == UNIT_MERCENARIES)
105 105
       {
106
-        if($unit_id == MRC_ADMIRAL)
106
+        if ($unit_id == MRC_ADMIRAL)
107 107
         {
108
-          foreach($ube_convert_techs as $ube_id)
108
+          foreach ($ube_convert_techs as $ube_id)
109 109
           {
110 110
             $combat_data[UBE_PLAYERS][$player_id][UBE_BONUSES][$ube_id] += $unit_count * get_unit_param($unit_id, P_BONUS_VALUE) / 100;
111 111
           }
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-function sn_ube_simulator_encode_replay($combat, $type)
4
-{
3
+function sn_ube_simulator_encode_replay($combat, $type) {
5 4
   $strPacked = "{$type}!";
6 5
 
7 6
   foreach($combat as $fleetID => $fleetCompress)
@@ -17,8 +16,7 @@  discard block
 block discarded – undo
17 16
   return $strPacked;
18 17
 }
19 18
 
20
-function sn_ube_simulator_decode_replay($str_data)
21
-{
19
+function sn_ube_simulator_decode_replay($str_data) {
22 20
   $fleet_id = 0;
23 21
 
24 22
   $arr_data_unpacked = explode('!', $str_data);
@@ -58,8 +56,7 @@  discard block
 block discarded – undo
58 56
 
59 57
 // ------------------------------------------------------------------------------------------------
60 58
 // Преобразовывает данные симулятора в данные для расчета боя
61
-function sn_ube_simulator_fill_side(&$combat_data, $side_info, $attacker, $player_id = -1)
62
-{
59
+function sn_ube_simulator_fill_side(&$combat_data, $side_info, $attacker, $player_id = -1) {
63 60
   global $ube_convert_techs;
64 61
 
65 62
   $player_id = $player_id == -1 ? count($combat_data[UBE_PLAYERS]) : $player_id;
@@ -82,16 +79,13 @@  discard block
 block discarded – undo
82 79
       if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE)
83 80
       {
84 81
         $combat_data[UBE_FLEETS][$player_id][UBE_COUNT][$unit_id] = $unit_count;
85
-      }
86
-      elseif($unit_type == UNIT_RESOURCES)
82
+      } elseif($unit_type == UNIT_RESOURCES)
87 83
       {
88 84
         $combat_data[UBE_FLEETS][$player_id][UBE_RESOURCES][$unit_id] = $unit_count;
89
-      }
90
-      elseif($unit_type == UNIT_TECHNOLOGIES)
85
+      } elseif($unit_type == UNIT_TECHNOLOGIES)
91 86
       {
92 87
         $combat_data[UBE_PLAYERS][$player_id][UBE_BONUSES][$ube_convert_techs[$unit_id]] += $unit_count * get_unit_param($unit_id, P_BONUS_VALUE) / 100;
93
-      }
94
-      elseif($unit_type == UNIT_GOVERNORS)
88
+      } elseif($unit_type == UNIT_GOVERNORS)
95 89
       {
96 90
         if($unit_id == MRC_FORTIFIER)
97 91
         {
@@ -100,8 +94,7 @@  discard block
 block discarded – undo
100 94
             $combat_data[UBE_FLEETS][$player_id][UBE_BONUSES][$ube_id] += $unit_count * get_unit_param($unit_id, P_BONUS_VALUE) / 100;
101 95
           }
102 96
         }
103
-      }
104
-      elseif($unit_type == UNIT_MERCENARIES)
97
+      } elseif($unit_type == UNIT_MERCENARIES)
105 98
       {
106 99
         if($unit_id == MRC_ADMIRAL)
107 100
         {
@@ -115,8 +108,7 @@  discard block
 block discarded – undo
115 108
   }
116 109
 }
117 110
 
118
-function sn_ube_simulator_fleet_converter($sym_attacker, $sym_defender)
119
-{
111
+function sn_ube_simulator_fleet_converter($sym_attacker, $sym_defender) {
120 112
   $combat_data = array(
121 113
     UBE_OPTIONS => array(
122 114
       UBE_SIMULATOR => sys_get_param_int('simulator'),
Please login to merge, or discard this patch.
includes/includes/flt_functions.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
+/**
4
+ * @return double
5
+ */
3 6
 function flt_fleet_speed($user, $fleet)
4 7
 {
5 8
   if (!is_array($fleet))
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@  discard block
 block discarded – undo
8 8
   }
9 9
 
10 10
   $speeds = array();
11
-  if(!empty($fleet))
11
+  if (!empty($fleet))
12 12
   {
13 13
     foreach ($fleet as $ship_id => $amount)
14 14
     {
15
-      if($amount && in_array($ship_id, sn_get_groups(array('fleet', 'missile'))))
15
+      if ($amount && in_array($ship_id, sn_get_groups(array('fleet', 'missile'))))
16 16
       {
17 17
         $single_ship_data = get_ship_data($ship_id, $user);
18 18
         $speeds[] = $single_ship_data['speed'];
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
 function flt_travel_distance($from, $to) {
27 27
   global $config;
28 28
 
29
-  if($from['galaxy'] != $to['galaxy'])
29
+  if ($from['galaxy'] != $to['galaxy'])
30 30
   {
31 31
     $distance = abs($from['galaxy'] - $to['galaxy']) * $config->uni_galaxy_distance;
32 32
   }
33
-  elseif($from['system'] != $to['system'])
33
+  elseif ($from['system'] != $to['system'])
34 34
   {
35 35
     $distance = abs($from['system'] - $to['system']) * 5 * 19 + 2700;
36 36
   }
37
-  elseif($from['planet'] != $to['planet'])
37
+  elseif ($from['planet'] != $to['planet'])
38 38
   {
39 39
     $distance = abs($from['planet'] - $to['planet']) * 5 + 1000;
40 40
   }
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 
66 66
   $game_fleet_speed = flt_server_flight_speed_multiplier();
67 67
   $fleet_speed = flt_fleet_speed($user_row, $fleet_array);
68
-  if(!empty($fleet_array) && $fleet_speed && $game_fleet_speed)
68
+  if (!empty($fleet_array) && $fleet_speed && $game_fleet_speed)
69 69
   {
70 70
     $speed_percent = $speed_percent ? max(min($speed_percent, 10), 1) : 10;
71 71
     $real_speed = $speed_percent * sqrt($fleet_speed);
72 72
 
73 73
     $duration = max(1, round((35000 / $speed_percent * sqrt($distance * 10 / $fleet_speed) + 10) / $game_fleet_speed));
74 74
 
75
-    foreach($fleet_array as $ship_id => $ship_count)
75
+    foreach ($fleet_array as $ship_id => $ship_count)
76 76
     {
77 77
       if (!$ship_id || !$ship_count)
78 78
       {
@@ -126,19 +126,19 @@  discard block
 block discarded – undo
126 126
 
127 127
   $config_bashing_attacks = $config->fleet_bashing_attacks;
128 128
   $config_bashing_interval = $config->fleet_bashing_interval;
129
-  if(!$config_bashing_attacks) {
129
+  if (!$config_bashing_attacks) {
130 130
     // Bashing allowed - protection disabled
131 131
     return ATTACK_ALLOWED;
132 132
   }
133 133
 
134 134
   $bashing_result = ATTACK_BASHING;
135
-  if($user['ally_id'] && $enemy['ally_id']) {
135
+  if ($user['ally_id'] && $enemy['ally_id']) {
136 136
     $relations = ali_relations($user['ally_id'], $enemy['ally_id']);
137
-    if(!empty($relations)) {
137
+    if (!empty($relations)) {
138 138
       $relations = $relations[$enemy['ally_id']];
139
-      switch($relations['alliance_diplomacy_relation']) {
139
+      switch ($relations['alliance_diplomacy_relation']) {
140 140
         case ALLY_DIPLOMACY_WAR:
141
-          if(SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= $config->fleet_bashing_war_delay) {
141
+          if (SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= $config->fleet_bashing_war_delay) {
142 142
             $bashing_result = ATTACK_BASHING_WAR_DELAY;
143 143
           } else {
144 144
             return ATTACK_ALLOWED;
@@ -175,9 +175,9 @@  discard block
 block discarded – undo
175 175
 //    }
176 176
 //  }
177 177
   $bashing_fleet_list = fleet_list_bashing($user['id'], $planet_dst);
178
-  foreach($bashing_fleet_list as $fleet_row) {
178
+  foreach ($bashing_fleet_list as $fleet_row) {
179 179
     // Checking for ACS - each ACS count only once
180
-    if($fleet_row['fleet_group']) {
180
+    if ($fleet_row['fleet_group']) {
181 181
       $bashing_list["{$user['id']}_{$fleet_row['fleet_group']}"] = $fleet_row['fleet_start_time'];
182 182
     } else {
183 183
       $bashing_list[] = $fleet_row['fleet_start_time'];
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
   }
186 186
 
187 187
   // Check for joining to ACS - if there are already fleets in ACS no checks should be done
188
-  if($mission == MT_AKS && $bashing_list["{$user['id']}_{$fleet_group}"]) {
188
+  if ($mission == MT_AKS && $bashing_list["{$user['id']}_{$fleet_group}"]) {
189 189
     return ATTACK_ALLOWED;
190 190
   }
191 191
 
192 192
   $query = doquery("SELECT bashing_time FROM {{bashing}} WHERE bashing_user_id = {$user['id']} AND bashing_planet_id = {$planet_dst['id']} AND bashing_time >= {$time_limit};");
193
-  while($bashing_row = db_fetch($query)) {
193
+  while ($bashing_row = db_fetch($query)) {
194 194
     $bashing_list[] = $bashing_row['bashing_time'];
195 195
   }
196 196
 
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
   $last_attack = 0;
200 200
   $wave = 0;
201 201
   $attack = 1;
202
-  foreach($bashing_list as &$bash_time) {
202
+  foreach ($bashing_list as &$bash_time) {
203 203
     $attack++;
204
-    if($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) {
204
+    if ($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) {
205 205
       $attack = 1;
206 206
       $wave++;
207 207
     }
@@ -212,21 +212,21 @@  discard block
 block discarded – undo
212 212
   return ($wave > $config->fleet_bashing_waves ? $bashing_result : ATTACK_ALLOWED);
213 213
 }
214 214
 
215
-function flt_can_attack($planet_src, $planet_dst, $fleet = array(), $mission, $options = false){return sn_function_call('flt_can_attack', array($planet_src, $planet_dst, $fleet, $mission, $options, &$result));}
215
+function flt_can_attack($planet_src, $planet_dst, $fleet = array(), $mission, $options = false) {return sn_function_call('flt_can_attack', array($planet_src, $planet_dst, $fleet, $mission, $options, &$result)); }
216 216
 function sn_flt_can_attack($planet_src, $planet_dst, $fleet = array(), $mission, $options = false, &$result) {
217 217
   //TODO: try..catch
218 218
   global $config, $user;
219 219
 
220
-  if($user['vacation']) {
220
+  if ($user['vacation']) {
221 221
     return $result = ATTACK_OWN_VACATION;
222 222
   }
223 223
 
224
-  if(empty($fleet) || !is_array($fleet)) {
224
+  if (empty($fleet) || !is_array($fleet)) {
225 225
     return $result = ATTACK_NO_FLEET;
226 226
   }
227 227
 
228 228
   $sn_groups_mission = sn_get_groups('missions');
229
-  if(!isset($sn_groups_mission[$mission])) {
229
+  if (!isset($sn_groups_mission[$mission])) {
230 230
     return $result = ATTACK_MISSION_ABSENT;
231 231
   }
232 232
   $sn_data_mission = $sn_groups_mission[$mission];
@@ -245,32 +245,32 @@  discard block
 block discarded – undo
245 245
   $resources = 0;
246 246
   $ship_ids = sn_get_groups('fleet');
247 247
   $resource_ids = sn_get_groups('resources_loot');
248
-  foreach($fleet as $ship_id => $ship_count) {
248
+  foreach ($fleet as $ship_id => $ship_count) {
249 249
     $is_ship = in_array($ship_id, $ship_ids);
250 250
     $is_resource = in_array($ship_id, $resource_ids);
251
-    if(!$is_ship && !$is_resource) {
251
+    if (!$is_ship && !$is_resource) {
252 252
       // TODO Спецобработчик для Капитана и модулей
253 253
 //      return ATTACK_WRONG_UNIT;
254 254
     }
255 255
 
256
-    if($ship_count < 0) {
256
+    if ($ship_count < 0) {
257 257
       return $result = $is_ship ? ATTACK_SHIP_COUNT_WRONG : ATTACK_RESOURCE_COUNT_WRONG;
258 258
     }
259 259
 
260
-    if($ship_count > mrc_get_level($user, $planet_src, $ship_id)) {
260
+    if ($ship_count > mrc_get_level($user, $planet_src, $ship_id)) {
261 261
       // TODO ATTACK_NO_MISSILE
262 262
       return $result = $is_ship ? ATTACK_NO_SHIPS : ATTACK_NO_RESOURCES;
263 263
     }
264 264
 
265
-    if($is_ship) {
265
+    if ($is_ship) {
266 266
       $single_ship_data = get_ship_data($ship_id, $user);
267
-      if($single_ship_data[P_SPEED] <= 0) {
267
+      if ($single_ship_data[P_SPEED] <= 0) {
268 268
         return $result = ATTACK_ZERO_SPEED;
269 269
       }
270 270
       $ships += $ship_count;
271 271
       $recyclers += in_array($ship_id, sn_get_groups('flt_recyclers')) ? $ship_count : 0;
272 272
       $spies += $ship_id == SHIP_SPY ? $ship_count : 0;
273
-    } elseif($is_resource) {
273
+    } elseif ($is_resource) {
274 274
       $resources += $ship_count;
275 275
     }
276 276
   }
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
   }
282 282
 */
283 283
 
284
-  if(isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) {
284
+  if (isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) {
285 285
     return $result = ATTACK_RESOURCE_FORBIDDEN;
286 286
   }
287 287
 
@@ -293,35 +293,35 @@  discard block
 block discarded – undo
293 293
   */
294 294
 
295 295
   $speed = $options['fleet_speed_percent'];
296
-  if($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) {
296
+  if ($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) {
297 297
     return $result = ATTACK_WRONG_SPEED;
298 298
   }
299 299
 
300 300
   $travel_data = flt_travel_data($user, $planet_src, $planet_dst, $fleet, $options['fleet_speed_percent']);
301 301
 
302 302
 
303
-  if(mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) {
303
+  if (mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) {
304 304
     return $result = ATTACK_NO_FUEL;
305 305
   }
306 306
 
307
-  if($travel_data['consumption'] > $travel_data['capacity']) {
307
+  if ($travel_data['consumption'] > $travel_data['capacity']) {
308 308
     return $result = ATTACK_TOO_FAR;
309 309
   }
310 310
 
311
-  if($travel_data['hold'] < $resources) {
311
+  if ($travel_data['hold'] < $resources) {
312 312
     return $result = ATTACK_OVERLOADED;
313 313
   }
314 314
 
315 315
   $fleet_start_time = SN_TIME_NOW + $travel_data['duration'];
316 316
 
317 317
   $fleet_group = $options['fleet_group'];
318
-  if($fleet_group) {
319
-    if($mission != MT_AKS) {
318
+  if ($fleet_group) {
319
+    if ($mission != MT_AKS) {
320 320
       return $result = ATTACK_WRONG_MISSION;
321 321
     };
322 322
 
323 323
     $acs = doquery("SELECT * FROM {{aks}} WHERE id = '{$fleet_group}' LIMIT 1;", '', true);
324
-    if(!$acs['id']) {
324
+    if (!$acs['id']) {
325 325
       return $result = ATTACK_NO_ACS;
326 326
     }
327 327
 
@@ -329,70 +329,70 @@  discard block
 block discarded – undo
329 329
       return $result = ATTACK_ACS_WRONG_TARGET;
330 330
     }
331 331
 
332
-    if ($fleet_start_time>$acs['ankunft']) {
332
+    if ($fleet_start_time > $acs['ankunft']) {
333 333
       return $result = ATTACK_ACS_TOO_LATE;
334 334
     }
335 335
   }
336 336
 
337 337
   $flying_fleets = $options['flying_fleets'];
338
-  if(!$flying_fleets) {
338
+  if (!$flying_fleets) {
339 339
 //    $flying_fleets = doquery("SELECT COUNT(fleet_id) AS `flying_fleets` FROM {{fleets}} WHERE `fleet_owner` = '{$user['id']}';", '', true);
340 340
 //    $flying_fleets = $flying_fleets['flying_fleets'];
341 341
     $flying_fleets = fleet_count_flying($user['id']);
342 342
   }
343
-  if(GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) {
343
+  if (GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) {
344 344
     return $result = ATTACK_NO_SLOTS;
345 345
   }
346 346
 
347 347
   // В одиночку шпионские зонды могут летать только в миссии Шпионаж, Передислокация и Транспорт
348
-  if($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) {
348
+  if ($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) {
349 349
     return $result = ATTACK_SPIES_LONLY;
350 350
   }
351 351
 
352 352
   // Checking for no planet
353
-  if(!$planet_dst['id_owner']) {
354
-    if($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) {
353
+  if (!$planet_dst['id_owner']) {
354
+    if ($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) {
355 355
       return $result = ATTACK_NO_COLONIZER;
356 356
     }
357 357
 
358
-    if($mission == MT_EXPLORE || $mission == MT_COLONIZE) {
358
+    if ($mission == MT_EXPLORE || $mission == MT_COLONIZE) {
359 359
       return $result = ATTACK_ALLOWED;
360 360
     }
361 361
     return $result = ATTACK_NO_TARGET;
362 362
   }
363 363
 
364
-  if($mission == MT_RECYCLE) {
365
-    if($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) {
364
+  if ($mission == MT_RECYCLE) {
365
+    if ($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) {
366 366
       return $result = ATTACK_NO_DEBRIS;
367 367
     }
368
-    if($recyclers <= 0) {
368
+    if ($recyclers <= 0) {
369 369
       return $result = ATTACK_NO_RECYCLERS;
370 370
     }
371 371
     return $result = ATTACK_ALLOWED;
372 372
   }
373 373
 
374 374
   // Got planet. Checking if it is ours
375
-  if($planet_dst['id_owner'] == $user['id']) {
376
-    if($mission == MT_TRANSPORT || $mission == MT_RELOCATE) {
375
+  if ($planet_dst['id_owner'] == $user['id']) {
376
+    if ($mission == MT_TRANSPORT || $mission == MT_RELOCATE) {
377 377
       return $result = ATTACK_ALLOWED;
378 378
     }
379 379
     return $planet_src['id'] == $planet_dst['id'] ? ATTACK_SAME : ATTACK_OWN;
380 380
   }
381 381
 
382 382
   // No, planet not ours. Cutting mission that can't be send to not-ours planet
383
-  if($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) {
383
+  if ($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) {
384 384
     return $result = ATTACK_WRONG_MISSION;
385 385
   }
386 386
 
387 387
   $enemy = db_user_by_id($planet_dst['id_owner']);
388 388
   // We cannot attack or send resource to users in VACATION mode
389
-  if($enemy['vacation'] && $mission != MT_RECYCLE) {
389
+  if ($enemy['vacation'] && $mission != MT_RECYCLE) {
390 390
     return $result = ATTACK_VACATION;
391 391
   }
392 392
 
393 393
   // Multi IP protection
394 394
   // TODO: Here we need a procedure to check proxies
395
-  if(sys_is_multiaccount($user, $enemy)) {
395
+  if (sys_is_multiaccount($user, $enemy)) {
396 396
     return $result = ATTACK_SAME_IP;
397 397
   }
398 398
 
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
   $enemy_points = $enemy['total_points'];
401 401
 
402 402
   // Is it transport? If yes - checking for buffing to prevent mega-alliance destroyer
403
-  if($mission == MT_TRANSPORT) {
404
-    if($user_points >= $enemy_points || $config->allow_buffing) {
403
+  if ($mission == MT_TRANSPORT) {
404
+    if ($user_points >= $enemy_points || $config->allow_buffing) {
405 405
       return $result = ATTACK_ALLOWED;
406 406
     } else {
407 407
       return $result = ATTACK_BUFFING;
@@ -411,65 +411,65 @@  discard block
 block discarded – undo
411 411
   // Only aggresive missions passed to this point. HOLD counts as passive but aggresive
412 412
 
413 413
   // Is it admin with planet protection?
414
-  if($planet_dst['id_level'] > $user['authlevel']) {
414
+  if ($planet_dst['id_level'] > $user['authlevel']) {
415 415
     return $result = ATTACK_ADMIN;
416 416
   }
417 417
 
418 418
   // Okay. Now skipping protection checks for inactive longer then 1 week
419
-  if(!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60*60*24*7)) {
420
-    if(
419
+  if (!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) {
420
+    if (
421 421
       ($enemy_points <= $config->game_noob_points && $user_points > $config->game_noob_points)
422 422
       ||
423 423
       ($config->game_noob_factor && $user_points > $enemy_points * $config->game_noob_factor)
424 424
     ) {
425
-      if($mission != MT_HOLD) {
425
+      if ($mission != MT_HOLD) {
426 426
         return $result = ATTACK_NOOB;
427 427
       }
428
-      if($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && $config->ally_help_weak)) {
428
+      if ($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && $config->ally_help_weak)) {
429 429
         return $result = ATTACK_NOOB;
430 430
       }
431 431
     }
432 432
   }
433 433
 
434 434
   // Is it HOLD mission? If yes - there should be ally deposit
435
-  if($mission == MT_HOLD) {
436
-    if(mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) {
435
+  if ($mission == MT_HOLD) {
436
+    if (mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) {
437 437
       return $result = ATTACK_ALLOWED;
438 438
     }
439 439
     return $result = ATTACK_NO_ALLY_DEPOSIT;
440 440
   }
441 441
 
442
-  if($mission == MT_SPY) {
442
+  if ($mission == MT_SPY) {
443 443
     return $result = $spies >= 1 ? ATTACK_ALLOWED : ATTACK_NO_SPIES;
444 444
   }
445 445
 
446 446
   // Is it MISSILE mission?
447
-  if($mission == MT_MISSILE) {
447
+  if ($mission == MT_MISSILE) {
448 448
     $sn_data_mip = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET);
449
-    if(mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) {
449
+    if (mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) {
450 450
       return $result = ATTACK_NO_SILO;
451 451
     }
452 452
 
453
-    if(!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) {
453
+    if (!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) {
454 454
       return $result = ATTACK_NO_MISSILE;
455 455
     }
456 456
 
457 457
     $distance = abs($planet_dst['system'] - $planet_src['system']);
458 458
     $mip_range = flt_get_missile_range($user);
459
-    if($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) {
459
+    if ($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) {
460 460
       return $result = ATTACK_MISSILE_TOO_FAR;
461 461
     }
462 462
 
463
-    if(isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) {
463
+    if (isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) {
464 464
       return $result = ATTACK_WRONG_STRUCTURE;
465 465
     }
466 466
   }
467 467
 
468
-  if($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) {
468
+  if ($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) {
469 469
     return $result = ATTACK_WRONG_MISSION;
470 470
   }
471 471
 
472
-  if($mission == MT_ATTACK || $mission == MT_AKS || $mission == MT_DESTROY) {
472
+  if ($mission == MT_ATTACK || $mission == MT_AKS || $mission == MT_DESTROY) {
473 473
     return $result = flt_bashing_check($user, $enemy, $planet_dst, $mission, $travel_data['duration'], $fleet_group);
474 474
   }
475 475
 
@@ -495,18 +495,18 @@  discard block
 block discarded – undo
495 495
   $from = $from['planet'];
496 496
 
497 497
   $can_attack = flt_can_attack($from, $to, $fleet, $mission, $options);
498
-  if($can_attack != ATTACK_ALLOWED) {
498
+  if ($can_attack != ATTACK_ALLOWED) {
499 499
     $internal_transaction ? sn_db_transaction_rollback() : false;
500 500
     return $can_attack;
501 501
   }
502 502
 
503 503
   $fleet_group = isset($options['fleet_group']) ? floatval($options['fleet_group']) : 0;
504 504
 
505
-  $travel_data  = flt_travel_data($user, $from, $to, $fleet, $options['fleet_speed_percent']);
505
+  $travel_data = flt_travel_data($user, $from, $to, $fleet, $options['fleet_speed_percent']);
506 506
 
507 507
   $fleet_start_time = SN_TIME_NOW + $travel_data['duration'];
508 508
 
509
-  if($mission == MT_EXPLORE || $mission == MT_HOLD) {
509
+  if ($mission == MT_EXPLORE || $mission == MT_HOLD) {
510 510
     $stay_duration = $options['stay_time'] * 3600;
511 511
     $stay_time     = $fleet_start_time + $stay_duration;
512 512
   } else {
@@ -519,20 +519,20 @@  discard block
 block discarded – undo
519 519
   $fleet_string      = '';
520 520
   $db_changeset = array();
521 521
   $planet_fields = array();
522
-  foreach($fleet as $unit_id => $amount)
522
+  foreach ($fleet as $unit_id => $amount)
523 523
   {
524
-    if(!$amount || !$unit_id)
524
+    if (!$amount || !$unit_id)
525 525
     {
526 526
       continue;
527 527
     }
528 528
 
529
-    if(in_array($unit_id, sn_get_groups('fleet')))
529
+    if (in_array($unit_id, sn_get_groups('fleet')))
530 530
     {
531 531
       $fleet_ship_count += $amount;
532 532
       $fleet_string     .= "{$unit_id},{$amount};";
533 533
       $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, -$amount, $user, $from['id']);
534 534
     }
535
-    elseif(in_array($unit_id, sn_get_groups('resources_loot')))
535
+    elseif (in_array($unit_id, sn_get_groups('resources_loot')))
536 536
     {
537 537
       $planet_fields[pname_resource_name($unit_id)]['delta'] -= $amount;
538 538
     }
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 
641 641
   $ship_data = array();
642 642
   $fleet_array = array();
643
-  foreach($ship_list as $transport_id => $cork)
643
+  foreach ($ship_list as $transport_id => $cork)
644 644
   {
645 645
     $ship_data[$transport_id] = flt_travel_data($user, $from, $to, array($transport_id => 1), 10);
646 646
   }
@@ -649,10 +649,10 @@  discard block
 block discarded – undo
649 649
   $fleet_hold = 0;
650 650
   $fleet_capacity = 0;
651 651
   $fuel_total = $fuel_left = mrc_get_level($user, $from, RES_DEUTERIUM);
652
-  foreach($ship_data as $transport_id => &$ship_info)
652
+  foreach ($ship_data as $transport_id => &$ship_info)
653 653
   {
654 654
     $ship_loaded = min($ship_list[$transport_id], ceil($resource_amount / $ship_info['hold']), floor($fuel_left / $ship_info['consumption']));
655
-    if($ship_loaded)
655
+    if ($ship_loaded)
656 656
     {
657 657
       $fleet_array[$transport_id] = $ship_loaded;
658 658
       $resource_amount -= min($resource_amount, $ship_info['hold'] * $ship_loaded);
Please login to merge, or discard this 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'][] = sn_db_unit_changeset_prepare($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.
includes/includes/flt_mission_spy.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -29,6 +29,9 @@
 block discarded – undo
29 29
   }
30 30
 }
31 31
 
32
+/**
33
+ * @param string $group_name
34
+ */
32 35
 function flt_spy_scan($target_planet, $group_name, $section_title, $target_user = array())
33 36
 {
34 37
   global $lang;
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
 // ----------------------------------------------------------------------------------------------------------------
13 13
 function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array())
14 14
 {
15
-  foreach($unit_group as $unit_id)
15
+  foreach ($unit_group as $unit_id)
16 16
   {
17
-    if(($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0)
17
+    if (($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0)
18 18
     {
19 19
       $compress_data[$unit_id] = $unit_count;
20 20
     }
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
   global $lang;
35 35
 
36 36
   $result = "<tr><td class=\"c\" colspan=\"4\">{$section_title}</td></tr>";
37
-  foreach(sn_get_groups($group_name) as $unit_id)
37
+  foreach (sn_get_groups($group_name) as $unit_id)
38 38
   {
39
-    if(($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0)
39
+    if (($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0)
40 40
     {
41 41
       $result .= "<tr><td align=\"left\" colspan=\"3\">{$lang['tech'][$unit_id]}</td><td align=\"right\">{$unit_amount}</td></tr>";
42 42
     }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
   $spying_user_row   = &$mission_data['src_user'];
64 64
   $spying_planet_row = &$mission_data['src_planet'];
65 65
 
66
-  if(!isset($target_user_row['id']) || !isset($target_planet_row['id']) || !isset($spying_user_row['id']))
66
+  if (!isset($target_user_row['id']) || !isset($target_planet_row['id']) || !isset($spying_user_row['id']))
67 67
   {
68 68
 //    doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;");
69 69
     fleet_send_back($fleet_row);
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
   }
72 72
 
73 73
   $fleet_array = sys_unit_str2arr($fleet_row['fleet_array']);
74
-  if($fleet_array[SHIP_SPY] > 0)
74
+  if ($fleet_array[SHIP_SPY] > 0)
75 75
   {
76 76
     $TargetSpyLvl      = GetSpyLevel($target_user_row);
77 77
     $CurrentSpyLvl     = GetSpyLevel($spying_user_row);
78 78
     $spy_diff_empire = $CurrentSpyLvl - $TargetSpyLvl;
79 79
 
80 80
     $spy_probes = $fleet_array[SHIP_SPY];
81
-    $spy_diff   = $spy_diff_empire + sqrt($spy_probes) - 1 ;
81
+    $spy_diff   = $spy_diff_empire + sqrt($spy_probes) - 1;
82 82
 
83 83
     $combat_pack[0] = array(
84 84
       RES_METAL => $target_planet_row['metal'],
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     $spy_message .= "<td width=220>{$lang['sys_metal']}</td><td width=220 align=right>" . pretty_number($target_planet_row['metal']) . "</td>";
95 95
     $spy_message .= "<td width=220>{$lang['sys_crystal']}</td></td><td width=220 align=right>" . pretty_number($target_planet_row['crystal']) . "</td>";
96 96
     $spy_message .= "</tr><tr>";
97
-    $spy_message .= "<td width=220>{$lang['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium'])  . "</td>";
97
+    $spy_message .= "<td width=220>{$lang['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium']) . "</td>";
98 98
     $spy_message .= "<td width=220>{$lang['sys_energy']}</td><td width=220 align=right>" . pretty_number($target_planet_row['energy_max']) . "</td>";
99 99
     $spy_message .= "</tr>";
100 100
     if ($spy_diff >= 2)
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
       $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'structures', $lang['tech'][UNIT_STRUCTURES], $target_user_row) . "</div>";
112 112
     }
113 113
 
114
-    if($spy_diff_empire >= 0)
114
+    if ($spy_diff_empire >= 0)
115 115
     {
116 116
       $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'tech', $lang['tech'][UNIT_TECHNOLOGIES], $target_user_row) . "</div>";
117 117
       coe_compress_add_units(array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR), $target_planet_row, $combat_pack[0], $target_user_row);
@@ -121,14 +121,14 @@  discard block
 block discarded – undo
121 121
     $simulator_link = sn_ube_simulator_encode_replay($combat_pack, 'D');
122 122
 
123 123
     $target_unit_list = 0;
124
-    foreach(sn_get_groups('fleet') as $unit_id)
124
+    foreach (sn_get_groups('fleet') as $unit_id)
125 125
     {
126 126
       $target_unit_list += max(0, mrc_get_level($target_user_row, $target_planet_row, $unit_id, false, true));
127 127
     }
128 128
 
129 129
     $spy_detected = $spy_probes * $target_unit_list / 4 * pow(2, $TargetSpyLvl - $CurrentSpyLvl);
130 130
 
131
-    if(mt_rand(0, 99) > $spy_detected)
131
+    if (mt_rand(0, 99) > $spy_detected)
132 132
     {
133 133
       $spy_outcome_str = sprintf($lang['sys_mess_spy_detect_chance'], $spy_detected);
134 134
       $spy_detected = false;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 
154 154
     $target_user_id = $fleet_row['fleet_target_owner'];
155 155
 
156
-    if($spy_detected)
156
+    if ($spy_detected)
157 157
     {
158 158
 //      doquery("DELETE FROM {{fleets}} WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;");
159 159
       db_fleet_delete($fleet_row['fleet_id']);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
       $spy_cost = get_unit_param(SHIP_SPY, P_COST);
164 164
 
165 165
       DBStaticPlanet::db_planet_set_by_id($debris_planet_id,
166
-        "`debris_metal` = `debris_metal` + ". floor($spy_probes * $spy_cost[RES_METAL] * 0.3) .", `debris_crystal` = `debris_crystal` + ". floor($spy_probes * $spy_cost[RES_CRYSTAL] * 0.3));
166
+        "`debris_metal` = `debris_metal` + " . floor($spy_probes * $spy_cost[RES_METAL] * 0.3) . ", `debris_crystal` = `debris_crystal` + " . floor($spy_probes * $spy_cost[RES_CRYSTAL] * 0.3));
167 167
 
168 168
       $target_message .= "<br />{$lang['sys_mess_spy_destroyed_enemy']}";
169 169
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     msg_send_simple_message($target_user_id, '', $fleet_row['fleet_start_time'], MSG_TYPE_SPY, $lang['sys_mess_spy_control'], $lang['sys_mess_spy_activity'], $target_message);
177 177
   }
178 178
 
179
-  if(!$spy_detected)
179
+  if (!$spy_detected)
180 180
   {
181 181
 //    doquery("UPDATE {{fleets}} SET `fleet_mess` = '1' WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;");
182 182
     fleet_send_back($fleet_row);
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,8 +10,7 @@  discard block
 block discarded – undo
10 10
  * @copyright 2008
11 11
  */
12 12
 // ----------------------------------------------------------------------------------------------------------------
13
-function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array())
14
-{
13
+function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array()) {
15 14
   foreach($unit_group as $unit_id)
16 15
   {
17 16
     if(($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0)
@@ -29,8 +28,7 @@  discard block
 block discarded – undo
29 28
   }
30 29
 }
31 30
 
32
-function flt_spy_scan($target_planet, $group_name, $section_title, $target_user = array())
33
-{
31
+function flt_spy_scan($target_planet, $group_name, $section_title, $target_user = array()) {
34 32
   global $lang;
35 33
 
36 34
   $result = "<tr><td class=\"c\" colspan=\"4\">{$section_title}</td></tr>";
@@ -53,8 +51,7 @@  discard block
 block discarded – undo
53 51
   return $result;
54 52
 }
55 53
 
56
-function flt_mission_spy(&$mission_data)
57
-{
54
+function flt_mission_spy(&$mission_data) {
58 55
   global $lang;
59 56
 
60 57
   $fleet_row         = &$mission_data['fleet'];
@@ -132,8 +129,7 @@  discard block
 block discarded – undo
132 129
     {
133 130
       $spy_outcome_str = sprintf($lang['sys_mess_spy_detect_chance'], $spy_detected);
134 131
       $spy_detected = false;
135
-    }
136
-    else
132
+    } else
137 133
     {
138 134
       $spy_outcome_str = $lang['sys_mess_spy_destroyed'];
139 135
       $spy_detected = true;
@@ -168,8 +164,7 @@  discard block
 block discarded – undo
168 164
       $target_message .= "<br />{$lang['sys_mess_spy_destroyed_enemy']}";
169 165
 
170 166
       $result = CACHE_FLEET | CACHE_PLANET_DST;
171
-    }
172
-    else
167
+    } else
173 168
     {
174 169
       $result = CACHE_FLEET;
175 170
     }
Please login to merge, or discard this patch.
includes/includes/mrc_mercenary.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -26,6 +26,10 @@
 block discarded – undo
26 26
   return true;
27 27
 }
28 28
 
29
+/**
30
+ * @param integer $mode
31
+ * @param integer $mercenary_id
32
+ */
29 33
 function mrc_mercenary_hire($mode, $user, $mercenary_id) {
30 34
   global $config, $lang, $sn_powerup_buy_discounts;
31 35
 
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,8 +62,8 @@
 block discarded – undo
62 62
     if($mercenary_level) {
63 63
       $darkmater_cost = eco_get_total_cost($mercenary_id, $mercenary_level);
64 64
       if(!$config->empire_mercenary_temporary && $mercenary_level_old) {
65
-       $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old);
66
-       $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER];
65
+        $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old);
66
+        $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER];
67 67
       }
68 68
       $darkmater_cost = ceil($darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] * $mercenary_period * $sn_powerup_buy_discounts[$mercenary_period] / $config->empire_mercenary_base_period);
69 69
     } else {
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@  discard block
 block discarded – undo
7 7
   global $config;
8 8
 
9 9
   $mercenary_info = get_unit_param($mercenary_id);
10
-  if($config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS)
10
+  if ($config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS)
11 11
   {
12 12
     return true;
13 13
   }
14 14
 
15
-  if(isset($mercenary_info[P_REQUIRE]))
15
+  if (isset($mercenary_info[P_REQUIRE]))
16 16
   {
17
-    foreach($mercenary_info[P_REQUIRE] as $unit_id => $unit_level)
17
+    foreach ($mercenary_info[P_REQUIRE] as $unit_id => $unit_level)
18 18
     {
19
-      if(mrc_get_level($user, null, $unit_id) < $unit_level)
19
+      if (mrc_get_level($user, null, $unit_id) < $unit_level)
20 20
       {
21 21
         return false;
22 22
       }
@@ -33,35 +33,35 @@  discard block
 block discarded – undo
33 33
     $is_permanent = $mode == UNIT_PLANS || !$config->empire_mercenary_temporary;
34 34
     $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? $config->ali_bonus_members : 1);
35 35
     $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1;
36
-    if(!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) {
36
+    if (!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) {
37 37
       throw new Exception($lang['mrc_msg_error_wrong_mercenary'], ERR_ERROR);
38 38
     }
39 39
 
40
-    if(!mrc_officer_accessible($user, $mercenary_id)) {
40
+    if (!mrc_officer_accessible($user, $mercenary_id)) {
41 41
       throw new Exception($lang['mrc_msg_error_requirements'], ERR_ERROR);
42 42
     }
43 43
 
44 44
     $mercenary_level = sys_get_param_int('mercenary_level');
45
-    if($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) {
45
+    if ($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) {
46 46
       throw new Exception($lang['mrc_msg_error_wrong_level'], ERR_ERROR);
47 47
     }
48 48
 
49
-    if($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) {
49
+    if ($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) {
50 50
       throw new Exception($lang['mrc_msg_error_wrong_period'], ERR_ERROR);
51 51
     }
52 52
 
53 53
     sn_db_transaction_start();
54 54
 
55 55
     $mercenary_level_old = mrc_get_level($user, $planetrow, $mercenary_id, true, true);
56
-    if($config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) {
56
+    if ($config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) {
57 57
       throw new Exception($lang['mrc_msg_error_already_hired'], ERR_ERROR); // Can't hire already hired temp mercenary - dismiss first
58
-    } elseif($config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) {
58
+    } elseif ($config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) {
59 59
       throw new Exception('', ERR_NONE); // Can't dismiss (!$mercenary_level) not hired (!$mercenary_level_old) temp mercenary. But no error
60 60
     }
61 61
 
62
-    if($mercenary_level) {
62
+    if ($mercenary_level) {
63 63
       $darkmater_cost = eco_get_total_cost($mercenary_id, $mercenary_level);
64
-      if(!$config->empire_mercenary_temporary && $mercenary_level_old) {
64
+      if (!$config->empire_mercenary_temporary && $mercenary_level_old) {
65 65
        $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old);
66 66
        $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER];
67 67
       }
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
     }
72 72
     $darkmater_cost *= $cost_alliance_multiplyer;
73 73
 
74
-    if(mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) {
74
+    if (mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) {
75 75
       throw new Exception($lang['mrc_msg_error_no_resource'], ERR_ERROR);
76 76
     }
77 77
 
78
-    if(($darkmater_cost && $mercenary_level) || !$is_permanent) {
78
+    if (($darkmater_cost && $mercenary_level) || !$is_permanent) {
79 79
       $unit_row = DBStaticUnit::db_unit_by_location($user['id'], LOC_USER, $user['id'], $mercenary_id);
80
-      if(is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) {
80
+      if (is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) {
81 81
         $dismiss_full_cost = eco_get_total_cost($mercenary_id, $unit_row['unit_level']);
82 82
         $dismiss_full_cost = $dismiss_full_cost[BUILD_CREATE][RES_DARK_MATTER];
83 83
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
       DBStaticUnit::db_unit_list_delete($user['id'], LOC_USER, $user['id'], $mercenary_id);
96 96
     }
97 97
 
98
-    if($darkmater_cost && $mercenary_level) {
98
+    if ($darkmater_cost && $mercenary_level) {
99 99
       DBStaticUnit::db_unit_set_insert(
100 100
         "unit_player_id = {$user['id']},
101 101
         unit_location_type = " . LOC_USER . ",
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
   $mode = in_array($mode, array(UNIT_MERCENARIES, UNIT_PLANS)) ? $mode : UNIT_MERCENARIES;
131 131
   $is_permanent = $mode == UNIT_PLANS || !$config->empire_mercenary_temporary;
132 132
 
133
-  if($mercenary_id = sys_get_param_int('mercenary_id'))
133
+  if ($mercenary_id = sys_get_param_int('mercenary_id'))
134 134
   {
135 135
     $operation_result = mrc_mercenary_hire($mode, $user, $mercenary_id);
136 136
   }
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
 
140 140
   $template = gettemplate('mrc_mercenary_hire', true);
141 141
 
142
-  if(!empty($operation_result))
142
+  if (!empty($operation_result))
143 143
   {
144 144
     $template->assign_block_vars('result', $operation_result);
145 145
   }
146 146
 
147
-  foreach($sn_powerup_buy_discounts as $hire_period => $hire_discount)
147
+  foreach ($sn_powerup_buy_discounts as $hire_period => $hire_discount)
148 148
   {
149 149
     $template->assign_block_vars('period', array(
150 150
       'LENGTH'   => $hire_period,
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
   $user_dark_matter = mrc_get_level($user, '', RES_DARK_MATTER);
158 158
   $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? $config->ali_bonus_members : 1);
159 159
   $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1;
160
-  foreach(sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id)
160
+  foreach (sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id)
161 161
   {
162 162
     {
163 163
       $mercenary = get_unit_param($mercenary_id);
164 164
       $mercenary_bonus = $mercenary['bonus'];
165 165
       $mercenary_bonus = $mercenary_bonus >= 0 ? "+{$mercenary_bonus}" : "{$mercenary_bonus}";
166
-      switch($mercenary['bonus_type'])
166
+      switch ($mercenary['bonus_type'])
167 167
       {
168 168
         case BONUS_PERCENT:
169 169
           $mercenary_bonus = "{$mercenary_bonus}% ";
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
       $mercenary_level = mrc_get_level($user, null, $mercenary_id, false, true);
182 182
       $mercenary_level_bonus = max(0, mrc_get_level($user, null, $mercenary_id) - $mercenary_level);
183 183
       $total_cost_old = 0;
184
-      if($is_permanent)
184
+      if ($is_permanent)
185 185
       {
186 186
         $total_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level);
187 187
         $total_cost_old = $total_cost_old[BUILD_CREATE][RES_DARK_MATTER] * $cost_alliance_multiplyer;
@@ -205,13 +205,13 @@  discard block
 block discarded – undo
205 205
         'BONUS_TYPE'  => $mercenary['bonus_type'],
206 206
         'HIRE_END'    => $mercenary_time_finish && $mercenary_time_finish >= SN_TIME_NOW ? date(FMT_DATE_TIME, $mercenary_time_finish) : '',
207 207
         'HIRE_LEFT_PERCENT'    => $mercenary_time_finish && $mercenary_time_finish >= SN_TIME_NOW
208
-          ? round(($mercenary_time_finish - SN_TIME_NOW)/($mercenary_time_finish - $mercenary_time_start) * 100, 1)
208
+          ? round(($mercenary_time_finish - SN_TIME_NOW) / ($mercenary_time_finish - $mercenary_time_start) * 100, 1)
209 209
           : 0,
210 210
         'CAN_BUY'     => mrc_officer_accessible($user, $mercenary_id),
211 211
       ));
212 212
 
213 213
       $upgrade_cost = 1;
214
-      for($i = $config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++)
214
+      for ($i = $config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++)
215 215
       {
216 216
         $total_cost = eco_get_total_cost($mercenary_id, $i);
217 217
         $total_cost[BUILD_CREATE][RES_DARK_MATTER] *= $cost_alliance_multiplyer;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,7 @@
 block discarded – undo
2 2
 
3 3
 lng_include('mrc_mercenary');
4 4
 
5
-function mrc_officer_accessible(&$user, $mercenary_id)
6
-{
5
+function mrc_officer_accessible(&$user, $mercenary_id) {
7 6
   global $config;
8 7
 
9 8
   $mercenary_info = get_unit_param($mercenary_id);
Please login to merge, or discard this patch.
includes/includes/ube_attack_calculate.php 3 patches
Doc Comments   +15 added lines patch added patch discarded remove patch
@@ -108,6 +108,9 @@  discard block
 block discarded – undo
108 108
 
109 109
 // ------------------------------------------------------------------------------------------------
110 110
 // Заполняет данные по флоту
111
+/**
112
+ * @param boolean $is_attacker
113
+ */
111 114
 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 115
 function sn_ube_attack_prepare_fleet(&$combat_data, &$fleet, $is_attacker)
113 116
 {
@@ -331,6 +334,9 @@  discard block
 block discarded – undo
331 334
 
332 335
 // ------------------------------------------------------------------------------------------------
333 336
 // Вычисление дополнительной информации для расчета раунда
337
+/**
338
+ * @param integer $round
339
+ */
334 340
 function sn_ube_combat_round_prepare(&$combat_data, $round)
335 341
 {
336 342
   global $ube_combat_bonus_list;
@@ -393,6 +399,9 @@  discard block
 block discarded – undo
393 399
 
394 400
 // ------------------------------------------------------------------------------------------------
395 401
 // Рассчитывает результат столкновения флотов ака раунд
402
+/**
403
+ * @param integer $round
404
+ */
396 405
 function sn_ube_combat_round_crossfire_fleet(&$combat_data, $round)
397 406
 {
398 407
   if(BE_DEBUG === true)
@@ -510,6 +519,9 @@  discard block
 block discarded – undo
510 519
   }
511 520
 }
512 521
 
522
+/**
523
+ * @param double $amplified_damage
524
+ */
513 525
 function sn_ube_combat_round_crossfire_unit_damage_current(&$defend_fleet_data, $defend_unit_id, &$amplified_damage, &$units_lost, &$units_boomed, &$combat_options)
514 526
 {
515 527
   $unit_is_lost = false;
@@ -632,6 +644,9 @@  discard block
 block discarded – undo
632 644
 
633 645
 // ------------------------------------------------------------------------------------------------
634 646
 // Анализирует результаты раунда и генерирует данные для следующего раунда
647
+/**
648
+ * @param integer $round
649
+ */
635 650
 function sn_ube_combat_round_analyze(&$combat_data, $round)
636 651
 {
637 652
   $round_data = &$combat_data[UBE_ROUNDS][$round];
Please login to merge, or discard this patch.
Spacing   +128 added lines, -129 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
 */
53 53
 
54
-if(BE_DEBUG === true)
54
+if (BE_DEBUG === true)
55 55
 {
56 56
   require_once('ube_zi_helpers.php');
57 57
 }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 {
84 84
   global $ube_convert_techs;
85 85
 
86
-  if(!isset($combat_data[UBE_PLAYERS][$player_id]))
86
+  if (!isset($combat_data[UBE_PLAYERS][$player_id]))
87 87
   {
88 88
     $combat_data[UBE_PLAYERS][$player_id] = array(UBE_ATTACKER => $is_attacker);
89 89
     $player_info = &$combat_data[UBE_PLAYERS][$player_id];
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     $player_info[UBE_PLAYER_DATA] = $player_data;
96 96
 
97 97
     $admiral_bonus = mrc_get_level($player_data, false, MRC_ADMIRAL) * get_unit_param(MRC_ADMIRAL, P_BONUS_VALUE) / 100;
98
-    foreach($ube_convert_techs as $unit_id => $ube_id)
98
+    foreach ($ube_convert_techs as $unit_id => $ube_id)
99 99
     {
100 100
       $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 101
     }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
 // ------------------------------------------------------------------------------------------------
110 110
 // Заполняет данные по флоту
111
-function ube_attack_prepare_fleet(&$combat_data, &$fleet, $is_attacker){return sn_function_call('ube_attack_prepare_fleet', array(&$combat_data, &$fleet, $is_attacker));}
111
+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 112
 function sn_ube_attack_prepare_fleet(&$combat_data, &$fleet, $is_attacker)
113 113
 {
114 114
   $fleet_owner_id = $fleet['fleet_owner'];
@@ -121,15 +121,15 @@  discard block
 block discarded – undo
121 121
   $combat_data[UBE_FLEETS][$fleet_id][UBE_OWNER] = $fleet_owner_id;
122 122
   $fleet_info = &$combat_data[UBE_FLEETS][$fleet_id];
123 123
   $fleet_info[UBE_FLEET_GROUP] = $fleet['fleet_group'];
124
-  foreach($fleet_data as $unit_id => $unit_count)
124
+  foreach ($fleet_data as $unit_id => $unit_count)
125 125
   {
126
-    if(!$unit_count)
126
+    if (!$unit_count)
127 127
     {
128 128
       continue;
129 129
     }
130 130
 
131 131
     $unit_type = get_unit_param($unit_id, P_UNIT_TYPE);
132
-    if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE)
132
+    if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE)
133 133
     {
134 134
       $fleet_info[UBE_COUNT][$unit_id] = $unit_count;
135 135
     }
@@ -169,23 +169,23 @@  discard block
 block discarded – undo
169 169
   $combat_data[UBE_FLEETS][0] = array(UBE_OWNER => $player_id);
170 170
   $fleet_info = &$combat_data[UBE_FLEETS][0];
171 171
 
172
-  foreach(sn_get_groups('combat') as $unit_id)
172
+  foreach (sn_get_groups('combat') as $unit_id)
173 173
   {
174
-    if($unit_count = mrc_get_level($player, $planet, $unit_id))
174
+    if ($unit_count = mrc_get_level($player, $planet, $unit_id))
175 175
     {
176 176
       $fleet_info[UBE_COUNT][$unit_id] = $unit_count;
177 177
     }
178 178
   }
179 179
 
180
-  foreach(sn_get_groups('resources_loot') as $resource_id)
180
+  foreach (sn_get_groups('resources_loot') as $resource_id)
181 181
   {
182 182
     $fleet_info[UBE_RESOURCES][$resource_id] = floor(mrc_get_level($player, $planet, $resource_id));
183 183
   }
184 184
 
185
-  if($fortifier_level = mrc_get_level($player, $planet, MRC_FORTIFIER))
185
+  if ($fortifier_level = mrc_get_level($player, $planet, MRC_FORTIFIER))
186 186
   {
187 187
     $fortifier_bonus = $fortifier_level * get_unit_param(MRC_FORTIFIER, P_BONUS_VALUE) / 100;
188
-    foreach($ube_combat_bonus_list as $ube_id)
188
+    foreach ($ube_combat_bonus_list as $ube_id)
189 189
     {
190 190
       $fleet_info[UBE_BONUSES][$ube_id] += $fortifier_bonus;
191 191
     }
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
     PLANET_SIZE   => $planet['diameter'],
202 202
   );
203 203
 
204
-  $combat_data[UBE_OPTIONS][UBE_DEFENDER_ACTIVE] = $player['onlinetime'] >= $combat_data[UBE_TIME] - 60*60*24*7;
204
+  $combat_data[UBE_OPTIONS][UBE_DEFENDER_ACTIVE] = $player['onlinetime'] >= $combat_data[UBE_TIME] - 60 * 60 * 24 * 7;
205 205
 }
206 206
 
207 207
 
@@ -241,12 +241,12 @@  discard block
 block discarded – undo
241 241
 //    ube_attack_prepare_fleet($combat_data, $fleet, false);
242 242
 //  }
243 243
   $fleet_list_on_hold = fleet_list_on_hold($fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet'], $fleet_row['fleet_end_type'], $ube_time);
244
-  foreach($fleet_list_on_hold as $fleet) {
244
+  foreach ($fleet_list_on_hold as $fleet) {
245 245
     ube_attack_prepare_fleet($combat_data, $fleet, false);
246 246
   }
247 247
 
248 248
   // Готовим инфу по атакующим
249
-  if($fleet_row['fleet_group'])
249
+  if ($fleet_row['fleet_group'])
250 250
   {
251 251
 //    $fleets = doquery("SELECT * FROM {{fleets}} WHERE fleet_group = {$fleet_row['fleet_group']} FOR UPDATE");
252 252
 //    while($fleet = db_fetch($fleets))
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 //      ube_attack_prepare_fleet($combat_data, $fleet, true);
255 255
 //    }
256 256
     $acs_fleet_list = fleet_list_by_group($fleet_row['fleet_group']);
257
-    foreach($acs_fleet_list as $fleet) {
257
+    foreach ($acs_fleet_list as $fleet) {
258 258
       ube_attack_prepare_fleet($combat_data, $fleet, true);
259 259
     }
260 260
   }
@@ -279,13 +279,13 @@  discard block
 block discarded – undo
279 279
 
280 280
   // Готовим информацию для первого раунда - проводим все нужные вычисления из исходных данных
281 281
   $first_round_data = array();
282
-  foreach($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info)
282
+  foreach ($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info)
283 283
   {
284 284
     $fleet_info[UBE_COUNT] = is_array($fleet_info[UBE_COUNT]) ? $fleet_info[UBE_COUNT] : array();
285 285
     $player_data = &$combat_data[UBE_PLAYERS][$fleet_info[UBE_OWNER]];
286 286
     $fleet_info[UBE_FLEET_TYPE] = $player_data[UBE_ATTACKER] ? UBE_ATTACKERS : UBE_DEFENDERS;
287 287
 
288
-    foreach($ube_combat_bonus_list as $bonus_id => $bonus_value)
288
+    foreach ($ube_combat_bonus_list as $bonus_id => $bonus_value)
289 289
     {
290 290
       // Вычисляем бонус игрока
291 291
       $bonus_value = isset($player_data[UBE_BONUSES][$bonus_id]) ? $player_data[UBE_BONUSES][$bonus_id] : 0;
@@ -294,16 +294,16 @@  discard block
 block discarded – undo
294 294
     }
295 295
 
296 296
     $first_round_data[$fleet_id][UBE_COUNT] = $fleet_info[UBE_PRICE] = array();
297
-    foreach($fleet_info[UBE_COUNT] as $unit_id => $unit_count)
297
+    foreach ($fleet_info[UBE_COUNT] as $unit_id => $unit_count)
298 298
     {
299
-      if($unit_count <= 0)
299
+      if ($unit_count <= 0)
300 300
       {
301 301
         continue;
302 302
       }
303 303
 
304 304
       $unit_info = get_unit_param($unit_id);
305 305
       // Заполняем информацию о кораблях в информации флота
306
-      foreach($ube_combat_bonus_list as $bonus_id => $bonus_value)
306
+      foreach ($ube_combat_bonus_list as $bonus_id => $bonus_value)
307 307
       {
308 308
         $fleet_info[$bonus_id][$unit_id] = floor($unit_info[$ube_convert_to_techs[$bonus_id]] * (1 + $fleet_info[UBE_BONUSES][$bonus_id]));
309 309
       }
@@ -346,16 +346,16 @@  discard block
 block discarded – undo
346 346
   $is_simulator = $combat_data[UBE_OPTIONS][UBE_SIMULATOR];
347 347
 
348 348
   $round_data = &$combat_data[UBE_ROUNDS][$round];
349
-  foreach($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data)
349
+  foreach ($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data)
350 350
   {
351 351
     // Кэшируем переменные для легкого доступа к подмассивам
352 352
     $fleet_info = &$combat_data[UBE_FLEETS][$fleet_id];
353 353
     $fleet_data[UBE_FLEET_INFO] = &$fleet_info;
354 354
     $fleet_type = $fleet_info[UBE_FLEET_TYPE];
355 355
 
356
-    foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
356
+    foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
357 357
     {
358
-      if($unit_count <= 0)
358
+      if ($unit_count <= 0)
359 359
       {
360 360
         continue;
361 361
       }
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
       // Для не-симулятора - рандомизируем каждый раунд значения атаки и щитов
366 366
       $fleet_data[UBE_ATTACK_BASE][$unit_id] = floor($fleet_info[UBE_ATTACK][$unit_id] * ($is_simulator ? 1 : mt_rand(80, 120) / 100));
367 367
       $fleet_data[UBE_SHIELD_BASE][$unit_id] = floor($fleet_info[UBE_SHIELD][$unit_id] * ($is_simulator ? 1 : mt_rand(80, 120) / 100));
368
-      $fleet_data[UBE_ARMOR_BASE][$unit_id]  = floor($fleet_info[UBE_ARMOR][$unit_id]);// * ($is_simulator ? 1 : mt_rand(80, 120) / 100));
368
+      $fleet_data[UBE_ARMOR_BASE][$unit_id]  = floor($fleet_info[UBE_ARMOR][$unit_id]); // * ($is_simulator ? 1 : mt_rand(80, 120) / 100));
369 369
 
370 370
       $fleet_data[UBE_ATTACK][$unit_id] = $fleet_data[UBE_ATTACK_BASE][$unit_id] * $unit_count;
371 371
       $fleet_data[UBE_SHIELD][$unit_id] = $fleet_data[UBE_SHIELD_BASE][$unit_id] * $unit_count;
@@ -375,24 +375,24 @@  discard block
 block discarded – undo
375 375
     }
376 376
 
377 377
     // Суммируем данные по флоту
378
-    foreach($ube_combat_bonus_list as $bonus_id)
378
+    foreach ($ube_combat_bonus_list as $bonus_id)
379 379
     {
380 380
       $round_data[$fleet_type][$bonus_id][$fleet_id] += is_array($fleet_data[$bonus_id]) ? array_sum($fleet_data[$bonus_id]) : 0;
381 381
     }
382 382
   }
383 383
 
384 384
   // Суммируем данные по атакующим и защитникам
385
-  foreach($ube_combat_bonus_list as $bonus_id)
385
+  foreach ($ube_combat_bonus_list as $bonus_id)
386 386
   {
387 387
     $round_data[UBE_TOTAL][UBE_DEFENDERS][$bonus_id] = array_sum($round_data[UBE_DEFENDERS][$bonus_id]);
388 388
     $round_data[UBE_TOTAL][UBE_ATTACKERS][$bonus_id] = array_sum($round_data[UBE_ATTACKERS][$bonus_id]);
389 389
   }
390 390
 
391 391
   // Высчитываем долю атаки, приходящейся на юнит равную отношению брони юнита к общей броне - крупные цели атакуют чаще
392
-  foreach($round_data[UBE_FLEETS] as &$fleet_data)
392
+  foreach ($round_data[UBE_FLEETS] as &$fleet_data)
393 393
   {
394 394
     $fleet_type = $fleet_data[UBE_FLEET_INFO][UBE_FLEET_TYPE];
395
-    foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
395
+    foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
396 396
     {
397 397
       $fleet_data[UBE_DAMAGE_PERCENT][$unit_id] = $fleet_data[UBE_ARMOR][$unit_id] / $round_data[UBE_TOTAL][$fleet_type][UBE_ARMOR];
398 398
     }
@@ -403,24 +403,24 @@  discard block
 block discarded – undo
403 403
 // Рассчитывает результат столкновения флотов ака раунд
404 404
 function sn_ube_combat_round_crossfire_fleet(&$combat_data, $round)
405 405
 {
406
-  if(BE_DEBUG === true)
406
+  if (BE_DEBUG === true)
407 407
   {
408 408
     // sn_ube_combat_helper_round_header($round);
409 409
   }
410 410
 
411 411
   $round_data = &$combat_data[UBE_ROUNDS][$round];
412 412
   // Проводим бой. Сталкиваем каждый корабль атакующего с каждым кораблем атакуемого
413
-  foreach($round_data[UBE_ATTACKERS][UBE_ATTACK] as $attack_fleet_id => $temp)
413
+  foreach ($round_data[UBE_ATTACKERS][UBE_ATTACK] as $attack_fleet_id => $temp)
414 414
   {
415 415
     $attack_fleet_data = &$round_data[UBE_FLEETS][$attack_fleet_id];
416
-    foreach($round_data[UBE_DEFENDERS][UBE_ATTACK] as $defend_fleet_id => $temp2)
416
+    foreach ($round_data[UBE_DEFENDERS][UBE_ATTACK] as $defend_fleet_id => $temp2)
417 417
     {
418 418
       $defend_fleet_data = &$round_data[UBE_FLEETS][$defend_fleet_id];
419 419
 
420
-      foreach($attack_fleet_data[UBE_COUNT] as $attack_unit_id => $attack_unit_count)
420
+      foreach ($attack_fleet_data[UBE_COUNT] as $attack_unit_id => $attack_unit_count)
421 421
       {
422 422
         // if($attack_unit_count <= 0) continue; // TODO: Это пока нельзя включать - вот если будут "боевые порядки юнитов..."
423
-        foreach($defend_fleet_data[UBE_COUNT] as $defend_unit_id => $defend_unit_count)
423
+        foreach ($defend_fleet_data[UBE_COUNT] as $defend_unit_id => $defend_unit_count)
424 424
         {
425 425
           sn_ube_combat_round_crossfire_unit2($attack_fleet_data, $defend_fleet_data, $attack_unit_id, $defend_unit_id, $combat_data[UBE_OPTIONS]);
426 426
           sn_ube_combat_round_crossfire_unit2($defend_fleet_data, $attack_fleet_data, $defend_unit_id, $attack_unit_id, $combat_data[UBE_OPTIONS]);
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
     }
430 430
   }
431 431
 
432
-  if(BE_DEBUG === true)
432
+  if (BE_DEBUG === true)
433 433
   {
434 434
     // sn_ube_combat_helper_round_footer();
435 435
   }
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
   $boom = 0;
478 478
   $boom_limit = 75;
479 479
   $random = $combat_options[UBE_SIMULATOR] ? $boom_limit / 2 : mt_rand(0, 100);
480
-  if($armor_damage && $units_left > 0 && $last_unit_percent <= $boom_limit && $last_unit_percent <= $random)
480
+  if ($armor_damage && $units_left > 0 && $last_unit_percent <= $boom_limit && $last_unit_percent <= $random)
481 481
   {
482 482
     $boom = 1;
483 483
     $units_left--;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 
488 488
   $defend_fleet_data[UBE_COUNT][$defend_unit_id] = $units_left;
489 489
 
490
-  if(BE_DEBUG === true)
490
+  if (BE_DEBUG === true)
491 491
   {
492 492
     $debug_unit_crossfire_result = array(
493 493
       'attack_unit_id' => $attack_unit_id,
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
   $units_lost = $units_lost ? $units_lost : 0;
527 527
 
528 528
   $boom_limit = 75; // Взрываемся на 75% прочности
529
-  if($defend_fleet_data[UBE_COUNT][$defend_unit_id] > 0 && $amplified_damage)
529
+  if ($defend_fleet_data[UBE_COUNT][$defend_unit_id] > 0 && $amplified_damage)
530 530
   {
531 531
     // $defend_fleet_info = &$defend_fleet_data[UBE_FLEET_INFO];
532 532
 
@@ -539,18 +539,18 @@  discard block
 block discarded – undo
539 539
     $defend_fleet_data[UBE_ARMOR_REST][$defend_unit_id] -= $damage_to_armor;
540 540
 
541 541
     // Если брони не осталось - юнит потерян
542
-    if($defend_fleet_data[UBE_ARMOR_REST][$defend_unit_id] <= 0)
542
+    if ($defend_fleet_data[UBE_ARMOR_REST][$defend_unit_id] <= 0)
543 543
     {
544 544
       $unit_is_lost = true;
545 545
     }
546 546
     // Если броня осталось, но не осталось щитов - прошел дамадж по броне и надо проверить - не взорвался ли корабль
547
-    elseif($defend_fleet_data[UBE_SHIELD_REST][$defend_unit_id] <= 0)
547
+    elseif ($defend_fleet_data[UBE_SHIELD_REST][$defend_unit_id] <= 0)
548 548
     {
549 549
       $last_unit_hp = $defend_fleet_data[UBE_ARMOR_REST][$defend_unit_id];
550 550
       $last_unit_percent = $last_unit_hp / $defend_fleet_data[UBE_ARMOR_BASE][$defend_unit_id] * 100;
551 551
 
552 552
       $random = $combat_options[UBE_SIMULATOR] ? $boom_limit / 2 : mt_rand(0, 100);
553
-      if($last_unit_percent <= $boom_limit && $last_unit_percent <= $random)
553
+      if ($last_unit_percent <= $boom_limit && $last_unit_percent <= $random)
554 554
       {
555 555
         $unit_is_lost = true;
556 556
         $units_boomed++;
@@ -563,11 +563,11 @@  discard block
 block discarded – undo
563 563
     $defend_fleet_data[UBE_ARMOR][$defend_unit_id] -= $damage_to_armor;
564 564
     $defend_fleet_data[UBE_SHIELD][$defend_unit_id] -= $damage_to_shield;
565 565
 
566
-    if($unit_is_lost)
566
+    if ($unit_is_lost)
567 567
     {
568 568
       $units_lost++;
569 569
       $defend_fleet_data[UBE_COUNT][$defend_unit_id]--;
570
-      if($defend_fleet_data[UBE_COUNT][$defend_unit_id])
570
+      if ($defend_fleet_data[UBE_COUNT][$defend_unit_id])
571 571
       {
572 572
         $defend_fleet_data[UBE_ARMOR_REST][$defend_unit_id] = $defend_fleet_data[UBE_ARMOR_BASE][$defend_unit_id];
573 573
         $defend_fleet_data[UBE_SHIELD_REST][$defend_unit_id] = $defend_fleet_data[UBE_SHIELD_BASE][$defend_unit_id];
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 // Рассчитывает результат столкновения двух юнитов ака ход
583 583
 function sn_ube_combat_round_crossfire_unit2(&$attack_fleet_data, &$defend_fleet_data, $attack_unit_id, $defend_unit_id, &$combat_options)
584 584
 {
585
-  if($defend_fleet_data[UBE_COUNT][$defend_unit_id] <= 0)
585
+  if ($defend_fleet_data[UBE_COUNT][$defend_unit_id] <= 0)
586 586
   {
587 587
     return;
588 588
   }
@@ -625,16 +625,16 @@  discard block
 block discarded – undo
625 625
 
626 626
   $outcome = array();
627 627
   $next_round_fleet = array();
628
-  foreach($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data)
628
+  foreach ($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data)
629 629
   {
630
-    if(array_sum($fleet_data[UBE_COUNT]) <= 0)
630
+    if (array_sum($fleet_data[UBE_COUNT]) <= 0)
631 631
     {
632 632
       continue;
633 633
     }
634 634
 
635
-    foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
635
+    foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
636 636
     {
637
-      if($unit_count <= 0)
637
+      if ($unit_count <= 0)
638 638
       {
639 639
         continue;
640 640
       }
@@ -646,17 +646,17 @@  discard block
 block discarded – undo
646 646
   }
647 647
 
648 648
   // Проверяем - если кого-то не осталось или не осталось обоих - заканчиваем цикл
649
-  if(count($outcome) == 0 || $round == 10)
649
+  if (count($outcome) == 0 || $round == 10)
650 650
   {
651 651
     $round_data[UBE_OUTCOME] = UBE_COMBAT_RESULT_DRAW_END;
652 652
   }
653
-  elseif(count($outcome) == 1)
653
+  elseif (count($outcome) == 1)
654 654
   {
655 655
     $round_data[UBE_OUTCOME] = isset($outcome[UBE_ATTACKERS]) ? UBE_COMBAT_RESULT_WIN : UBE_COMBAT_RESULT_LOSS;
656 656
   }
657
-  elseif(count($outcome) == 2)
657
+  elseif (count($outcome) == 2)
658 658
   {
659
-    if($round < 10)
659
+    if ($round < 10)
660 660
     {
661 661
       $combat_data[UBE_ROUNDS][$round + 1][UBE_FLEETS] = $next_round_fleet;
662 662
     }
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
   $start = microtime(true);
675 675
   sn_ube_combat_prepare_first_round($combat_data);
676 676
 
677
-  for($round = 1; $round <= 10; $round++)
677
+  for ($round = 1; $round <= 10; $round++)
678 678
   {
679 679
     // Готовим данные для раунда
680 680
     sn_ube_combat_round_prepare($combat_data, $round);
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
     sn_ube_combat_round_crossfire_fleet($combat_data, $round);
684 684
 
685 685
     // Анализируем итоги текущего раунда и готовим данные для следующего
686
-    if(sn_ube_combat_round_analyze($combat_data, $round) != UBE_COMBAT_RESULT_DRAW)
686
+    if (sn_ube_combat_round_analyze($combat_data, $round) != UBE_COMBAT_RESULT_DRAW)
687 687
     {
688 688
       break;
689 689
     }
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
   $combat_data[UBE_OPTIONS][UBE_EXCHANGE] = array(RES_METAL => $config->rpg_exchange_metal);
705 705
 
706 706
   $exchange = &$combat_data[UBE_OPTIONS][UBE_EXCHANGE];
707
-  foreach(array(RES_CRYSTAL => 'rpg_exchange_crystal', RES_DEUTERIUM => 'rpg_exchange_deuterium', RES_DARK_MATTER => 'rpg_exchange_darkMatter') as $resource_id => $resource_name)
707
+  foreach (array(RES_CRYSTAL => 'rpg_exchange_crystal', RES_DEUTERIUM => 'rpg_exchange_deuterium', RES_DARK_MATTER => 'rpg_exchange_darkMatter') as $resource_id => $resource_name)
708 708
   {
709 709
     $exchange[$resource_id] = $config->$resource_name * $exchange[RES_METAL];
710 710
   }
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
   $outcome[UBE_DEBRIS] = array();
719 719
 
720 720
   // Генерируем результат боя
721
-  foreach($fleets_info as $fleet_id => &$fleet_info)
721
+  foreach ($fleets_info as $fleet_id => &$fleet_info)
722 722
   {
723 723
     $fleet_type = $fleet_info[UBE_FLEET_TYPE];
724 724
     // Инициализируем массив результатов для флота
@@ -729,32 +729,32 @@  discard block
 block discarded – undo
729 729
     $fleet_outcome = &$outcome[UBE_FLEETS][$fleet_id];
730 730
     $fleet_data = &$last_round_data[UBE_FLEETS][$fleet_id];
731 731
 
732
-    foreach($fleet_info[UBE_COUNT] as $unit_id => $unit_count)
732
+    foreach ($fleet_info[UBE_COUNT] as $unit_id => $unit_count)
733 733
     {
734 734
       // Вычисляем сколько юнитов осталось и сколько потеряно
735 735
       $units_left = $fleet_data[UBE_COUNT][$unit_id];
736 736
 
737 737
       // Восстановление обороны - 75% от уничтоженной
738
-      if($fleet_info[UBE_TYPE][$unit_id] == UNIT_DEFENCE)
738
+      if ($fleet_info[UBE_TYPE][$unit_id] == UNIT_DEFENCE)
739 739
       {
740 740
         $giveback_chance = 75; // TODO Configure
741 741
         $units_lost = $unit_count - $units_left;
742
-        if($combat_data[UBE_OPTIONS][UBE_SIMULATOR])
742
+        if ($combat_data[UBE_OPTIONS][UBE_SIMULATOR])
743 743
         { // for simulation just return 75% of loss
744 744
           $units_giveback = round($units_lost * $giveback_chance / 100);
745 745
         }
746 746
         else
747 747
         {
748
-          if($unit_count > 10)
748
+          if ($unit_count > 10)
749 749
           { // if there were more then 10 defense elements - mass-calculating giveback
750 750
             $units_giveback = round($units_lost * mt_rand($giveback_chance * 0.8, $giveback_chance * 1.2) / 100);
751 751
           }
752 752
           else
753 753
           { //if there were less then 10 defense elements - calculating giveback per element
754 754
             $units_giveback = 0;
755
-            for($i = 1; $i <= $units_lost; $i++)
755
+            for ($i = 1; $i <= $units_lost; $i++)
756 756
             {
757
-              if(mt_rand(1,100) <= $giveback_chance)
757
+              if (mt_rand(1, 100) <= $giveback_chance)
758 758
               {
759 759
                 $units_giveback++;
760 760
               }
@@ -773,13 +773,13 @@  discard block
 block discarded – undo
773 773
       $outcome[$fleet_type][UBE_CAPACITY][$fleet_id] += $fleet_info[UBE_CAPACITY][$unit_id] * $units_left;
774 774
 
775 775
       // Вычисляем потери в ресурсах
776
-      if($units_lost)
776
+      if ($units_lost)
777 777
       {
778 778
         $fleet_outcome[UBE_UNITS_LOST][$unit_id] = $units_lost;
779 779
 
780
-        foreach($fleet_info[UBE_PRICE] as $resource_id => $unit_prices)
780
+        foreach ($fleet_info[UBE_PRICE] as $resource_id => $unit_prices)
781 781
         {
782
-          if(!$unit_prices[$unit_id])
782
+          if (!$unit_prices[$unit_id])
783 783
           {
784 784
             continue;
785 785
           }
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
           $fleet_outcome[UBE_RESOURCES_LOST][$resource_id] += $resources_lost;
790 790
 
791 791
           // Если это корабль - прибавляем потери к обломкам на орбите
792
-          if($fleet_info[UBE_TYPE][$unit_id] == UNIT_SHIPS)
792
+          if ($fleet_info[UBE_TYPE][$unit_id] == UNIT_SHIPS)
793 793
           {
794 794
             $outcome[UBE_DEBRIS][$resource_id] += floor($resources_lost * ($combat_data[UBE_OPTIONS][UBE_SIMULATOR] ? 30 : mt_rand(20, 40)) / 100); // TODO: Configurize
795 795
           }
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
     }
803 803
 
804 804
     // На планете ($fleet_id = 0) ресурсы в космос не выбрасываются
805
-    if($fleet_id == 0)
805
+    if ($fleet_id == 0)
806 806
     {
807 807
       continue;
808 808
     }
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
     // Количество ресурсов флота
811 811
     $fleet_total_resources = empty($fleet_info[UBE_RESOURCES]) ? 0 : array_sum($fleet_info[UBE_RESOURCES]);
812 812
     // Если на борту нет ресурсов - зачем нам все это?
813
-    if($fleet_total_resources == 0)
813
+    if ($fleet_total_resources == 0)
814 814
     {
815 815
       continue;
816 816
     }
@@ -818,13 +818,13 @@  discard block
 block discarded – undo
818 818
     // Емкость трюмов флота
819 819
     $fleet_capacity = $outcome[$fleet_type][UBE_CAPACITY][$fleet_id];
820 820
     // Если емкость трюмов меньше количество ресурсов - часть ресов выбрасываем нахуй
821
-    if($fleet_capacity < $fleet_total_resources)
821
+    if ($fleet_capacity < $fleet_total_resources)
822 822
     {
823 823
       $left_percent = $fleet_capacity / $fleet_total_resources; // Сколько ресурсов будет оставлено
824
-      foreach($fleet_info[UBE_RESOURCES] as $resource_id => $resource_amount)
824
+      foreach ($fleet_info[UBE_RESOURCES] as $resource_id => $resource_amount)
825 825
       {
826 826
         // Не просчитываем ресурсы, которых нет на борту кораблей флота
827
-        if(!$resource_amount)
827
+        if (!$resource_amount)
828 828
         {
829 829
           continue;
830 830
         }
@@ -847,9 +847,9 @@  discard block
 block discarded – undo
847 847
   // SFR - Small Fleet Reconnaissance ака РМФ
848 848
   $outcome[UBE_SFR] = count($combat_data[UBE_ROUNDS]) == 2 && $outcome[UBE_COMBAT_RESULT] == UBE_COMBAT_RESULT_LOSS;
849 849
 
850
-  if(!$combat_data[UBE_OPTIONS][UBE_LOADED])
850
+  if (!$combat_data[UBE_OPTIONS][UBE_LOADED])
851 851
   {
852
-    if($combat_data[UBE_OPTIONS][UBE_MOON_WAS])
852
+    if ($combat_data[UBE_OPTIONS][UBE_MOON_WAS])
853 853
     {
854 854
       $outcome[UBE_MOON] = UBE_MOON_WAS;
855 855
     }
@@ -859,10 +859,10 @@  discard block
 block discarded – undo
859 859
     }
860 860
 
861 861
     // Лутаем ресурсы - если аттакер выиграл
862
-    if($outcome[UBE_COMBAT_RESULT] == UBE_COMBAT_RESULT_WIN)
862
+    if ($outcome[UBE_COMBAT_RESULT] == UBE_COMBAT_RESULT_WIN)
863 863
     {
864 864
       sn_ube_combat_analyze_loot($combat_data);
865
-      if($combat_data[UBE_OPTIONS][UBE_MOON_WAS] && $combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_DESTROY)
865
+      if ($combat_data[UBE_OPTIONS][UBE_MOON_WAS] && $combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_DESTROY)
866 866
       {
867 867
         sn_ube_combat_analyze_moon_destroy($combat_data);
868 868
       }
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
   $planet_looted_in_metal = 0;
882 882
   $planet_resource_looted = array();
883 883
   $planet_resource_total = is_array($planet_resource_list) ? array_sum($planet_resource_list) : 0;
884
-  if($planet_resource_total && ($total_capacity = array_sum($outcome[UBE_ATTACKERS][UBE_CAPACITY])))
884
+  if ($planet_resource_total && ($total_capacity = array_sum($outcome[UBE_ATTACKERS][UBE_CAPACITY])))
885 885
   {
886 886
     // Можно вывести только половину ресурсов, но не больше, чем общая вместимость флотов атакующих
887 887
     $planet_lootable = min($planet_resource_total / 2, $total_capacity);
@@ -892,11 +892,11 @@  discard block
 block discarded – undo
892 892
     $total_lootable = min($planet_lootable, $total_capacity);
893 893
 
894 894
     // Вычисляем сколько ресурсов вывезено
895
-    foreach($outcome[UBE_ATTACKERS][UBE_CAPACITY] as $fleet_id => $fleet_capacity)
895
+    foreach ($outcome[UBE_ATTACKERS][UBE_CAPACITY] as $fleet_id => $fleet_capacity)
896 896
     {
897 897
       $looted_in_metal = 0;
898 898
       $fleet_loot_data = array();
899
-      foreach($planet_resource_list as $resource_id => $resource_amount)
899
+      foreach ($planet_resource_list as $resource_id => $resource_amount)
900 900
       {
901 901
         // TODO Восстанавливаем ошибку округления - придумать нормальный алгоритм - вроде round() должно быть достаточно. Проверить
902 902
         $fleet_lootable_percent = $fleet_capacity / $total_capacity;
@@ -919,25 +919,25 @@  discard block
 block discarded – undo
919 919
 function sn_ube_combat_analyze_moon(&$outcome, $is_simulator)
920 920
 {
921 921
   $outcome[UBE_DEBRIS_TOTAL] = 0;
922
-  foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) // TODO via array
922
+  foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) // TODO via array
923 923
   {
924 924
     $outcome[UBE_DEBRIS_TOTAL] += $outcome[UBE_DEBRIS][$resource_id];
925 925
   }
926 926
 
927
-  if($outcome[UBE_DEBRIS_TOTAL])
927
+  if ($outcome[UBE_DEBRIS_TOTAL])
928 928
   {
929 929
     // TODO uni_calculate_moon_chance
930 930
     $moon_chance = min($outcome[UBE_DEBRIS_TOTAL] / 1000000, 30); // TODO Configure
931 931
     $moon_chance = $moon_chance >= 1 ? $moon_chance : 0;
932 932
     $outcome[UBE_MOON_CHANCE] = $moon_chance;
933
-    if($moon_chance)
933
+    if ($moon_chance)
934 934
     {
935
-      if($is_simulator || mt_rand(1, 100) <= $moon_chance)
935
+      if ($is_simulator || mt_rand(1, 100) <= $moon_chance)
936 936
       {
937 937
         $outcome[UBE_MOON_SIZE] = round($is_simulator ? $moon_chance * 150 + 1999 : mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999));
938 938
         $outcome[UBE_MOON] = UBE_MOON_CREATE_SUCCESS;
939 939
 
940
-        if($outcome[UBE_DEBRIS_TOTAL] <= 30000000)
940
+        if ($outcome[UBE_DEBRIS_TOTAL] <= 30000000)
941 941
         {
942 942
           $outcome[UBE_DEBRIS_TOTAL] = 0;
943 943
           $outcome[UBE_DEBRIS] = array();
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
           $moon_debris_left_percent = ($outcome[UBE_DEBRIS_TOTAL] - $moon_debris_spent) / $outcome[UBE_DEBRIS_TOTAL];
949 949
 
950 950
           $outcome[UBE_DEBRIS_TOTAL] = 0;
951
-          foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) // TODO via array
951
+          foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) // TODO via array
952 952
           {
953 953
             $outcome[UBE_DEBRIS][$resource_id] = floor($outcome[UBE_DEBRIS][$resource_id] * $moon_debris_left_percent);
954 954
             $outcome[UBE_DEBRIS_TOTAL] += $outcome[UBE_DEBRIS][$resource_id];
@@ -972,11 +972,11 @@  discard block
 block discarded – undo
972 972
 {
973 973
   // TODO: $is_simulator
974 974
   $reapers = 0;
975
-  foreach($combat_data[UBE_ROUNDS][count($combat_data[UBE_ROUNDS])-1][UBE_FLEETS] as $fleet_data)
975
+  foreach ($combat_data[UBE_ROUNDS][count($combat_data[UBE_ROUNDS]) - 1][UBE_FLEETS] as $fleet_data)
976 976
   {
977
-    if($fleet_data[UBE_FLEET_INFO][UBE_FLEET_TYPE] == UBE_ATTACKERS)
977
+    if ($fleet_data[UBE_FLEET_INFO][UBE_FLEET_TYPE] == UBE_ATTACKERS)
978 978
     {
979
-      foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
979
+      foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
980 980
       {
981 981
         // TODO: Работа по группам - группа "Уничтожители лун"
982 982
         $reapers += ($unit_id == SHIP_HUGE_DEATH_STAR) ? $unit_count : 0;
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
   }
986 986
 
987 987
   $moon_size = $combat_data[UBE_OUTCOME][UBE_PLANET][PLANET_SIZE];
988
-  if($reapers)
988
+  if ($reapers)
989 989
   {
990 990
     $random = mt_rand(1, 100);
991 991
     $combat_data[UBE_OUTCOME][UBE_MOON_DESTROY_CHANCE] = max(1, min(99, round((100 - sqrt($moon_size)) * sqrt($reapers))));
@@ -1019,38 +1019,37 @@  discard block
 block discarded – undo
1019 1019
     $planet_info[PLANET_SYSTEM],
1020 1020
     $planet_info[PLANET_PLANET],
1021 1021
     htmlentities($planet_info[PLANET_NAME], ENT_COMPAT, 'UTF-8'),
1022
-    $lang[$outcome['UBE_COMBAT_RESULT'] == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' :
1023
-      ($outcome['UBE_COMBAT_RESULT'] == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')
1022
+    $lang[$outcome['UBE_COMBAT_RESULT'] == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : ($outcome['UBE_COMBAT_RESULT'] == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')
1024 1023
     ]
1025 1024
   );
1026 1025
 
1027 1026
   $text_defender = '';
1028
-  foreach($outcome[UBE_DEBRIS] as $resource_id => $resource_amount)
1027
+  foreach ($outcome[UBE_DEBRIS] as $resource_id => $resource_amount)
1029 1028
   {
1030
-    if($resource_id == RES_DEUTERIUM)
1029
+    if ($resource_id == RES_DEUTERIUM)
1031 1030
     {
1032 1031
       continue;
1033 1032
     }
1034 1033
 
1035 1034
     $text_defender .= "{$lang['tech'][$resource_id]}: " . pretty_number($resource_amount) . '<br />';
1036 1035
   }
1037
-  if($text_defender)
1036
+  if ($text_defender)
1038 1037
   {
1039 1038
     $text_defender = "{$lang['ube_report_msg_body_debris']}{$text_defender}<br />";
1040 1039
   }
1041 1040
 
1042
-  if($outcome[UBE_MOON] == UBE_MOON_CREATE_SUCCESS)
1041
+  if ($outcome[UBE_MOON] == UBE_MOON_CREATE_SUCCESS)
1043 1042
   {
1044 1043
     $text_defender .= "{$lang['ube_report_moon_created']} {$outcome[UBE_MOON_SIZE]} {$lang['sys_kilometers_short']}<br /><br />";
1045 1044
   }
1046
-  elseif($outcome[UBE_MOON] == UBE_MOON_CREATE_FAILED)
1045
+  elseif ($outcome[UBE_MOON] == UBE_MOON_CREATE_FAILED)
1047 1046
   {
1048 1047
     $text_defender .= "{$lang['ube_report_moon_chance']} {$outcome[UBE_MOON_CHANCE]}%<br /><br />";
1049 1048
   }
1050 1049
 
1051
-  if($combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_DESTROY)
1050
+  if ($combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_DESTROY)
1052 1051
   {
1053
-    if($outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_NONE)
1052
+    if ($outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_NONE)
1054 1053
     {
1055 1054
       $text_defender .= $lang['ube_report_moon_reapers_none'];
1056 1055
     }
@@ -1068,7 +1067,7 @@  discard block
 block discarded – undo
1068 1067
   $text_defender .= "{$lang['ube_report_info_link']}: <a href=\"index.php?page=battle_report&cypher={$combat_data[UBE_REPORT_CYPHER]}\">{$combat_data[UBE_REPORT_CYPHER]}</a>";
1069 1068
 
1070 1069
   // TODO: Оптимизировать отсылку сообщений - отсылать пакетами
1071
-  foreach($combat_data[UBE_PLAYERS] as $player_id => $player_info)
1070
+  foreach ($combat_data[UBE_PLAYERS] as $player_id => $player_info)
1072 1071
   {
1073 1072
     $message = $text_common . ($outcome[UBE_SFR] && $player_info[UBE_ATTACKER] ? $lang['ube_report_msg_body_sfr'] : $text_defender);
1074 1073
     msg_send_simple_message($player_id, '', $combat_data[UBE_TIME], MSG_TYPE_COMBAT, $lang['sys_mess_tower'], $lang['sys_mess_attack_report'], $message);
@@ -1080,7 +1079,7 @@  discard block
 block discarded – undo
1080 1079
 // ------------------------------------------------------------------------------------------------
1081 1080
 // Записывает результат боя в БД
1082 1081
 /** @noinspection SpellCheckingInspection */
1083
-function ube_combat_result_apply(&$combat_data){return sn_function_call('ube_combat_result_apply', array(&$combat_data));}
1082
+function ube_combat_result_apply(&$combat_data) {return sn_function_call('ube_combat_result_apply', array(&$combat_data)); }
1084 1083
 function sn_ube_combat_result_apply(&$combat_data)
1085 1084
 {
1086 1085
 // TODO: Поменять все отладки на запросы
@@ -1090,7 +1089,7 @@  discard block
 block discarded – undo
1090 1089
   $planet_info = &$outcome[UBE_PLANET];
1091 1090
   $planet_id = $planet_info[PLANET_ID];
1092 1091
   // Обновляем поле обломков на планете
1093
-  if(!$combat_data[UBE_OPTIONS][UBE_COMBAT_ADMIN] && !empty($outcome[UBE_DEBRIS]))
1092
+  if (!$combat_data[UBE_OPTIONS][UBE_COMBAT_ADMIN] && !empty($outcome[UBE_DEBRIS]))
1094 1093
   {
1095 1094
     DBStaticPlanet::db_planet_set_by_gspt($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], PT_PLANET,
1096 1095
       "`debris_metal` = `debris_metal` + " . floor($outcome[UBE_DEBRIS][RES_METAL]) . ", `debris_crystal` = `debris_crystal` + " . floor($outcome[UBE_DEBRIS][RES_CRYSTAL])
@@ -1102,9 +1101,9 @@  discard block
 block discarded – undo
1102 1101
   );
1103 1102
 
1104 1103
   $fleets_outcome = &$outcome[UBE_FLEETS];
1105
-  foreach($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info)
1104
+  foreach ($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info)
1106 1105
   {
1107
-    if($fleet_info[UBE_FLEET_GROUP])
1106
+    if ($fleet_info[UBE_FLEET_GROUP])
1108 1107
     {
1109 1108
       $db_save[UBE_FLEET_GROUP][$fleet_info[UBE_FLEET_GROUP]] = $fleet_info[UBE_FLEET_GROUP];
1110 1109
     }
@@ -1117,28 +1116,28 @@  discard block
 block discarded – undo
1117 1116
     $old_fleet_count = array_sum($fleet_info[UBE_COUNT]);
1118 1117
     $new_fleet_count = $old_fleet_count - array_sum($fleets_outcome[$fleet_id][UBE_UNITS_LOST]);
1119 1118
     // Перебираем юниты если во время боя количество юнитов изменилось и при этом во флоту остались юниты или это планета
1120
-    if($new_fleet_count != $old_fleet_count && (!$fleet_id || $new_fleet_count))
1119
+    if ($new_fleet_count != $old_fleet_count && (!$fleet_id || $new_fleet_count))
1121 1120
     {
1122 1121
       // Просматриваем результаты изменения флотов
1123
-      foreach($fleet_info[UBE_COUNT] as $unit_id => $unit_count)
1122
+      foreach ($fleet_info[UBE_COUNT] as $unit_id => $unit_count)
1124 1123
       {
1125 1124
         // Перебираем аутком на случай восстановления юнитов
1126
-        $units_lost = (float)$fleets_outcome[$fleet_id][UBE_UNITS_LOST][$unit_id];
1125
+        $units_lost = (float) $fleets_outcome[$fleet_id][UBE_UNITS_LOST][$unit_id];
1127 1126
 
1128 1127
         $units_left = $unit_count - $units_lost;
1129
-        if($fleet_id)
1128
+        if ($fleet_id)
1130 1129
         {
1131 1130
           // Не планета - всегда сразу записываем строку итогов флота
1132 1131
           $fleet_query[$unit_id] = "{$unit_id},{$units_left}";
1133 1132
         }
1134
-        elseif($units_lost)
1133
+        elseif ($units_lost)
1135 1134
         {
1136 1135
           // Планета - записываем в ИД юнита его потери только если есть потери
1137 1136
           $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, -$units_lost, $combat_data[UBE_PLAYERS][$destination_user_id][UBE_PLAYER_DATA], $planet_id);
1138 1137
         }
1139 1138
       }
1140 1139
 
1141
-      if($fleet_id)
1140
+      if ($fleet_id)
1142 1141
       {
1143 1142
         // Для флотов перегенерируем массив как одно вхождение в SET SQL-запроса
1144 1143
 //        $fleet_query = implode(';', $fleet_query);
@@ -1151,12 +1150,12 @@  discard block
 block discarded – undo
1151 1150
 
1152 1151
     $fleet_delta = array();
1153 1152
     // Если во флоте остались юниты или это планета - генерируем изменение ресурсов
1154
-    if($new_fleet_count || !$fleet_id)
1153
+    if ($new_fleet_count || !$fleet_id)
1155 1154
     {
1156
-      foreach(sn_get_groups('resources_loot') as $resource_id)
1155
+      foreach (sn_get_groups('resources_loot') as $resource_id)
1157 1156
       {
1158
-        $resource_change = (float)$fleets_outcome[$fleet_id][UBE_RESOURCES_LOOTED][$resource_id] + (float)$fleets_outcome[$fleet_id][UBE_CARGO_DROPPED][$resource_id];
1159
-        if($resource_change)
1157
+        $resource_change = (float) $fleets_outcome[$fleet_id][UBE_RESOURCES_LOOTED][$resource_id] + (float) $fleets_outcome[$fleet_id][UBE_CARGO_DROPPED][$resource_id];
1158
+        if ($resource_change)
1160 1159
         {
1161 1160
           $resource_db_name = ($fleet_id ? 'fleet_resource_' : '') . pname_resource_name($resource_id);
1162 1161
 //          $fleet_query[] = "`{$resource_db_name}` = `{$resource_db_name}` - ({$resource_change})";
@@ -1170,10 +1169,10 @@  discard block
 block discarded – undo
1170 1169
           continue;
1171 1170
         }
1172 1171
     */
1173
-    if($fleet_id && $new_fleet_count)
1172
+    if ($fleet_id && $new_fleet_count)
1174 1173
     {
1175 1174
       // Если защитник и не РМФ - отправляем флот назад
1176
-      if(($fleet_info[UBE_FLEET_TYPE] == UBE_DEFENDERS && !$outcome[UBE_SFR]) || $fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS)
1175
+      if (($fleet_info[UBE_FLEET_TYPE] == UBE_DEFENDERS && !$outcome[UBE_SFR]) || $fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS)
1177 1176
       {
1178 1177
 //        $fleet_query[] = '`fleet_mess` = 1';
1179 1178
         $fleet_query['fleet_mess'] = 1;
@@ -1188,16 +1187,16 @@  discard block
 block discarded – undo
1188 1187
 
1189 1188
 //global $debug;
1190 1189
 //    $fleet_query = implode(',', $fleet_query);
1191
-    if($fleet_id) // Не планета
1190
+    if ($fleet_id) // Не планета
1192 1191
     {
1193
-      if($fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS && $outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_DIED)
1192
+      if ($fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS && $outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_DIED)
1194 1193
       {
1195 1194
         $new_fleet_count = 0;
1196 1195
       }
1197 1196
 
1198
-      if($new_fleet_count)
1197
+      if ($new_fleet_count)
1199 1198
       {
1200
-        if(!empty($fleet_query) || !empty($fleet_delta))
1199
+        if (!empty($fleet_query) || !empty($fleet_delta))
1201 1200
         {
1202 1201
 //          doquery("UPDATE {{fleets}} SET {$fleet_query}, `fleet_amount` = '{$new_fleet_count}' WHERE `fleet_id` = {$fleet_id} LIMIT 1");
1203 1202
 //          db_fleet_update_set_safe_string($fleet_id, "{$fleet_query}, `fleet_amount` = '{$new_fleet_count}'");
@@ -1216,15 +1215,15 @@  discard block
 block discarded – undo
1216 1215
     else // Планета
1217 1216
     {
1218 1217
       // Сохраняем изменения ресурсов - если они есть
1219
-      if(!empty($fleet_delta))
1218
+      if (!empty($fleet_delta))
1220 1219
       {
1221 1220
         $temp = array();
1222
-        foreach($fleet_delta as $resource_db_name => $resource_amount) {
1221
+        foreach ($fleet_delta as $resource_db_name => $resource_amount) {
1223 1222
           $temp[] = "`{$resource_db_name}` = `{$resource_db_name}` + ({$resource_amount})";
1224 1223
         }
1225 1224
         DBStaticPlanet::db_planet_set_by_id($planet_id, implode(',', $temp));
1226 1225
       }
1227
-      if(!empty($db_changeset)) // Сохраняем изменения юнитов на планете - если они есть
1226
+      if (!empty($db_changeset)) // Сохраняем изменения юнитов на планете - если они есть
1228 1227
       {
1229 1228
         db_changeset_apply($db_changeset);
1230 1229
       }
@@ -1233,34 +1232,34 @@  discard block
 block discarded – undo
1233 1232
 
1234 1233
   // TODO: Связать сабы с флотами констраинтами ON DELETE SET NULL
1235 1234
   // $db_save[UBE_FLEET_GROUP][$fleet_info[UBE_FLEET_GROUP]] = $fleet_info[UBE_FLEET_GROUP];
1236
-  if(!empty($db_save[UBE_FLEET_GROUP]))
1235
+  if (!empty($db_save[UBE_FLEET_GROUP]))
1237 1236
   {
1238 1237
     $db_save[UBE_FLEET_GROUP] = implode(',', $db_save[UBE_FLEET_GROUP]);
1239 1238
     doquery("DELETE FROM {{aks}} WHERE `id` IN ({$db_save[UBE_FLEET_GROUP]})");
1240 1239
   }
1241 1240
 
1242
-  if($outcome[UBE_MOON] == UBE_MOON_CREATE_SUCCESS)
1241
+  if ($outcome[UBE_MOON] == UBE_MOON_CREATE_SUCCESS)
1243 1242
   {
1244 1243
     $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);
1245 1244
     $outcome[UBE_MOON_NAME] = $moon_row['name'];
1246 1245
     unset($moon_row);
1247 1246
   }
1248
-  elseif($outcome[UBE_MOON] == UBE_MOON_DESTROY_SUCCESS)
1247
+  elseif ($outcome[UBE_MOON] == UBE_MOON_DESTROY_SUCCESS)
1249 1248
   {
1250 1249
     DBStaticPlanet::db_planet_delete_by_id($planet_id);
1251 1250
   }
1252 1251
 
1253 1252
   {
1254 1253
     $bashing_list = array();
1255
-    foreach($combat_data[UBE_PLAYERS] as $player_id => $player_info)
1254
+    foreach ($combat_data[UBE_PLAYERS] as $player_id => $player_info)
1256 1255
     {
1257
-      if($player_info[UBE_ATTACKER])
1256
+      if ($player_info[UBE_ATTACKER])
1258 1257
       {
1259
-        if($outcome[UBE_MOON] != UBE_MOON_DESTROY_SUCCESS)
1258
+        if ($outcome[UBE_MOON] != UBE_MOON_DESTROY_SUCCESS)
1260 1259
         {
1261 1260
           $bashing_list[] = "({$player_id}, {$planet_id}, {$combat_data[UBE_TIME]})";
1262 1261
         }
1263
-        if($combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_ATTACK && $combat_data[UBE_OPTIONS][UBE_DEFENDER_ACTIVE])
1262
+        if ($combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_ATTACK && $combat_data[UBE_OPTIONS][UBE_DEFENDER_ACTIVE])
1264 1263
         {
1265 1264
           $str_loose_or_win = $outcome[UBE_COMBAT_RESULT] == UBE_COMBAT_RESULT_WIN ? 'raidswin' : 'raidsloose';
1266 1265
           db_user_set_by_id($player_id, "`xpraid` = `xpraid` + 1, `raids` = `raids` + 1, `{$str_loose_or_win}` = `{$str_loose_or_win}` + 1");
@@ -1268,7 +1267,7 @@  discard block
 block discarded – undo
1268 1267
       }
1269 1268
     }
1270 1269
     $bashing_list = implode(',', $bashing_list);
1271
-    if($bashing_list)
1270
+    if ($bashing_list)
1272 1271
     {
1273 1272
       doquery("INSERT INTO {{bashing}} (bashing_user_id, bashing_planet_id, bashing_time) VALUES {$bashing_list};");
1274 1273
     }
Please login to merge, or discard this 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'][] = sn_db_unit_changeset_prepare($unit_id, -$units_lost, $combat_data[UBE_PLAYERS][$destination_user_id][UBE_PLAYER_DATA], $planet_id);
@@ -1188,11 +1162,13 @@  discard block
 block discarded – undo
1188 1162
 
1189 1163
 //global $debug;
1190 1164
 //    $fleet_query = implode(',', $fleet_query);
1191
-    if($fleet_id) // Не планета
1165
+    if($fleet_id) {
1166
+      // Не планета
1192 1167
     {
1193 1168
       if($fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS && $outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_DIED)
1194 1169
       {
1195 1170
         $new_fleet_count = 0;
1171
+    }
1196 1172
       }
1197 1173
 
1198 1174
       if($new_fleet_count)
@@ -1204,16 +1180,14 @@  discard block
 block discarded – undo
1204 1180
           $fleet_query['fleet_amount'] = $new_fleet_count;
1205 1181
           fleet_update_set($fleet_id, $fleet_query, $fleet_delta);
1206 1182
         }
1207
-      }
1208
-      else
1183
+      } else
1209 1184
       {
1210 1185
         // Удаляем пустые флоты
1211 1186
         // doquery("DELETE FROM {{fleets}} WHERE `fleet_id` = {$fleet_id} LIMIT 1");
1212 1187
         db_fleet_delete($fleet_id);
1213 1188
         DBStaticUnit::db_unit_list_delete(0, LOC_FLEET, $fleet_id, 0);
1214 1189
       }
1215
-    }
1216
-    else // Планета
1190
+    } else // Планета
1217 1191
     {
1218 1192
       // Сохраняем изменения ресурсов - если они есть
1219 1193
       if(!empty($fleet_delta))
@@ -1224,10 +1198,12 @@  discard block
 block discarded – undo
1224 1198
         }
1225 1199
         DBStaticPlanet::db_planet_set_by_id($planet_id, implode(',', $temp));
1226 1200
       }
1227
-      if(!empty($db_changeset)) // Сохраняем изменения юнитов на планете - если они есть
1201
+      if(!empty($db_changeset)) {
1202
+        // Сохраняем изменения юнитов на планете - если они есть
1228 1203
       {
1229 1204
         db_changeset_apply($db_changeset);
1230 1205
       }
1206
+      }
1231 1207
     }
1232 1208
   }
1233 1209
 
@@ -1244,8 +1220,7 @@  discard block
 block discarded – undo
1244 1220
     $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);
1245 1221
     $outcome[UBE_MOON_NAME] = $moon_row['name'];
1246 1222
     unset($moon_row);
1247
-  }
1248
-  elseif($outcome[UBE_MOON] == UBE_MOON_DESTROY_SUCCESS)
1223
+  } elseif($outcome[UBE_MOON] == UBE_MOON_DESTROY_SUCCESS)
1249 1224
   {
1250 1225
     DBStaticPlanet::db_planet_delete_by_id($planet_id);
1251 1226
   }
Please login to merge, or discard this patch.
includes/includes/ube_report.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -281,6 +281,9 @@  discard block
 block discarded – undo
281 281
 
282 282
 // ------------------------------------------------------------------------------------------------
283 283
 // Читает боевой отчет из БД
284
+/**
285
+ * @param string $report_cypher
286
+ */
284 287
 function sn_ube_report_load($report_cypher)
285 288
 {
286 289
   $report_cypher = db_escape($report_cypher);
@@ -480,6 +483,9 @@  discard block
 block discarded – undo
480 483
 
481 484
 // ------------------------------------------------------------------------------------------------
482 485
 // Парсит инфу о раунде для темплейта
486
+/**
487
+ * @param integer $round
488
+ */
483 489
 function sn_ube_report_round_fleet(&$combat_data, $round)
484 490
 {
485 491
   global $lang;
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
   global $config;
8 8
 
9 9
   // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем
10
-  if($combat_data[UBE_REPORT_CYPHER])
10
+  if ($combat_data[UBE_REPORT_CYPHER])
11 11
   {
12 12
     return false;
13 13
   }
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
   {
18 18
     $combat_data[UBE_REPORT_CYPHER] = sys_random_string(32);
19 19
   }
20
-  while(doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$combat_data[UBE_REPORT_CYPHER]}' LIMIT 1 FOR UPDATE", true));
20
+  while (doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$combat_data[UBE_REPORT_CYPHER]}' LIMIT 1 FOR UPDATE", true));
21 21
 
22 22
   // Инициализация таблицы для пакетной вставки информации
23 23
   $sql_perform = array(
@@ -113,55 +113,55 @@  discard block
 block discarded – undo
113 113
       `ube_report_time_combat` = '" . date(FMT_DATE_TIME_SQL, $combat_data[UBE_TIME]) . "',
114 114
       `ube_report_time_spent` = {$combat_data[UBE_TIME_SPENT]},
115 115
 
116
-      `ube_report_combat_admin` = " . (int)$combat_data[UBE_OPTIONS][UBE_COMBAT_ADMIN] . ",
116
+      `ube_report_combat_admin` = " . (int) $combat_data[UBE_OPTIONS][UBE_COMBAT_ADMIN] . ",
117 117
       `ube_report_mission_type` = {$combat_data[UBE_OPTIONS][UBE_MISSION_TYPE]},
118 118
 
119 119
       `ube_report_combat_result` = {$outcome[UBE_COMBAT_RESULT]},
120
-      `ube_report_combat_sfr` = " . (int)$outcome[UBE_SFR] .",
120
+      `ube_report_combat_sfr` = " . (int) $outcome[UBE_SFR] . ",
121 121
 
122
-      `ube_report_debris_metal` = " . (float)$outcome[UBE_DEBRIS][RES_METAL] . ",
123
-      `ube_report_debris_crystal` = " . (float)$outcome[UBE_DEBRIS][RES_CRYSTAL] . ",
122
+      `ube_report_debris_metal` = " . (float) $outcome[UBE_DEBRIS][RES_METAL] . ",
123
+      `ube_report_debris_crystal` = " . (float) $outcome[UBE_DEBRIS][RES_CRYSTAL] . ",
124 124
       `ube_report_debris_total_in_metal` = " . $ube_report_debris_total_in_metal . ",
125 125
 
126
-      `ube_report_planet_id`          = " . (int)$outcome[UBE_PLANET][PLANET_ID] . ",
126
+      `ube_report_planet_id`          = " . (int) $outcome[UBE_PLANET][PLANET_ID] . ",
127 127
       `ube_report_planet_name`        = '" . db_escape($outcome[UBE_PLANET][PLANET_NAME]) . "',
128
-      `ube_report_planet_size`        = " . (int)$outcome[UBE_PLANET][PLANET_SIZE] . ",
129
-      `ube_report_planet_galaxy`      = " . (int)$outcome[UBE_PLANET][PLANET_GALAXY] . ",
130
-      `ube_report_planet_system`      = " . (int)$outcome[UBE_PLANET][PLANET_SYSTEM] . ",
131
-      `ube_report_planet_planet`      = " . (int)$outcome[UBE_PLANET][PLANET_PLANET] . ",
132
-      `ube_report_planet_planet_type` = " . (int)$outcome[UBE_PLANET][PLANET_TYPE] . ",
128
+      `ube_report_planet_size`        = " . (int) $outcome[UBE_PLANET][PLANET_SIZE] . ",
129
+      `ube_report_planet_galaxy`      = " . (int) $outcome[UBE_PLANET][PLANET_GALAXY] . ",
130
+      `ube_report_planet_system`      = " . (int) $outcome[UBE_PLANET][PLANET_SYSTEM] . ",
131
+      `ube_report_planet_planet`      = " . (int) $outcome[UBE_PLANET][PLANET_PLANET] . ",
132
+      `ube_report_planet_planet_type` = " . (int) $outcome[UBE_PLANET][PLANET_TYPE] . ",
133 133
 
134
-      `ube_report_moon` = " . (int)$outcome[UBE_MOON] .",
135
-      `ube_report_moon_chance` = " . (int)$outcome[UBE_MOON_CHANCE] . ",
136
-      `ube_report_moon_size` = " . (float)$outcome[UBE_MOON_SIZE] . ",
134
+      `ube_report_moon` = " . (int) $outcome[UBE_MOON] . ",
135
+      `ube_report_moon_chance` = " . (int) $outcome[UBE_MOON_CHANCE] . ",
136
+      `ube_report_moon_size` = " . (float) $outcome[UBE_MOON_SIZE] . ",
137 137
 
138
-      `ube_report_moon_reapers` = " . (int)$outcome[UBE_MOON_REAPERS] . ",
139
-      `ube_report_moon_destroy_chance` = " . (int)$outcome[UBE_MOON_DESTROY_CHANCE] . ",
140
-      `ube_report_moon_reapers_die_chance` = " . (int)$outcome[UBE_MOON_REAPERS_DIE_CHANCE] . ",
138
+      `ube_report_moon_reapers` = " . (int) $outcome[UBE_MOON_REAPERS] . ",
139
+      `ube_report_moon_destroy_chance` = " . (int) $outcome[UBE_MOON_DESTROY_CHANCE] . ",
140
+      `ube_report_moon_reapers_die_chance` = " . (int) $outcome[UBE_MOON_REAPERS_DIE_CHANCE] . ",
141 141
 
142
-      `ube_report_capture_result` = " . (int)$outcome[UBE_CAPTURE_RESULT] . "
142
+      `ube_report_capture_result` = " . (int) $outcome[UBE_CAPTURE_RESULT] . "
143 143
   ");
144 144
   $ube_report_id = $combat_data[UBE_REPORT_ID] = db_insert_id();
145 145
 
146 146
   // Сохраняем общую информацию по игрокам
147
-  foreach($combat_data[UBE_PLAYERS] as $player_id => &$player_info)
147
+  foreach ($combat_data[UBE_PLAYERS] as $player_id => &$player_info)
148 148
   {
149 149
     $sql_perform['ube_report_player'][] = array(
150 150
       $ube_report_id,
151 151
       $player_id,
152 152
 
153 153
       "'" . db_escape($player_info[UBE_NAME]) . "'",
154
-      (int)$player_info[UBE_ATTACKER],
154
+      (int) $player_info[UBE_ATTACKER],
155 155
 
156
-      (float)$player_info[UBE_BONUSES][UBE_ATTACK],
157
-      (float)$player_info[UBE_BONUSES][UBE_SHIELD],
158
-      (float)$player_info[UBE_BONUSES][UBE_ARMOR],
156
+      (float) $player_info[UBE_BONUSES][UBE_ATTACK],
157
+      (float) $player_info[UBE_BONUSES][UBE_SHIELD],
158
+      (float) $player_info[UBE_BONUSES][UBE_ARMOR],
159 159
     );
160 160
   }
161 161
 
162 162
   // Всякая информация по флотам
163 163
   $unit_sort_order = 0;
164
-  foreach($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info)
164
+  foreach ($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info)
165 165
   {
166 166
     // Сохраняем общую информацию по флотам
167 167
     $sql_perform['ube_report_fleet'][] = array(
@@ -169,20 +169,20 @@  discard block
 block discarded – undo
169 169
       $fleet_info[UBE_OWNER],
170 170
       $fleet_id,
171 171
 
172
-      (float)$fleet_info[UBE_PLANET][PLANET_ID],
172
+      (float) $fleet_info[UBE_PLANET][PLANET_ID],
173 173
       "'" . db_escape($fleet_info[UBE_PLANET][PLANET_NAME]) . "'",
174
-      (int)$fleet_info[UBE_PLANET][PLANET_GALAXY],
175
-      (int)$fleet_info[UBE_PLANET][PLANET_SYSTEM],
176
-      (int)$fleet_info[UBE_PLANET][PLANET_PLANET],
177
-      (int)$fleet_info[UBE_PLANET][PLANET_TYPE],
178
-
179
-      (float)$fleet_info[UBE_RESOURCES][RES_METAL],
180
-      (float)$fleet_info[UBE_RESOURCES][RES_CRYSTAL],
181
-      (float)$fleet_info[UBE_RESOURCES][RES_DEUTERIUM],
182
-
183
-      (float)$fleet_info[UBE_BONUSES][UBE_ATTACK],
184
-      (float)$fleet_info[UBE_BONUSES][UBE_SHIELD],
185
-      (float)$fleet_info[UBE_BONUSES][UBE_ARMOR],
174
+      (int) $fleet_info[UBE_PLANET][PLANET_GALAXY],
175
+      (int) $fleet_info[UBE_PLANET][PLANET_SYSTEM],
176
+      (int) $fleet_info[UBE_PLANET][PLANET_PLANET],
177
+      (int) $fleet_info[UBE_PLANET][PLANET_TYPE],
178
+
179
+      (float) $fleet_info[UBE_RESOURCES][RES_METAL],
180
+      (float) $fleet_info[UBE_RESOURCES][RES_CRYSTAL],
181
+      (float) $fleet_info[UBE_RESOURCES][RES_DEUTERIUM],
182
+
183
+      (float) $fleet_info[UBE_BONUSES][UBE_ATTACK],
184
+      (float) $fleet_info[UBE_BONUSES][UBE_SHIELD],
185
+      (float) $fleet_info[UBE_BONUSES][UBE_ARMOR],
186 186
     );
187 187
 
188 188
     // Сохраняем итоговую информацию по ресурсам флота - потеряно, выброшено, увезено
@@ -191,25 +191,25 @@  discard block
 block discarded – undo
191 191
       $ube_report_id,
192 192
       $fleet_id,
193 193
 
194
-      (float)$fleet_outcome_data[UBE_RESOURCES_LOST][RES_METAL],
195
-      (float)$fleet_outcome_data[UBE_RESOURCES_LOST][RES_CRYSTAL],
196
-      (float)$fleet_outcome_data[UBE_RESOURCES_LOST][RES_DEUTERIUM],
194
+      (float) $fleet_outcome_data[UBE_RESOURCES_LOST][RES_METAL],
195
+      (float) $fleet_outcome_data[UBE_RESOURCES_LOST][RES_CRYSTAL],
196
+      (float) $fleet_outcome_data[UBE_RESOURCES_LOST][RES_DEUTERIUM],
197 197
 
198
-      (float)$fleet_outcome_data[UBE_CARGO_DROPPED][RES_METAL],
199
-      (float)$fleet_outcome_data[UBE_CARGO_DROPPED][RES_CRYSTAL],
200
-      (float)$fleet_outcome_data[UBE_CARGO_DROPPED][RES_DEUTERIUM],
198
+      (float) $fleet_outcome_data[UBE_CARGO_DROPPED][RES_METAL],
199
+      (float) $fleet_outcome_data[UBE_CARGO_DROPPED][RES_CRYSTAL],
200
+      (float) $fleet_outcome_data[UBE_CARGO_DROPPED][RES_DEUTERIUM],
201 201
 
202
-      (float)$fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_METAL],
203
-      (float)$fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_CRYSTAL],
204
-      (float)$fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_DEUTERIUM],
202
+      (float) $fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_METAL],
203
+      (float) $fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_CRYSTAL],
204
+      (float) $fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_DEUTERIUM],
205 205
 
206
-      (float)$fleet_outcome_data[UBE_RESOURCES_LOST_IN_METAL][RES_METAL],
206
+      (float) $fleet_outcome_data[UBE_RESOURCES_LOST_IN_METAL][RES_METAL],
207 207
     );
208 208
 
209 209
     // Сохраняем результаты по юнитам - потеряно и восстановлено
210
-    foreach($fleet_info[UBE_COUNT] as $unit_id => $unit_count)
210
+    foreach ($fleet_info[UBE_COUNT] as $unit_id => $unit_count)
211 211
     {
212
-      if($fleet_outcome_data[UBE_UNITS_LOST][$unit_id] || $fleet_outcome_data[UBE_DEFENCE_RESTORE][$unit_id])
212
+      if ($fleet_outcome_data[UBE_UNITS_LOST][$unit_id] || $fleet_outcome_data[UBE_DEFENCE_RESTORE][$unit_id])
213 213
       {
214 214
         $unit_sort_order++;
215 215
         $sql_perform['ube_report_outcome_unit'][] = array(
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
           $fleet_id,
218 218
 
219 219
           $unit_id,
220
-          (float)$fleet_outcome_data[UBE_DEFENCE_RESTORE][$unit_id],
221
-          (float)$fleet_outcome_data[UBE_UNITS_LOST][$unit_id],
220
+          (float) $fleet_outcome_data[UBE_DEFENCE_RESTORE][$unit_id],
221
+          (float) $fleet_outcome_data[UBE_UNITS_LOST][$unit_id],
222 222
 
223 223
           $unit_sort_order,
224 224
         );
@@ -228,11 +228,11 @@  discard block
 block discarded – undo
228 228
 
229 229
   // Сохраняем информацию о раундах
230 230
   $unit_sort_order = 0;
231
-  foreach($combat_data[UBE_ROUNDS] as $round => &$round_data)
231
+  foreach ($combat_data[UBE_ROUNDS] as $round => &$round_data)
232 232
   {
233
-    foreach($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data)
233
+    foreach ($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data)
234 234
     {
235
-      foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
235
+      foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
236 236
       {
237 237
         $unit_sort_order++;
238 238
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 
245 245
           $unit_id,
246 246
           $unit_count,
247
-          (int)$fleet_data[UBE_UNITS_BOOM][$unit_id],
247
+          (int) $fleet_data[UBE_UNITS_BOOM][$unit_id],
248 248
 
249 249
           $fleet_data[UBE_ATTACK][$unit_id],
250 250
           $fleet_data[UBE_SHIELD][$unit_id],
@@ -261,13 +261,13 @@  discard block
 block discarded – undo
261 261
   }
262 262
 
263 263
   // Пакетная вставка данных
264
-  foreach($sql_perform as $table_name => $table_data)
264
+  foreach ($sql_perform as $table_name => $table_data)
265 265
   {
266
-    if(count($table_data) < 2)
266
+    if (count($table_data) < 2)
267 267
     {
268 268
       continue;
269 269
     }
270
-    foreach($table_data as &$record_data)
270
+    foreach ($table_data as &$record_data)
271 271
     {
272 272
       $record_data = '(' . implode(',', $record_data) . ')';
273 273
     }
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
   $report_cypher = db_escape($report_cypher);
287 287
 
288 288
   $report_row = doquery("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1", true);
289
-  if(!$report_row)
289
+  if (!$report_row)
290 290
   {
291 291
     return UBE_REPORT_NOT_FOUND;
292 292
   }
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
   $outcome = &$combat_data[UBE_OUTCOME];
341 341
 
342 342
   $query = doquery("SELECT * FROM {{ube_report_player}} WHERE `ube_report_id` = {$report_row['ube_report_id']}");
343
-  while($player_row = db_fetch($query))
343
+  while ($player_row = db_fetch($query))
344 344
   {
345 345
     $combat_data[UBE_PLAYERS][$player_row['ube_report_player_player_id']] = array(
346 346
       UBE_NAME => $player_row['ube_report_player_name'],
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
   }
356 356
 
357 357
   $query = doquery("SELECT * FROM {{ube_report_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}");
358
-  while($fleet_row = db_fetch($query))
358
+  while ($fleet_row = db_fetch($query))
359 359
   {
360 360
     $combat_data[UBE_FLEETS][$fleet_row['ube_report_fleet_fleet_id']] = array(
361 361
       UBE_OWNER => $fleet_row['ube_report_fleet_player_id'],
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
   $rounds_data = &$combat_data[UBE_ROUNDS];
390 390
 
391 391
   $query = doquery("SELECT * FROM {{ube_report_unit}} WHERE `ube_report_id` = {$report_row['ube_report_id']} ORDER BY `ube_report_unit_sort_order`");
392
-  while($round_row = db_fetch($query))
392
+  while ($round_row = db_fetch($query))
393 393
   {
394 394
     $round = $round_row['ube_report_unit_round'];
395 395
     $fleet_id = $round_row['ube_report_unit_fleet_id'];
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
     $side = $combat_data[UBE_FLEETS][$fleet_id][UBE_FLEET_TYPE];
398 398
     $rounds_data[$round][$side][UBE_ATTACK][$fleet_id] = 0;
399 399
 
400
-    if(!isset($rounds_data[$round][UBE_FLEETS][$fleet_id]))
400
+    if (!isset($rounds_data[$round][UBE_FLEETS][$fleet_id]))
401 401
     {
402 402
       $rounds_data[$round][UBE_FLEETS][$fleet_id] = array();
403 403
     }
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 
419 419
 
420 420
   $query = doquery("SELECT * FROM {{ube_report_outcome_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}");
421
-  while($row = db_fetch($query))
421
+  while ($row = db_fetch($query))
422 422
   {
423 423
     $fleet_id = $row['ube_report_outcome_fleet_fleet_id'];
424 424
 
@@ -452,10 +452,10 @@  discard block
 block discarded – undo
452 452
   }
453 453
 
454 454
   $query = doquery("SELECT * FROM {{ube_report_outcome_unit}} WHERE `ube_report_id` = {$report_row['ube_report_id']} ORDER BY `ube_report_outcome_unit_sort_order`");
455
-  while($row = db_fetch($query))
455
+  while ($row = db_fetch($query))
456 456
   {
457 457
     $fleet_id = $row['ube_report_outcome_unit_fleet_id'];
458
-    $side= $combat_data[UBE_FLEETS][$fleet_id][UBE_FLEET_TYPE];
458
+    $side = $combat_data[UBE_FLEETS][$fleet_id][UBE_FLEET_TYPE];
459 459
     $outcome[$side][UBE_FLEETS][$fleet_id][UBE_UNITS_LOST][$row['ube_report_outcome_unit_unit_id']] = $row['ube_report_outcome_unit_lost'];
460 460
     $outcome[$side][UBE_FLEETS][$fleet_id][UBE_DEFENCE_RESTORE][$row['ube_report_outcome_unit_unit_id']] = $row['ube_report_outcome_unit_restored'];
461 461
   }
@@ -487,10 +487,10 @@  discard block
 block discarded – undo
487 487
   $fleets_info = &$combat_data[UBE_FLEETS];
488 488
   $round_template = array();
489 489
   $round_data = &$combat_data[UBE_ROUNDS][$round];
490
-  foreach(array(UBE_ATTACKERS, UBE_DEFENDERS) as $side)
490
+  foreach (array(UBE_ATTACKERS, UBE_DEFENDERS) as $side)
491 491
   {
492 492
     $round_data[$side][UBE_ATTACK] = $round_data[$side][UBE_ATTACK] ? $round_data[$side][UBE_ATTACK] : array();
493
-    foreach($round_data[$side][UBE_ATTACK] as $fleet_id => $temp)
493
+    foreach ($round_data[$side][UBE_ATTACK] as $fleet_id => $temp)
494 494
     {
495 495
       $fleet_data = &$round_data[UBE_FLEETS][$fleet_id];
496 496
       $fleet_data_prev = &$combat_data[UBE_ROUNDS][$round - 1][UBE_FLEETS][$fleet_id];
@@ -500,14 +500,14 @@  discard block
 block discarded – undo
500 500
         'PLAYER_NAME' => htmlentities($combat_data[UBE_PLAYERS][$fleets_info[$fleet_id][UBE_OWNER]][UBE_NAME], ENT_COMPAT, 'UTF-8'),
501 501
       );
502 502
 
503
-      if(is_array($combat_data[UBE_FLEETS][$fleet_id][UBE_PLANET]))
503
+      if (is_array($combat_data[UBE_FLEETS][$fleet_id][UBE_PLANET]))
504 504
       {
505 505
         $fleet_template += $combat_data[UBE_FLEETS][$fleet_id][UBE_PLANET];
506 506
         $fleet_template[PLANET_NAME] = $fleet_template[PLANET_NAME] ? htmlentities($fleet_template[PLANET_NAME], ENT_COMPAT, 'UTF-8') : '';
507 507
         $fleet_template['PLANET_TYPE_TEXT'] = $lang['sys_planet_type_sh'][$fleet_template['PLANET_TYPE']];
508 508
       }
509 509
 
510
-      foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
510
+      foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
511 511
       {
512 512
         $shields_original = $fleet_data[UBE_SHIELD_BASE][$unit_id] * $fleet_data_prev[UBE_COUNT][$unit_id];
513 513
         $ship_template = array(
@@ -540,11 +540,11 @@  discard block
 block discarded – undo
540 540
   global $lang;
541 541
 
542 542
   $result = array();
543
-  if(!empty($array))
543
+  if (!empty($array))
544 544
   {
545
-    foreach($array as $unit_id => $unit_count)
545
+    foreach ($array as $unit_id => $unit_count)
546 546
     {
547
-      if($unit_count)
547
+      if ($unit_count)
548 548
       {
549 549
         $result[] = array(
550 550
           'NAME' => $lang['tech'][$unit_id],
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
         );
553 553
       }
554 554
     }
555
-    if($header && count($result))
555
+    if ($header && count($result))
556 556
     {
557 557
       array_unshift($result, array('NAME' => $header));
558 558
     }
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 // Генерирует данные для отчета из разобранных данных боя
566 566
 function sn_ube_report_generate(&$combat_data, &$template_result)
567 567
 {
568
-  if(!is_array($combat_data))
568
+  if (!is_array($combat_data))
569 569
   {
570 570
     return;
571 571
   }
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
   $fleets_info = &$combat_data[UBE_FLEETS];
578 578
   $outcome = &$combat_data[UBE_OUTCOME];
579 579
   // Генерируем отчет по флотам
580
-  for($round = 1; $round <= count($combat_data[UBE_ROUNDS]) - 1; $round++)
580
+  for ($round = 1; $round <= count($combat_data[UBE_ROUNDS]) - 1; $round++)
581 581
   {
582 582
     $round_template = array(
583 583
       'NUMBER' => $round,
@@ -589,13 +589,13 @@  discard block
 block discarded – undo
589 589
   }
590 590
 
591 591
   // Боевые потери флотов
592
-  foreach(array(UBE_ATTACKERS, UBE_DEFENDERS) as $side)
592
+  foreach (array(UBE_ATTACKERS, UBE_DEFENDERS) as $side)
593 593
   {
594
-    if(!is_array($outcome[$side][UBE_FLEETS]))
594
+    if (!is_array($outcome[$side][UBE_FLEETS]))
595 595
     {
596 596
       continue;
597 597
     }
598
-    foreach($outcome[$side][UBE_FLEETS] as $fleet_id => $temp)
598
+    foreach ($outcome[$side][UBE_FLEETS] as $fleet_id => $temp)
599 599
     {
600 600
       $player_info = &$players_info[$fleets_info[$fleet_id][UBE_OWNER]];
601 601
       $fleet_outcome = &$outcome[UBE_FLEETS][$fleet_id];
@@ -620,9 +620,9 @@  discard block
 block discarded – undo
620 620
 
621 621
   // Обломки
622 622
   $debris = array();
623
-  foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id)
623
+  foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id)
624 624
   {
625
-    if($resource_amount = $outcome[UBE_DEBRIS][$resource_id])
625
+    if ($resource_amount = $outcome[UBE_DEBRIS][$resource_id])
626 626
     {
627 627
       $debris[] = array(
628 628
         'NAME' => $lang['tech'][$resource_id],
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 
636 636
   // Координаты, тип и название планеты - если есть
637 637
 //R  $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER];
638
-  if(isset($combat_data[UBE_OUTCOME][UBE_PLANET]))
638
+  if (isset($combat_data[UBE_OUTCOME][UBE_PLANET]))
639 639
   {
640 640
     $template_result += $combat_data[UBE_OUTCOME][UBE_PLANET];
641 641
     $template_result[PLANET_NAME] = str_replace(' ', '&nbsp;', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8'));
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -2,8 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 // ------------------------------------------------------------------------------------------------
4 4
 // Записывает боевой отчет в БД
5
-function sn_ube_report_save(&$combat_data)
6
-{
5
+function sn_ube_report_save(&$combat_data) {
7 6
   global $config;
8 7
 
9 8
   // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем
@@ -281,8 +280,7 @@  discard block
 block discarded – undo
281 280
 
282 281
 // ------------------------------------------------------------------------------------------------
283 282
 // Читает боевой отчет из БД
284
-function sn_ube_report_load($report_cypher)
285
-{
283
+function sn_ube_report_load($report_cypher) {
286 284
   $report_cypher = db_escape($report_cypher);
287 285
 
288 286
   $report_row = doquery("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1", true);
@@ -480,8 +478,7 @@  discard block
 block discarded – undo
480 478
 
481 479
 // ------------------------------------------------------------------------------------------------
482 480
 // Парсит инфу о раунде для темплейта
483
-function sn_ube_report_round_fleet(&$combat_data, $round)
484
-{
481
+function sn_ube_report_round_fleet(&$combat_data, $round) {
485 482
   global $lang;
486 483
 
487 484
   $fleets_info = &$combat_data[UBE_FLEETS];
@@ -535,8 +532,7 @@  discard block
 block discarded – undo
535 532
 
536 533
 // ------------------------------------------------------------------------------------------------
537 534
 // Рендерит таблицу общего результата боя
538
-function sn_ube_report_table_render(&$array, $header)
539
-{
535
+function sn_ube_report_table_render(&$array, $header) {
540 536
   global $lang;
541 537
 
542 538
   $result = array();
@@ -563,8 +559,7 @@  discard block
 block discarded – undo
563 559
 
564 560
 // ------------------------------------------------------------------------------------------------
565 561
 // Генерирует данные для отчета из разобранных данных боя
566
-function sn_ube_report_generate(&$combat_data, &$template_result)
567
-{
562
+function sn_ube_report_generate(&$combat_data, &$template_result) {
568 563
   if(!is_array($combat_data))
569 564
   {
570 565
     return;
Please login to merge, or discard this patch.
includes/includes/upd_helpers.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -107,6 +107,9 @@
 block discarded – undo
107 107
   }
108 108
 }
109 109
 
110
+/**
111
+ * @param string $table
112
+ */
110 113
 function upd_alter_table($table, $alters, $condition = true) {
111 114
   global $config, $update_tables;
112 115
 
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('IN_UPDATE')) {
3
+if (!defined('IN_UPDATE')) {
4 4
   die('Trying to call update helpers externally!');
5 5
 }
6 6
 
@@ -8,13 +8,13 @@  discard block
 block discarded – undo
8 8
   global $update_tables;
9 9
 
10 10
   upd_add_more_time();
11
-  if(!$no_log) {
11
+  if (!$no_log) {
12 12
     upd_log_message("Performing query '{$query}'");
13 13
   }
14 14
 
15 15
   // classSupernova::$db->sn_db_connect();
16
-  if(!(strpos($query, '{{') === false)) {
17
-    foreach($update_tables as $tableName => $cork) {
16
+  if (!(strpos($query, '{{') === false)) {
17
+    foreach ($update_tables as $tableName => $cork) {
18 18
       $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix . $tableName, $query);
19 19
     }
20 20
   }
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
   global $config, $sys_log_disabled;
27 27
 
28 28
   $config->db_loadItem($key);
29
-  if($condition || !isset($config->$key)) {
29
+  if ($condition || !isset($config->$key)) {
30 30
     upd_add_more_time();
31
-    if(!$sys_log_disabled) {
31
+    if (!$sys_log_disabled) {
32 32
       upd_log_message("Updating config key '{$key}' with value '{$default_value}'");
33 33
     }
34 34
     $config->db_saveItem($key, $default_value);
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 function upd_log_message($message) {
57 57
   global $sys_log_disabled, $upd_log, $debug;
58 58
 
59
-  if($sys_log_disabled)
59
+  if ($sys_log_disabled)
60 60
   {
61 61
 //    print("{$message}<br />");
62 62
   } else {
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
 function upd_unset_table_info($table_name) {
69 69
   global $update_tables, $update_indexes, $update_foreigns;
70 70
 
71
-  if(isset($update_tables[$table_name])) {
71
+  if (isset($update_tables[$table_name])) {
72 72
     unset($update_tables[$table_name]);
73 73
   }
74 74
 
75
-  if(isset($update_indexes[$table_name])) {
75
+  if (isset($update_indexes[$table_name])) {
76 76
     unset($update_indexes[$table_name]);
77 77
   }
78 78
 
79
-  if(isset($update_foreigns[$table_name])) {
79
+  if (isset($update_foreigns[$table_name])) {
80 80
     unset($update_foreigns[$table_name]);
81 81
   }
82 82
 }
@@ -90,18 +90,18 @@  discard block
 block discarded – undo
90 90
   upd_unset_table_info($tableName);
91 91
 
92 92
   $q1 = upd_do_query("SHOW FULL COLUMNS FROM {$prefix_table_name};", true);
93
-  while($r1 = db_fetch($q1)) {
93
+  while ($r1 = db_fetch($q1)) {
94 94
     $update_tables[$tableName][$r1['Field']] = $r1;
95 95
   }
96 96
 
97 97
   $q1 = upd_do_query("SHOW INDEX FROM {$prefix_table_name};", true);
98
-  while($r1 = db_fetch($q1)) {
98
+  while ($r1 = db_fetch($q1)) {
99 99
     $update_indexes[$tableName][$r1['Key_name']] .= "{$r1['Column_name']},";
100 100
     $update_indexes_full[$tableName][$r1['Key_name']][$r1['Column_name']] = $r1;
101 101
   }
102 102
 
103
-  $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name). "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true);
104
-  while($r1 = db_fetch($q1)) {
103
+  $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true);
104
+  while ($r1 = db_fetch($q1)) {
105 105
     $table_referenced = str_replace($config->db_prefix, '', $r1['REFERENCED_TABLE_NAME']);
106 106
 
107 107
     $update_foreigns[$tableName][$r1['CONSTRAINT_NAME']] .= "{$r1['COLUMN_NAME']},{$table_referenced},{$r1['REFERENCED_COLUMN_NAME']};";
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 function upd_alter_table($table, $alters, $condition = true) {
112 112
   global $config, $update_tables;
113 113
 
114
-  if(!$condition) {
114
+  if (!$condition) {
115 115
     return;
116 116
   }
117 117
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
   $alters_print = is_array($alters) ? dump($alters) : $alters;
120 120
   upd_log_message("Altering table '{$table}' with alterations {$alters_print}");
121 121
 
122
-  if(!is_array($alters)) {
122
+  if (!is_array($alters)) {
123 123
     $alters = array($alters);
124 124
   }
125 125
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
   //$result = db_query($qry);
131 131
   $result = upd_do_query($qry);
132 132
   $error = db_error();
133
-  if($error) {
133
+  if ($error) {
134 134
     die("Altering error for table `{$table}`: {$error}<br />{$alters_print}");
135 135
   }
136 136
 
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
 function upd_create_table($table_name, $declaration) {
154 154
   global $config, $update_tables;
155 155
 
156
-  if(!$update_tables[$table_name]) {
156
+  if (!$update_tables[$table_name]) {
157 157
     upd_do_query('set foreign_key_checks = 0;', true);
158 158
     $result = upd_do_query("CREATE TABLE IF NOT EXISTS `{$config->db_prefix}{$table_name}` {$declaration}");
159 159
     $error = db_error();
160
-    if($error) {
160
+    if ($error) {
161 161
       die("Creating error for table `{$table_name}`: {$error}<br />" . dump($declaration));
162 162
     }
163 163
     upd_do_query('set foreign_key_checks = 1;', true);
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
 
184 184
 
185 185
 function upd_db_unit_changeset_prepare($unit_id, $unit_value, $user, $planet_id = null) {
186
-  if(!is_array($user)) {
186
+  if (!is_array($user)) {
187 187
     // TODO - remove later
188 188
     print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER is not ARRAY</h1>');
189 189
     pdump(debug_backtrace());
190 190
     die('USER is not ARRAY');
191 191
   }
192 192
 
193
-  if(!isset($user['id']) || !$user['id']) {
193
+  if (!isset($user['id']) || !$user['id']) {
194 194
     // TODO - remove later
195 195
     print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER[id] пустой</h1>');
196 196
     pdump($user);
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 
206 206
   $db_changeset = array();
207 207
   $temp = upd_db_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id');
208
-  if($temp['unit_id']) {
208
+  if ($temp['unit_id']) {
209 209
     // update
210 210
     $db_changeset = array(
211 211
       'action' => SQL_OP_UPDATE,
@@ -251,53 +251,53 @@  discard block
 block discarded – undo
251 251
 
252 252
 
253 253
 function upd_db_changeset_apply($db_changeset) {
254
-  if(!is_array($db_changeset) || empty($db_changeset)) {
254
+  if (!is_array($db_changeset) || empty($db_changeset)) {
255 255
     return;
256 256
   }
257 257
 
258
-  foreach($db_changeset as $table_name => $table_data) {
259
-    foreach($table_data as $record_id => $conditions) {
258
+  foreach ($db_changeset as $table_name => $table_data) {
259
+    foreach ($table_data as $record_id => $conditions) {
260 260
       $where = '';
261
-      if(!empty($conditions['where'])) {
261
+      if (!empty($conditions['where'])) {
262 262
         $where = 'WHERE ' . implode(' AND ', $conditions['where']);
263 263
       }
264 264
 
265 265
       $fields = array();
266
-      if($conditions['fields']) {
267
-        foreach($conditions['fields'] as $field_name => $field_data) {
266
+      if ($conditions['fields']) {
267
+        foreach ($conditions['fields'] as $field_name => $field_data) {
268 268
           $condition = "`{$field_name}` = ";
269 269
           $value = '';
270
-          if($field_data['delta']) {
270
+          if ($field_data['delta']) {
271 271
             $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta'];
272
-          } elseif($field_data['set']) {
273
-            $value = (is_string($field_data['set']) ? "'{$field_data['set']}'": $field_data['set']);
272
+          } elseif ($field_data['set']) {
273
+            $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']);
274 274
           }
275
-          if($value) {
275
+          if ($value) {
276 276
             $fields[] = $condition . $value;
277 277
           }
278 278
         }
279 279
       }
280 280
       $fields = implode(',', $fields);
281 281
 
282
-      switch($conditions['action']) {
282
+      switch ($conditions['action']) {
283 283
         case SQL_OP_DELETE:
284 284
           upd_do_query("DELETE FROM {{{$table_name}}} {$where}");
285 285
           break;
286 286
 
287 287
         case SQL_OP_UPDATE:
288
-          if($fields) {
288
+          if ($fields) {
289 289
             upd_do_query("UPDATE {{{$table_name}}} SET {$fields} {$where}");
290 290
           }
291 291
           break;
292 292
 
293 293
         case SQL_OP_INSERT:
294
-          if($fields) {
294
+          if ($fields) {
295 295
             upd_do_query("INSERT INTO {{{$table_name}}} SET {$fields}");
296 296
           }
297 297
           break;
298 298
 
299 299
         case SQL_OP_REPLACE:
300
-          if($fields) {
300
+          if ($fields) {
301 301
             upd_do_query("REPLACE INTO {{{$table_name}}} SET {$fields}");
302 302
           }
303 303
           break;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@
 block discarded – undo
170 170
 
171 171
 function upd_db_unit_by_location($user_id = 0, $location_type, $location_id, $unit_snid = 0, $for_update = false, $fields = '*') {
172 172
   return db_fetch(upd_do_query(
173
-    "SELECT {$fields}
173
+    "select {$fields}
174 174
     FROM {{unit}}
175 175
     WHERE
176 176
       `unit_location_type` = {$location_type} AND `unit_location_id` = {$location_id} AND " . DBStaticUnit::db_unit_time_restrictions() .
Please login to merge, or discard this patch.
includes/template.php 2 patches
Doc Comments   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * @param string    $title
35 35
  * @param string    $dest
36 36
  * @param int       $time
37
- * @param bool|true $show_header
37
+ * @param boolean $show_header
38 38
  */
39 39
 function message($mes, $title = 'Error', $dest = '', $time = 5, $show_header = true) {
40 40
   $template = gettemplate('message_body', true);
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
  * @param bool|true       $isDisplayTopNav
196 196
  * @param string          $metatags
197 197
  * @param bool|false      $AdminPage
198
- * @param bool|true       $isDisplayMenu
198
+ * @param boolean       $isDisplayMenu
199 199
  *
200 200
  * @return mixed
201 201
  */
@@ -208,7 +208,6 @@  discard block
 block discarded – undo
208 208
  * @param string          $title
209 209
  * @param bool|true       $isDisplayTopNav
210 210
  * @param string          $metatags
211
- * @param bool|false      $AdminPage
212 211
  * @param bool|true       $isDisplayMenu
213 212
  * @param bool|int|string $exitStatus - Код или сообщение выхода
214 213
  */
@@ -352,10 +351,10 @@  discard block
 block discarded – undo
352 351
 
353 352
 /**
354 353
  * @param $time
355
- * @param $event
354
+ * @param integer $event
356 355
  * @param $msg
357
- * @param $prefix
358
- * @param $is_decrease
356
+ * @param string $prefix
357
+ * @param boolean $is_decrease
359 358
  * @param $fleet_flying_row
360 359
  * @param $fleet_flying_sorter
361 360
  * @param $fleet_flying_events
@@ -650,7 +649,7 @@  discard block
 block discarded – undo
650 649
 }
651 650
 
652 651
 /**
653
- * @param array|string  $files
652
+ * @param string  $files
654 653
  * @param template|bool $template
655 654
  * @param string|bool   $template_path
656 655
  *
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 function gettemplatename($u_dpath) {
11 11
   static $template_names = array();
12 12
 
13
-  if(!isset($template_names[$u_dpath])) {
13
+  if (!isset($template_names[$u_dpath])) {
14 14
     $template_names[$u_dpath] = file_exists(SN_ROOT_PHYSICAL . $u_dpath . 'tmpl.ini') ? sys_file_read(SN_ROOT_PHYSICAL . $u_dpath . 'tmpl.ini') : TEMPLATE_NAME;
15 15
   }
16 16
 
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
  * @param $sn_menu_extra
53 53
  */
54 54
 function tpl_menu_merge_extra(&$sn_menu, &$sn_menu_extra) {
55
-  if(empty($sn_menu) || empty($sn_menu_extra)) {
55
+  if (empty($sn_menu) || empty($sn_menu_extra)) {
56 56
     return;
57 57
   }
58 58
 
59
-  foreach($sn_menu_extra as $menu_item_id => $menu_item) {
60
-    if(empty($menu_item['LOCATION'])) {
59
+  foreach ($sn_menu_extra as $menu_item_id => $menu_item) {
60
+    if (empty($menu_item['LOCATION'])) {
61 61
       $sn_menu[$menu_item_id] = $menu_item;
62 62
       continue;
63 63
     }
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
     unset($menu_item['LOCATION']);
67 67
 
68 68
     $is_positioned = $item_location[0];
69
-    if($is_positioned == '+' || $is_positioned == '-') {
69
+    if ($is_positioned == '+' || $is_positioned == '-') {
70 70
       $item_location = substr($item_location, 1);
71 71
     } else {
72 72
       $is_positioned = '';
73 73
     }
74 74
 
75
-    if($item_location) {
75
+    if ($item_location) {
76 76
       $menu_keys = array_keys($sn_menu);
77 77
       $insert_position = array_search($item_location, $menu_keys);
78
-      if($insert_position === false) {
78
+      if ($insert_position === false) {
79 79
         $insert_position = count($sn_menu) - 1;
80 80
         $is_positioned = '+';
81 81
         $item_location = '';
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     $spliced = array_splice($sn_menu, $insert_position, count($sn_menu) - $insert_position);
89 89
     $sn_menu[$menu_item_id] = $menu_item;
90 90
 
91
-    if(!$is_positioned && $item_location) {
91
+    if (!$is_positioned && $item_location) {
92 92
       unset($spliced[$item_location]);
93 93
     }
94 94
     $sn_menu = array_merge($sn_menu, $spliced);
@@ -104,24 +104,24 @@  discard block
 block discarded – undo
104 104
 function tpl_menu_assign_to_template(&$sn_menu, &$template) {
105 105
   global $lang;
106 106
 
107
-  if(empty($sn_menu) || !is_array($sn_menu)) {
107
+  if (empty($sn_menu) || !is_array($sn_menu)) {
108 108
     return;
109 109
   }
110 110
 
111
-  foreach($sn_menu as $menu_item_id => $menu_item) {
112
-    if(!$menu_item) {
111
+  foreach ($sn_menu as $menu_item_id => $menu_item) {
112
+    if (!$menu_item) {
113 113
       continue;
114 114
     }
115 115
 
116
-    if(is_string($menu_item_id)) {
116
+    if (is_string($menu_item_id)) {
117 117
       $menu_item['ID'] = $menu_item_id;
118 118
     }
119 119
 
120
-    if($menu_item['TYPE'] == 'lang') {
120
+    if ($menu_item['TYPE'] == 'lang') {
121 121
       $lang_string = &$lang;
122
-      if(preg_match('#(\w+)(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?#', $menu_item['ITEM'], $matches) && count($matches) > 1) {
123
-        for($i = 1; $i < count($matches); $i++) {
124
-          if(defined($matches[$i])) {
122
+      if (preg_match('#(\w+)(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?#', $menu_item['ITEM'], $matches) && count($matches) > 1) {
123
+        for ($i = 1; $i < count($matches); $i++) {
124
+          if (defined($matches[$i])) {
125 125
             $matches[$i] = constant($matches[$i]);
126 126
           }
127 127
           $lang_string = &$lang_string[$matches[$i]];
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
     $menu_item['ALT'] = htmlentities($menu_item['ALT']);
134 134
     $menu_item['TITLE'] = htmlentities($menu_item['TITLE']);
135 135
 
136
-    if(!empty($menu_item['ICON'])) {
137
-      if(is_string($menu_item['ICON'])) {
136
+    if (!empty($menu_item['ICON'])) {
137
+      if (is_string($menu_item['ICON'])) {
138 138
         $menu_item['ICON_PATH'] = $menu_item['ICON'];
139 139
       } else {
140 140
         $menu_item['ICON'] = $menu_item_id;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
     'MENU_START_HIDE'     => !empty($_COOKIE[SN_COOKIE . '_menu_hidden']) || defined('SN_GOOGLE'),
165 165
   ));
166 166
 
167
-  if(isset($template_result['MENU_CUSTOMIZE'])) {
167
+  if (isset($template_result['MENU_CUSTOMIZE'])) {
168 168
     $template->assign_vars(array(
169 169
       'PLAYER_OPTION_MENU_SHOW_ON_BUTTON'   => classSupernova::$user_options[PLAYER_OPTION_MENU_SHOW_ON_BUTTON],
170 170
       'PLAYER_OPTION_MENU_HIDE_ON_BUTTON'   => classSupernova::$user_options[PLAYER_OPTION_MENU_HIDE_ON_BUTTON],
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
     ));
179 179
   }
180 180
 
181
-  if(defined('IN_ADMIN') && IN_ADMIN === true && !empty($user['authlevel']) && $user['authlevel'] > 0) {
181
+  if (defined('IN_ADMIN') && IN_ADMIN === true && !empty($user['authlevel']) && $user['authlevel'] > 0) {
182 182
     tpl_menu_merge_extra($sn_menu_admin, $sn_menu_admin_extra);
183 183
     tpl_menu_assign_to_template($sn_menu_admin, $template);
184 184
   } else {
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
   $in_admin = defined('IN_ADMIN') && IN_ADMIN === true;
219 219
   $is_login = defined('LOGIN_LOGOUT') && LOGIN_LOGOUT === true;
220 220
 
221
-  if(is_object($page)) {
221
+  if (is_object($page)) {
222 222
     isset($page->_rootref['MENU']) ? $isDisplayMenu = $page->_rootref['MENU'] : false;
223 223
     isset($page->_rootref['NAVBAR']) ? $isDisplayTopNav = $page->_rootref['NAVBAR'] : false;
224 224
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     !isset($page->_rootref['PAGE_HEADER']) && $title ? $page->assign_var('PAGE_HEADER', $title) : false;
227 227
   }
228 228
 
229
-  if(empty($user['id']) || !is_numeric($user['id'])) {
229
+  if (empty($user['id']) || !is_numeric($user['id'])) {
230 230
     $isDisplayMenu = false;
231 231
     $isDisplayTopNav = false;
232 232
   }
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
   $user_time_measured_unix = intval(isset($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) ? strtotime($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) : 0);
239 239
 
240 240
   $font_size = !empty($_COOKIE[SN_COOKIE_F]) ? $_COOKIE[SN_COOKIE_F] : classSupernova::$user_options[PLAYER_OPTION_BASE_FONT_SIZE];
241
-  if(strpos($font_size, '%') !== false) {
241
+  if (strpos($font_size, '%') !== false) {
242 242
     // Размер шрифта в процентах
243 243
     $font_size = min(max(floatval($font_size), FONT_SIZE_PERCENT_MIN), FONT_SIZE_PERCENT_MAX) . '%';
244
-  } elseif(strpos($font_size, 'px') !== false) {
244
+  } elseif (strpos($font_size, 'px') !== false) {
245 245
     // Размер шрифта в пикселях
246 246
     $font_size = min(max(floatval($font_size), FONT_SIZE_PIXELS_MIN), FONT_SIZE_PIXELS_MAX) . 'px';
247 247
   } else {
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
 
254 254
   $template = gettemplate('_global_header', true);
255 255
 
256
-  if(!empty($sn_mvc['javascript'])) {
257
-    foreach($sn_mvc['javascript'] as $page_name => $script_list) {
258
-      if(empty($page_name) || $page_name == $sn_page_name) {
259
-        foreach($script_list as $filename => $content) {
256
+  if (!empty($sn_mvc['javascript'])) {
257
+    foreach ($sn_mvc['javascript'] as $page_name => $script_list) {
258
+      if (empty($page_name) || $page_name == $sn_page_name) {
259
+        foreach ($script_list as $filename => $content) {
260 260
           $template_result['.']['javascript'][] = array(
261 261
             'FILE'    => $filename,
262 262
             'CONTENT' => $content,
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
     'design/css/jquery-ui.css' => '',
281 281
     'design/css/global.min.css' => '',
282 282
   );
283
-  $is_login ? $standard_css['design/css/login.min.css'] = '': false;
283
+  $is_login ? $standard_css['design/css/login.min.css'] = '' : false;
284 284
   $standard_css += array(
285 285
 //    'design/css/design/css/global-ie.min.css' => '', // TODO
286 286
     TEMPLATE_PATH . '/_template.min.css' => '',
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
   $sn_mvc['css'][''] = array_merge($standard_css, $sn_mvc['css']['']);
292 292
 
293 293
 
294
-  foreach($sn_mvc['css'] as $page_name => $script_list) {
295
-    if(empty($page_name) || $page_name == $sn_page_name) {
296
-      foreach($script_list as $filename => $content) {
294
+  foreach ($sn_mvc['css'] as $page_name => $script_list) {
295
+    if (empty($page_name) || $page_name == $sn_page_name) {
296
+      foreach ($script_list as $filename => $content) {
297 297
         $template_result['.']['css'][] = array(
298 298
           'FILE'    => $filename,
299 299
           'CONTENT' => $content,
@@ -340,12 +340,12 @@  discard block
 block discarded – undo
340 340
   $template->assign_recursive($template_result);
341 341
   displayP(parsetemplate($template));
342 342
 
343
-  if(($isDisplayMenu || $in_admin) && !isset($_COOKIE['menu_disable'])) {
343
+  if (($isDisplayMenu || $in_admin) && !isset($_COOKIE['menu_disable'])) {
344 344
     // $AdminPage = $AdminPage ? $user['authlevel'] : 0;
345 345
     displayP(parsetemplate(tpl_render_menu()));
346 346
   }
347 347
 
348
-  if($isDisplayTopNav && !$in_admin) {
348
+  if ($isDisplayTopNav && !$in_admin) {
349 349
     displayP(parsetemplate(tpl_render_topnav($user, $planetrow)));
350 350
   }
351 351
 
@@ -353,8 +353,8 @@  discard block
 block discarded – undo
353 353
 
354 354
   !is_array($page) ? $page = array($page) : false;
355 355
   $result_added = false;
356
-  foreach($page as $page_item) {
357
-    if(!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) {
356
+  foreach ($page as $page_item) {
357
+    if (!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) {
358 358
       $page_item = gettemplate('_result_message', $page_item);
359 359
       $temp = $page_item->files['_result_message'];
360 360
       unset($page_item->files['_result_message']);
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
   ));
378 378
   displayP(parsetemplate($template));
379 379
 
380
-  $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false;;
380
+  $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false; ;
381 381
 
382 382
   sn_db_disconnect();
383 383
 
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
  * @param string   $type
416 416
  */
417 417
 function tpl_topnav_event_build(&$template, $fleet_flying_list, $type = 'fleet') {
418
-  if(empty($fleet_flying_list)) {
418
+  if (empty($fleet_flying_list)) {
419 419
     return;
420 420
   }
421 421
 
@@ -424,19 +424,19 @@  discard block
 block discarded – undo
424 424
   $fleet_event_count = 0;
425 425
   $fleet_flying_sorter = array();
426 426
   $fleet_flying_events = array();
427
-  foreach($fleet_flying_list as &$fleet_flying_row) {
427
+  foreach ($fleet_flying_list as &$fleet_flying_row) {
428 428
     $will_return = true;
429
-    if($fleet_flying_row['fleet_mess'] == 0) {
429
+    if ($fleet_flying_row['fleet_mess'] == 0) {
430 430
       // cut fleets on Hold and Expedition
431
-      if($fleet_flying_row['fleet_start_time'] >= SN_TIME_NOW) {
431
+      if ($fleet_flying_row['fleet_start_time'] >= SN_TIME_NOW) {
432 432
         $fleet_flying_row['fleet_mission'] == MT_RELOCATE ? $will_return = false : false;
433 433
         tpl_topnav_event_build_helper($fleet_flying_row['fleet_start_time'], EVENT_FLEET_ARRIVE, $lang['sys_event_arrive'], 'fleet_end_', !$will_return, $fleet_flying_row, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count);
434 434
       }
435
-      if($fleet_flying_row['fleet_end_stay']) {
435
+      if ($fleet_flying_row['fleet_end_stay']) {
436 436
         tpl_topnav_event_build_helper($fleet_flying_row['fleet_end_stay'], EVENT_FLEET_STAY, $lang['sys_event_stay'], 'fleet_end_', false, $fleet_flying_row, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count);
437 437
       }
438 438
     }
439
-    if($will_return) {
439
+    if ($will_return) {
440 440
       tpl_topnav_event_build_helper($fleet_flying_row['fleet_end_time'], EVENT_FLEET_RETURN, $lang['sys_event_return'], 'fleet_start_', true, $fleet_flying_row, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count);
441 441
     }
442 442
   }
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
   asort($fleet_flying_sorter);
445 445
 
446 446
   $fleet_flying_count = count($fleet_flying_list);
447
-  foreach($fleet_flying_sorter as $fleet_event_id => $fleet_time) {
447
+  foreach ($fleet_flying_sorter as $fleet_event_id => $fleet_time) {
448 448
     $fleet_event = &$fleet_flying_events[$fleet_event_id];
449 449
     $template->assign_block_vars("flying_{$type}s", array(
450 450
       'TIME' => max(0, $fleet_time - SN_TIME_NOW),
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 function sn_tpl_render_topnav(&$user, $planetrow) {
473 473
   global $lang, $config, $sn_module_list, $template_result, $sn_mvc;
474 474
 
475
-  if(!is_array($user)) {
475
+  if (!is_array($user)) {
476 476
     return '';
477 477
   }
478 478
 
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
 
494 494
   $ThisUsersPlanets = DBStaticPlanet::db_planet_list_sorted($user);
495 495
   // while ($CurPlanet = db_fetch($ThisUsersPlanets))
496
-  foreach($ThisUsersPlanets as $CurPlanet) {
497
-    if($CurPlanet['destruyed']) {
496
+  foreach ($ThisUsersPlanets as $CurPlanet) {
497
+    if ($CurPlanet['destruyed']) {
498 498
       continue;
499 499
     }
500 500
 
@@ -520,8 +520,8 @@  discard block
 block discarded – undo
520 520
   que_tpl_parse($template, QUE_RESEARCH, $user, array(), null, !classSupernova::$user_options[PLAYER_OPTION_NAVBAR_RESEARCH_WIDE]);
521 521
   que_tpl_parse($template, SUBQUE_FLEET, $user, $planetrow, null, true);
522 522
 
523
-  if(!empty($sn_mvc['navbar_prefix_button']) && is_array($sn_mvc['navbar_prefix_button'])) {
524
-    foreach($sn_mvc['navbar_prefix_button'] as $navbar_button_image => $navbar_button_url) {
523
+  if (!empty($sn_mvc['navbar_prefix_button']) && is_array($sn_mvc['navbar_prefix_button'])) {
524
+    foreach ($sn_mvc['navbar_prefix_button'] as $navbar_button_image => $navbar_button_url) {
525 525
       $template->assign_block_vars('navbar_prefix_button', array(
526 526
         'IMAGE' => $navbar_button_image,
527 527
         'URL_RELATIVE' => $navbar_button_url,
@@ -535,13 +535,13 @@  discard block
 block discarded – undo
535 535
   $time_now_parsed = getdate(SN_TIME_NOW);
536 536
   $time_local_parsed = getdate(defined('SN_CLIENT_TIME_LOCAL') ? SN_CLIENT_TIME_LOCAL : SN_TIME_NOW);
537 537
 
538
-  if($config->game_news_overview) {
538
+  if ($config->game_news_overview) {
539 539
     $user_last_read_safe = intval($user['news_lastread']);
540 540
     nws_render($template, "WHERE UNIX_TIMESTAMP(`tsTimeStamp`) >= {$user_last_read_safe}", $config->game_news_overview);
541 541
   }
542 542
 
543 543
   $notes_query = doquery("SELECT * FROM {{notes}} WHERE `owner` = {$user['id']} AND `sticky` = 1 ORDER BY priority DESC, time DESC");
544
-  while($note_row = db_fetch($notes_query)) {
544
+  while ($note_row = db_fetch($notes_query)) {
545 545
     note_assign($template, $note_row);
546 546
   }
547 547
 
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
     'QUE_ID'   => QUE_RESEARCH,
553 553
     'QUE_HTML' => 'topnav',
554 554
 
555
-    'RESEARCH_ONGOING' => (boolean)$user['que'],
555
+    'RESEARCH_ONGOING' => (boolean) $user['que'],
556 556
 
557 557
     'TIME_TEXT'       => sprintf($str_date_format, $time_now_parsed['year'], $lang['months'][$time_now_parsed['mon']], $time_now_parsed['mday'],
558 558
       $time_now_parsed['hours'], $time_now_parsed['minutes'], $time_now_parsed['seconds']
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
     'QUE_STRUCTURES' => QUE_STRUCTURES,
630 630
   ));
631 631
 
632
-  if((defined('SN_RENDER_NAVBAR_PLANET') && SN_RENDER_NAVBAR_PLANET === true) || ($user['option_list'][OPT_INTERFACE]['opt_int_navbar_resource_force'] && SN_RENDER_NAVBAR_PLANET !== false)) {
632
+  if ((defined('SN_RENDER_NAVBAR_PLANET') && SN_RENDER_NAVBAR_PLANET === true) || ($user['option_list'][OPT_INTERFACE]['opt_int_navbar_resource_force'] && SN_RENDER_NAVBAR_PLANET !== false)) {
633 633
     tpl_set_resource_info($template, $planetrow);
634 634
     $template->assign_vars(array(
635 635
       'SN_RENDER_NAVBAR_PLANET' => true,
@@ -644,12 +644,12 @@  discard block
 block discarded – undo
644 644
  * @param template|string $template
645 645
  */
646 646
 function displayP($template) {
647
-  if(is_object($template)) {
648
-    if(empty($template->parsed)) {
647
+  if (is_object($template)) {
648
+    if (empty($template->parsed)) {
649 649
       parsetemplate($template);
650 650
     }
651 651
 
652
-    foreach($template->files as $section => $filename) {
652
+    foreach ($template->files as $section => $filename) {
653 653
       $template->display($section);
654 654
     }
655 655
   } else {
@@ -664,11 +664,11 @@  discard block
 block discarded – undo
664 664
  * @return mixed
665 665
  */
666 666
 function parsetemplate($template, $array = false) {
667
-  if(is_object($template)) {
667
+  if (is_object($template)) {
668 668
     global $user;
669 669
 
670
-    if(!empty($array) && is_array($array)) {
671
-      foreach($array as $key => $data) {
670
+    if (!empty($array) && is_array($array)) {
671
+      foreach ($array as $key => $data) {
672 672
         $template->assign_var($key, $data);
673 673
       }
674 674
     }
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 
711 711
   $template_ex = '.tpl.html';
712 712
 
713
-  if($template === false) {
713
+  if ($template === false) {
714 714
     return sys_file_read(TEMPLATE_DIR . '/' . $files . $template_ex);
715 715
   }
716 716
 
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
   !empty($sn_mvc['i18n']['']) ? lng_load_i18n($sn_mvc['i18n']['']) : false;
731 731
   $sn_page_name ? lng_load_i18n($sn_mvc['i18n'][$sn_page_name]) : false;
732 732
 
733
-  foreach($files as &$filename) {
733
+  foreach ($files as &$filename) {
734 734
     $filename = $filename . $template_ex;
735 735
   }
736 736
 
@@ -755,13 +755,13 @@  discard block
 block discarded – undo
755 755
     'LANG'     => $language ? $language : '',
756 756
     'referral' => $id_ref ? '&id_ref=' . $id_ref : '',
757 757
 
758
-    'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '',// "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''),
758
+    'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '', // "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''),
759 759
     'FILENAME'       => basename($_SERVER['PHP_SELF']),
760 760
   ));
761 761
 
762
-  foreach(lng_get_list() as $lng_id => $lng_data) {
763
-    if(isset($lng_data['LANG_VARIANTS']) && is_array($lng_data['LANG_VARIANTS'])) {
764
-      foreach($lng_data['LANG_VARIANTS'] as $lang_variant) {
762
+  foreach (lng_get_list() as $lng_id => $lng_data) {
763
+    if (isset($lng_data['LANG_VARIANTS']) && is_array($lng_data['LANG_VARIANTS'])) {
764
+      foreach ($lng_data['LANG_VARIANTS'] as $lang_variant) {
765 765
         $lng_data1 = $lng_data;
766 766
         $lng_data1 = array_merge($lng_data1, $lang_variant);
767 767
         $template->assign_block_vars('language', $lng_data1);
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 //  }
788 788
 
789 789
   $fleet_flying_list[0] = fleet_list_by_owner_id($user['id']);
790
-  foreach($fleet_flying_list[0] as $fleet_id => $fleet_flying_row) {
790
+  foreach ($fleet_flying_list[0] as $fleet_id => $fleet_flying_row) {
791 791
     $fleet_flying_list[$fleet_flying_row['fleet_mission']][$fleet_id] = &$fleet_flying_list[0][$fleet_id];
792 792
   }
793 793
 
@@ -806,8 +806,8 @@  discard block
 block discarded – undo
806 806
   $que = $que['ques'][$que_type][$planet['id_owner']][$planet['id']];
807 807
 
808 808
   $que_length = 0;
809
-  if(!empty($que)) {
810
-    foreach($que as $que_item) {
809
+  if (!empty($que)) {
810
+    foreach ($que as $que_item) {
811 811
       $template->assign_block_vars('que', que_tpl_parse_element($que_item));
812 812
     }
813 813
     $que_length = count($que);
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 function tpl_planet_density_info(&$template, &$density_price_chart, $user_dark_matter) {
825 825
   global $lang;
826 826
 
827
-  foreach($density_price_chart as $density_price_index => &$density_price_data) {
827
+  foreach ($density_price_chart as $density_price_index => &$density_price_data) {
828 828
     $density_cost = $density_price_data;
829 829
     $density_number_style = pretty_number($density_cost, true, $user_dark_matter, false, false);
830 830
 
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
 function tpl_assign_select(&$template, $name, $values) {
849 849
   !is_array($values) ? $values = array($values => $values) : false;
850 850
 
851
-  foreach($values as $key => $value) {
851
+  foreach ($values as $key => $value) {
852 852
     $template->assign_block_vars($name, array(
853 853
       'KEY'   => htmlentities($key, ENT_COMPAT, 'UTF-8'),
854 854
       'VALUE' => htmlentities($value, ENT_COMPAT, 'UTF-8'),
Please login to merge, or discard this patch.
resources.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
 
93 93
 for ($Option = 10; $Option >= 0; $Option--)
94 94
 {
95
- $template->assign_block_vars('option', array(
96
-   'VALUE' => $Option * 10,
97
- ));
95
+  $template->assign_block_vars('option', array(
96
+    'VALUE' => $Option * 10,
97
+  ));
98 98
 }
99 99
 
100 100
 $caps_real = eco_get_planet_caps($user, $planetrow, 3600);
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
 int_calc_storage_bar(RES_DEUTERIUM);
164 164
 
165 165
 $template->assign_vars(array(
166
- 'PLANET_NAME'          => $planetrow['name'],
167
- 'PLANET_TYPE'          => $planetrow['planet_type'],
168
- 'PLANET_DENSITY_INDEX' => $planet_density_index,
169
- 'PLANET_CORE_TEXT'     => $lang['uni_planet_density_types'][$planet_density_index],
166
+  'PLANET_NAME'          => $planetrow['name'],
167
+  'PLANET_TYPE'          => $planetrow['planet_type'],
168
+  'PLANET_DENSITY_INDEX' => $planet_density_index,
169
+  'PLANET_CORE_TEXT'     => $lang['uni_planet_density_types'][$planet_density_index],
170 170
 
171
- 'PRODUCTION_LEVEL'     => floor($caps_real['efficiency'] * 100),
171
+  'PRODUCTION_LEVEL'     => floor($caps_real['efficiency'] * 100),
172 172
 
173
- 'PAGE_HINT'            => $lang['res_hint'],
173
+  'PAGE_HINT'            => $lang['res_hint'],
174 174
 ));
175 175
 
176 176
 display($template, $lang['res_planet_production']);
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
   ));
47 47
 };
48 48
 
49
-$ValidList['percent'] = array (  0,  10,  20,  30,  40,  50,  60,  70,  80,  90, 100 );
49
+$ValidList['percent'] = array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100);
50 50
 $template = gettemplate('resources', true);
51 51
 
52 52
 $transmutation_result = sn_sys_planet_core_transmute($user, $planetrow);
53
-if(!empty($transmutation_result))
53
+if (!empty($transmutation_result))
54 54
 {
55 55
   $template->assign_block_vars('result', $transmutation_result); // array('STATUS' => $transmutation_result['STATUS'], 'MESSAGE' => $transmutation_result['MESSAGE']));
56 56
 }
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
 $production = $_POST['production'];
60 60
 //$SubQry     = '';
61 61
 $SubQry     = array();
62
-if(is_array($production)) {
63
-  foreach($production as $prod_id => $percent) {
64
-    if($percent > 100 || $percent < 0) {
62
+if (is_array($production)) {
63
+  foreach ($production as $prod_id => $percent) {
64
+    if ($percent > 100 || $percent < 0) {
65 65
       $debug->warning('Supplying wrong production percent (less then 0 or greater then 100)', 'Hack attempt', 302, array('base_dump' => true));
66 66
       die();
67 67
     }
68 68
 
69 69
     $prod_id = intval($prod_id);
70
-    if(in_array($prod_id, $sn_group_factories) && get_unit_param($prod_id, P_MINING_IS_MANAGED)) {
70
+    if (in_array($prod_id, $sn_group_factories) && get_unit_param($prod_id, P_MINING_IS_MANAGED)) {
71 71
       $field_name              = pname_factory_production_field_name($prod_id);
72 72
       $percent                 = floor($percent / 10);
73 73
       $planetrow[$field_name]  = $percent;
74 74
       //$SubQry                 .= "`{$field_name}` = '{$percent}',";
75
-      $SubQry[]                 = "`{$field_name}` = '{$percent}'";
75
+      $SubQry[] = "`{$field_name}` = '{$percent}'";
76 76
     } else {
77 77
       $debug->warning('Supplying wrong ID in production array - attempt to change some field - ID' . $prod_id, 'Resource Page', 301);
78 78
       continue;
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
   'ENERGY_TYPE'    => pretty_number($caps_real['production'][RES_ENERGY][0], true, true),
109 109
 ));
110 110
 
111
-foreach($sn_group_factories as $unit_id)
111
+foreach ($sn_group_factories as $unit_id)
112 112
 {
113
-  if(mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id))
113
+  if (mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id))
114 114
   {
115 115
     $level_plain = mrc_get_level($user, $planetrow, $unit_id, false, true);
116 116
     $template->assign_block_vars('production', array(
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,8 +24,7 @@
 block discarded – undo
24 24
 
25 25
 include('common.' . substr(strrchr(__FILE__, '.'), 1));
26 26
 
27
-function int_calc_storage_bar($resource_id)
28
-{
27
+function int_calc_storage_bar($resource_id) {
29 28
   global $lang, $template, $caps_real, $planetrow, $user;
30 29
 
31 30
   $totalProduction      = $caps_real['total'][$resource_id];
Please login to merge, or discard this patch.